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);
}
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);
}
}
}
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);
}
}
}
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;
}
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);
}
}
}
Aggregations