Search in sources :

Example 1 with CopyableComponent

use of artisynth.core.modelbase.CopyableComponent in project artisynth_core by artisynth.

the class TracingProbePanel method getPrototypeProbe.

protected TracingProbe getPrototypeProbe(String traceableName) {
    TracingProbe tmpProbe = TracingProbe.create(myTraceable, traceableName);
    Class<?> type = tmpProbe.getClass();
    TracingProbe comp = myPrototypeMap.get(type);
    if (comp == null) {
        // look for prototype as the last instance in the
        // container
        RootModel root = myMain.getRootModel();
        for (Probe probe : root.getOutputProbes()) {
            if (type.isAssignableFrom(probe.getClass())) {
                comp = (TracingProbe) probe;
            }
        }
        if (comp == null || !(comp instanceof CopyableComponent)) {
            comp = tmpProbe;
            // try {
            // comp = (TracingProbe)type.newInstance();
            // }
            // catch (Exception e) {
            // throw new InternalErrorException (
            // "cannot create no-args instance of " + type);
            // }
            initializePrototype(comp);
        } else {
            comp = (TracingProbe) ((CopyableComponent) comp).copy(0, null);
        }
        myPrototypeMap.put(type, comp);
    }
    return comp;
}
Also used : RootModel(artisynth.core.workspace.RootModel) CopyableComponent(artisynth.core.modelbase.CopyableComponent) TracingProbe(artisynth.core.probes.TracingProbe) TracingProbe(artisynth.core.probes.TracingProbe) Probe(artisynth.core.probes.Probe)

Aggregations

CopyableComponent (artisynth.core.modelbase.CopyableComponent)1 Probe (artisynth.core.probes.Probe)1 TracingProbe (artisynth.core.probes.TracingProbe)1 RootModel (artisynth.core.workspace.RootModel)1