Search in sources :

Example 11 with CompositeComponent

use of artisynth.core.modelbase.CompositeComponent in project artisynth_core by artisynth.

the class ControlPanel method postscanWidget.

public void postscanWidget(Deque<ScanToken> tokens, CompositeComponent ancestor) throws IOException {
    String propPath = null;
    if (tokens.peek() instanceof StringToken) {
        propPath = (String) tokens.poll().value();
    }
    if (!(tokens.peek() instanceof ObjectToken)) {
        throw new IOException("Expecting ObjectToken containing widget");
    }
    Component comp = (Component) tokens.poll().value();
    if (comp instanceof LabeledComponentBase) {
        Property property = null;
        LabeledComponentBase widget = (LabeledComponentBase) comp;
        // such as range could cause the property value itself to be reset
        if (widget instanceof LabeledControl) {
            ((LabeledControl) widget).maskValueChangeListeners(true);
        }
        if (propPath != null) {
            property = ancestor.getProperty(propPath);
            if (property == null) {
                System.out.println("Ignoring control panel widget for " + propPath);
                widget = null;
            } else {
                boolean widgetSet = false;
                try {
                    // initialize widget, but don't set properties because
                    // these will have already been set in the scan method
                    widgetSet = PropertyWidget.initializeWidget(widget, property);
                } catch (Exception e) {
                    e.printStackTrace();
                    widgetSet = false;
                }
                if (widgetSet == false) {
                    System.out.println("Warning: widget " + widget + " inappropriate for property " + propPath + "; ignoring");
                    widget = null;
                }
            }
        }
        if (widget instanceof LabeledControl) {
            ((LabeledControl) widget).maskValueChangeListeners(false);
        }
        // properties (such as the range) are initialized
        if (widget != null && property != null) {
            PropertyWidget.finishWidget(widget, property);
            myPanel.processPropertyWidget(property, widget);
        }
        if (widget != null) {
            addWidget(widget);
        }
    } else {
        addWidget(comp);
    }
}
Also used : LabeledControl(maspack.widgets.LabeledControl) LabeledComponentBase(maspack.widgets.LabeledComponentBase) IOException(java.io.IOException) MutableCompositeComponent(artisynth.core.modelbase.MutableCompositeComponent) Component(java.awt.Component) ModelComponent(artisynth.core.modelbase.ModelComponent) CompositeComponent(artisynth.core.modelbase.CompositeComponent) JComponent(javax.swing.JComponent) Property(maspack.properties.Property) EditingProperty(maspack.properties.EditingProperty) IOException(java.io.IOException)

Example 12 with CompositeComponent

use of artisynth.core.modelbase.CompositeComponent in project artisynth_core by artisynth.

the class SkinMeshBody method writeFrameInfo.

protected void writeFrameInfo(PrintWriter pw, NumberFormat fmt, Object ref) throws IOException {
    if (myFrameInfo.size() == 0) {
        pw.println("[ ]");
    } else {
        CompositeComponent ancestor = ComponentUtils.castRefToAncestor(ref);
        pw.println("[");
        IndentingPrintWriter.addIndentation(pw, 2);
        for (int i = 0; i < myFrameInfo.size(); i++) {
            FrameInfo finfo = myFrameInfo.get(i);
            pw.println(ComponentUtils.getWritePathName(ancestor, finfo.myFrame));
            pw.print("[ ");
            IndentingPrintWriter.addIndentation(pw, 2);
            finfo.myBasePose.write(pw, fmt);
            IndentingPrintWriter.addIndentation(pw, -2);
            pw.println("]");
        }
        IndentingPrintWriter.addIndentation(pw, -2);
        pw.println("]");
    }
}
Also used : CompositeComponent(artisynth.core.modelbase.CompositeComponent) ContactPoint(artisynth.core.mechmodels.ContactPoint) Point(artisynth.core.mechmodels.Point)

Aggregations

CompositeComponent (artisynth.core.modelbase.CompositeComponent)12 ModelComponent (artisynth.core.modelbase.ModelComponent)7 Point (artisynth.core.mechmodels.Point)3 MutableCompositeComponent (artisynth.core.modelbase.MutableCompositeComponent)3 ContactPoint (artisynth.core.mechmodels.ContactPoint)2 Component (java.awt.Component)2 JComponent (javax.swing.JComponent)2 HasMenuItems (artisynth.core.modelbase.HasMenuItems)1 PropertyChangeEvent (artisynth.core.modelbase.PropertyChangeEvent)1 RenderableComponentList (artisynth.core.modelbase.RenderableComponentList)1 RootModel (artisynth.core.workspace.RootModel)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 CompositeProperty (maspack.properties.CompositeProperty)1 EditingProperty (maspack.properties.EditingProperty)1 Property (maspack.properties.Property)1 RenderProps (maspack.render.RenderProps)1 LabeledComponentBase (maspack.widgets.LabeledComponentBase)1 LabeledControl (maspack.widgets.LabeledControl)1 OptionPanel (maspack.widgets.OptionPanel)1