1 18 19 package org.apache.batik.css.engine; 20 21 import java.awt.SystemColor ; 22 import java.util.HashMap ; 23 import java.util.Map ; 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 37 public class SystemColorSupport implements CSSConstants { 38 39 42 public static Value getSystemColor(String ident) { 43 ident = ident.toLowerCase(); 44 SystemColor sc = (SystemColor )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 54 protected final static Map factories = new HashMap (); 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 117 protected SystemColorSupport() { 118 } 119 } 120 | Popular Tags |