]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor/ColorManager.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.scl.ui / src / org / simantics / scl / ui / editor / ColorManager.java
diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor/ColorManager.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor/ColorManager.java
new file mode 100755 (executable)
index 0000000..cf57dec
--- /dev/null
@@ -0,0 +1,28 @@
+package org.simantics.scl.ui.editor;
+
+import java.util.HashMap;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+
+public class ColorManager {
+
+       protected HashMap<RGB, Color> colorTable = new HashMap<RGB, Color>();
+
+       public void dispose() {
+               for(Color c : colorTable.values())
+                       c.dispose();
+               colorTable.clear();
+       }
+       
+       public Color get(RGB rgb) {
+               Color color = colorTable.get(rgb);
+               if (color == null) {
+                       color = new Color(Display.getCurrent(), rgb);
+                       colorTable.put(rgb, color);
+               }
+               return color;
+       }
+       
+}