sysmodelmgr/com.symbian.smt.gui/src/com/symbian/smt/gui/editors/xmleditor/ColorManager.java
equal
deleted
inserted
replaced
|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 package com.symbian.smt.gui.editors.xmleditor; |
|
19 |
|
20 import java.util.HashMap; |
|
21 import java.util.Iterator; |
|
22 import java.util.Map; |
|
23 |
|
24 import org.eclipse.swt.graphics.Color; |
|
25 import org.eclipse.swt.graphics.RGB; |
|
26 import org.eclipse.swt.widgets.Display; |
|
27 |
|
28 /** |
|
29 * @author barbararosi-schwartz |
|
30 * |
|
31 */ |
|
32 public class ColorManager { |
|
33 |
|
34 protected Map<RGB, Color> fColorTable = new HashMap<RGB, Color>(10); |
|
35 |
|
36 public void dispose() { |
|
37 Iterator<Color> e = fColorTable.values().iterator(); |
|
38 |
|
39 while (e.hasNext()) |
|
40 ((Color) e.next()).dispose(); |
|
41 } |
|
42 |
|
43 public Color getColor(RGB rgb) { |
|
44 Color color = (Color) fColorTable.get(rgb); |
|
45 |
|
46 if (color == null) { |
|
47 color = new Color(Display.getCurrent(), rgb); |
|
48 fColorTable.put(rgb, color); |
|
49 } |
|
50 |
|
51 return color; |
|
52 } |
|
53 } |