use of maspack.widgets.ValueChangeListener in project artisynth_core by artisynth.
the class MeshCollisionViewer method createRenderPropsPanel.
private void createRenderPropsPanel(PolygonalMesh mesh) {
PropertyDialog dialog = new PropertyDialog("Edit render props", new RenderPropsPanel(PropertyUtils.createProperties(mesh.getRenderProps())), "OK Cancel");
dialog.locateRight(this);
dialog.addGlobalValueChangeListener(new ValueChangeListener() {
public void valueChange(ValueChangeEvent e) {
viewer.rerender();
}
});
dialog.setVisible(true);
}
use of maspack.widgets.ValueChangeListener in project artisynth_core by artisynth.
the class MeshViewer method actionPerformed.
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
if (cmd.equals("Edit render props")) {
PropertyDialog dialog = new PropertyDialog("Edit render props", new RenderPropsPanel(PropertyUtils.createProperties(myRenderProps)), "OK Cancel");
dialog.locateRight(this);
dialog.addGlobalValueChangeListener(new ValueChangeListener() {
public void valueChange(ValueChangeEvent e) {
for (MeshBase mesh : myMeshes) {
mesh.setRenderProps(myRenderProps);
}
viewer.rerender();
}
});
myPopupManager.registerDialog(dialog);
dialog.setVisible(true);
} else if (cmd.equals("Edit viewer props")) {
PropertyDialog dialog = myPopupManager.createPropertyDialog("OK Cancel");
dialog.setVisible(true);
} else if (cmd.equals("Quit")) {
exit(0);
} else if (cmd.equals("Load mesh ...")) {
int retVal = myMeshChooser.showOpenDialog(this);
if (retVal == JFileChooser.APPROVE_OPTION) {
File file = myMeshChooser.getSelectedFile();
loadMesh(file);
}
} else if (cmd.equals("Save mesh ...")) {
int retVal = myMeshChooser.showOpenDialog(this);
if (retVal == JFileChooser.APPROVE_OPTION) {
File file = myMeshChooser.getSelectedFile();
saveMesh(file);
}
} else if (cmd.equals("Show mesh selector")) {
if (myMeshSelector == null) {
createMeshSelector();
myMeshSelector.setSelected(myMeshCursor);
}
myMeshSelector.setLocationRelativeTo(this);
myMeshSelector.setVisible(true);
} else if (cmd.equals("Hide mesh selector")) {
myMeshSelector.setVisible(false);
} else if (cmd.equals("Show property dialog ...")) {
setPropertyDialogVisible(true);
} else if (cmd.equals("Hide property dialog")) {
setPropertyDialogVisible(false);
} else if (cmd.equals("Background color")) {
setBackgroundColor();
} else if (cmd.equals("Perspective view")) {
viewer.setOrthographicView(false);
} else if (cmd.equals("Orthographic view")) {
viewer.setOrthographicView(true);
}
}
use of maspack.widgets.ValueChangeListener 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.ValueChangeListener 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.ValueChangeListener 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