Search in sources :

Example 21 with Property

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;
}
Also used : IOException(java.io.IOException) Property(maspack.properties.Property)

Example 22 with Property

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();
}
Also used : NumericInputProbe(artisynth.core.probes.NumericInputProbe) File(java.io.File) Property(maspack.properties.Property) TargetPoint(artisynth.core.inverse.TargetPoint)

Example 23 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, 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;
}
Also used : InheritableProperty(maspack.properties.InheritableProperty) CompositeProperty(maspack.properties.CompositeProperty) Property(maspack.properties.Property)

Example 24 with Property

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);
    }
}
Also used : EditingProperty(maspack.properties.EditingProperty) PropTreeCell(maspack.properties.PropTreeCell) HostList(maspack.properties.HostList) InheritableProperty(maspack.properties.InheritableProperty) CompositeProperty(maspack.properties.CompositeProperty) Property(maspack.properties.Property) EditingProperty(maspack.properties.EditingProperty) CompositeProperty(maspack.properties.CompositeProperty)

Example 25 with Property

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");
    }
}
Also used : EditingProperty(maspack.properties.EditingProperty) PropTreeCell(maspack.properties.PropTreeCell) 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