use of org.knime.core.data.container.ContainerTable in project knime-core by knime.
the class BoxPlotNodeModel method loadInternals.
/**
* {@inheritDoc}
*/
@Override
protected void loadInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
try {
File f = new File(nodeInternDir, FILE_NAME);
FileInputStream fis = new FileInputStream(f);
NodeSettingsRO settings = NodeSettings.loadFromXML(fis);
m_statistics = new LinkedHashMap<DataColumnSpec, double[]>();
m_mildOutliers = new LinkedHashMap<String, Map<Double, Set<RowKey>>>();
m_extremeOutliers = new LinkedHashMap<String, Map<Double, Set<RowKey>>>();
int nrOfCols = settings.getInt(CFG_NR_COLS);
for (int i = 0; i < nrOfCols; i++) {
NodeSettings subSetting = (NodeSettings) settings.getConfig(CFG_COL + i);
DataColumnSpec spec = DataColumnSpec.load(subSetting);
double[] stats = settings.getDoubleArray(CFG_STATS + spec.getName());
m_statistics.put(spec, stats);
loadOutliers(settings, spec);
}
File data = new File(nodeInternDir, ARRAY_FILE);
ContainerTable table = DataContainer.readFromZip(data);
m_array = new DefaultDataArray(table, 1, 2, exec);
} catch (Exception e) {
LOGGER.warn(e);
throw new IOException(e.getMessage());
}
}
use of org.knime.core.data.container.ContainerTable in project knime-core by knime.
the class ConditionalBoxPlotNodeModel method loadInternals.
/**
* {@inheritDoc}
*/
@Override
protected void loadInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
try {
File f = new File(nodeInternDir, "conditionalBoxPlotInternals");
FileInputStream fis = new FileInputStream(f);
NodeSettingsRO settings = NodeSettings.loadFromXML(fis);
fis.close();
m_statistics = new LinkedHashMap<DataColumnSpec, double[]>();
m_mildOutliers = new LinkedHashMap<String, Map<Double, Set<RowKey>>>();
m_extremeOutliers = new LinkedHashMap<String, Map<Double, Set<RowKey>>>();
/* Load the numerical column spec if available.*/
if (settings.containsKey("numColSpec")) {
m_numColSpec = DataColumnSpec.load(settings.getConfig("numColSpec"));
}
int nrOfCols = settings.getInt("nrOfCols");
for (int i = 0; i < nrOfCols; i++) {
DataColumnSpec spec = DataColumnSpec.load(settings.getConfig("col" + i));
String colName = spec.getName();
double[] stats = settings.getDoubleArray("stats" + colName);
m_statistics.put(spec, stats);
double[] mild = settings.getDoubleArray("mild" + colName);
Map<Double, Set<RowKey>> mildmap = new LinkedHashMap<Double, Set<RowKey>>();
for (int j = 0; j < mild.length; j++) {
Set<RowKey> set = new HashSet<RowKey>();
String[] mildKeys = settings.getStringArray("mildKeys" + colName + j);
for (int k = 0; k < mildKeys.length; k++) {
set.add(new RowKey(mildKeys[k]));
}
mildmap.put(mild[j], set);
}
m_mildOutliers.put(colName, mildmap);
double[] extr = settings.getDoubleArray("extreme" + colName);
Map<Double, Set<RowKey>> extrmap = new LinkedHashMap<Double, Set<RowKey>>();
for (int j = 0; j < extr.length; j++) {
Set<RowKey> set = new HashSet<RowKey>();
String[] extrKeys = settings.getStringArray("extremeKeys" + colName + j);
for (int k = 0; k < extrKeys.length; k++) {
set.add(new RowKey(extrKeys[k]));
}
extrmap.put(extr[j], set);
}
m_extremeOutliers.put(colName, extrmap);
}
File dataFile = new File(nodeInternDir, "conditionalBoxPlotDataFile");
ContainerTable table = DataContainer.readFromZip(dataFile);
m_dataArray = new DefaultDataArray(table, 1, 2, exec);
} catch (Exception e) {
throw new IOException("Unable to load internals: " + e.getMessage(), e);
}
}
use of org.knime.core.data.container.ContainerTable in project knime-core by knime.
the class InteractiveHistogramDataModel method loadFromFile.
/**
* @param dataDir the data directory to read from
* @param exec the {@link ExecutionMonitor}
* @return the {@link InteractiveHistogramDataModel}
* @throws IOException if the file is invalid
* @throws InvalidSettingsException if a setting is invalid
* @throws CanceledExecutionException if the process was canceled
*/
public static InteractiveHistogramDataModel loadFromFile(final File dataDir, final ExecutionMonitor exec) throws IOException, InvalidSettingsException, CanceledExecutionException {
final File settingFile = new File(dataDir, CFG_SETTING_FILE);
final FileInputStream is = new FileInputStream(settingFile);
final GZIPInputStream inData = new GZIPInputStream(is);
final ConfigRO config = NodeSettings.loadFromXML(inData);
final ConfigRO colorColsConf = config.getConfig(CFG_COLOR_COLS);
final int counter = colorColsConf.getInt(CFG_ROW_COLOR_COUNTER);
final List<Color> rowColors = new ArrayList<Color>();
for (int i = 0; i < counter; i++) {
rowColors.add(new Color(colorColsConf.getInt(CFG_ROW_COLOR + i)));
}
exec.checkCanceled();
final File dataFile = new File(dataDir, CFG_DATA_FILE);
final ContainerTable table = DataContainer.readFromZip(dataFile);
final int rowCount = table.getRowCount();
final DefaultDataArray dataArray = new DefaultDataArray(table, 1, rowCount, exec);
return new InteractiveHistogramDataModel(dataArray, rowColors);
}
use of org.knime.core.data.container.ContainerTable in project knime-core by knime.
the class InteractivePieDataModel method loadFromFile.
/**
* @param dataDir the data directory to read from
* @param exec {@link ExecutionMonitor}
* @return the {@link InteractivePieDataModel}
* @throws IOException if the file could not be read
* @throws InvalidSettingsException if a setting wasn't present
* @throws CanceledExecutionException if the operation was canceled
*/
public static InteractivePieDataModel loadFromFile(final File dataDir, final ExecutionMonitor exec) throws IOException, InvalidSettingsException, CanceledExecutionException {
final File settingFile = new File(dataDir, CFG_SETTING_FILE);
final FileInputStream is = new FileInputStream(settingFile);
final GZIPInputStream inData = new GZIPInputStream(is);
final ConfigRO config = NodeSettings.loadFromXML(inData);
final boolean supportHiliting = config.getBoolean(CFG_HILITING);
final boolean detailsAvailable = config.getBoolean(CFG_DETAILS);
exec.checkCanceled();
final File dataFile = new File(dataDir, CFG_DATA_FILE);
final ContainerTable table = DataContainer.readFromZip(dataFile);
final int rowCount = table.getRowCount();
final DefaultDataArray dataArray = new DefaultDataArray(table, 1, rowCount, exec);
return new InteractivePieDataModel(dataArray, detailsAvailable, supportHiliting);
}
use of org.knime.core.data.container.ContainerTable in project knime-core by knime.
the class DefaultVisualizationNodeModel method loadInternals.
/**
* Loads the converted {@link org.knime.base.node.util.DataArray}.
*
* {@inheritDoc}
*/
@Override
protected void loadInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
File f = new File(nodeInternDir, FILE_NAME);
ContainerTable table = DataContainer.readFromZip(f);
m_input = new DefaultDataArray(table, 1, m_maxRows.getIntValue(), exec);
}
Aggregations