use of maspack.properties.HasProperties 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.properties.HasProperties in project artisynth_core by artisynth.
the class LabeledComponentPanel method actionPerformed.
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if (command.equals("delete")) {
LinkedList<JComponent> list = new LinkedList<JComponent>();
list.addAll(mySelectedWidgets);
for (JComponent comp : list) {
removeWidget(comp);
}
repackContainingWindow();
} else if (command.equals("add separator")) {
JComponent comp = mySelectedWidgets.iterator().next();
addWidget(new JSeparator(), getComponentIndex(comp) + 1);
repackContainingWindow();
} else if (command.equals("set properties")) {
Window win = SwingUtilities.getWindowAncestor(this);
if (win != null) {
LinkedList<HasProperties> hosts = new LinkedList<HasProperties>();
JComponent lastComp = null;
for (JComponent comp : mySelectedWidgets) {
if (comp instanceof HasProperties) {
hosts.add((HasProperties) comp);
}
lastComp = comp;
}
HostList hostList = new HostList(hosts);
PropertyDialog dialog = PropertyDialog.createDialog(win, "Edit properties", hostList, "OK Cancel");
// PropertyDialog dialog = PropertyDialog.createDialog (
// win, "Edit properties", new PropertyPanel (comp), "OK Cancel");
GuiUtils.locateVertically(dialog, lastComp, GuiUtils.BELOW);
GuiUtils.locateHorizontally(dialog, this, GuiUtils.CENTER);
dialog.setModal(true);
dialog.setVisible(true);
}
} else if (command.equals("reset sliderRange")) {
for (JComponent comp : mySelectedWidgets) {
if (comp instanceof NumericFieldSlider) {
// fix this for regular sliders too?
NumericFieldSlider nslider = (NumericFieldSlider) comp;
nslider.setSliderRange(SliderRange.estimateBoundsIfNecessary(nslider.getRange(), nslider.getDoubleValue()));
}
}
} else if (mySelectedWidgets.size() == 1) {
JComponent comp = mySelectedWidgets.iterator().next();
if (comp instanceof LabeledComponentBase) {
((LabeledComponentBase) comp).actionPerformed(e);
}
} else {
throw new InternalErrorException("Unexpected action: " + e);
}
}
use of maspack.properties.HasProperties in project artisynth_core by artisynth.
the class MenuBarHandler method showPullControllerRenderPropsDialog.
private void showPullControllerRenderPropsDialog() {
if (myPullControllerRenderPropsDialog == null) {
PullController pc = myMain.getPullController();
LinkedList<HasProperties> list = new LinkedList<HasProperties>();
list.add(pc);
RenderPropsDialog dialog = new RenderPropsDialog("Edit render properties", list);
dialog.locateRight(myMain.getFrame());
// dialog.setSynchronizeObject(myMain.getRootModel());
dialog.setTitle("RenderProps for PullController");
dialog.addWindowListener(new WindowAdapter() {
public void windowClosed(WindowEvent e) {
myPullControllerRenderPropsDialog = null;
}
});
myMain.registerWindow(dialog);
myPullControllerRenderPropsDialog = dialog;
dialog.pack();
dialog.setVisible(true);
}
}
use of maspack.properties.HasProperties in project artisynth_core by artisynth.
the class AddPropertyPane method RecursePropString.
private Property RecursePropString(String propPath, Object parent) {
// System.out.println("recurse path: " + propPath);
if (// if there is a . in the path, then we
propPath.indexOf(".") > 0) // need to go down further
{
String propName = propPath.substring(0, propPath.indexOf("."));
String rest = propPath.substring(propPath.indexOf(".") + 1, propPath.length());
Property prop = ((HasProperties) parent).getProperty(propName);
if (prop != null) {
Object obj = prop.get();
return RecursePropString(rest, obj);
} else {
return (Property) parent;
}
} else {
// if there are no more "."s in the name, then just
// simply get all the properties contained within this property
System.out.println("no more .'s... just list the properties at this level");
Property prop = ((HasProperties) parent).getProperty(propPath);
if (prop != null) {
// System.out.println("bottom prop found");
return prop;
} else {
// System.out.println("bottom prop NOT found");
return null;
}
}
}
use of maspack.properties.HasProperties in project artisynth_core by artisynth.
the class IsRenderableEditor method applyAction.
public void applyAction(String actionCommand, LinkedList<ModelComponent> selection, Rectangle popupBounds) {
if (glEditCmd.equals(actionCommand)) {
ArrayList<HasProperties> contained = new ArrayList<HasProperties>(selection.size());
for (ModelComponent mc : selection) {
if (mc instanceof IsRenderableHolder) {
IsRenderableHolder holder = (IsRenderableHolder) mc;
IsRenderable glr = holder.getRenderable();
if (glr instanceof HasProperties) {
contained.add((HasProperties) glr);
}
}
}
if (contained.size() > 0) {
createPropertyDialog(contained, true, popupBounds);
} else {
JOptionPane.showMessageDialog(null, "No properties for selected components", "No properties", JOptionPane.INFORMATION_MESSAGE);
}
}
}
Aggregations