ContextHelp now in new module net.sourceforge.phpeclipse.phphelp
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / util / PHPColorProvider.java
1 /**********************************************************************
2 Copyright (c) 2000, 2002 IBM Corp. and others.
3 All rights reserved. This program and the accompanying materials
4 are made available under the terms of the Common Public License v1.0
5 which accompanies this distribution, and is available at
6 http://www.eclipse.org/legal/cpl-v10.html
7
8 Contributors:
9     IBM Corporation - Initial implementation
10     Klaus Hartlage - www.eclipseproject.de
11 **********************************************************************/
12 package net.sourceforge.phpeclipse.phpeditor.util;
13
14 import java.util.HashMap;
15 import java.util.Iterator;
16 import java.util.Map;
17 import org.eclipse.swt.graphics.Color;
18 import org.eclipse.swt.graphics.RGB;
19 import org.eclipse.swt.widgets.Display;
20  
21 /**
22  * Manager for colors used in the Java editor
23  */
24 public class PHPColorProvider {
25
26         public static final RGB MULTI_LINE_COMMENT= new RGB(63, 127, 95);
27         public static final RGB SINGLE_LINE_COMMENT= new RGB(63, 127, 95);
28         public static final RGB KEYWORD= new RGB(127, 0, 85);
29   public static final RGB VARIABLE= new RGB(127, 159, 191);
30         public static final RGB FUNCTION_NAME= new RGB(127, 127, 159);
31         public static final RGB STRING= new RGB(42, 0, 255);
32         public static final RGB DEFAULT= new RGB(0, 0, 0);
33   
34   public static final RGB  LINKED_POSITION_COLOR= new RGB(0, 0, 0);
35   public static final RGB  LINE_NUMBER_COLOR= new RGB(0, 0, 0);
36   public static final RGB  BACKGROUND_COLOR= new RGB(255, 255, 255);
37   
38         protected Map fColorTable= new HashMap(10);
39
40         /**
41          * Release all of the color resources held onto by the receiver.
42          */     
43         public void dispose() {
44                 Iterator e= fColorTable.values().iterator();
45                 while (e.hasNext())
46                          ((Color) e.next()).dispose();
47         }
48         
49         /**
50          * Return the Color that is stored in the Color table as rgb.
51          */
52         public Color getColor(RGB rgb) {
53                 Color color= (Color) fColorTable.get(rgb);
54                 if (color == null) {
55                         color= new Color(Display.getCurrent(), rgb);
56                         fColorTable.put(rgb, color);
57                 }
58                 return color;
59         }
60 }