]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.datatypes/src/org/simantics/datatypes/literal/RGB.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.datatypes / src / org / simantics / datatypes / literal / RGB.java
diff --git a/bundles/org.simantics.datatypes/src/org/simantics/datatypes/literal/RGB.java b/bundles/org.simantics.datatypes/src/org/simantics/datatypes/literal/RGB.java
new file mode 100644 (file)
index 0000000..b7b7233
--- /dev/null
@@ -0,0 +1,69 @@
+package org.simantics.datatypes.literal;\r
+\r
+import org.simantics.common.color.Color;\r
+import org.simantics.common.utils.CommonUtils;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.databoard.binding.Binding;\r
+import org.simantics.databoard.util.Bean;\r
+\r
+\r
+public class RGB {\r
+\r
+       public static class Integer extends Bean implements Color {\r
+       \r
+        private static final long serialVersionUID = -8574259779076550543L;\r
+\r
+        public static final Binding BINDING = Bindings.getBindingUnchecked(Integer.class);\r
+               \r
+               public int red;\r
+               public int green;\r
+               public int blue;\r
+               \r
+               public Integer(int r, int g, int b) {\r
+                       super(BINDING);\r
+                       this.red = r; this.green = g; this.blue = b;\r
+               }\r
+               \r
+               @Override\r
+               public String toString() {\r
+                       return "RGB.Integer[r=" + red + " ,g=" + green + " ,b=" + blue + "]";\r
+               }\r
+\r
+               @Override\r
+               public double getR() {\r
+                       return CommonUtils.convertColor256ToDouble(red);\r
+               }\r
+\r
+               @Override\r
+               public double getG() {\r
+                       return CommonUtils.convertColor256ToDouble(green);\r
+               }\r
+\r
+               @Override\r
+               public double getB() {\r
+                       return CommonUtils.convertColor256ToDouble(blue);\r
+               }\r
+\r
+               @Override\r
+               public double getA() {\r
+                       return 0;\r
+               }\r
+\r
+               @Override\r
+               public double getH() {\r
+                       throw new UnsupportedOperationException();\r
+               }\r
+\r
+               @Override\r
+               public double getS() {\r
+                       throw new UnsupportedOperationException();\r
+               }\r
+\r
+               @Override\r
+               public double getV() {\r
+                       throw new UnsupportedOperationException();\r
+               }\r
+               \r
+       }\r
+       \r
+}\r