Example usage for javax.media.j3d SceneGraphObject getClass

List of usage examples for javax.media.j3d SceneGraphObject getClass

Introduction

In this page you can find the example usage for javax.media.j3d SceneGraphObject getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:Capabilities.java

/**
 * Return an array of capability bits for the object
 *
 * If no capabilities are set then an array of length 0 is returned
 *
 * @param obj The object for which to extract the capability bits
 *//*  ww  w.j  av  a 2s. co  m*/
public static int[] getCapabilities(javax.media.j3d.SceneGraphObject obj) {
    ArrayList bits = new ArrayList();

    int value;
    String str;
    Class cl = obj.getClass();

    java.lang.reflect.Field[] fields = cl.getFields();

    try {
        for (int i = 0; i < fields.length; i++) {
            str = fields[i].getName();
            value = fields[i].getInt(fields[i]);
            if (str.indexOf("ALLOW_") != -1 || str.indexOf("ENABLE_") != -1) {
                if (obj.getCapability(value))
                    bits.add(new Integer(value));
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException("Internal Error");
    }

    int[] ret = new int[bits.size()];
    for (int i = 0; i < ret.length; i++)
        ret[i] = ((Integer) bits.get(i)).intValue();

    return ret;
}

From source file:Capabilities.java

/** Extract the names of all the SET capabilities in the object.
* The names (Strings) are appended to the arrayList
* @param obj The object for which to extract the capability strings
* @param capabilityStrings The ArrayList to which the capability names will be appended
*//*  w  ww  .j  a  va2  s.c o m*/
public static void getCapabilities(javax.media.j3d.SceneGraphObject obj,
        java.util.ArrayList capabilityStrings) {

    int value;
    String str;
    Class cl = obj.getClass();

    java.lang.reflect.Field[] fields = cl.getFields();

    try {
        for (int i = 0; i < fields.length; i++) {
            str = fields[i].getName();
            value = fields[i].getInt(fields[i]);
            if (str.indexOf("ALLOW") != -1 || str.indexOf("ENABLE_") != -1) {
                if (obj.getCapability(value))
                    capabilityStrings.add(str);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException("Internal Error");
    }
}