1 19 20 package org.netbeans.modules.options.colors; 21 22 import java.awt.Color ; 23 import java.util.HashMap ; 24 import java.util.Map ; 25 import org.openide.util.NbBundle; 26 27 32 class ColorValue { 33 34 public static final ColorValue CUSTOM_COLOR = 35 new ColorValue (loc ("Custom"), null); 37 private static Map colorMap = new HashMap (); 38 static { 39 colorMap.put (Color.BLACK, loc ("Black")); colorMap.put (Color.BLUE, loc ("Blue")); colorMap.put (Color.CYAN, loc ("Cyan")); colorMap.put (Color.DARK_GRAY, loc ("Dark_Gray")); colorMap.put (Color.GRAY, loc ("Gray")); colorMap.put (Color.GREEN, loc ("Green")); colorMap.put (Color.LIGHT_GRAY, loc ("Light_Gray")); colorMap.put (Color.MAGENTA, loc ("Magenta")); colorMap.put (Color.ORANGE, loc ("Orange")); colorMap.put (Color.PINK, loc ("Pink")); colorMap.put (Color.RED, loc ("Red")); colorMap.put (Color.WHITE, loc ("White")); colorMap.put (Color.YELLOW, loc ("Yellow")); } 53 54 String text; 55 Color color; 56 57 ColorValue (Color color) { 58 this.color = color; 59 text = (String ) colorMap.get (color); 60 if (text != null) return; 61 StringBuffer sb = new StringBuffer (); 62 sb.append ('[').append (color.getRed ()). 63 append (',').append (color.getGreen ()). 64 append (',').append (color.getBlue ()). 65 append (']'); 66 text = sb.toString (); 67 } 68 69 ColorValue (String text, Color color) { 70 this.text = text; 71 this.color = color; 72 } 73 74 private static String loc (String key) { 75 return NbBundle.getMessage (ColorComboBox.class, key); 76 } 77 } 78 | Popular Tags |