1. /* ===========================================================
  2. * JFreeChart : a free chart library for the Java(tm) platform
  3. * ===========================================================
  4. *
  5. * (C) Copyright 2000-2004, 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 under the terms
  10. * of the GNU Lesser General Public License as published by the Free Software Foundation;
  11. * either version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  14. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. * See the GNU Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public License along with this
  18. * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  19. * Boston, MA 02111-1307, USA.
  20. *
  21. * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
  22. * in the United States and other countries.]
  23. *
  24. * -------------------
  25. * RainbowPalette.java
  26. * -------------------
  27. * (C) Copyright 2002-2004, by David M. O'Donnell and Contributors.
  28. *
  29. * Original Author: David M. O'Donnell;
  30. * Contributor(s): David Gilbert (for Object Refinery Limited);
  31. *
  32. * $Id: RainbowPalette.java,v 1.1 2004/08/31 14:54:21 mungady Exp $
  33. *
  34. * Changes
  35. * -------
  36. * 26-Nov-2002 : Version 1 contributed by David M. O'Donnell (DG);
  37. * 26-Mar-2003 : Implemented Serializable (DG);
  38. *
  39. */
  40. package org.jfree.chart.ui;
  41. import java.io.Serializable;
  42. /**
  43. * Contains the data to constuct an 8-bit rainbow palette
  44. * This come from an old application which ran on 8-bit graphics device.
  45. * Thus indexes 0 and 1 were preserved for rendering white and black respectively.
  46. *
  47. * @author David M. O'Donnell
  48. */
  49. public class RainbowPalette extends ColorPalette implements Serializable {
  50. /** The red values. */
  51. private int[] red =
  52. {255, 0, 120, 115, 111, 106, 102, 97, 93, 88, 84, 79, 75, 70, 66, 61,
  53. 57, 52, 48, 43, 39, 34, 30, 25, 21, 16, 12, 7, 3, 0, 0, 0,
  54. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  55. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  56. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  57. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  58. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  59. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  60. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 5,
  61. 10, 14, 19, 23, 28, 32, 37, 41, 46, 50, 55, 59, 64, 68, 73, 77,
  62. 82, 86, 91, 95, 100, 104, 109, 113, 118, 123, 127, 132, 136, 141, 145, 150,
  63. 154, 159, 163, 168, 172, 177, 181, 186, 190, 195, 199, 204, 208, 213, 217, 222,
  64. 226, 231, 235, 240, 244, 249, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  65. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  66. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  67. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 };
  68. /** The green values. */
  69. private int[] green =
  70. {255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  71. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 6, 11,
  72. 15, 20, 24, 29, 33, 38, 42, 47, 51, 56, 60, 65, 69, 74, 78, 83,
  73. 87, 92, 96, 101, 105, 110, 114, 119, 123, 128, 132, 137, 141, 146, 150, 155,
  74. 159, 164, 168, 173, 177, 182, 186, 191, 195, 200, 204, 209, 213, 218, 222, 227,
  75. 231, 236, 241, 245, 250, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  76. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  77. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  78. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  79. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  80. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  81. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  82. 255, 255, 255, 255, 255, 255, 255, 252, 248, 243, 239, 234, 230, 225, 221, 216,
  83. 212, 207, 203, 198, 194, 189, 185, 180, 176, 171, 167, 162, 158, 153, 149, 144,
  84. 140, 135, 131, 126, 122, 117, 113, 108, 104, 99, 95, 90, 86, 81, 77, 72,
  85. 68, 63, 59, 54, 50, 45, 41, 36, 32, 27, 23, 18, 14, 9, 5, 0 };
  86. /** The blue values. */
  87. private int[] blue =
  88. {255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  89. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  90. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  91. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  92. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  93. 255, 255, 255, 255, 255, 255, 251, 247, 242, 238, 233, 229, 224, 220, 215, 211,
  94. 206, 202, 197, 193, 188, 184, 179, 175, 170, 166, 161, 157, 152, 148, 143, 139,
  95. 134, 130, 125, 121, 116, 112, 107, 103, 98, 94, 89, 85, 80, 76, 71, 67,
  96. 62, 58, 53, 49, 44, 40, 35, 31, 26, 22, 17, 13, 8, 4, 0, 0,
  97. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  98. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  99. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  100. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  101. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  102. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  103. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  104. /**
  105. * Default constructor.
  106. */
  107. public RainbowPalette() {
  108. super();
  109. initialize();
  110. }
  111. /**
  112. * Intializes the palettes indexes
  113. */
  114. public void initialize() {
  115. setPaletteName("Rainbow");
  116. this.r = new int[this.red.length];
  117. this.g = new int[this.green.length];
  118. this.b = new int[this.blue.length];
  119. System.arraycopy(this.red, 0, this.r, 0, this.red.length);
  120. System.arraycopy(this.green, 0, this.g, 0, this.green.length);
  121. System.arraycopy(this.blue, 0, this.b, 0, this.blue.length);
  122. }
  123. }