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);
}
}
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));
}
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;
}
}
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);
}
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;
}
Aggregations