use of maspack.widgets.ValueChangeEvent 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.ValueChangeEvent 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.ValueChangeEvent in project artisynth_core by artisynth.
the class SelectComponentPanelHandler method createPanel.
public void createPanel() {
myPanel = new JPanel();
myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.X_AXIS));
ImageIcon comboSelectIcon = GuiUtils.loadIcon(SelectableComponentPanel.class, "icon/downArrow.png");
mySelectFilterButton = ButtonCreator.createIconicButton(comboSelectIcon, "Set Filter", "Set selection filter", true, false, null);
componentFilter = new ClassField("", ClassField.All, 15);
componentFilter.getTextField().setHorizontalAlignment(JTextField.RIGHT);
componentFilter.setSpacing(0);
componentFilter.getTextField().addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
if (e.getModifiersEx() == ButtonMasks.getContextMenuMask()) {
showFilterPopup();
}
}
});
componentFilter.addValueChangeListener(new ValueChangeListener() {
public void valueChange(ValueChangeEvent e) {
doSetComponentFilter((Class) e.getValue());
}
});
GuiUtils.setFixedSize(mySelectFilterButton, 18, 18);
mySelectFilterButton.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1) {
showFilterPopup();
}
}
});
myComponentField = new ComponentField("", 30, myMain);
// GuiUtils.setFixedSize (parentBtn, 24, 24);
myPanel.add(Box.createRigidArea(new Dimension(36, 20)));
myPanel.add(mySelectFilterButton);
myPanel.add(componentFilter);
myPanel.add(myComponentField);
// myPanel.add(componentName);
// //myPanel.add(selectParent);
// myPanel.add(parentBtn);
myFrame.add(myPanel, BorderLayout.SOUTH);
}
use of maspack.widgets.ValueChangeEvent in project artisynth_core by artisynth.
the class ComponentPropertyField method addPropertySelector.
protected void addPropertySelector() {
myPropertySelector = new StringSelector("", new String[] { nullString });
myPropertySelector.setValue(nullString);
myPropertySelector.addValueChangeListener(new ValueChangeListener() {
public void valueChange(ValueChangeEvent e) {
setValueFromPropertySelector();
}
});
myPropertiesAllowed = true;
addMajorComponent(myPropertySelector);
}
Aggregations