Search in sources :

Example 1 with DoubleListParameter

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));
    }
}
Also used : DoubleRangeExtractor(com.genericworkflownodes.util.ranges.DoubleRangeExtractor) ArrayList(java.util.ArrayList) DoubleListParameter(com.genericworkflownodes.knime.parameter.DoubleListParameter)

Example 2 with DoubleListParameter

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, ""));
    }
}
Also used : DoubleListParameter(com.genericworkflownodes.knime.parameter.DoubleListParameter)

Example 3 with DoubleListParameter

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;
}
Also used : IntegerParameter(com.genericworkflownodes.knime.parameter.IntegerParameter) DoubleParameter(com.genericworkflownodes.knime.parameter.DoubleParameter) IntegerListParameter(com.genericworkflownodes.knime.parameter.IntegerListParameter) JTextField(javax.swing.JTextField) DoubleListParameter(com.genericworkflownodes.knime.parameter.DoubleListParameter)

Example 4 with DoubleListParameter

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;
}
Also used : StringListParameter(com.genericworkflownodes.knime.parameter.StringListParameter) IntegerListParameter(com.genericworkflownodes.knime.parameter.IntegerListParameter) DoubleListParameter(com.genericworkflownodes.knime.parameter.DoubleListParameter)

Aggregations

DoubleListParameter (com.genericworkflownodes.knime.parameter.DoubleListParameter)4 IntegerListParameter (com.genericworkflownodes.knime.parameter.IntegerListParameter)2 DoubleParameter (com.genericworkflownodes.knime.parameter.DoubleParameter)1 IntegerParameter (com.genericworkflownodes.knime.parameter.IntegerParameter)1 StringListParameter (com.genericworkflownodes.knime.parameter.StringListParameter)1 DoubleRangeExtractor (com.genericworkflownodes.util.ranges.DoubleRangeExtractor)1 ArrayList (java.util.ArrayList)1 JTextField (javax.swing.JTextField)1