1 package net.sourceforge.phpdt.externaltools.internal.model;
3 /**********************************************************************
4 Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
5 This file is made available under the terms of the Common Public License v1.0
6 which accompanies this distribution, and is available at
7 http://www.eclipse.org/legal/cpl-v10.html
8 **********************************************************************/
10 import java.util.HashMap;
11 import java.util.Iterator;
14 import org.eclipse.swt.graphics.Color;
15 import org.eclipse.swt.graphics.RGB;
16 import org.eclipse.swt.widgets.Display;
19 * Generic color manager.
21 public class ColorManager {
23 private static ColorManager fgColorManager;
25 private ColorManager() {
28 public static ColorManager getDefault() {
29 if (fgColorManager == null) {
30 fgColorManager= new ColorManager();
32 return fgColorManager;
35 protected Map fColorTable= new HashMap(10);
37 public Color getColor(RGB rgb) {
38 Color color= (Color) fColorTable.get(rgb);
40 color= new Color(Display.getCurrent(), rgb);
41 fColorTable.put(rgb, color);
46 public void dispose() {
47 Iterator e= fColorTable.values().iterator();
49 ((Color) e.next()).dispose();