use of artisynth.core.modelbase.CompositeComponent in project artisynth_core by artisynth.
the class ControlPanel method postscanWidget.
public void postscanWidget(Deque<ScanToken> tokens, CompositeComponent ancestor) throws IOException {
String propPath = null;
if (tokens.peek() instanceof StringToken) {
propPath = (String) tokens.poll().value();
}
if (!(tokens.peek() instanceof ObjectToken)) {
throw new IOException("Expecting ObjectToken containing widget");
}
Component comp = (Component) tokens.poll().value();
if (comp instanceof LabeledComponentBase) {
Property property = null;
LabeledComponentBase widget = (LabeledComponentBase) comp;
// such as range could cause the property value itself to be reset
if (widget instanceof LabeledControl) {
((LabeledControl) widget).maskValueChangeListeners(true);
}
if (propPath != null) {
property = ancestor.getProperty(propPath);
if (property == null) {
System.out.println("Ignoring control panel widget for " + propPath);
widget = null;
} else {
boolean widgetSet = false;
try {
// initialize widget, but don't set properties because
// these will have already been set in the scan method
widgetSet = PropertyWidget.initializeWidget(widget, property);
} catch (Exception e) {
e.printStackTrace();
widgetSet = false;
}
if (widgetSet == false) {
System.out.println("Warning: widget " + widget + " inappropriate for property " + propPath + "; ignoring");
widget = null;
}
}
}
if (widget instanceof LabeledControl) {
((LabeledControl) widget).maskValueChangeListeners(false);
}
// properties (such as the range) are initialized
if (widget != null && property != null) {
PropertyWidget.finishWidget(widget, property);
myPanel.processPropertyWidget(property, widget);
}
if (widget != null) {
addWidget(widget);
}
} else {
addWidget(comp);
}
}
use of artisynth.core.modelbase.CompositeComponent in project artisynth_core by artisynth.
the class SkinMeshBody method writeFrameInfo.
protected void writeFrameInfo(PrintWriter pw, NumberFormat fmt, Object ref) throws IOException {
if (myFrameInfo.size() == 0) {
pw.println("[ ]");
} else {
CompositeComponent ancestor = ComponentUtils.castRefToAncestor(ref);
pw.println("[");
IndentingPrintWriter.addIndentation(pw, 2);
for (int i = 0; i < myFrameInfo.size(); i++) {
FrameInfo finfo = myFrameInfo.get(i);
pw.println(ComponentUtils.getWritePathName(ancestor, finfo.myFrame));
pw.print("[ ");
IndentingPrintWriter.addIndentation(pw, 2);
finfo.myBasePose.write(pw, fmt);
IndentingPrintWriter.addIndentation(pw, -2);
pw.println("]");
}
IndentingPrintWriter.addIndentation(pw, -2);
pw.println("]");
}
}
Aggregations