Search in sources :

Example 1 with Property

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

the class FemMuscleHeart method addHeartProbe.

protected void addHeartProbe(MuscleBundle longBundle, MuscleBundle radialBundle) {
    Property[] props = new Property[2];
    props[0] = longBundle.getProperty("excitation");
    props[1] = radialBundle.getProperty("excitation");
    NumericInputProbe probe = new NumericInputProbe();
    probe.setInputProperties(props);
    double startTime = 3.0;
    double stopTime = 60.0;
    // seconds per heart beat
    double cycleTime = 0.8;
    probe.setStartStopTimes(startTime, stopTime);
    // beat cycle
    double[] beat0 = { 0, 0 };
    double[] beat1 = { 0.9, 0 };
    double[] beat2 = { 0, 0.3 };
    for (double t = 0; t < stopTime - startTime; t += cycleTime) {
        // NOTE: times are relative to "startTime"
        probe.addData(t, beat0);
        probe.addData(t + cycleTime * 0.15, beat1);
        probe.addData(t + cycleTime * 0.3, beat2);
        probe.addData(t + cycleTime * 0.4, beat0);
    }
    addInputProbe(probe);
}
Also used : NumericInputProbe(artisynth.core.probes.NumericInputProbe) Property(maspack.properties.Property)

Example 2 with Property

use of maspack.properties.Property 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 3 with Property

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

the class PropertyPanel method updateWidgetValues.

/**
 * Update the widgets in this panel so that they reflect the values of the
 * underlying properties.
 *
 * <p>Underlying properties which are instances of EditingProperty will
 * first normally update their own values from their source component(s).
 * In some cases it may be desirable to suppress this behavior, which can be
 * done by setting <code>updateFromSource</code> to <code>false</code>.
 *
 * @param updateFromSource if <code>false</code>, do not update the values
 * of EditingProperties from their underlying source component(s).
 */
public void updateWidgetValues(boolean updateFromSource) {
    for (int i = 0; i < myWidgets.size(); i++) {
        if (myWidgets.get(i) instanceof LabeledControl) {
            LabeledControl widget = (LabeledControl) myWidgets.get(i);
            Property prop = myWidgetPropMap.get(widget);
            if (prop != null) {
                // their values, which need to be updated from the source
                if (prop instanceof EditingProperty && updateFromSource) {
                    ((EditingProperty) prop).updateValue();
                }
                PropertyWidget.updateValue(widget, prop);
            }
        } else if (myWidgets.get(i) instanceof LabeledPanel) {
            ((LabeledPanel) myWidgets.get(i)).updateWidgetValues(updateFromSource);
        }
    }
}
Also used : EditingProperty(maspack.properties.EditingProperty) InheritableProperty(maspack.properties.InheritableProperty) Property(maspack.properties.Property) EditingProperty(maspack.properties.EditingProperty)

Example 4 with Property

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

the class SetHandler method create.

public static LabeledComponentBase create(String labelText, HasProperties host, String name) {
    Property prop = host.getProperty(name);
    LabeledComponentBase comp = null;
    if (prop != null) {
        comp = create(prop);
        if (comp instanceof LabeledWidget) {
            LabeledWidget lwidget = (LabeledWidget) comp;
            lwidget.setLabelText(labelText);
            lwidget.setToolTipText(prop.getInfo().getDescription());
        }
    }
    return comp;
}
Also used : InheritableProperty(maspack.properties.InheritableProperty) CompositeProperty(maspack.properties.CompositeProperty) Property(maspack.properties.Property)

Example 5 with Property

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

the class CompositePropertyPanel method doUpdateWidgets.

private void doUpdateWidgets(boolean updateFromSource) {
    int i = 0;
    for (Property prop : myWidgetProps) {
        LabeledComponentBase widget = myWidgets[i++];
        if (widget instanceof LabeledControl) {
            LabeledControl ctrl = (LabeledControl) widget;
            if (prop instanceof EditingProperty && updateFromSource) {
                ((EditingProperty) prop).updateValue();
            }
            PropertyWidget.updateValue(ctrl, prop);
        } else if (widget instanceof CompositePropertyPanel) {
            CompositePropertyPanel cpanel = (CompositePropertyPanel) widget;
            cpanel.updateWidgetValues(updateFromSource);
        }
    }
}
Also used : EditingProperty(maspack.properties.EditingProperty) InheritableProperty(maspack.properties.InheritableProperty) CompositeProperty(maspack.properties.CompositeProperty) Property(maspack.properties.Property) EditingProperty(maspack.properties.EditingProperty)

Aggregations

Property (maspack.properties.Property)44 CompositeProperty (maspack.properties.CompositeProperty)15 EditingProperty (maspack.properties.EditingProperty)15 InheritableProperty (maspack.properties.InheritableProperty)10 ModelComponent (artisynth.core.modelbase.ModelComponent)9 IOException (java.io.IOException)7 InternalErrorException (maspack.util.InternalErrorException)7 ArrayList (java.util.ArrayList)6 LabeledComponentBase (maspack.widgets.LabeledComponentBase)6 NumericInputProbe (artisynth.core.probes.NumericInputProbe)5 HasProperties (maspack.properties.HasProperties)5 NumericOutputProbe (artisynth.core.probes.NumericOutputProbe)4 NumericProbeVariable (artisynth.core.probes.NumericProbeVariable)4 RootModel (artisynth.core.workspace.RootModel)3 Component (java.awt.Component)3 Point (java.awt.Point)3 File (java.io.File)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 Timeline (artisynth.core.gui.Timeline)2