use of maspack.properties.Property in project artisynth_core by artisynth.
the class NumericProbeBase method scanProperties.
protected ArrayList<Property> scanProperties(ReaderTokenizer rtok, CompositeComponent ancestor) throws IOException {
ArrayList<Property> list = new ArrayList<Property>();
IOException errorex = null;
rtok.scanToken('[');
int csave = rtok.getCharSetting(':');
int dsave = rtok.getCharSetting('-');
rtok.wordChar(':');
rtok.wordChar('-');
while (rtok.nextToken() != ']') {
if (!rtok.tokenIsWord() && rtok.ttype != '"') {
errorex = new IOException("expected property name; got " + rtok);
break;
}
if (ancestor == null) {
errorex = new IOException("CompositeComponent reference object required");
break;
}
Property prop = ComponentUtils.findProperty(ancestor, rtok.sval);
if (prop == null) {
errorex = new IOException("Cannot find property " + rtok.sval);
break;
}
list.add(prop);
}
rtok.setCharSetting(':', csave);
rtok.setCharSetting('-', dsave);
if (errorex != null) {
throw errorex;
}
return list;
}
use of maspack.properties.Property in project artisynth_core by artisynth.
the class ForceTargetDemo method loadForceInputProbe.
public void loadForceInputProbe(ForceTargetTerm mft) throws IOException {
ArtisynthPath.setWorkingDir(new File(ArtisynthPath.getSrcRelativePath(this, "data/")));
Property[] proparr = new Property[mft.getForceTargets().size()];
for (int i = 0; i < mft.getForceTargets().size(); i++) {
System.out.println(mft.getForceTargets().get(i).getConnector().getName());
proparr[i] = mft.getForceTargets().get(i).getProperty("targetLambda");
}
NumericInputProbe forprobe = new NumericInputProbe();
forprobe.setModel(mech);
forprobe.setInputProperties(proparr);
forprobe.setInterval(0, 1);
forprobe.setName("Force Target");
if (two_cons == true) {
forprobe.setAttachedFileName("inputforcetarget3.txt");
} else {
forprobe.setAttachedFileName("inputforcetarget2.txt");
}
forprobe.setStartStopTimes(0, 10);
addInputProbe(forprobe);
forprobe.load();
}
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, double min, double max) {
Property prop = host.getProperty(name);
LabeledComponentBase comp = null;
if (prop != null) {
comp = create(prop, min, max);
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 createWidgetProps.
/**
* Create properties for the widgets controlling the property values of the
* current composite property.
*/
private LinkedList<Property> createWidgetProps() {
if (myCpropProperty instanceof EditingProperty) {
EditingProperty eprop = (EditingProperty) myCpropProperty;
HostList hostList = eprop.getHostList();
PropTreeCell cell = eprop.getCell();
cell.removeAllChildren();
CompositeProperty cprop = createCprop(myCpropType);
LinkedList<Property> props = PropertyUtils.createProperties(cprop);
for (Property prop : props) {
cell.addChild(new PropTreeCell(prop.getInfo(), prop.get()));
}
hostList.setSubHostsFromValue(cell);
hostList.saveBackupValues(cell);
hostList.getCommonValues(cell, /*live=*/
true);
cell.setValue(CompositeProperty.class);
return EditingProperty.createProperties(cell, hostList, /*live=*/
true);
} else {
myCprop = (CompositeProperty) myCpropProperty.get();
return PropertyUtils.createProperties(myCprop);
}
}
use of maspack.properties.Property in project artisynth_core by artisynth.
the class CompositePropertyPanel method printWidgetProps.
// For debugging only ...
void printWidgetProps(LinkedList<Property> props) {
if (myCpropProperty instanceof EditingProperty) {
EditingProperty eprop = (EditingProperty) myCpropProperty;
// HostList hostList = eprop.getHostList();
PropTreeCell cell = eprop.getCell();
System.out.println("parent cell=@" + cell.hashCode());
for (Property p : props) {
EditingProperty ep = (EditingProperty) p;
ep.getCell().getIndex();
System.out.println(" " + ep.getName() + "=@" + ep.getCell().hashCode());
if (ep.getCell().getParent() != cell) {
System.out.println("BAD");
}
}
System.out.println("OK");
}
}
Aggregations