Source for org.jfree.chart.ChartColor

   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:  * ChartColor.java
  29:  * ---------------
  30:  * (C) Copyright 2003-2007, by Cameron Riley and Contributors.
  31:  *
  32:  * Original Author:  Cameron Riley;
  33:  * Contributor(s):   David Gilbert (for Object Refinery Limited);
  34:  *
  35:  * $Id: ChartColor.java,v 1.3.2.3 2007/02/02 15:53:36 mungady Exp $
  36:  *
  37:  * Changes
  38:  * -------
  39:  * 23-Jan-2003 : Version 1, contributed by Cameron Riley (DG);
  40:  * 25-Nov-2004 : Changed first 7 colors to softer shades (DG);
  41:  * 03-Nov-2005 : Removed orange color, too close to yellow - see bug
  42:  *               report 1328408 (DG);
  43:  * ------------- JFREECHART 1.0.x ---------------------------------------------
  44:  * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG);
  45:  *
  46:  */
  47: 
  48: package org.jfree.chart;
  49: 
  50: import java.awt.Color;
  51: import java.awt.Paint;
  52: 
  53: /**
  54:  * Class to extend the number of Colors available to the charts. This
  55:  * extends the java.awt.Color object and extends the number of final
  56:  * Colors publically accessible.
  57:  */
  58: public class ChartColor extends Color {
  59: 
  60:     /** A very dark red color. */
  61:     public static final Color VERY_DARK_RED = new Color(0x80, 0x00, 0x00);
  62: 
  63:     /** A dark red color. */
  64:     public static final Color DARK_RED = new Color(0xc0, 0x00, 0x00);
  65: 
  66:     /** A light red color. */
  67:     public static final Color LIGHT_RED = new Color(0xFF, 0x40, 0x40);
  68: 
  69:     /** A very light red color. */
  70:     public static final Color VERY_LIGHT_RED = new Color(0xFF, 0x80, 0x80);
  71: 
  72:     /** A very dark yellow color. */
  73:     public static final Color VERY_DARK_YELLOW = new Color(0x80, 0x80, 0x00);
  74: 
  75:     /** A dark yellow color. */
  76:     public static final Color DARK_YELLOW = new Color(0xC0, 0xC0, 0x00);
  77: 
  78:     /** A light yellow color. */
  79:     public static final Color LIGHT_YELLOW = new Color(0xFF, 0xFF, 0x40);
  80: 
  81:     /** A very light yellow color. */
  82:     public static final Color VERY_LIGHT_YELLOW = new Color(0xFF, 0xFF, 0x80);
  83: 
  84:     /** A very dark green color. */
  85:     public static final Color VERY_DARK_GREEN = new Color(0x00, 0x80, 0x00);
  86: 
  87:     /** A dark green color. */
  88:     public static final Color DARK_GREEN = new Color(0x00, 0xC0, 0x00);
  89: 
  90:     /** A light green color. */
  91:     public static final Color LIGHT_GREEN = new Color(0x40, 0xFF, 0x40);
  92: 
  93:     /** A very light green color. */
  94:     public static final Color VERY_LIGHT_GREEN = new Color(0x80, 0xFF, 0x80);
  95: 
  96:     /** A very dark cyan color. */
  97:     public static final Color VERY_DARK_CYAN = new Color(0x00, 0x80, 0x80);
  98: 
  99:     /** A dark cyan color. */
 100:     public static final Color DARK_CYAN = new Color(0x00, 0xC0, 0xC0);
 101: 
 102:     /** A light cyan color. */
 103:     public static final Color LIGHT_CYAN = new Color(0x40, 0xFF, 0xFF);
 104: 
 105:     /** Aa very light cyan color. */
 106:     public static final Color VERY_LIGHT_CYAN = new Color(0x80, 0xFF, 0xFF);
 107: 
 108:     /** A very dark blue color. */
 109:     public static final Color VERY_DARK_BLUE = new Color(0x00, 0x00, 0x80);
 110: 
 111:     /** A dark blue color. */
 112:     public static final Color DARK_BLUE = new Color(0x00, 0x00, 0xC0);
 113: 
 114:     /** A light blue color. */
 115:     public static final Color LIGHT_BLUE = new Color(0x40, 0x40, 0xFF);
 116: 
 117:     /** A very light blue color. */
 118:     public static final Color VERY_LIGHT_BLUE = new Color(0x80, 0x80, 0xFF);
 119: 
 120:     /** A very dark magenta/purple color. */
 121:     public static final Color VERY_DARK_MAGENTA = new Color(0x80, 0x00, 0x80);
 122: 
 123:     /** A dark magenta color. */
 124:     public static final Color DARK_MAGENTA = new Color(0xC0, 0x00, 0xC0);
 125: 
 126:     /** A light magenta color. */
 127:     public static final Color LIGHT_MAGENTA = new Color(0xFF, 0x40, 0xFF);
 128: 
 129:     /** A very light magenta color. */
 130:     public static final Color VERY_LIGHT_MAGENTA = new Color(0xFF, 0x80, 0xFF);
 131: 
 132:     /**
 133:      * Creates a Color with an opaque sRGB with red, green and blue values in 
 134:      * range 0-255.
 135:      *
 136:      * @param r  the red component in range 0x00-0xFF.
 137:      * @param g  the green component in range 0x00-0xFF.
 138:      * @param b  the blue component in range 0x00-0xFF.
 139:      */
 140:     public ChartColor(int r, int g, int b) {
 141:         super(r, g, b);
 142:     }
 143: 
 144:     /**
 145:      * Convenience method to return an array of <code>Paint</code> objects that
 146:      * represent the pre-defined colors in the <code>Color<code> and 
 147:      * <code>ChartColor</code> objects.
 148:      *
 149:      * @return An array of objects with the <code>Paint</code> interface.
 150:      */
 151:     public static Paint[] createDefaultPaintArray() {
 152: 
 153:         return new Paint[] {
 154:             new Color(0xFF, 0x55, 0x55),
 155:             new Color(0x55, 0x55, 0xFF),
 156:             new Color(0x55, 0xFF, 0x55),
 157:             new Color(0xFF, 0xFF, 0x55),
 158:             new Color(0xFF, 0x55, 0xFF),
 159:             new Color(0x55, 0xFF, 0xFF),
 160:             Color.pink,
 161:             Color.gray,
 162:             ChartColor.DARK_RED,
 163:             ChartColor.DARK_BLUE,
 164:             ChartColor.DARK_GREEN,
 165:             ChartColor.DARK_YELLOW,
 166:             ChartColor.DARK_MAGENTA,
 167:             ChartColor.DARK_CYAN,
 168:             Color.darkGray,
 169:             ChartColor.LIGHT_RED,
 170:             ChartColor.LIGHT_BLUE,
 171:             ChartColor.LIGHT_GREEN,
 172:             ChartColor.LIGHT_YELLOW,
 173:             ChartColor.LIGHT_MAGENTA,
 174:             ChartColor.LIGHT_CYAN,
 175:             Color.lightGray,
 176:             ChartColor.VERY_DARK_RED,
 177:             ChartColor.VERY_DARK_BLUE,
 178:             ChartColor.VERY_DARK_GREEN,
 179:             ChartColor.VERY_DARK_YELLOW,
 180:             ChartColor.VERY_DARK_MAGENTA,
 181:             ChartColor.VERY_DARK_CYAN,
 182:             ChartColor.VERY_LIGHT_RED,
 183:             ChartColor.VERY_LIGHT_BLUE,
 184:             ChartColor.VERY_LIGHT_GREEN,
 185:             ChartColor.VERY_LIGHT_YELLOW,
 186:             ChartColor.VERY_LIGHT_MAGENTA,
 187:             ChartColor.VERY_LIGHT_CYAN
 188:         };
 189:     }
 190: 
 191: }