use of maspack.widgets.PropertyPanel in project artisynth_core by artisynth.
the class ExcitationTargetAgent method createPropertyPanel.
protected void createPropertyPanel() {
HostList hostList = new HostList(new HasProperties[] { myExciter });
myPropTree = hostList.commonProperties(null, false);
// remove properties which are to be excluded
String[] excludedProps = new String[] { "excitation" };
for (int i = 0; i < excludedProps.length; i++) {
myPropTree.removeDescendant(excludedProps[i]);
}
hostList.saveBackupValues(myPropTree);
hostList.getCommonValues(myPropTree, /* live= */
true);
myPropertyPanel = new PropertyPanel(EditingProperty.createProperties(myPropTree, hostList, /* isLive= */
false));
myPropertyPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
addWidget(myPropertyPanel);
}
use of maspack.widgets.PropertyPanel in project artisynth_core by artisynth.
the class FrameBasedEditingAgent method createDisplayFrame.
/**
* Creates the frame associated with this agent. After this method is called,
* subclasses can use specialized methods to add specific components to the
* frame, e.g.:
*
* <pre>
* createFrame ("Add AxialSprings");
* createSeparator();
* createTypeSelector (typeMap);
* createPropertyFrame();
* </pre>
*/
protected void createDisplayFrame(String frameName) {
myDisplay = new JFrame(frameName);
myDisplay.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
myDisplay.addWindowListener(new WindowAdapter() {
public void windowClosed(WindowEvent e) {
dispose();
}
});
myContentPane = new PropertyPanel();
myContentPane.setWidgetsDraggable(false);
myContentPane.setWidgetsSelectable(false);
myContentPane.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
myDisplay.getContentPane().add(myContentPane);
}
use of maspack.widgets.PropertyPanel in project artisynth_core by artisynth.
the class MotionTargetComponentAgent method createPropertyPanel.
protected void createPropertyPanel() {
HostList hostList = new HostList(new HasProperties[] { myController });
myPropTree = hostList.commonProperties(null, false);
// remove properties which are to be excluded
String[] excludedProps = new String[] { "excitation" };
for (int i = 0; i < excludedProps.length; i++) {
myPropTree.removeDescendant(excludedProps[i]);
}
hostList.saveBackupValues(myPropTree);
hostList.getCommonValues(myPropTree, /* live= */
true);
myPropertyPanel = new PropertyPanel(EditingProperty.createProperties(myPropTree, hostList, /* isLive= */
false));
myPropertyPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
addWidget(myPropertyPanel);
}
use of maspack.widgets.PropertyPanel 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.PropertyPanel in project artisynth_core by artisynth.
the class MenuBarHandler method selectClass.
private Class<?> selectClass(String existingClassName) {
// ClassDialog dialog =
// ClassDialog.createDialog (
// myFrame, "Choose model class", "Load", "class", existingClassName);
WidgetDialog dialog = WidgetDialog.createDialog(myFrame, "Choose model class", "Load");
// find all instances of 'RootModel' and create an AutoComplete test field
ArrayList<String> demoClassNames = ClassFinder.findClassNames("artisynth.models", RootModel.class);
AutoCompleteStringField widget = new AutoCompleteStringField("class:", lastSelectedClassName, 30, demoClassNames);
// widget.addValueCheckListener (
// new ValueCheckListener() {
// public Object validateValue(ValueChangeEvent e, StringHolder errMsg) {
// String className = (String)e.getValue();
// if (className != null || !className.equals("")) {
// Class type = getClassFromName (className);
// if (type == null) {
// return PropertyUtils.illegalValue (
// "class not found", errMsg);
// }
// if (!RootModel.class.isAssignableFrom (type)) {
// return PropertyUtils.illegalValue (
// "class not an instance of RootModel", errMsg);
// }
// }
// return PropertyUtils.validValue (className, errMsg);
// }
// });
dialog.setValidator(new WidgetDialog.Validator() {
public String validateSettings(PropertyPanel panel) {
StringField widget = (StringField) panel.getWidgets()[0];
String className = widget.getStringValue();
if (className != null) {
Class<?> type = getClassFromName(className);
if (type == null) {
return "class not found";
}
if (!RootModel.class.isAssignableFrom(type)) {
return "class not an instance of RootModel";
}
}
return null;
}
});
dialog.addWidget(widget);
GuiUtils.locateCenter(dialog, myFrame);
dialog.setVisible(true);
if (dialog.getReturnValue() == OptionPanel.OK_OPTION) {
String className = widget.getStringValue();
if (className != null && !className.equals("")) {
lastSelectedClassName = className;
return getClassFromName(className);
}
}
return null;
}
Aggregations