X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.ui%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fui%2Feditor%2FColorManager.java;fp=bundles%2Forg.simantics.scl.ui%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fui%2Feditor%2FColorManager.java;h=cf57decdc92b4f9c12c0caf3a7db4e3175e3ca8f;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git 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 index 000000000..cf57decdc --- /dev/null +++ b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor/ColorManager.java @@ -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 colorTable = new HashMap(); + + 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; + } + +}