1 4 package org.terracotta.dso.editors.xml; 5 6 import org.eclipse.swt.graphics.Color; 7 import org.eclipse.swt.graphics.RGB; 8 import org.eclipse.swt.widgets.Display; 9 10 import java.util.HashMap ; 11 import java.util.Iterator ; 12 import java.util.Map ; 13 14 public class ColorManager { 15 protected Map <RGB, Color> fColorTable = new HashMap <RGB, Color>(10); 16 17 public void dispose() { 18 Iterator e = fColorTable.values().iterator(); 19 while (e.hasNext()) 20 ((Color) e.next()).dispose(); 21 } 22 23 public Color getColor(RGB rgb) { 24 Color color = fColorTable.get(rgb); 25 if (color == null) { 26 color = new Color(Display.getCurrent(), rgb); 27 fColorTable.put(rgb, color); 28 } 29 return color; 30 } 31 } 32 | Popular Tags |