use of maspack.widgets.PropertyDialog 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.PropertyDialog 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.PropertyDialog in project artisynth_core by artisynth.
the class PropertyGuiTest method main.
public static void main(String[] args) {
TestHierarchy test = new TestHierarchy();
LinkedList<TestNode> nodeList = new LinkedList<TestNode>();
for (int i = 0; i < args.length; i++) {
TestNode node = test.getNode(args[i]);
if (node == null) {
System.err.println("Node '" + args[i] + "' not found");
System.exit(1);
}
nodeList.add(node);
}
// test.M1.getMaterial().setStiffness (123.0);
System.out.println("Properties:");
test.printAllProperties(System.out, test.recordAllProperties(test.getRoot()));
if (nodeList.size() == 0) {
System.err.println("Usage: java maspack.apps.PropertyGuiTest <NodeName1> <NodeName2> ... ");
System.exit(1);
} else if (nodeList.size() == 1) {
HasProperties host = nodeList.get(0);
PropertyDialog dialog = new PropertyDialog("prop panel test", host, "OK Cancel");
dialog.setVisible(true);
while (dialog.isVisible()) {
try {
Thread.sleep(100);
} catch (Exception e) {
//
}
}
dialog.dispose();
} else {
HostList hostList = new HostList((HasProperties[]) nodeList.toArray(new TestNode[0]));
PropertyDialog dialog = new PropertyDialog("prop panel test", hostList, "OK Cancel");
dialog.setVisible(true);
while (dialog.isVisible()) {
try {
Thread.sleep(100);
} catch (Exception e) {
//
}
}
dialog.dispose();
}
}
use of maspack.widgets.PropertyDialog in project artisynth_core by artisynth.
the class IsRenderableEditor method createPropertyDialog.
public void createPropertyDialog(Collection<? extends HasProperties> selectedItems, boolean locateClose, Rectangle popupBounds) {
HostList hostList = new HostList(selectedItems);
PropTreeCell tree = hostList.commonProperties(null, /* allowReadonly= */
true);
if (tree.numChildren() == 0) {
JOptionPane.showMessageDialog(null, "No common properties for selected components", "no common properties", JOptionPane.INFORMATION_MESSAGE);
} else {
PropertyDialog propDialog = new PropertyDialog("Edit properties", tree, hostList, "OK Cancel LiveUpdate");
propDialog.setScrollable(true);
if (locateClose) {
GuiUtils.locateRelative(propDialog, popupBounds, 0.5, 0.5, 0, 0.5);
} else {
propDialog.locateRight(myMain.getFrame());
}
// propDialog.setSynchronizeObject (myMain.getRootModel());
myMain.registerWindow(propDialog);
propDialog.setTitle("Properties for selected IsRenderables");
propDialog.setVisible(true);
}
}
use of maspack.widgets.PropertyDialog 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());
}
}
Aggregations