Search in sources :

Example 11 with HostList

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();
}
Also used : PropTreeCell(maspack.properties.PropTreeCell) HasProperties(maspack.properties.HasProperties) HostList(maspack.properties.HostList) PropertyInfo(maspack.properties.PropertyInfo)

Example 12 with HostList

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);
    }
}
Also used : EditingProperty(maspack.properties.EditingProperty) PropTreeCell(maspack.properties.PropTreeCell) HostList(maspack.properties.HostList) InheritableProperty(maspack.properties.InheritableProperty) CompositeProperty(maspack.properties.CompositeProperty) Property(maspack.properties.Property) EditingProperty(maspack.properties.EditingProperty) CompositeProperty(maspack.properties.CompositeProperty)

Example 13 with HostList

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();
    }
}
Also used : EditingProperty(maspack.properties.EditingProperty) PropTreeCell(maspack.properties.PropTreeCell) HostList(maspack.properties.HostList) PropertyInfo(maspack.properties.PropertyInfo)

Example 14 with HostList

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();
    }
}
Also used : EditingProperty(maspack.properties.EditingProperty) HostList(maspack.properties.HostList)

Example 15 with HostList

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();
        }
    }
}
Also used : HostList(maspack.properties.HostList)

Aggregations

HostList (maspack.properties.HostList)18 EditingProperty (maspack.properties.EditingProperty)8 PropTreeCell (maspack.properties.PropTreeCell)8 HasProperties (maspack.properties.HasProperties)4 InternalErrorException (maspack.util.InternalErrorException)3 PropertyDialog (maspack.widgets.PropertyDialog)3 PropertyPanel (maspack.widgets.PropertyPanel)3 LinkedList (java.util.LinkedList)2 CompositeProperty (maspack.properties.CompositeProperty)2 Property (maspack.properties.Property)2 PropertyInfo (maspack.properties.PropertyInfo)2 Window (java.awt.Window)1 JComponent (javax.swing.JComponent)1 JSeparator (javax.swing.JSeparator)1 InheritableProperty (maspack.properties.InheritableProperty)1 TestHierarchy (maspack.properties.TestHierarchy)1 TestNode (maspack.properties.TestNode)1 Clonable (maspack.util.Clonable)1 ExpandablePropertyPanel (maspack.widgets.ExpandablePropertyPanel)1