use of org.knime.core.node.NodeSettingsRO 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.node.NodeSettingsRO in project knime-core by knime.
the class BinnerNodeDialogPane method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
DataTableSpec spec = (DataTableSpec) specs[0];
// numeric columns' settings
m_intervals.clear();
m_numMdl.removeAllElements();
for (int i = 0; i < spec.getNumColumns(); i++) {
DataColumnSpec cspec = spec.getColumnSpec(i);
if (cspec.getType().isCompatible(DoubleValue.class)) {
m_numMdl.addElement(cspec);
}
}
String[] columns = settings.getStringArray(BinnerNodeModel.NUMERIC_COLUMNS, (String[]) null);
// if numeric columns in settings, select first
if (columns != null && columns.length > 0) {
for (int i = 0; i < columns.length; i++) {
if (!spec.containsName(columns[i])) {
continue;
}
DataTableSpec dataspec = (DataTableSpec) specs[0];
DataType type = dataspec.getColumnSpec(columns[i]).getType();
if (!type.isCompatible(DoubleValue.class)) {
continue;
}
NodeSettingsRO col;
try {
col = settings.getNodeSettings(columns[i].toString());
} catch (InvalidSettingsException ise) {
LOGGER.warn("NodeSettings not available for column: " + columns[i]);
continue;
}
String appendedColumn = null;
if (settings.containsKey(columns[i].toString() + BinnerNodeModel.IS_APPENDED)) {
appendedColumn = settings.getString(columns[i].toString() + BinnerNodeModel.IS_APPENDED, null);
}
IntervalPanel p = new IntervalPanel(columns[i], appendedColumn, m_numList, type);
m_intervals.put(columns[i], p);
for (String binId : col.keySet()) {
NumericBin theBin = null;
try {
theBin = new NumericBin(col.getNodeSettings(binId));
} catch (InvalidSettingsException ise) {
LOGGER.warn("NodeSettings not available for " + "interval bin: " + binId);
continue;
}
String binName = theBin.getBinName();
boolean leftOpen = theBin.isLeftOpen();
double left = theBin.getLeftValue();
boolean rightOpen = theBin.isRightOpen();
double right = theBin.getRightValue();
IntervalItemPanel item = new IntervalItemPanel(p, leftOpen, left, rightOpen, right, binName, type);
p.addIntervalItem(item);
}
DataColumnSpec cspec = spec.getColumnSpec(columns[i]);
// select column and scroll to position
m_numList.setSelectedValue(cspec, true);
}
}
getPanel().validate();
getPanel().repaint();
}
use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class BinnerNodeModel method validateSettings.
/**
* {@inheritDoc}
*/
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
StringBuffer sb = new StringBuffer();
String[] columns = settings.getStringArray(NUMERIC_COLUMNS, new String[0]);
if (columns == null) {
sb.append("Numeric column array can't be 'null'\n");
} else {
for (int i = 0; i < columns.length; i++) {
// appended or replaced
settings.getString(columns[i].toString() + IS_APPENDED, null);
double old = Double.NEGATIVE_INFINITY;
if (columns[i] == null) {
sb.append("Column can't be 'null': " + i + "\n");
continue;
}
NodeSettingsRO set = settings.getNodeSettings(columns[i].toString());
for (String binKey : set.keySet()) {
NodeSettingsRO bin = set.getNodeSettings(binKey);
NumericBin theBin = null;
try {
theBin = new NumericBin(bin);
} catch (InvalidSettingsException ise) {
sb.append(columns[i] + ": " + ise.getMessage() + "\n");
continue;
}
String binName = theBin.getBinName();
double l = theBin.getLeftValue();
if (l != old) {
sb.append(columns[i] + ": " + binName + " check interval: " + "left=" + l + ",oldright=" + old + "\n");
}
double r = theBin.getRightValue();
boolean lOpen = theBin.isLeftOpen();
boolean rOpen = theBin.isRightOpen();
if (r < l) {
sb.append(columns[i] + ": " + binName + " check interval: " + "left=" + l + ",right=" + r + "\n");
} else {
if (r == l && !(!lOpen && !rOpen)) {
sb.append(columns[i] + ": " + binName + " check borders: " + "left=" + l + ",right=" + r + "\n");
}
}
old = r;
}
if (old != Double.POSITIVE_INFINITY) {
sb.append(columns[i] + ": check last right interval value=" + old + "\n");
}
}
}
if (sb.length() > 0) {
throw new InvalidSettingsException(sb.toString());
}
}
use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class DropPane method loadSettingsFrom.
/**
* @param settings
* @param specs
* @throws InvalidSettingsException
* @throws NotConfigurableException
*/
@Override
public void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws InvalidSettingsException, NotConfigurableException {
m_loading = true;
NodeSettingsRO ns = settings.getNodeSettings(CFGKEY_DROPPANE + getPosition());
m_dialog.loadSettingsFrom(ns, specs);
m_loading = false;
}
use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class TypePane method loadSettingsFrom.
/**
* @param settings
* @param specs
* @throws InvalidSettingsException
* @throws NotConfigurableException
*/
@Override
public void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws InvalidSettingsException, NotConfigurableException {
NodeSettingsRO ns = settings.getNodeSettings(CFGKEY_DROPPANE + getPosition());
m_dialog.loadSettingsFrom(ns, specs);
}
Aggregations