Search in sources :

Example 6 with NumericInterval

use of maspack.util.NumericInterval in project artisynth_core by artisynth.

the class PropertyWidgetDialog method getDefaultRange.

private DoubleInterval getDefaultRange(Property prop) {
    DoubleInterval range = myRangeMap.get(prop.getInfo());
    if (range == null) {
        NumericInterval nrange = PropertyWidget.getNumericRange(prop);
        if (nrange != null) {
            range = new DoubleInterval(nrange);
        } else {
            range = new DoubleInterval(0, 1);
        }
        myRangeMap.put(prop.getInfo(), range);
    }
    return range;
}
Also used : DoubleInterval(maspack.util.DoubleInterval) NumericInterval(maspack.util.NumericInterval)

Example 7 with NumericInterval

use of maspack.util.NumericInterval in project artisynth_core by artisynth.

the class PropertyDesc method parseOptions.

protected void parseOptions(String optionStr) throws IllegalArgumentException {
    String[] tokens = optionStr.split("\\s+");
    for (int i = 0; i < tokens.length; i++) {
        int firstChar = tokens[i].charAt(0);
        String token = tokens[i];
        if (firstChar == '%') {
            try {
                setPrintFormat(token);
            } catch (IllegalArgumentException e) {
                System.err.println("Property '" + myName + "': illegal numeric format string");
            }
        } else if (firstChar == '[' || firstChar == '(') {
            NumericInterval range = new DoubleInterval(token);
            setNumericRange(range);
        } else if (token.equals("NE") || token.equals("NeverEdit")) {
            setEditing(Edit.Never);
        } else if (token.equals("NW") || token.equals("NoAutoWrite")) {
            setAutoWrite(false);
        } else if (token.equals("AE") || token.equals("AlwaysEdit")) {
            setEditing(Edit.Always);
        } else if (token.equals("1E") || token.equals("SingleEdit")) {
            setEditing(Edit.Single);
        } else if (token.equals("XE") || token.equals("ExpandedEdit")) {
            setWidgetExpandState(ExpandState.Expanded);
        } else if (token.equals("CE") || token.equals("ContractedEdit")) {
            setWidgetExpandState(ExpandState.Contracted);
        } else if (token.equals("AW") || token.equals("AutoWrite")) {
            setAutoWrite(true);
        } else if (token.equals("SH") || token.equals("Sharable")) {
            setSharable(true);
        } else if (token.equals("NV") || token.equals("NullOK")) {
            setNullValueOK(true);
        } else if (token.startsWith("D")) {
            String dimStr;
            if (token.startsWith("Dimension")) {
                dimStr = token.substring("Dimension".length());
            } else {
                dimStr = token.substring("D".length());
            }
            int dim;
            try {
                dim = Integer.parseInt(dimStr);
                if (myDimension != -1 && dim != myDimension) {
                    throw new IllegalArgumentException("Property '" + myName + "': dimension specified as " + dim + " but is known to be " + myDimension);
                } else if (myDimension == -1 && !typeIsNumeric()) {
                    System.err.println("Warning: dimension specified for non-numeric property '" + myName + "'");
                }
                setDimension(dim);
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException("Property '" + myName + "': malformed dimension expression: " + token);
            }
        } else {
            throw new IllegalArgumentException("Property '" + myName + " unrecognized option token " + token);
        }
    }
}
Also used : DoubleInterval(maspack.util.DoubleInterval) NumericInterval(maspack.util.NumericInterval)

Aggregations

NumericInterval (maspack.util.NumericInterval)7 EnumRange (maspack.util.EnumRange)4 Range (maspack.util.Range)4 StringRange (maspack.util.StringRange)4 PropertyInfo (maspack.properties.PropertyInfo)3 DoubleInterval (maspack.util.DoubleInterval)3 IntegerInterval (maspack.util.IntegerInterval)2 Color (java.awt.Color)1 Font (java.awt.Font)1 AffineTransform3d (maspack.matrix.AffineTransform3d)1 AxisAngle (maspack.matrix.AxisAngle)1 SymmetricMatrix3d (maspack.matrix.SymmetricMatrix3d)1 VectorBase (maspack.matrix.VectorBase)1 VectorNd (maspack.matrix.VectorNd)1 VectorNi (maspack.matrix.VectorNi)1 VectoriBase (maspack.matrix.VectoriBase)1 InternalErrorException (maspack.util.InternalErrorException)1