Search in sources :

Example 11 with DoubleInterval

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

the class OutputNumericProbeEditor method setOutputProbe.

private void setOutputProbe() {
    ArrayList<String> variableNames = new ArrayList<String>();
    for (Map.Entry<String, NumericProbeVariable> entry : myVariables.entrySet()) {
        variableNames.add(entry.getKey());
        System.out.println("variable: " + entry.getKey() + " added to list");
    }
    for (Property prop : myProperties) {
        System.out.println("property " + prop.getName() + " found");
    }
    // System.out.println("myProps size ="+myProperties.size());
    // System.out.println("myVars size ="+variableNames.size());
    NumericOutputProbe probeToSet;
    if (oldProbe == null) {
        probeToSet = new NumericOutputProbe();
    } else {
        probeToSet = oldProbe;
    }
    probeToSet.set(myProperties.toArray(new Property[0]), getDriverExpressions(), variableNames.toArray(new String[0]));
    probeToSet.setStartTime(startTimeField.getDoubleValue());
    probeToSet.setStopTime(endTimeField.getDoubleValue());
    probeToSet.setName(probeNameField.getStringValue());
    probeToSet.setUpdateInterval(intervalField.getDoubleValue());
    if (!rangeField.valueIsVoid()) {
        DoubleInterval range = rangeField.getRangeValue();
        probeToSet.setDefaultDisplayRange(range.getLowerBound(), range.getUpperBound());
    }
    // probeToSet.setDefaultDisplayRange(
    // dispLowerField.getDoubleValue(), dispUpperField.getDoubleValue());
    probeToSet.setAttachedFileName(attachedFileField.getText());
    if (oldProbe == null) {
        AddComponentsCommand cmd = new AddComponentsCommand("add output probe", probeToSet, myMain.getRootModel().getOutputProbes());
        myMain.getUndoManager().saveStateAndExecute(cmd);
    // System.out.println("track index: "+probeToSet.getTrack());
    // myMain.getRootModel().addOutputProbe(probeToSet);
    // myMain.getTimeline().addProbe(probeToSet);
    }
}
Also used : NumericProbeVariable(artisynth.core.probes.NumericProbeVariable) AddComponentsCommand(artisynth.core.gui.editorManager.AddComponentsCommand) ArrayList(java.util.ArrayList) NumericOutputProbe(artisynth.core.probes.NumericOutputProbe) DoubleInterval(maspack.util.DoubleInterval) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Property(maspack.properties.Property)

Example 12 with DoubleInterval

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

the class RevoluteJoint method setMinTheta.

// public double getMaxTheta() {
// return Math.toDegrees(((RevoluteCoupling)myCoupling).getMaximumTheta());
// }
public void setMinTheta(double min) {
    double max = myThetaRange.getUpperBound();
    setThetaRange(new DoubleInterval(min, max));
}
Also used : DoubleInterval(maspack.util.DoubleInterval)

Example 13 with DoubleInterval

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

the class IntegerFieldSlider method updateInternalValue.

protected boolean updateInternalValue(Object value) {
    if (super.updateInternalValue(value)) {
        if (value instanceof Number && mySliderRange != null) {
            int newValue = ((Number) value).intValue();
            int max = (int) mySliderRange.getUpperBound();
            int min = (int) mySliderRange.getLowerBound();
            if (myAutoRangingP) {
                IntegerInterval newRange = null;
                if (newValue > max) {
                    newRange = new IntegerInterval(min, newValue);
                } else if (newValue < min) {
                    newRange = new IntegerInterval(newValue, max);
                }
                if (newRange != null) {
                    DoubleInterval dNewRange = SliderRange.roundBoundsTo125(newRange);
                    // make sure hard range OK
                    dNewRange.intersect(getRange());
                    setSliderRange(dNewRange);
                }
                // and if this widget does not have hard bounds
                if (!myRange.isBounded() && mySlider != null) {
                    int halfPixel = halfPixelValue();
                    if (newValue < halfPixel && newValue >= min) {
                        int newMax = (int) SliderRange.roundUp125(min + 4 * (newValue - min));
                        setSliderRange(new IntegerInterval(min, newMax));
                    }
                }
            }
            if (newValue < min || newValue > max) {
                mySlider.setBackground(Color.GRAY);
            } else {
                mySlider.setBackground(null);
            }
        }
        return true;
    } else {
        return false;
    }
}
Also used : IntegerInterval(maspack.util.IntegerInterval) DoubleInterval(maspack.util.DoubleInterval)

Example 14 with DoubleInterval

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

the class GreyscaleColorMap method setBrightnessRange.

/**
 * Sets the greyscale range [min, max].  If max {@code <} min,
 * then colors will be interpolated from bright to dark
 */
public void setBrightnessRange(double min, double max) {
    myMinBrightness = Math.max(Math.min(min, 1), 0);
    myMaxBrightness = Math.max(Math.min(max, 1), 0);
    if (myBrightnessRange == null) {
        myBrightnessRange = new DoubleInterval();
    }
    myBrightnessRange.set(myMinBrightness, myMaxBrightness);
}
Also used : DoubleInterval(maspack.util.DoubleInterval)

Example 15 with DoubleInterval

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

the class ColorBar method setDefaults.

@Override
protected void setDefaults() {
    setFont(new Font(defaultFontName, 0, defaultFontSize));
    myRenderProps = createDefaultRenderProps();
    hAlignment = defaultHAlignment;
    vAlignment = defaultVAlignment;
    myTextSize = defaultTextSize;
    myFontSize = defaultFontSize;
    myLoc = new Rectangle2d(defaultLoc);
    myColorMap = defaultColorMap;
    myValueRange = new DoubleInterval(defaultInterval);
    nBarDivisions = defaultBarDivisions;
    myTickFractions = new Vector2d(defaultTickFraction);
    myLabelPos = new VectorNd(0);
    myLabelText = new ArrayList<String>();
    myTextOffset = new Vector2d(defaultTextOffset);
    myNumberFormat = new NumberFormat(defaultNumberFormat);
    myRenderObject = null;
    myRenderObjectRebuildRequest = true;
}
Also used : Vector2d(maspack.matrix.Vector2d) Rectangle2d(maspack.geometry.Rectangle2d) VectorNd(maspack.matrix.VectorNd) DoubleInterval(maspack.util.DoubleInterval) Font(java.awt.Font) NumberFormat(maspack.util.NumberFormat)

Aggregations

DoubleInterval (maspack.util.DoubleInterval)22 NumericInterval (maspack.util.NumericInterval)3 Property (maspack.properties.Property)2 IntegerInterval (maspack.util.IntegerInterval)2 BooleanSelector (maspack.widgets.BooleanSelector)2 DoubleIntervalField (maspack.widgets.DoubleIntervalField)2 AddComponentsCommand (artisynth.core.gui.editorManager.AddComponentsCommand)1 PropertyField (artisynth.core.gui.widgets.PropertyField)1 Point (artisynth.core.mechmodels.Point)1 NumericOutputProbe (artisynth.core.probes.NumericOutputProbe)1 NumericProbeVariable (artisynth.core.probes.NumericProbeVariable)1 ColorBar (artisynth.core.renderables.ColorBar)1 BorderLayout (java.awt.BorderLayout)1 Container (java.awt.Container)1 Dimension (java.awt.Dimension)1 Font (java.awt.Font)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 BoxLayout (javax.swing.BoxLayout)1