KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > chart > ui > RainbowPalette


1 /* ===========================================================
2  * JFreeChart : a free chart library for the Java(tm) platform
3  * ===========================================================
4  *
5  * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
6  *
7  * Project Info: http://www.jfree.org/jfreechart/index.html
8  *
9  * This library is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this library; if not, write to the Free Software Foundation,
21  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
24  * in the United States and other countries.]
25  *
26  * -------------------
27  * RainbowPalette.java
28  * -------------------
29  * (C) Copyright 2002-2005, by David M. O'Donnell and Contributors.
30  *
31  * Original Author: David M. O'Donnell;
32  * Contributor(s): David Gilbert (for Object Refinery Limited);
33  *
34  * $Id: RainbowPalette.java,v 1.3 2005/05/19 14:01:47 mungady Exp $
35  *
36  * Changes
37  * -------
38  * 26-Nov-2002 : Version 1 contributed by David M. O'Donnell (DG);
39  * 26-Mar-2003 : Implemented Serializable (DG);
40  *
41  */

42
43 package org.jfree.chart.ui;
44
45 import java.io.Serializable JavaDoc;
46
47 /**
48  * Contains the data to constuct an 8-bit rainbow palette
49  * This come from an old application which ran on 8-bit graphics device.
50  * Thus indexes 0 and 1 were preserved for rendering white and black
51  * respectively.
52  *
53  * @author David M. O'Donnell
54  */

