use of maspack.util.DoubleInterval in project artisynth_core by artisynth.
the class DoubleIntervalField method valueToText.
@Override
protected String[] valueToText(Object obj) {
String[] strs = new String[2];
if (obj instanceof DoubleInterval) {
DoubleInterval rng = (DoubleInterval) obj;
strs[0] = myFmt.format(rng.getLowerBound());
strs[1] = myFmt.format(rng.getUpperBound());
return strs;
} else {
strs[0] = strs[1] = "";
}
return strs;
}
use of maspack.util.DoubleInterval in project artisynth_core by artisynth.
the class FemMeshBase method setStressPlotRange.
public void setStressPlotRange(DoubleInterval range) {
myStressPlotRange = new DoubleInterval(range);
myStressPlotRangeMode = PropertyUtils.propagateValue(this, "stressPlotRange", range, myStressPlotRangeMode);
}
use of maspack.util.DoubleInterval in project artisynth_core by artisynth.
the class NumericProbeDisplayLarge method initialize.
private void initialize() {
setSize(new Dimension(700, 400));
String inputOutputString = (myProbe.isInput()) ? "Input probe" : "Output probe";
setTitle(myTrackNumber + " " + inputOutputString + ": " + myProbe.getName());
// create probe panels based on the fact if it is input or output probes
myPanel = (NumericProbePanel) myProbe.getDisplay(getWidth(), getHeight(), LARGE_PROBE_DISPLAY);
if (myPanel.isAutoRanging()) {
myPanel.adjustRangeIfNecessary();
}
JToolBar sideToolBar = new JToolBar(JToolBar.VERTICAL);
zoomInBtn = ButtonCreator.createIconicButton(zoomInIcon, "Zoom In", "Zoom In", true, false, this);
zoomOutBtn = ButtonCreator.createIconicButton(zoomOutIcon, "Zoom Out", "Zoom Out", true, false, this);
moveDisplayBtn = ButtonCreator.createIconicButton(moveDisplayIcon, "Move Display", "Move Display", true, false, this);
pointerBtn = ButtonCreator.createIconicButton(pointerIcon, "Edit Plot", "Edit Plot", true, false, this);
upArrowBtn = ButtonCreator.createIconicButton(upArrowIcon, "Increase Range", "Increase Range", true, false, this);
downArrowBtn = ButtonCreator.createIconicButton(downArrowIcon, "Decrease Range", "Decrease Range", true, false, this);
fitRangeBtn = ButtonCreator.createIconicButton(fitRangeIcon, "Fit Range", "Fit Range", true, false, this);
autoRangeCheck = new BooleanSelector("Auto range", true);
autoRangeCheck.addValueChangeListener(this);
setYRange(myPanel.getAutoRange());
setXRange(myPanel.getDefaultDomain());
yRangeField = new DoubleIntervalField("Y range", new DoubleInterval(yMin, yMax), "%.6g");
yRangeField.addValueChangeListener(this);
xRangeField = new DoubleIntervalField("X range", new DoubleInterval(xMin, xMax), "%.6g");
xRangeField.addValueChangeListener(this);
sideToolBar.add(pointerBtn);
sideToolBar.addSeparator();
sideToolBar.add(zoomInBtn);
sideToolBar.add(zoomOutBtn);
sideToolBar.add(moveDisplayBtn);
sideToolBar.addSeparator();
sideToolBar.add(upArrowBtn);
sideToolBar.add(downArrowBtn);
sideToolBar.add(fitRangeBtn);
sideToolBar.addSeparator();
JToolBar rangeToolBar = new JToolBar();
rangeToolBar.add(autoRangeCheck);
rangeToolBar.addSeparator();
rangeToolBar.add(yRangeField);
rangeToolBar.addSeparator();
rangeToolBar.add(xRangeField);
rangeToolBar.addSeparator();
normalBorder = zoomInBtn.getBorder();
getContentPane().setLayout(new BorderLayout());
getContentPane().add(myPanel, BorderLayout.CENTER);
getContentPane().add(sideToolBar, BorderLayout.WEST);
getContentPane().add(rangeToolBar, BorderLayout.NORTH);
pack();
}
use of maspack.util.DoubleInterval in project artisynth_core by artisynth.
the class NumericProbeDisplayLarge method valueChange.
public void valueChange(ValueChangeEvent e) {
Object source = e.getSource();
if (source == yRangeField) {
double lower = yRangeField.getLowerBound();
double upper = yRangeField.getUpperBound();
if (lower != yMin && lower < upper) {
yMin = lower;
myPanel.setDisplayRangeManually(lower, upper);
} else if (upper != yMax && upper > lower) {
yMax = upper;
myPanel.setDisplayRangeManually(lower, upper);
}
yRangeField.setValue(new DoubleInterval(yMin, yMax));
autoRangeCheck.setValue(false);
myPanel.setAutoRanging(false);
} else if (source == xRangeField) {
double lower = xRangeField.getLowerBound();
double upper = xRangeField.getUpperBound();
if (lower != xMin && lower < upper) {
xMin = lower;
myPanel.setDisplayDomain(lower, upper);
} else if (upper != xMax && upper > lower) {
xMax = upper;
myPanel.setDisplayDomain(lower, upper);
}
xRangeField.setValue(new DoubleInterval(xMin, xMax));
autoRangeCheck.setValue(false);
myPanel.setAutoRanging(false);
} else if (source == autoRangeCheck) {
if (autoRangeCheck.getBooleanValue()) {
yRangeField.removeValueChangeListener(this);
xRangeField.removeValueChangeListener(this);
myPanel.setAutoRanging(true);
setYRange(myPanel.getAutoRange());
setXRange(myPanel.getDefaultDomain());
yRangeField.setValue(new DoubleInterval(yMin, yMax));
xRangeField.setValue(new DoubleInterval(xMin, xMax));
myPanel.setDisplayRangeManually(yMin, yMax);
myPanel.setDisplayDomain(xMin, xMax);
yRangeField.addValueChangeListener(this);
xRangeField.addValueChangeListener(this);
}
}
myPanel.repaint();
}
use of maspack.util.DoubleInterval in project artisynth_core by artisynth.
the class PropertyWidgetDialog method initialize.
private void initialize() {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
Container pane = getContentPane();
pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
LabeledComponentPanel propPanel = new LabeledComponentPanel();
propPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
// myChooser = new PropertyChooser ("component/property", 30, myMain);
// myChooser.setAlignmentX (Component.CENTER_ALIGNMENT);
// myChooser.addValueChangeListener (this);
// pane.add (Box.createRigidArea (new Dimension (0, 4)));
// propPanel.addWidget (myChooser);
myPropField = new PropertyField("component/property", 30, myMain);
myPropField.setAlignmentX(Component.CENTER_ALIGNMENT);
myPropField.addValueChangeListener(this);
propPanel.addWidget(myPropField);
propPanel.addWidget(new JSeparator());
mySliderSelector = new BooleanSelector("slider");
mySliderSelector.addValueChangeListener(this);
propPanel.addWidget(mySliderSelector);
myRangeField = new DoubleIntervalField("range", new DoubleInterval(0, 1), "%.6g");
// new VectorMultiField (
// "range", new String[] { "min:", "max:" }, new Vector2d (0, 1),
// "%.6f");
// myRangeField.setAlignmentX (Component.CENTER_ALIGNMENT);
propPanel.addWidget(myRangeField);
myLabelTextField = new StringField("labelText", 20);
myLabelTextField.setEnabledAll(false);
myLabelTextField.addValueCheckListener(new ValueCheckListener() {
public Object validateValue(ValueChangeEvent e, StringHolder errMsg) {
String newName = (String) e.getValue();
String err = ModelComponentBase.checkName(newName, null);
if (err != null) {
err = "Invalid name '" + newName + "': " + err;
newName = null;
}
if (errMsg != null) {
errMsg.value = err;
}
return newName;
}
});
propPanel.addWidget(myLabelTextField);
myLabelFontColorSelector = new ColorSelector("labelFontColor");
myLabelFontColorSelector.enableNullColors();
myLabelFontColorSelector.setValue(null);
propPanel.addWidget(myLabelFontColorSelector);
myBackgroundColorSelector = new ColorSelector("backgroundColor");
myBackgroundColorSelector.enableNullColors();
myBackgroundColorSelector.setValue(null);
propPanel.addWidget(myBackgroundColorSelector);
// sliderPanel.add (myRangeField);
// pane.add (Box.createRigidArea (new Dimension (0, 4)));
// pane.add (sliderPanel);
pane.add(propPanel);
pane.add(new JSeparator());
// set slider value here because valueChanged needs some
// other widgets instantiated.
mySliderSelector.setValue(false);
mySliderSelector.setEnabledAll(false);
OptionPanel options = new OptionPanel("OK Cancel", this);
myOKButton = options.getButton("OK");
myOKButton.setEnabled(false);
options.setAlignmentX(Component.CENTER_ALIGNMENT);
pane.add(options);
pack();
}
Aggregations