use of gaiasky.util.filter.attrib.IAttribute 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;
}
use of gaiasky.util.filter.attrib.IAttribute in project gaiasky by langurmonkey.
the class EventScriptingInterface method highlightDataset.
@Override
public boolean highlightDataset(String dsName, String attributeName, String colorMap, double minMap, double maxMap, boolean highlight) {
if (checkString(dsName, "datasetName")) {
boolean exists = this.catalogManager.contains(dsName);
if (exists) {
CatalogInfo ci = this.catalogManager.get(dsName);
IAttribute attribute = getAttributeByName(attributeName, ci);
int cmapIndex = getCmapIndexByName(colorMap);
if (attribute != null && cmapIndex >= 0) {
ci.plainColor = false;
ci.hlCmapIndex = cmapIndex;
ci.hlCmapMin = minMap;
ci.hlCmapMax = maxMap;
ci.hlCmapAttribute = attribute;
postRunnable(() -> EventManager.publish(Event.CATALOG_HIGHLIGHT, this, ci, highlight));
} else {
if (attribute == null)
logger.error("Could not find attribute with name '" + attributeName + "'");
if (cmapIndex < 0)
logger.error("Could not find color map with name '" + colorMap + "'");
}
} else {
logger.warn("Dataset with name " + dsName + " does not exist");
}
return exists;
}
return false;
}
Aggregations