use of maspack.widgets.BooleanSelector 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.widgets.BooleanSelector 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();
}
use of maspack.widgets.BooleanSelector in project artisynth_core by artisynth.
the class TimelineController method getWayPointFromUser.
/**
* Gets waypoint information from the user and adds the waypoint to
* the waypoint probe.
*/
public void getWayPointFromUser() {
DoubleField myTimeField = new DoubleField("Time");
myTimeField.addValueCheckListener(new ValueCheckListener() {
public Object validateValue(ValueChangeEvent e, StringHolder errMsg) {
Object val = e.getValue();
if (val instanceof Double && ((Double) val).doubleValue() <= 0) {
if (errMsg != null) {
errMsg.value = "Time value must be positive";
}
return Property.IllegalValue;
} else {
if (errMsg != null) {
errMsg.value = null;
}
return val;
}
}
});
myTimeField.setVoidValueEnabled(true);
myTimeField.setValue(Property.VoidValue);
IntegerField myRepeatField = new IntegerField("Repeat", 1);
myRepeatField.setRange(1, Integer.MAX_VALUE);
BooleanSelector myBreakpointSelector = new BooleanSelector("Breakpoint", false);
PropertyPanel addPanel = new PropertyPanel();
addPanel.addWidget(myTimeField);
addPanel.addWidget(myRepeatField);
addPanel.addWidget(myBreakpointSelector);
PropertyDialog addDialog = new PropertyDialog(this, "Add Waypoints", addPanel, "OK Cancel");
addDialog.setModal(true);
GuiUtils.locateCenter(addDialog, this);
addDialog.setVisible(true);
if (addDialog.getReturnValue() == OptionPanel.OK_OPTION && !myTimeField.valueIsVoid()) {
double t = myTimeField.getDoubleValue();
for (int i = 1; i <= myRepeatField.getIntValue(); i++) {
addWayPoint(t * i, myBreakpointSelector.getBooleanValue());
}
myToolBar.validateFastForward(myMain.getRootModel());
}
}
use of maspack.widgets.BooleanSelector in project artisynth_core by artisynth.
the class FemMuscleDemo method createMusclePanel.
public void createMusclePanel() {
ControlPanel myControlPanel = new ControlPanel("options", "LiveUpdate");
FemControlPanel.addMuscleControls(myControlPanel, tissue, myModel);
myControlPanel.addWidget(tissue, "profile");
ComponentList<MuscleBundle> muscles = ((FemMuscleModel) tissue).getMuscleBundles();
for (int i = 0; i < muscles.size(); ++i) {
DoubleFieldSlider slider = (DoubleFieldSlider) myControlPanel.addWidget("activation [N per Muscle]", this, "models/FemBeam/models/fem/bundles/" + i + ":excitation", 0, 1);
slider.setRoundingTolerance(0.00001);
slider.getLabel().setForeground(getMuscleColor(i));
BooleanSelector checkBox = (BooleanSelector) PropertyWidget.create("", muscles.get(i), "renderProps.visible");
checkBox.addValueChangeListener(new ValueChangeListener() {
public void valueChange(ValueChangeEvent e) {
rerender();
}
});
slider.add(checkBox);
}
for (int i = 0; i < muscles.size(); ++i) {
BooleanSelector selector = (BooleanSelector) myControlPanel.addWidget("fibres active", this, "models/FemBeam/models/fem/bundles/" + i + ":fibresActive");
selector.getLabel().setForeground(getMuscleColor(i));
BooleanSelector checkBox = (BooleanSelector) PropertyWidget.create("", muscles.get(i).getFibres(), "renderProps.visible");
checkBox.addValueChangeListener(new ValueChangeListener() {
public void valueChange(ValueChangeEvent e) {
rerender();
}
});
selector.add(checkBox);
}
addControlPanel(myControlPanel);
}
use of maspack.widgets.BooleanSelector in project artisynth_core by artisynth.
the class DicomLoader method createControlPanel.
void createControlPanel() {
panel = new ControlPanel("DICOM controls");
fnf = new FileNameField("File or folder:", 30);
fnf.getFileChooser().setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
fnf.getFileChooser().setCurrentDirectory(ArtisynthPath.getSrcRelativeFile(this, "data/"));
fnf.setName("dicom_path");
panel.addWidget(fnf);
fnp = new StringField("File regex:", 30);
fnp.setValue(".*");
panel.addWidget(fnp);
fns = new BooleanSelector("Subdirectories", true);
panel.addWidget(fns);
// panel for full-width button
JPanel jpanel = new JPanel();
jpanel.setLayout(new GridLayout());
panel.addWidget(jpanel);
JButton button = new JButton("Load");
button.setActionCommand("load");
button.addActionListener(this);
jpanel.add(button);
button = new JButton("Add Plane");
button.setActionCommand("plane");
button.addActionListener(this);
jpanel.add(button);
addControlPanel(panel);
}
Aggregations