Search in sources :

Example 1 with PropertyList

use of maspack.properties.PropertyList in project artisynth_core by artisynth.

the class IsRenderableHolder method init.

private void init(IsRenderable renderable) {
    if (renderable == null) {
        throw new IllegalArgumentException("Cannot hold a null object");
    }
    myRenderable = renderable;
    myProps = new PropertyList(IsRenderableHolder.class, RenderableComponentBase.class);
    myProps.add("renderProps * *", "render properties", null);
    if (myRenderable instanceof HasProperties) {
        myProps.addReadOnly("renderable", "the held renderable object");
    }
    if (myRenderable instanceof HasRenderProps) {
        myHasRenderProps = (HasRenderProps) myRenderable;
        getRenderPropsMethod = null;
        setRenderPropsMethod = null;
        createRenderPropsMethod = null;
    } else {
        myHasRenderProps = null;
        // try to find methods
        Class<?> clazz = myRenderable.getClass();
        getRenderPropsMethod = getMethod(clazz, "getRenderProps");
        setRenderPropsMethod = getMethod(clazz, "setRenderProps", RenderProps.class);
        createRenderPropsMethod = getMethod(clazz, "createRenderProps");
    }
    if (myRenderable instanceof Scannable) {
        myScannable = (Scannable) myRenderable;
        writeMethod = null;
        scanMethod = null;
    } else {
        myScannable = null;
        Class<?> clazz = myRenderable.getClass();
        writeMethod = getMethod(clazz, "write", PrintWriter.class, NumberFormat.class, Object.class);
        scanMethod = getMethod(clazz, "scan", ReaderTokenizer.class, CompositeComponent.class);
    }
}
Also used : HasRenderProps(maspack.render.HasRenderProps) HasProperties(maspack.properties.HasProperties) HasRenderProps(maspack.render.HasRenderProps) RenderProps(maspack.render.RenderProps) PropertyList(maspack.properties.PropertyList) ReaderTokenizer(maspack.util.ReaderTokenizer) Scannable(maspack.util.Scannable) PrintWriter(java.io.PrintWriter) NumberFormat(maspack.util.NumberFormat)

Aggregations

PrintWriter (java.io.PrintWriter)1 HasProperties (maspack.properties.HasProperties)1 PropertyList (maspack.properties.PropertyList)1 HasRenderProps (maspack.render.HasRenderProps)1 RenderProps (maspack.render.RenderProps)1 NumberFormat (maspack.util.NumberFormat)1 ReaderTokenizer (maspack.util.ReaderTokenizer)1 Scannable (maspack.util.Scannable)1