Search in sources :

Example 1 with PropertyPanel

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);
}
Also used : HostList(maspack.properties.HostList) PropertyPanel(maspack.widgets.PropertyPanel)

Example 2 with PropertyPanel

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 (&quot;Add AxialSprings&quot;);
 * 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);
}
Also used : PropertyPanel(maspack.widgets.PropertyPanel)

Example 3 with PropertyPanel

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);
}
Also used : HostList(maspack.properties.HostList) PropertyPanel(maspack.widgets.PropertyPanel)

Example 4 with PropertyPanel

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());
    }
}
Also used : ValueCheckListener(maspack.widgets.ValueCheckListener) ValueChangeEvent(maspack.widgets.ValueChangeEvent) StringHolder(maspack.util.StringHolder) BooleanSelector(maspack.widgets.BooleanSelector) PropertyDialog(maspack.widgets.PropertyDialog) IntegerField(maspack.widgets.IntegerField) DoubleField(maspack.widgets.DoubleField) WayPoint(artisynth.core.probes.WayPoint) PropertyPanel(maspack.widgets.PropertyPanel)

Example 5 with PropertyPanel

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;
}
Also used : WidgetDialog(maspack.widgets.WidgetDialog) AutoCompleteStringField(maspack.widgets.AutoCompleteStringField) AutoCompleteStringField(maspack.widgets.AutoCompleteStringField) StringField(maspack.widgets.StringField) PropertyPanel(maspack.widgets.PropertyPanel)

Aggregations

PropertyPanel (maspack.widgets.PropertyPanel)8 HostList (maspack.properties.HostList)3 PropertyDialog (maspack.widgets.PropertyDialog)2 WayPoint (artisynth.core.probes.WayPoint)1 PullController (artisynth.core.workspace.PullController)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 LinkedList (java.util.LinkedList)1 EditingProperty (maspack.properties.EditingProperty)1 HasProperties (maspack.properties.HasProperties)1 Property (maspack.properties.Property)1 StringHolder (maspack.util.StringHolder)1 AutoCompleteStringField (maspack.widgets.AutoCompleteStringField)1 BooleanSelector (maspack.widgets.BooleanSelector)1 DoubleField (maspack.widgets.DoubleField)1 ExpandablePropertyPanel (maspack.widgets.ExpandablePropertyPanel)1 IntegerField (maspack.widgets.IntegerField)1 LabeledWidget (maspack.widgets.LabeledWidget)1 StringField (maspack.widgets.StringField)1 ValueChangeEvent (maspack.widgets.ValueChangeEvent)1