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