Search in sources :

Example 1 with Clonable

use of maspack.util.Clonable in project artisynth_core by artisynth.

the class CompositePropertyPanel method tryCreatingCpropFromPrototype.

/**
 * Try to create a prototype for a particular type of composite property by
 * cloning an instance (if there is one) in a host list.
 */
private CompositeProperty tryCreatingCpropFromPrototype(Class<?> type) {
    CompositeProperty protoCprop = null;
    EditingProperty eprop = (EditingProperty) myCpropProperty;
    HostList hostList = eprop.getHostList();
    Object[] values = hostList.getAllValues(eprop.getCell());
    for (int i = 0; i < values.length; i++) {
        if (type.isInstance(values[i]) && values[i] instanceof Clonable) {
            try {
                protoCprop = (CompositeProperty) ((Clonable) values[i]).clone();
            } catch (Exception e) {
                System.out.println("Warning: clone failed for " + values[i].getClass());
            }
            if (protoCprop != null) {
                break;
            }
        }
    }
    return protoCprop;
}
Also used : EditingProperty(maspack.properties.EditingProperty) Clonable(maspack.util.Clonable) HostList(maspack.properties.HostList) CompositeProperty(maspack.properties.CompositeProperty) InternalErrorException(maspack.util.InternalErrorException)

Aggregations

CompositeProperty (maspack.properties.CompositeProperty)1 EditingProperty (maspack.properties.EditingProperty)1 HostList (maspack.properties.HostList)1 Clonable (maspack.util.Clonable)1 InternalErrorException (maspack.util.InternalErrorException)1