1 11 package org.eclipse.debug.internal.ui; 12 13 14 import java.util.HashMap ; 15 import java.util.Iterator ; 16 import java.util.Map ; 17 18 import org.eclipse.swt.graphics.Color; 19 import org.eclipse.swt.graphics.RGB; 20 import org.eclipse.swt.widgets.Display; 21 22 25 public class ColorManager { 26 27 private static ColorManager fgColorManager; 28 29 private ColorManager() { 30 } 31 32 public static ColorManager getDefault() { 33 if (fgColorManager == null) { 34 fgColorManager= new ColorManager(); 35 } 36 return fgColorManager; 37 } 38 39 protected Map fColorTable= new HashMap (10); 40 41 public Color getColor(RGB rgb) { 42 Color color= (Color) fColorTable.get(rgb); 43 if (color == null) { 44 color= new Color(Display.getCurrent(), rgb); 45 fColorTable.put(rgb, color); 46 } 47 return color; 48 } 49 50 public void dispose() { 51 Iterator e= fColorTable.values().iterator(); 52 while (e.hasNext()) 53 ((Color) e.next()).dispose(); 54 } 55 } 56 57 58 | Popular Tags |