use of org.knime.core.node.util.ColumnFilterPanel in project knime-core by knime.
the class FuzzyClusterNodeDialog method loadSettingsFrom.
/**
* Loads the settings from the model, Number of Clusters and
* maximum number of Iterations.
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
assert (settings != null && specs != null);
if (specs[0].getNumColumns() <= 0) {
throw new NotConfigurableException("No input data");
}
if (settings.containsKey(FuzzyClusterNodeModel.NRCLUSTERS_KEY)) {
try {
int tempnrclusters = settings.getInt(FuzzyClusterNodeModel.NRCLUSTERS_KEY);
if ((1 < tempnrclusters) && (tempnrclusters < MAXNRCLUSTERS)) {
m_nrClustersSpinner.setValue(tempnrclusters);
} else {
throw new InvalidSettingsException("Value out of range for number of" + " clusters, must be in [1,9999]");
}
} catch (InvalidSettingsException e) {
LOGGER.debug("Invalid Settings", e);
}
}
if (settings.containsKey(FuzzyClusterNodeModel.MAXITERATIONS_KEY)) {
try {
int tempmaxiter = settings.getInt(FuzzyClusterNodeModel.MAXITERATIONS_KEY);
if ((1 <= tempmaxiter) && (tempmaxiter < MAXNRCLUSTERS)) {
m_maxNrIterationsSpinner.setValue(tempmaxiter);
} else {
throw new InvalidSettingsException("Value out of range " + "for maximum number of iterations, must be in " + "[1,9999]");
}
} catch (InvalidSettingsException e) {
LOGGER.debug("Invalid Settings", e);
}
}
if (settings.containsKey(FuzzyClusterNodeModel.FUZZIFIER_KEY)) {
try {
double tempfuzzifier = settings.getDouble(FuzzyClusterNodeModel.FUZZIFIER_KEY);
if ((1 < tempfuzzifier) && (tempfuzzifier < MAXFUZZIFIER)) {
m_fuzzifierSpinner.setValue(tempfuzzifier);
} else {
throw new InvalidSettingsException("Value out of range " + "for fuzzifier, must be in " + "[>1,10]");
}
} catch (InvalidSettingsException e) {
LOGGER.debug("Invalid Settings", e);
}
}
if (settings.containsKey(FuzzyClusterNodeModel.NOISE_KEY)) {
try {
boolean noise = settings.getBoolean(FuzzyClusterNodeModel.NOISE_KEY);
if (noise) {
m_noisecheck.setSelected(noise);
if (settings.containsKey(FuzzyClusterNodeModel.DELTAVALUE_KEY)) {
double delta = settings.getDouble(FuzzyClusterNodeModel.DELTAVALUE_KEY);
if (delta > 0) {
m_providedeltaRB.setEnabled(true);
m_notprovidedeltaRB.setEnabled(true);
m_providedeltaRB.setSelected(true);
m_deltaSpinner.setEnabled(true);
m_deltaSpinner.setValue(delta);
}
}
if (settings.containsKey(FuzzyClusterNodeModel.LAMBDAVALUE_KEY)) {
double lambda = settings.getDouble(FuzzyClusterNodeModel.LAMBDAVALUE_KEY);
if (lambda > 0) {
m_notprovidedeltaRB.setEnabled(true);
m_providedeltaRB.setEnabled(true);
m_notprovidedeltaRB.setSelected(true);
m_lambdaSpinner.setEnabled(true);
m_lambdaSpinner.setValue(lambda);
}
}
}
} catch (InvalidSettingsException e) {
LOGGER.debug("Invalid Settings", e);
}
} else {
m_providedeltaRB.setEnabled(false);
m_notprovidedeltaRB.setEnabled(false);
}
if (specs[FuzzyClusterNodeModel.INPORT] == null) {
// settings can't be evaluated against the spec
return;
}
ColumnFilterPanel p = (ColumnFilterPanel) getTab(TAB2);
if (settings.containsKey(FuzzyClusterNodeModel.INCLUDELIST_KEY)) {
String[] columns = settings.getStringArray(FuzzyClusterNodeModel.INCLUDELIST_KEY, new String[0]);
HashSet<String> list = new HashSet<String>();
for (int i = 0; i < columns.length; i++) {
if (specs[FuzzyClusterNodeModel.INPORT].containsName(columns[i])) {
list.add(columns[i]);
}
}
// set include list on the panel
p.update(specs[FuzzyClusterNodeModel.INPORT], false, list);
} else {
p.update(specs[FuzzyClusterNodeModel.INPORT], true, new String[] {});
}
p.setKeepAllSelected(settings.getBoolean(FuzzyClusterNodeModel.CFGKEY_KEEPALL, false));
if (settings.containsKey(FuzzyClusterNodeModel.MEMORY_KEY)) {
try {
boolean memory = settings.getBoolean(FuzzyClusterNodeModel.MEMORY_KEY);
m_memoryCB.setSelected(memory);
} catch (InvalidSettingsException e) {
// nothing to do here.
}
}
if (settings.containsKey(FuzzyClusterNodeModel.MEASURES_KEY)) {
try {
boolean measures = settings.getBoolean(FuzzyClusterNodeModel.MEASURES_KEY);
m_measuresCB.setSelected(measures);
} catch (InvalidSettingsException e) {
// nothing to do here.
}
}
boolean useSeed = settings.getBoolean(FuzzyClusterNodeModel.USE_SEED_KEY, false);
m_useRandomSeed.setSelected(useSeed);
int seed = settings.getInt(FuzzyClusterNodeModel.SEED_KEY, (int) (2 * (Math.random() - 0.5) * Integer.MAX_VALUE));
m_randomSeed.setValue(seed);
m_randomSeed.setEnabled(useSeed);
}
use of org.knime.core.node.util.ColumnFilterPanel in project knime-core by knime.
the class LogRegLearnerNodeDialogPane method createIncludesPanel.
/**
* Create options panel for the included columns.
*/
private JPanel createIncludesPanel() {
JPanel p = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 0;
c.gridx = 0;
c.gridy = 0;
c.anchor = GridBagConstraints.BASELINE_LEADING;
c.insets = new Insets(5, 5, 0, 0);
m_filterPanel = new ColumnFilterPanel(true);
p.add(m_filterPanel, c);
c.gridy++;
m_notSortIncludes = new JCheckBox("Use order from column domain (applies only to nominal columns). " + "First value is chosen as reference for dummy variables.");
p.add(m_notSortIncludes, c);
return p;
}
Aggregations