KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > options > colors > ColorValue


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.options.colors;
21
22 import java.awt.Color JavaDoc;
23 import java.util.HashMap JavaDoc;
24 import java.util.Map JavaDoc;
25 import org.openide.util.NbBundle;
26
27 /**
28  * Represents one color with some text description.
29  *
30  * @author Administrator
31  */

32 class ColorValue {
33
34     public static final ColorValue CUSTOM_COLOR =
35             new ColorValue (loc ("Custom"), null); //NOI18N
36

37     private static Map JavaDoc colorMap = new HashMap JavaDoc ();
38     static {
39         colorMap.put (Color.BLACK, loc ("Black")); //NOI18N
40
colorMap.put (Color.BLUE, loc ("Blue")); //NOI18N
41
colorMap.put (Color.CYAN, loc ("Cyan")); //NOI18N
42
colorMap.put (Color.DARK_GRAY, loc ("Dark_Gray")); //NOI18N
43
colorMap.put (Color.GRAY, loc ("Gray")); //NOI18N
44
colorMap.put (Color.GREEN, loc ("Green")); //NOI18N
45
colorMap.put (Color.LIGHT_GRAY, loc ("Light_Gray")); //NOI18N
46
colorMap.put (Color.MAGENTA, loc ("Magenta")); //NOI18N
47
colorMap.put (Color.ORANGE, loc ("Orange")); //NOI18N
48
colorMap.put (Color.PINK, loc ("Pink")); //NOI18N
49
colorMap.put (Color.RED, loc ("Red")); //NOI18N
50
colorMap.put (Color.WHITE, loc ("White")); //NOI18N
51
colorMap.put (Color.YELLOW, loc ("Yellow")); //NOI18N
52
}
53     
54     String JavaDoc text;
55     Color JavaDoc color;
56
57     ColorValue (Color JavaDoc color) {
58         this.color = color;
59         text = (String JavaDoc) colorMap.get (color);
60         if (text != null) return;
61         StringBuffer JavaDoc sb = new StringBuffer JavaDoc ();
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 JavaDoc text, Color JavaDoc color) {
70         this.text = text;
71         this.color = color;
72     }
73     
74     private static String JavaDoc loc (String JavaDoc key) {
75         return NbBundle.getMessage (ColorComboBox.class, key);
76     }
77 }
78
Popular Tags