Search in sources :

Example 1 with AttributeUCD

use of gaiasky.util.filter.attrib.AttributeUCD in project gaiasky by langurmonkey.

the class EventScriptingInterface method getAttributeByName.

private IAttribute getAttributeByName(String name, CatalogInfo ci) {
    try {
        // One of the default attributes
        Class<?> clazz = Class.forName("gaiasky.util.filter.attrib.Attribute" + name);
        Constructor<?> ctor = clazz.getConstructor();
        return (IAttribute) ctor.newInstance();
    } catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
        // Try extra attributes
        if (ci.object instanceof ParticleGroup) {
            ParticleGroup pg = (ParticleGroup) ci.object;
            ObjectDoubleMap.Keys<UCD> ucds = pg.get(0).extraKeys();
            for (UCD ucd : ucds) if (ucd.colname.equalsIgnoreCase(name))
                return new AttributeUCD(ucd);
        }
    }
    return null;
}
Also used : AttributeUCD(gaiasky.util.filter.attrib.AttributeUCD) InvocationTargetException(java.lang.reflect.InvocationTargetException) Keys(com.badlogic.gdx.Input.Keys) AttributeUCD(gaiasky.util.filter.attrib.AttributeUCD) UCD(gaiasky.util.ucd.UCD) IAttribute(gaiasky.util.filter.attrib.IAttribute)

Aggregations

Keys (com.badlogic.gdx.Input.Keys)1 AttributeUCD (gaiasky.util.filter.attrib.AttributeUCD)1 IAttribute (gaiasky.util.filter.attrib.IAttribute)1 UCD (gaiasky.util.ucd.UCD)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1