Source for org.jfree.chart.plot.RainbowPalette

   1: /* ===========================================================
   2:  * JFreeChart : a free chart library for the Java(tm) platform
   3:  * ===========================================================
   4:  *
   5:  * (C) Copyright 2000-2007, 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
  20:  * License along with this library; if not, write to the Free Software
  21:  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
  22:  * USA.  
  23:  *
  24:  * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
  25:  * in the United States and other countries.]
  26:  *
  27:  * -------------------
  28:  * RainbowPalette.java
  29:  * -------------------
  30:  * (C) Copyright 2002-2007, by David M. O'Donnell and Contributors.
  31:  *
  32:  * Original Author:  David M. O'Donnell;
  33:  * Contributor(s):   David Gilbert (for Object Refinery Limited);
  34:  *
  35:  * $Id: RainbowPalette.java,v 1.1.2.3 2007/01/31 15:56:19 mungady Exp $
  36:  *
  37:  * Changes
  38:  * -------
  39:  * 26-Nov-2002 : Version 1 contributed by David M. O'Donnell (DG);
  40:  * 26-Mar-2003 : Implemented Serializable (DG);
  41:  * ------------- JFREECHART 1.0.x ---------------------------------------------
  42:  * 31-Jan-2007 : Deprecated (DG);
  43:  *
  44:  */
  45: 
  46: package org.jfree.chart.plot;
  47: 
  48: import java.io.Serializable;
  49: 
  50: import org.jfree.chart.renderer.xy.XYBlockRenderer;
  51: 
  52: 
  53: /**
  54:  * Contains the data to construct an 8-bit rainbow palette
  55:  * This come from an old application which ran on 8-bit graphics device.
  56:  * Thus indexes 0 and 1 were preserved for rendering white and black 
  57:  * respectively.
  58:  * 
  59:  * @deprecated This class is no longer supported.  If you are creating
  60:  *     contour plots, please try to use {@link XYPlot} and 
  61:  *     {@link XYBlockRenderer}.
  62:  */
  63: public class RainbowPalette extends ColorPalette implements Serializable {
  64: 
  65:     /** For serialization. */
  66:     private static final long serialVersionUID = -1906707320728242478L;
  67:     
  68:     /** The red values. */
  69:     private int[] red = {255,   0, 120, 115, 111, 106, 102,  97,  
  70:                           93,  88,  84,  79,  75,  70,  66,  61,
  71:                           57,  52,  48,  43,  39,  34,  30,  25, 
  72:                           21,  16,  12,   7,   3,   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,   0,   0,
  79:                            0,   0,   0,   0,   0,   0,   0,   0, 
  80:                            0,   0,   0,   0,   0,   0,   0,   0,
  81:                            0,   0,   0,   0,   0,   0,   0,   0, 
  82:                            0,   0,   0,   0,   0,   0,   0,   0,
  83:                            0,   0,   0,   0,   0,   0,   0,   0, 
  84:                            0,   0,   0,   0,   0,   0,   0,   0,
  85:                            0,   0,   0,   0,   0,   0,   0,   0, 
  86:                            0,   0,   0,   0,   0,   0,   1,   5,
  87:                           10,  14,  19,  23,  28,  32,  37,  41, 
  88:                           46,  50,  55,  59,  64,  68,  73,  77,
  89:                           82,  86,  91,  95, 100, 104, 109, 113, 
  90:                          118, 123, 127, 132, 136, 141, 145, 150,
  91:                          154, 159, 163, 168, 172, 177, 181, 186, 
  92:                          190, 195, 199, 204, 208, 213, 217, 222,
  93:                          226, 231, 235, 240, 244, 249, 253, 255, 
  94:                          255, 255, 255, 255, 255, 255, 255, 255,
  95:                          255, 255, 255, 255, 255, 255, 255, 255, 
  96:                          255, 255, 255, 255, 255, 255, 255, 255,
  97:                          255, 255, 255, 255, 255, 255, 255, 255, 
  98:                          255, 255, 255, 255, 255, 255, 255, 255,
  99:                          255, 255, 255, 255, 255, 255, 255, 255, 
 100:                          255, 255, 255, 255, 255, 255, 255, 255};
 101: 
 102:     /** The green values. */
 103:     private int[] green = {255,   0,   0,   0,   0,   0,   0,   0,
 104:                              0,   0,   0,   0,   0,   0,   0,   0,
 105:                              0,   0,   0,   0,   0,   0,   0,   0,
 106:                              0,   0,   0,   0,   0,   2,   6,  11,
 107:                             15,  20,  24,  29,  33,  38,  42,  47,
 108:                             51,  56,  60,  65,  69,  74,  78,  83,
 109:                             87,  92,  96, 101, 105, 110, 114, 119,
 110:                            123, 128, 132, 137, 141, 146, 150, 155,
 111:                            159, 164, 168, 173, 177, 182, 186, 191, 
 112:                            195, 200, 204, 209, 213, 218, 222, 227,
 113:                            231, 236, 241, 245, 250, 254, 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, 255,
 125:                            255, 255, 255, 255, 255, 255, 255, 255, 
 126:                            255, 255, 255, 255, 255, 255, 255, 255,
 127:                            255, 255, 255, 255, 255, 255, 255, 252, 
 128:                            248, 243, 239, 234, 230, 225, 221, 216,
 129:                            212, 207, 203, 198, 194, 189, 185, 180, 
 130:                            176, 171, 167, 162, 158, 153, 149, 144,
 131:                            140, 135, 131, 126, 122, 117, 113, 108, 
 132:                            104,  99,  95,  90,  86,  81,  77,  72,
 133:                             68,  63,  59,  54,  50,  45,  41,  36,  
 134:                             32,  27,  23,  18,  14,   9,   5,   0};
 135: 
 136:     /** The blue values. */
 137:     private int[] blue = {255,   0, 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, 255, 255,
 145:                           255, 255, 255, 255, 255, 255, 255, 255, 
 146:                           255, 255, 255, 255, 255, 255, 255, 255,
 147:                           255, 255, 255, 255, 255, 255, 251, 247, 
 148:                           242, 238, 233, 229, 224, 220, 215, 211,
 149:                           206, 202, 197, 193, 188, 184, 179, 175, 
 150:                           170, 166, 161, 157, 152, 148, 143, 139,
 151:                           134, 130, 125, 121, 116, 112, 107, 103,  
 152:                           98,  94,  89,  85,  80,  76,  71,  67,
 153:                            62,  58,  53,  49,  44,  40,  35,  31,  
 154:                            26,  22,  17,  13,   8,   4,   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:                             0,   0,   0,   0,   0,   0,   0,   0,
 167:                             0,   0,   0,   0,   0,   0,   0,   0,  
 168:                             0,   0,   0,   0,   0,   0,   0,   0};
 169: 
 170:     /**
 171:      * Default constructor.
 172:      */
 173:     public RainbowPalette() {
 174:         super();
 175:         initialize();
 176:     }
 177: 
 178:     /**
 179:      * Intializes the palettes indexes
 180:      */
 181:     public void initialize() {
 182: 
 183:         setPaletteName("Rainbow");
 184: 
 185:         this.r = new int[this.red.length];
 186:         this.g = new int[this.green.length];
 187:         this.b = new int[this.blue.length];
 188:         System.arraycopy(this.red, 0, this.r, 0, this.red.length);
 189:         System.arraycopy(this.green, 0, this.g, 0, this.green.length);
 190:         System.arraycopy(this.blue, 0, this.b, 0, this.blue.length);
 191: 
 192:     }
 193: 
 194: }