001/* =========================================================== 002 * JFreeChart : a free chart library for the Java(tm) platform 003 * =========================================================== 004 * 005 * (C) Copyright 2000-2020, 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 * ChartColor.java 029 * --------------- 030 * (C) Copyright 2003-2020, by Cameron Riley and Contributors. 031 * 032 * Original Author: Cameron Riley; 033 * Contributor(s): David Gilbert (for Object Refinery Limited); 034 * 035 */ 036 037package org.jfree.chart; 038 039import java.awt.Color; 040import java.awt.Paint; 041 042/** 043 * Class to extend the number of Colors available to the charts. This 044 * extends the java.awt.Color object and extends the number of final 045 * Colors publicly accessible. 046 */ 047public class ChartColor extends Color { 048 049 /** A very dark red color. */ 050 public static final Color VERY_DARK_RED = new Color(0x80, 0x00, 0x00); 051 052 /** A dark red color. */ 053 public static final Color DARK_RED = new Color(0xc0, 0x00, 0x00); 054 055 /** A light red color. */ 056 public static final Color LIGHT_RED = new Color(0xFF, 0x40, 0x40); 057 058 /** A very light red color. */ 059 public static final Color VERY_LIGHT_RED = new Color(0xFF, 0x80, 0x80); 060 061 /** A very dark yellow color. */ 062 public static final Color VERY_DARK_YELLOW = new Color(0x80, 0x80, 0x00); 063 064 /** A dark yellow color. */ 065 public static final Color DARK_YELLOW = new Color(0xC0, 0xC0, 0x00); 066 067 /** A light yellow color. */ 068 public static final Color LIGHT_YELLOW = new Color(0xFF, 0xFF, 0x40); 069 070 /** A very light yellow color. */ 071 public static final Color VERY_LIGHT_YELLOW = new Color(0xFF, 0xFF, 0x80); 072 073 /** A very dark green color. */ 074 public static final Color VERY_DARK_GREEN = new Color(0x00, 0x80, 0x00); 075 076 /** A dark green color. */ 077 public static final Color DARK_GREEN = new Color(0x00, 0xC0, 0x00); 078 079 /** A light green color. */ 080 public static final Color LIGHT_GREEN = new Color(0x40, 0xFF, 0x40); 081 082 /** A very light green color. */ 083 public static final Color VERY_LIGHT_GREEN = new Color(0x80, 0xFF, 0x80); 084 085 /** A very dark cyan color. */ 086 public static final Color VERY_DARK_CYAN = new Color(0x00, 0x80, 0x80); 087 088 /** A dark cyan color. */ 089 public static final Color DARK_CYAN = new Color(0x00, 0xC0, 0xC0); 090 091 /** A light cyan color. */ 092 public static final Color LIGHT_CYAN = new Color(0x40, 0xFF, 0xFF); 093 094 /** Aa very light cyan color. */ 095 public static final Color VERY_LIGHT_CYAN = new Color(0x80, 0xFF, 0xFF); 096 097 /** A very dark blue color. */ 098 public static final Color VERY_DARK_BLUE = new Color(0x00, 0x00, 0x80); 099 100 /** A dark blue color. */ 101 public static final Color DARK_BLUE = new Color(0x00, 0x00, 0xC0); 102 103 /** A light blue color. */ 104 public static final Color LIGHT_BLUE = new Color(0x40, 0x40, 0xFF); 105 106 /** A very light blue color. */ 107 public static final Color VERY_LIGHT_BLUE = new Color(0x80, 0x80, 0xFF); 108 109 /** A very dark magenta/purple color. */ 110 public static final Color VERY_DARK_MAGENTA = new Color(0x80, 0x00, 0x80); 111 112 /** A dark magenta color. */ 113 public static final Color DARK_MAGENTA = new Color(0xC0, 0x00, 0xC0); 114 115 /** A light magenta color. */ 116 public static final Color LIGHT_MAGENTA = new Color(0xFF, 0x40, 0xFF); 117 118 /** A very light magenta color. */ 119 public static final Color VERY_LIGHT_MAGENTA = new Color(0xFF, 0x80, 0xFF); 120 121 /** 122 * Creates a Color with an opaque sRGB with red, green and blue values in 123 * range 0-255. 124 * 125 * @param r the red component in range 0x00-0xFF. 126 * @param g the green component in range 0x00-0xFF. 127 * @param b the blue component in range 0x00-0xFF. 128 */ 129 public ChartColor(int r, int g, int b) { 130 super(r, g, b); 131 } 132 133 /** 134 * Convenience method to return an array of {@code Paint} objects that 135 * represent the pre-defined colors in the {@code Color} and 136 * {@code ChartColor} objects. 137 * 138 * @return An array of objects with the {@code Paint} interface. 139 */ 140 public static Paint[] createDefaultPaintArray() { 141 142 return new Paint[] { 143 new Color(0xFF, 0x55, 0x55), 144 new Color(0x55, 0x55, 0xFF), 145 new Color(0x55, 0xFF, 0x55), 146 new Color(0xFF, 0xFF, 0x55), 147 new Color(0xFF, 0x55, 0xFF), 148 new Color(0x55, 0xFF, 0xFF), 149 Color.PINK, 150 Color.GRAY, 151 ChartColor.DARK_RED, 152 ChartColor.DARK_BLUE, 153 ChartColor.DARK_GREEN, 154 ChartColor.DARK_YELLOW, 155 ChartColor.DARK_MAGENTA, 156 ChartColor.DARK_CYAN, 157 Color.DARK_GRAY, 158 ChartColor.LIGHT_RED, 159 ChartColor.LIGHT_BLUE, 160 ChartColor.LIGHT_GREEN, 161 ChartColor.LIGHT_YELLOW, 162 ChartColor.LIGHT_MAGENTA, 163 ChartColor.LIGHT_CYAN, 164 Color.LIGHT_GRAY, 165 ChartColor.VERY_DARK_RED, 166 ChartColor.VERY_DARK_BLUE, 167 ChartColor.VERY_DARK_GREEN, 168 ChartColor.VERY_DARK_YELLOW, 169 ChartColor.VERY_DARK_MAGENTA, 170 ChartColor.VERY_DARK_CYAN, 171 ChartColor.VERY_LIGHT_RED, 172 ChartColor.VERY_LIGHT_BLUE, 173 ChartColor.VERY_LIGHT_GREEN, 174 ChartColor.VERY_LIGHT_YELLOW, 175 ChartColor.VERY_LIGHT_MAGENTA, 176 ChartColor.VERY_LIGHT_CYAN 177 }; 178 } 179 180}