use of maspack.properties.HostList in project artisynth_core by artisynth.
the class RenderPropsDialog method build.
// public RenderPropsDialog (Frame owner, String title,
// Iterable<? extends HasProperties> renderables) {
// super (owner, title);
// initialize ("Done Reset");
// build (renderables);
// inheritGlobalListeners (owner);
// setDefaultCloseOperation (DISPOSE_ON_CLOSE);
// }
// public RenderPropsDialog (Dialog owner, String title,
// Iterable<? extends HasProperties> renderables) {
// super (owner, title);
// initialize ("Done Reset");
// build (renderables);
// inheritGlobalListeners (owner);
// setDefaultCloseOperation (DISPOSE_ON_CLOSE);
// }
// public static RenderPropsDialog createDialog (
// Window win, String title, Iterable<? extends HasProperties> renderables) {
// RenderPropsDialog dialog;
// if (win instanceof Dialog) {
// dialog = new RenderPropsDialog ((Dialog)win, title, renderables);
// }
// else if (win instanceof Frame) {
// dialog = new RenderPropsDialog ((Frame)win, title, renderables);
// }
// else if (win == null) {
// dialog = new RenderPropsDialog (title, renderables);
// }
// else {
// throw new InternalErrorException ("Unsupported window type " + win);
// }
// return dialog;
// }
private void build(Iterable<? extends HasProperties> renderables) {
myHostList = new HostList(renderables);
Iterator<? extends HasProperties> it = renderables.iterator();
if (!it.hasNext()) {
throw new IllegalArgumentException("list of renderables is empty");
}
HasProperties renderable = it.next();
PropertyInfo renderInfo = renderable.getAllPropertyInfo().get("renderProps");
if (renderInfo == null) {
throw new IllegalArgumentException("renderable '" + renderable.getClass() + "' does not contain property 'renderProps'");
}
PropTreeCell tree = new PropTreeCell();
PropTreeCell renderCell = new PropTreeCell(renderInfo, null);
tree.addChild(renderCell);
// need to expand the host list down one level before we
// can get to the render props
myHostList.saveBackupValues(tree);
// null render props will be stored as null here
myHostList.getCommonValues(tree, /* live= */
true);
// values for null render props will be expanded
// using props returned from createRenderProps
renderCell.addChildren(myHostList.commonProperties(renderCell, false));
// backup values will be saved, including the original
// null values
myHostList.saveBackupValues(renderCell);
// null render props will be replaced with the render props
// that were created during the the call to commonProperties
myHostList.addSubHostsIfNecessary(renderCell);
myHostList.getCommonValues(renderCell, /* live= */
true);
myNumProps = renderCell.numChildren();
setPanel(new RenderPropsPanel(EditingProperty.createProperties(renderCell, myHostList, /* isLive= */
true)));
setScrollable(true);
myTree = renderCell;
// enableAutoRerendering (true);
// ViewerManager driver = Main.getMain().getViewerManager();
// driver.setSelectionHighlighting (GLViewer.SelectionHighlighting.None);
// driver.render();
// addWindowListener (
// new PropertyWindowAdapter(this)
// {
// public void windowClosing (WindowEvent e)
// {
// getWindow().dispose();
// }
// public void windowClosed (WindowEvent e)
// {
// ViewerManager driver = Main.getMain().getViewerManager();
// driver.setSelectionHighlighting (
// GLViewer.SelectionHighlighting.Color);
// driver.render();
// }
// });
// addWindowListener (new WindowAdapter() {
// // public void windowClosing (WindowEvent e)
// // {
// // e.getSource().dispose();
// // }
//
// public void windowClosed (WindowEvent e) {
// ViewerManager driver = Main.getMain().getViewerManager();
// driver.setSelectionHighlighting (
// GLViewer.SelectionHighlighting.Color);
// driver.render();
// }
// });
// initFinish ("Done Reset");
pack();
}
use of maspack.properties.HostList 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);
}
}
use of maspack.properties.HostList in project artisynth_core by artisynth.
the class CompositePropertyPanel method isNullAllowed.
private boolean isNullAllowed(Property prop) {
if (prop instanceof EditingProperty) {
// then null values are allowed only if they are permitted
// on all the hosts
EditingProperty eprop = (EditingProperty) prop;
HostList hostList = eprop.getHostList();
PropTreeCell cell = eprop.getCell();
PropertyInfo[] infos = hostList.getAllInfos(cell);
boolean nullAllowed = true;
for (PropertyInfo info : infos) {
if (!info.getNullValueOK()) {
nullAllowed = false;
}
}
return nullAllowed;
} else {
return prop.getInfo().getNullValueOK();
}
}
use of maspack.properties.HostList in project artisynth_core by artisynth.
the class CompositePropertyPanel method getCurrentCprop.
/**
* Returns the current composite property.
*/
private Object getCurrentCprop() {
if (myCpropProperty instanceof EditingProperty) {
EditingProperty eprop = (EditingProperty) myCpropProperty;
HostList hostList = eprop.getHostList();
Object[] values = hostList.getAllValues(eprop.getCell());
Class<?> cpropType = getCpropType(values[0]);
if (cpropType == Property.VoidValue) {
return Property.VoidValue;
}
for (int i = 1; i < values.length; i++) {
Class<?> nextType = getCpropType(values[i]);
if (nextType == Property.VoidValue || nextType != cpropType) {
return Property.VoidValue;
}
}
return values[0];
} else {
return myCpropProperty.get();
}
}
use of maspack.properties.HostList in project artisynth_core by artisynth.
the class TracingProbePanel method setTracingProbe.
protected void setTracingProbe(String traceableName) {
if (traceableName.equals(myTraceableName)) {
return;
}
myTraceableName = traceableName;
// if (myPrototype != null)
// { setProperties (myPrototype, myPrototype);
// }
myPrototype = getPrototypeProbe(traceableName);
if (myPrototype != null) {
HostList hostList = new HostList(new HasProperties[] { myPrototype });
myPropTree = hostList.commonProperties(null, false);
// remove properties which are to be excluded
for (int i = 0; i < myExcludedProps.length; i++) {
myPropTree.removeDescendant(myExcludedProps[i]);
}
hostList.saveBackupValues(myPropTree);
hostList.getCommonValues(myPropTree, /* live= */
true);
// update fixed widgets
myUpdateIntervalField.setValue(myPrototype.getProperty("updateInterval").get());
// remove non-fixed widgets
int deleteCnt = myPanel.getComponentCount() - myNumFixedWidgets;
for (int i = 0; i < deleteCnt; i++) {
myPanel.removeWidget(myNumFixedWidgets);
}
// add the new widgets
myPanel.addWidgets(EditingProperty.createProperties(myPropTree, hostList, /* isLive= */
false));
validate();
if (isVisible()) {
pack();
}
}
}
Aggregations