Search in sources :

Example 1 with InheritableProperty

use of maspack.properties.InheritableProperty in project artisynth_core by artisynth.

the class PropertyPanel method doAddWidgetsFlat.

private void doAddWidgetsFlat(Iterable<?> items) {
    for (Object item : items) {
        // ignore inactive properties
        if (item instanceof Property) {
            Property prop = (Property) item;
            if (isInheritableProperty(prop) && ((InheritableProperty) prop).getMode() == PropertyMode.Inactive) {
                continue;
            }
            addWidget(prop);
        } else if (item instanceof Component) {
            addWidget((Component) item);
        }
    }
}
Also used : InheritableProperty(maspack.properties.InheritableProperty) Component(java.awt.Component) InheritableProperty(maspack.properties.InheritableProperty) Property(maspack.properties.Property) EditingProperty(maspack.properties.EditingProperty)

Example 2 with InheritableProperty

use of maspack.properties.InheritableProperty in project artisynth_core by artisynth.

the class ExpandablePropertyPanel method addExtraWidgets.

public void addExtraWidgets(Iterable<?> items) {
    for (Object item : items) {
        // ignore inactive properties
        if (item instanceof Property) {
            Property prop = (Property) item;
            if (isInheritableProperty(prop) && ((InheritableProperty) prop).getMode() == PropertyMode.Inactive) {
                continue;
            }
            addExtraWidget(prop);
        } else if (item instanceof Component) {
            addExtraWidget((Component) item);
        }
    }
}
Also used : InheritableProperty(maspack.properties.InheritableProperty) Component(java.awt.Component) InheritableProperty(maspack.properties.InheritableProperty) Property(maspack.properties.Property)

Example 3 with InheritableProperty

use of maspack.properties.InheritableProperty in project artisynth_core by artisynth.

the class CompositePropertyPanel method attachPropsToWidgets.

/**
 * Attaches a newly created set of properties to their associated
 * widgets.
 *
 * @param widgets list of widgets
 * @param props newly created properties
 * @param setValuesFromWidgets if <code>true</code>, then the properties
 * should be set to assume the values currently stored in the widgets.
 */
private void attachPropsToWidgets(LabeledComponentBase[] widgets, LinkedList<Property> props, boolean setValuesFromWidgets) {
    if (widgets.length != props.size()) {
        throw new InternalErrorException("Number of widgets (" + widgets.length + ") != number of properties (" + props.size() + ")");
    }
    int i = 0;
    for (Property prop : props) {
        LabeledComponentBase widget = widgets[i++];
        if (!setValuesFromWidgets || !(widget instanceof CompositePropertyPanel)) {
            PropertyWidget.initializeWidget(widget, prop);
        }
        if (setValuesFromWidgets) {
            if (widget instanceof CompositePropertyPanel) {
                CompositePropertyPanel cpanel = (CompositePropertyPanel) widget;
                if (cpanel.myCpropType != Property.VoidValue) {
                    setCpropValueFromWidget(prop, (CompositePropertyPanel) widget);
                } else {
                    cpanel.myCpropProperty = prop;
                    cpanel.updateWidgetValues(/*updateFromSource=*/
                    true);
                }
            } else if (widget instanceof LabeledControl) {
                LabeledControl ctrl = (LabeledControl) widget;
                if (ctrl.getValue() != Property.VoidValue) {
                    setValueFromWidget(prop, ctrl);
                } else {
                    if (prop instanceof EditingProperty) {
                        EditingProperty eprop = (EditingProperty) prop;
                        eprop.updateValue();
                    }
                    PropertyWidget.updateValue(ctrl, prop);
                }
            }
        }
        // will set value
        PropertyWidget.finishWidget(widget, prop);
        if (prop instanceof InheritableProperty) {
            PropertyModeButton button = PropertyWidget.getModeButton((LabeledComponentBase) widget);
            if (button != null) {
                button.setProperty((InheritableProperty) prop);
            }
        }
    }
}
Also used : EditingProperty(maspack.properties.EditingProperty) InheritableProperty(maspack.properties.InheritableProperty) InternalErrorException(maspack.util.InternalErrorException) InheritableProperty(maspack.properties.InheritableProperty) CompositeProperty(maspack.properties.CompositeProperty) Property(maspack.properties.Property) EditingProperty(maspack.properties.EditingProperty)

Aggregations

InheritableProperty (maspack.properties.InheritableProperty)3 Property (maspack.properties.Property)3 Component (java.awt.Component)2 EditingProperty (maspack.properties.EditingProperty)2 CompositeProperty (maspack.properties.CompositeProperty)1 InternalErrorException (maspack.util.InternalErrorException)1