KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > css > engine > SystemColorSupport


1 /*
2
3    Copyright 1999-2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17 */

18
19 package org.apache.batik.css.engine;
20
21 import java.awt.SystemColor JavaDoc;
22 import java.util.HashMap JavaDoc;
23 import java.util.Map JavaDoc;
24
25 import org.apache.batik.css.engine.value.FloatValue;
26 import org.apache.batik.css.engine.value.RGBColorValue;
27 import org.apache.batik.css.engine.value.Value;
28 import org.apache.batik.util.CSSConstants;
29 import org.w3c.dom.css.CSSPrimitiveValue;
30
31 /**
32  * This class provides support for AWT system colors.
33  *
34  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
35  * @version $Id: SystemColorSupport.java,v 1.4 2004/10/30 18:38:04 deweese Exp $
36  */

37 public class SystemColorSupport implements CSSConstants {
38     
39     /**
40      * Returns the Value corresponding to the given system color.
41      */

42     public static Value getSystemColor(String JavaDoc ident) {
43         ident = ident.toLowerCase();
44         SystemColor JavaDoc sc = (SystemColor JavaDoc)factories.get(ident);
45         return new RGBColorValue
46             (new FloatValue(CSSPrimitiveValue.CSS_NUMBER, sc.getRed()),
47              new FloatValue(CSSPrimitiveValue.CSS_NUMBER, sc.getGreen()),
48              new FloatValue(CSSPrimitiveValue.CSS_NUMBER, sc.getBlue()));
49     }
50
51     /**
52      * The color factories.
53      */

54     protected final static Map JavaDoc factories = new HashMap JavaDoc();
55     static {
56         factories.put(CSS_ACTIVEBORDER_VALUE,
57                       SystemColor.windowBorder);
58         factories.put(CSS_ACTIVECAPTION_VALUE,
59                       SystemColor.activeCaption);
60         factories.put(CSS_APPWORKSPACE_VALUE,
61                       SystemColor.desktop);
62         factories.put(CSS_BACKGROUND_VALUE,
63                       SystemColor.desktop);
64         factories.put(CSS_BUTTONFACE_VALUE,
65                       SystemColor.control);
66         factories.put(CSS_BUTTONHIGHLIGHT_VALUE,
67                       SystemColor.controlLtHighlight);
68         factories.put(CSS_BUTTONSHADOW_VALUE,
69                       SystemColor.controlDkShadow);
70         factories.put(CSS_BUTTONTEXT_VALUE,
71                       SystemColor.controlText);
72         factories.put(CSS_CAPTIONTEXT_VALUE,
73                       SystemColor.activeCaptionText);
74         factories.put(CSS_GRAYTEXT_VALUE,
75                       SystemColor.textInactiveText);
76         factories.put(CSS_HIGHLIGHT_VALUE,
77                       SystemColor.textHighlight);
78         factories.put(CSS_HIGHLIGHTTEXT_VALUE,
79                       SystemColor.textHighlightText);
80         factories.put(CSS_INACTIVEBORDER_VALUE,
81                       SystemColor.windowBorder);
82         factories.put(CSS_INACTIVECAPTION_VALUE,
83                       SystemColor.inactiveCaption);
84         factories.put(CSS_INACTIVECAPTIONTEXT_VALUE,
85                       SystemColor.inactiveCaptionText);
86         factories.put(CSS_INFOBACKGROUND_VALUE,
87                       SystemColor.info);
88         factories.put(CSS_INFOTEXT_VALUE,
89                       SystemColor.infoText);
90         factories.put(CSS_MENU_VALUE,
91                       SystemColor.menu);
92         factories.put(CSS_MENUTEXT_VALUE,
93                       SystemColor.menuText);
94         factories.put(CSS_SCROLLBAR_VALUE,
95                       SystemColor.scrollbar);
96         factories.put(CSS_THREEDDARKSHADOW_VALUE,
97                       SystemColor.controlDkShadow);
98         factories.put(CSS_THREEDFACE_VALUE,
99                       SystemColor.control);
100         factories.put(CSS_THREEDHIGHLIGHT_VALUE,
101                       SystemColor.controlHighlight);
102         factories.put(CSS_THREEDLIGHTSHADOW_VALUE,
103                       SystemColor.controlLtHighlight);
104         factories.put(CSS_THREEDSHADOW_VALUE,
105                       SystemColor.controlShadow);
106         factories.put(CSS_WINDOW_VALUE,
107                       SystemColor.window);
108         factories.put(CSS_WINDOWFRAME_VALUE,
109                       SystemColor.windowBorder);
110         factories.put(CSS_WINDOWTEXT_VALUE,
111                       SystemColor.windowText);
112     }
113
114     /**
115      * This class does not need to be instantiated.
116      */

117     protected SystemColorSupport() {
118     }
119 }
120
Popular Tags