use of maspack.properties.CompositeProperty in project artisynth_core by artisynth.
the class CompositePropertyPanel method valueChange.
/**
* Called when the composite property type is changed via the composite
* property type selector.
*/
public void valueChange(ValueChangeEvent e) {
if (e.getSource() == myCpropSelector) {
String newCpropName = (String) myCpropSelector.getValue();
Class<?> newCpropType = myCpropTypes.get(newCpropName);
CompositeProperty protoCprop = null;
if (myCpropType == Property.VoidValue && newCpropType != null && myCpropProperty instanceof EditingProperty) {
// if there is an existing composite property of this type among the
// hosts, try to create the prototype by cloning it so
// that we start with it's properties
protoCprop = tryCreatingCpropFromPrototype(newCpropType);
}
if (protoCprop == null) {
protoCprop = createCprop(newCpropType);
}
myCpropProperty.set(protoCprop);
myCpropType = newCpropType;
rebuildPanel(/*setValuesFromWidgets=*/
true);
GuiUtils.repackComponentWindow(this);
fireGlobalValueChangeListeners(new ValueChangeEvent(this, e));
} else if (e.getSource() == myExpandButton) {
if (myExpandButton.getBooleanValue()) {
setExpandState(ExpandState.Expanded);
} else {
setExpandState(ExpandState.Contracted);
}
} else {
throw new InternalErrorException("Unexpected valueChange event: " + e);
// fireGlobalValueChangeListeners(new ValueChangeEvent(this, e));
}
}
use of maspack.properties.CompositeProperty in project artisynth_core by artisynth.
the class NumericProbeEditor method getFullPropPath.
/**
* returns the full string path of a property by going up the hierachy and
* finding all its parent properties (if any) and component path.
*/
protected String getFullPropPath(Property prop) {
String compPath = prop.getName();
ModelComponent root = myMain.getRootModel();
Object host = prop.getHost();
// System.out.println("Looking for parent path...");
if (host instanceof CompositeProperty) {
while (host instanceof CompositeProperty) {
String name = ((CompositeProperty) host).getPropertyInfo().getName();
// System.out.println(name);
compPath = name + "." + compPath;
host = ((CompositeProperty) host).getPropertyHost();
}
String baseComp = ComponentUtils.getPathName((CompositeComponent) root, (ModelComponent) host);
compPath = baseComp + ComponentUtils.componentPropertySeparator + compPath;
} else {
compPath = ComponentUtils.getPathName((CompositeComponent) root, (ModelComponent) prop.getHost());
compPath += ComponentUtils.componentPropertySeparator + prop.getName();
}
// System.out.println("found component base path: "+compPath);
return compPath;
}
use of maspack.properties.CompositeProperty in project artisynth_core by artisynth.
the class ComponentPropertyField method valueToText.
protected String valueToText(Object value) {
ModelComponent comp = getComponent(value);
RootModel root = myMain.getRootModel();
if (root == null || comp == null) {
return "";
}
if (value instanceof ModelComponent) {
return ComponentUtils.getPathName(root, comp);
} else if (value instanceof Property) {
Property prop = (Property) value;
boolean excludeLeaf = (myPropertySelector != null && !(prop.get() instanceof CompositeProperty));
String path = ComponentUtils.getPropertyPathName(prop, root, false);
if (!path.contains(":")) {
// root component + property
path = "/:" + path;
}
return path;
} else {
throw new InternalErrorException("Unknown value type: " + value.getClass());
}
// String text = ComponentUtils.getPathName(root, comp);
// if (value instanceof Property)
// { Property prop = (Property)value;
// String propPath = getPropertyPath (prop, myPropertySelector != null);
// if (propPath.length() > 0)
// { text += "/" + propPath;
// }
// }
// return text;
}
Aggregations