use of maspack.properties.Property in project artisynth_core by artisynth.
the class ComponentPropertyField method valueToText.
protected String valueToText(Object value) {
ModelComponent comp = getComponent(value);
RootModel root = myMain.getRootModel();
if (root == null || comp == null) {
return "";
}
if (value instanceof ModelComponent) {
return ComponentUtils.getPathName(root, comp);
} else if (value instanceof Property) {
Property prop = (Property) value;
boolean excludeLeaf = (myPropertySelector != null && !(prop.get() instanceof CompositeProperty));
String path = ComponentUtils.getPropertyPathName(prop, root, false);
if (!path.contains(":")) {
// root component + property
path = "/:" + path;
}
return path;
} else {
throw new InternalErrorException("Unknown value type: " + value.getClass());
}
// String text = ComponentUtils.getPathName(root, comp);
// if (value instanceof Property)
// { Property prop = (Property)value;
// String propPath = getPropertyPath (prop, myPropertySelector != null);
// if (propPath.length() > 0)
// { text += "/" + propPath;
// }
// }
// return text;
}
use of maspack.properties.Property in project artisynth_core by artisynth.
the class ComponentPropertyField method setValueFromPropertySelector.
private void setValueFromPropertySelector() {
if (!myPropertyMask) {
String propName = (String) myPropertySelector.getValue();
HasProperties host = getHost();
if (propName.equals(nullString)) {
Object value = getValueForHost();
System.out.println("new value");
updateValueAndDisplay(value);
return;
}
if (host == null) {
throw new InternalErrorException("Current property host is null");
}
Property prop = host.getProperty(propName);
if (prop == null) {
throw new InternalErrorException("Current property host does not contain property " + propName);
}
updateValueAndDisplay(prop);
}
}
use of maspack.properties.Property in project artisynth_core by artisynth.
the class PropertyField method setNumericOnly.
/**
* Sets this field to accept only numeric properties (i.e., those whose
* values can be mapped onto a vector).
*
* @param enable
* if true, enables only numeric properties
*/
public void setNumericOnly(boolean enable) {
if (myNumericOnly != enable) {
myNumericOnly = enable;
// clear to ensure property selection list will be rebuilt ...
myLastSelectorHost = null;
if (enable) {
Property prop = getProperty();
if (prop != null && !isNumeric(prop.getInfo())) {
updateValueAndDisplay(getValueForHost());
return;
}
}
// will redo property selector entries
updatePropertySelector();
}
}
use of maspack.properties.Property in project artisynth_core by artisynth.
the class ForceTargetDemo method addConForceProbe.
public void addConForceProbe(double duration, double interval) {
ArrayList<Property> props = new ArrayList<Property>();
for (BodyConnector rbc : mech.bodyConnectors()) {
if (rbc.isEnabled() && rbc.getProperty("activation") != null) {
props.add(rbc.getProperty("activation"));
}
}
Property[] proparray = new Property[props.size()];
for (int i = 0; i < props.size(); i++) {
proparray[i] = props.get(i);
}
String name = "conforce";
NumericOutputProbe p = new NumericOutputProbe(proparray, interval);
p.setStartStopTimes(0, duration);
p.setName(name);
p.setAttachedFileName(name + "_output.txt");
p.setDefaultDisplayRange(-0.1, 0.1);
addOutputProbe(p);
}
Aggregations