use of com.genericworkflownodes.knime.parameter.DoubleListParameter in project GenericKnimeNodes by genericworkflownodes.
the class ParamHandler method handleDoubleList.
/**
* Convert the current element into a DoubleListParameter.
*
* @param paramName
* The name of the Parameter
* @param attributes
* Attributes of the Parameter.
*/
private void handleDoubleList(String paramName, Attributes attributes) {
m_currentParameter = new DoubleListParameter(paramName, new ArrayList<Double>());
// check for restrictions
String restrs = attributes.getValue(ATTR_RESTRICTIONS);
if (restrs != null) {
((DoubleListParameter) m_currentParameter).setLowerBound(new DoubleRangeExtractor().getLowerBound(restrs));
((DoubleListParameter) m_currentParameter).setUpperBound(new DoubleRangeExtractor().getUpperBound(restrs));
}
}
use of com.genericworkflownodes.knime.parameter.DoubleListParameter in project GenericKnimeNodes by genericworkflownodes.
the class CTDConfigurationWriter method addDoubleListParameterRestrictions.
private void addDoubleListParameterRestrictions(Parameter<?> p, StringBuffer restriction) {
DoubleListParameter dlp = (DoubleListParameter) p;
boolean lbSet = Double.NEGATIVE_INFINITY != dlp.getLowerBound().doubleValue();
boolean ubSet = Double.POSITIVE_INFINITY != dlp.getUpperBound().doubleValue();
if (lbSet) {
restriction.append(String.format(Locale.ENGLISH, "%f", dlp.getLowerBound()).replaceAll(REMOVE_TRAILING_0_RE, "").replaceAll(REMOVE_TRAILING_DOT_RE, ""));
}
if (ubSet || lbSet) {
restriction.append(':');
}
if (ubSet) {
restriction.append(String.format(Locale.ENGLISH, "%f", dlp.getUpperBound()).replaceAll(REMOVE_TRAILING_0_RE, "").replaceAll(REMOVE_TRAILING_DOT_RE, ""));
}
}
use of com.genericworkflownodes.knime.parameter.DoubleListParameter in project GenericKnimeNodes by genericworkflownodes.
the class ParameterVerifier method verify.
/*
* (non-Javadoc)
*
* @see javax.swing.InputVerifier#verify(javax.swing.JComponent)
*/
@Override
public boolean verify(JComponent input) {
boolean returnVal = false;
if (input instanceof JTextField) {
String inputValue = ((JTextField) input).getText();
if (m_parameter instanceof DoubleParameter) {
DoubleParameter dp = (DoubleParameter) m_parameter;
returnVal = verifyDouble(inputValue, dp.getLowerBound(), dp.getUpperBound());
} else if (m_parameter instanceof DoubleListParameter) {
DoubleListParameter dlp = (DoubleListParameter) m_parameter;
returnVal = verifyDouble(inputValue, dlp.getLowerBound(), dlp.getUpperBound());
} else if (m_parameter instanceof IntegerParameter) {
IntegerParameter ip = (IntegerParameter) m_parameter;
returnVal = verifyInteger(inputValue, ip.getLowerBound(), ip.getUpperBound());
} else if (m_parameter instanceof IntegerListParameter) {
IntegerListParameter ilp = (IntegerListParameter) m_parameter;
returnVal = verifyInteger(inputValue, ilp.getLowerBound(), ilp.getUpperBound());
} else {
returnVal = true;
}
if (!returnVal) {
// TODO we currently just show a message box in the ParamCellEditor (that uses the verify function).
// input.setBackground(Color.PINK);
LOGGER.debug("Tried to set Parameter to an invalid value. Please see the restrictrions of the parameter.");
}
}
return returnVal;
}
use of com.genericworkflownodes.knime.parameter.DoubleListParameter in project GenericKnimeNodes by genericworkflownodes.
the class ListEditorDialogModel method addValue.
public int addValue() {
// choose reasonable value to insert
String newValue = "";
if (parameter instanceof DoubleListParameter) {
DoubleListParameter dlp = (DoubleListParameter) parameter;
if (dlp.getLowerBound() != Double.NEGATIVE_INFINITY || dlp.getUpperBound() != Double.POSITIVE_INFINITY) {
newValue = (dlp.getLowerBound() != Double.NEGATIVE_INFINITY ? dlp.getLowerBound().toString() : dlp.getUpperBound().toString());
} else {
newValue = "0.0";
}
} else if (parameter instanceof IntegerListParameter) {
IntegerListParameter ilp = (IntegerListParameter) parameter;
if (ilp.getLowerBound() != Integer.MIN_VALUE || ilp.getUpperBound() != Integer.MAX_VALUE) {
newValue = (ilp.getLowerBound() != Integer.MIN_VALUE ? ilp.getLowerBound().toString() : ilp.getUpperBound().toString());
} else {
newValue = "0";
}
} else if (parameter instanceof StringListParameter && ((StringListParameter) parameter).getRestrictions() != null) {
String[] validValues = ((StringListParameter) parameter).getRestrictions();
int i = 0;
while ("".equals(newValue) && i < validValues.length) {
newValue = validValues[i];
++i;
}
}
values.add(newValue);
fireTableRowsInserted(values.size(), values.size());
return values.size() - 1;
}
Aggregations