001/* ===========================================================
002 * JFreeChart : a free chart library for the Java(tm) platform
003 * ===========================================================
004 *
005 * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
006 *
007 * Project Info:  http://www.jfree.org/jfreechart/index.html
008 *
009 * This library is free software; you can redistribute it and/or modify it
010 * under the terms of the GNU Lesser General Public License as published by
011 * the Free Software Foundation; either version 2.1 of the License, or
012 * (at your option) any later version.
013 *
014 * This library is distributed in the hope that it will be useful, but
015 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
016 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
017 * License for more details.
018 *
019 * You should have received a copy of the GNU Lesser General Public
020 * License along with this library; if not, write to the Free Software
021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
022 * USA.
023 *
024 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. 
025 * Other names may be trademarks of their respective owners.]
026 *
027 * -------------------
028 * RainbowPalette.java
029 * -------------------
030 * (C) Copyright 2002-2008, by David M. O'Donnell and Contributors.
031 *
032 * Original Author:  David M. O'Donnell;
033 * Contributor(s):   David Gilbert (for Object Refinery Limited);
034 *
035 * Changes
036 * -------
037 * 26-Nov-2002 : Version 1 contributed by David M. O'Donnell (DG);
038 * 26-Mar-2003 : Implemented Serializable (DG);
039 * ------------- JFREECHART 1.0.x ---------------------------------------------
040 * 31-Jan-2007 : Deprecated (DG);
041 *
042 */
043
044package org.jfree.chart.plot;
045
046import java.io.Serializable;
047
048import org.jfree.chart.renderer.xy.XYBlockRenderer;
049
050/**
051 * Contains the data to construct an 8-bit rainbow palette
052 * This come from an old application which ran on 8-bit graphics device.
053 * Thus indexes 0 and 1 were preserved for rendering white and black
054 * respectively.
055 *
056 * @deprecated This class is no longer supported (as of version 1.0.4).  If
057 *     you are creating contour plots, please try to use {@link XYPlot} and
058 *     {@link XYBlockRenderer}.
059 */
060public class RainbowPalette extends ColorPalette implements Serializable {
061
062    /** For serialization. */
063    private static final long serialVersionUID = -1906707320728242478L;
064
065    /** The red values. */
066    private int[] red = {255,   0, 120, 115, 111, 106, 102,  97,
067                          93,  88,  84,  79,  75,  70,  66,  61,
068                          57,  52,  48,  43,  39,  34,  30,  25,
069                          21,  16,  12,   7,   3,   0,   0,   0,
070                           0,   0,   0,   0,   0,   0,   0,   0,
071                           0,   0,   0,   0,   0,   0,   0,   0,
072                           0,   0,   0,   0,   0,   0,   0,   0,
073                           0,   0,   0,   0,   0,   0,   0,   0,
074                           0,   0,   0,   0,   0,   0,   0,   0,
075                           0,   0,   0,   0,   0,   0,   0,   0,
076                           0,   0,   0,   0,   0,   0,   0,   0,
077                           0,   0,   0,   0,   0,   0,   0,   0,
078                           0,   0,   0,   0,   0,   0,   0,   0,
079                           0,   0,   0,   0,   0,   0,   0,   0,
080                           0,   0,   0,   0,   0,   0,   0,   0,
081                           0,   0,   0,   0,   0,   0,   0,   0,
082                           0,   0,   0,   0,   0,   0,   0,   0,
083                           0,   0,   0,   0,   0,   0,   1,   5,
084                          10,  14,  19,  23,  28,  32,  37,  41,
085                          46,  50,  55,  59,  64,  68,  73,  77,
086                          82,  86,  91,  95, 100, 104, 109, 113,
087                         118, 123, 127, 132, 136, 141, 145, 150,
088                         154, 159, 163, 168, 172, 177, 181, 186,
089                         190, 195, 199, 204, 208, 213, 217, 222,
090                         226, 231, 235, 240, 244, 249, 253, 255,
091                         255, 255, 255, 255, 255, 255, 255, 255,
092                         255, 255, 255, 255, 255, 255, 255, 255,
093                         255, 255, 255, 255, 255, 255, 255, 255,
094                         255, 255, 255, 255, 255, 255, 255, 255,
095                         255, 255, 255, 255, 255, 255, 255, 255,
096                         255, 255, 255, 255, 255, 255, 255, 255,
097                         255, 255, 255, 255, 255, 255, 255, 255};
098
099    /** The green values. */
100    private int[] green = {255,   0,   0,   0,   0,   0,   0,   0,
101                             0,   0,   0,   0,   0,   0,   0,   0,
102                             0,   0,   0,   0,   0,   0,   0,   0,
103                             0,   0,   0,   0,   0,   2,   6,  11,
104                            15,  20,  24,  29,  33,  38,  42,  47,
105                            51,  56,  60,  65,  69,  74,  78,  83,
106                            87,  92,  96, 101, 105, 110, 114, 119,
107                           123, 128, 132, 137, 141, 146, 150, 155,
108                           159, 164, 168, 173, 177, 182, 186, 191,
109                           195, 200, 204, 209, 213, 218, 222, 227,
110                           231, 236, 241, 245, 250, 254, 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, 255,
120                           255, 255, 255, 255, 255, 255, 255, 255,
121                           255, 255, 255, 255, 255, 255, 255, 255,
122                           255, 255, 255, 255, 255, 255, 255, 255,
123                           255, 255, 255, 255, 255, 255, 255, 255,
124                           255, 255, 255, 255, 255, 255, 255, 252,
125                           248, 243, 239, 234, 230, 225, 221, 216,
126                           212, 207, 203, 198, 194, 189, 185, 180,
127                           176, 171, 167, 162, 158, 153, 149, 144,
128                           140, 135, 131, 126, 122, 117, 113, 108,
129                           104,  99,  95,  90,  86,  81,  77,  72,
130                            68,  63,  59,  54,  50,  45,  41,  36,
131                            32,  27,  23,  18,  14,   9,   5,   0};
132
133    /** The blue values. */
134    private int[] blue = {255,   0, 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, 255, 255,
140                          255, 255, 255, 255, 255, 255, 255, 255,
141                          255, 255, 255, 255, 255, 255, 255, 255,
142                          255, 255, 255, 255, 255, 255, 255, 255,
143                          255, 255, 255, 255, 255, 255, 255, 255,
144                          255, 255, 255, 255, 255, 255, 251, 247,
145                          242, 238, 233, 229, 224, 220, 215, 211,
146                          206, 202, 197, 193, 188, 184, 179, 175,
147                          170, 166, 161, 157, 152, 148, 143, 139,
148                          134, 130, 125, 121, 116, 112, 107, 103,
149                          98,  94,  89,  85,  80,  76,  71,  67,
150                           62,  58,  53,  49,  44,  40,  35,  31,
151                           26,  22,  17,  13,   8,   4,   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                            0,   0,   0,   0,   0,   0,   0,   0,
162                            0,   0,   0,   0,   0,   0,   0,   0,
163                            0,   0,   0,   0,   0,   0,   0,   0,
164                            0,   0,   0,   0,   0,   0,   0,   0,
165                            0,   0,   0,   0,   0,   0,   0,   0};
166
167    /**
168     * Default constructor.
169     */
170    public RainbowPalette() {
171        super();
172        initialize();
173    }
174
175    /**
176     * Intializes the palettes indexes
177     */
178    @Override
179    public void initialize() {
180
181        setPaletteName("Rainbow");
182
183        this.r = new int[this.red.length];
184        this.g = new int[this.green.length];
185        this.b = new int[this.blue.length];
186        System.arraycopy(this.red, 0, this.r, 0, this.red.length);
187        System.arraycopy(this.green, 0, this.g, 0, this.green.length);
188        System.arraycopy(this.blue, 0, this.b, 0, this.blue.length);
189
190    }
191
192}