import org.simantics.ui.selection.AnyResource;
import org.simantics.ui.selection.AnyVariable;
import org.simantics.ui.selection.WorkbenchSelectionContentType;
+import org.simantics.utils.ui.color.Color;
public class ElementSelectionTools {
return (T)element;
}
else if (contentType instanceof AnyVariable) {
+ AnyVariable type = (AnyVariable) contentType;
try {
- return (T) Simantics.getSession().syncRequest(new ResourceRead<Variable>(element) {
+ return (T) type.processor.syncRequest(new ResourceRead<Variable>(element) {
public Variable perform(ReadGraph graph) throws DatabaseException {
return ElementSelector.getVariableForElement(graph, resource);
}
}
}
+ public static float[] colorToLiteral(Color color) {
+ // BGRA float values out
+ return new float[] {
+ (float)color.getB() / 255,
+ (float)color.getG() / 255,
+ (float)color.getR() / 255,
+ 1.f,
+ };
+ }
+
+ public static Color literalToColor(float[] color) {
+ // BGRA float values in
+ return new Color((int) (color[2] * 255), (int) (color[1] * 255), (int) (color[0] * 255));
+ }
+
}