55 public class RainbowPalette extends ColorPalette implements Serializable JavaDoc {
56
57     /** For serialization. */
58     private static final long serialVersionUID = -1906707320728242478L;
59     
60     /** The red values. */
61     private int[] red = {255, 0, 120, 115, 111, 106, 102, 97,
62                           93, 88, 84, 79, 75, 70, 66, 61,
63                           57, 52, 48, 43, 39, 34, 30, 25,
64                           21, 16, 12, 7, 3, 0, 0, 0,
65                            0, 0, 0, 0, 0, 0, 0, 0,
66                            0, 0, 0, 0, 0, 0, 0, 0,
67                            0, 0, 0, 0, 0, 0, 0, 0,
68                            0, 0, 0, 0, 0, 0, 0, 0,
69                            0, 0, 0, 0, 0, 0, 0, 0,
70                            0, 0, 0, 0, 0, 0, 0, 0,
71                            0, 0, 0, 0, 0, 0, 0, 0,
72                            0, 0, 0, 0, 0, 0, 0, 0,
73                            0, 0, 0, 0, 0, 0, 0, 0,
74                            0, 0, 0, 0, 0, 0, 0, 0,
75                            0, 0, 0, 0, 0, 0, 0, 0,
76                            0, 0, 0, 0, 0, 0, 0, 0,
77                            0, 0, 0, 0, 0, 0, 0, 0,
78                            0, 0, 0, 0, 0, 0, 1, 5,
79                           10, 14, 19, 23, 28, 32, 37, 41,
80                           46, 50, 55, 59, 64, 68, 73, 77,
81                           82, 86, 91, 95, 100, 104, 109, 113,
82                          118, 123, 127, 132, 136, 141, 145, 150,
83                          154, 159, 163, 168, 172, 177, 181, 186,
84                          190, 195, 199, 204, 208, 213, 217, 222,
85                          226, 231, 235, 240, 244, 249, 253, 255,
86                          255, 255, 255, 255, 255, 255, 255, 255,
87                          255, 255, 255, 255, 255, 255, 255, 255,
88                          255, 255, 255, 255, 255, 255, 255, 255,
89                          255, 255, 255, 255, 255, 255, 255, 255,
90                          255, 255, 255, 255, 255, 255, 255, 255,
91                          255, 255, 255, 255, 255, 255, 255, 255,
92                          255, 255, 255, 255, 255, 255, 255, 255};
93
94     /** The green values. */
95     private int[] green = {255, 0, 0, 0, 0, 0, 0, 0,
96                              0, 0, 0, 0, 0, 0, 0, 0,
97                              0, 0, 0, 0, 0, 0, 0, 0,
98                              0, 0, 0, 0, 0, 2, 6, 11,
99                             15, 20, 24, 29, 33, 38, 42, 47,
100                             51, 56, 60, 65, 69, 74, 78, 83,
101                             87, 92, 96, 101, 105, 110, 114, 119,
102                            123, 128, 132, 137, 141, 146, 150, 155,
103                            159, 164, 168, 173, 177, 182, 186, 191,
104                            195, 200, 204, 209, 213, 218, 222, 227,
105                            231, 236, 241, 245, 250, 254, 255, 255,
106                            255, 255, 255, 255, 255, 255, 255, 255,
107                            255, 255, 255, 255, 255, 255, 255, 255,
108                            255, 255, 255, 255, 255, 255, 255, 255,
109                            255, 255, 255, 255, 255, 255, 255, 255,
110                            255, 255, 255, 255, 255, 255, 255, 255,
111                            255, 255, 255, 255, 255, 255, 255, 255,
112                            255, 255, 255, 255, 255, 255, 255, 255,
113                            255, 255, 255, 255, 255, 255, 255, 255,
114                            255, 255, 255, 255, 255, 255, 255, 255,
115                            255, 255, 255, 255, 255, 255, 255, 255,
116                            255, 255, 255, 255, 255, 255, 255, 255,
117                            255, 255, 255, 255, 255, 255, 255, 255,
118                            255, 255, 255, 255, 255, 255, 255, 255,
119                            255, 255, 255, 255, 255, 255, 255, 252,
120                            248, 243, 239, 234, 230, 225, 221, 216,
121                            212, 207, 203, 198, 194, 189, 185, 180,
122                            176, 171, 167, 162, 158, 153, 149, 144,
123                            140, 135, 131, 126, 122, 117, 113, 108,
124                            104, 99, 95, 90, 86, 81, 77, 72,
125                             68, 63, 59, 54, 50, 45, 41, 36,
126                             32, 27, 23, 18, 14, 9, 5, 0};
127
128     /** The blue values. */
129     private int[] blue = {255, 0, 255, 255, 255, 255, 255, 255,
130                           255, 255, 255, 255, 255, 255, 255, 255,
131                           255, 255, 255, 255, 255, 255, 255, 255,
132                           255, 255, 255, 255, 255, 255, 255, 255,
133                           255, 255, 255, 255, 255, 255, 255, 255,
134                           255, 255, 255, 255, 255, 255, 255, 255,
135                           255, 255, 255, 255, 255, 255, 255, 255,
136                           255, 255, 255, 255, 255, 255, 255, 255,
137                           255, 255, 255, 255, 255, 255, 255, 255,
138                           255, 255, 255, 255, 255, 255, 255, 255,
139                           255, 255, 255, 255, 255, 255, 251, 247,
140                           242, 238, 233, 229, 224, 220, 215, 211,
141                           206, 202, 197, 193, 188, 184, 179, 175,
142                           170, 166, 161, 157, 152, 148, 143, 139,
143                           134, 130, 125, 121, 116, 112, 107, 103,
144                           98, 94, 89, 85, 80, 76, 71, 67,
145                            62, 58, 53, 49, 44, 40, 35, 31,
146                            26, 22, 17, 13, 8, 4, 0, 0,
147                             0, 0, 0, 0, 0, 0, 0, 0,
148                             0, 0, 0, 0, 0, 0, 0, 0,
149                             0, 0, 0, 0, 0, 0, 0, 0,
150                             0, 0, 0, 0, 0, 0, 0, 0,
151                             0, 0, 0, 0, 0, 0, 0, 0,
152                             0, 0, 0, 0, 0, 0, 0, 0,
153                             0, 0, 0, 0, 0, 0, 0, 0,
154                             0, 0, 0, 0, 0, 0, 0, 0,
155                             0, 0, 0, 0, 0, 0, 0, 0,
156                             0, 0, 0, 0, 0, 0, 0, 0,
157                             0, 0, 0, 0, 0, 0, 0, 0,
158                             0, 0, 0, 0, 0, 0, 0, 0,
159                             0, 0, 0, 0, 0, 0, 0, 0,
160                             0, 0, 0, 0, 0, 0, 0, 0};
161
162     /**
163      * Default constructor.
164      */

165     public RainbowPalette() {
166         super();
167         initialize();
168     }
169
170     /**
171      * Intializes the palettes indexes
172      */

173     public void initialize() {
174
175         setPaletteName("Rainbow");
176
177         this.r = new int[this.red.length];
178         this.g = new int[this.green.length];
179         this.b = new int[this.blue.length];
180         System.arraycopy(this.red, 0, this.r, 0, this.red.length);
181         System.arraycopy(this.green, 0, this.g, 0, this.green.length);
182         System.arraycopy(this.blue, 0, this.b, 0, this.blue.length);
183
184     }
185
186 }
187
Popular Tags