    001/* ===========================================================
    002 * Orson Charts : a 3D chart library for the Java(tm) platform
    003 * ===========================================================
    004 *
    005 * (C)opyright 2013-2022, by David Gilbert.  All rights reserved.
    006 *
    007 * https://github.com/jfree/orson-charts
    008 *
    009 * This program is free software: you can redistribute it and/or modify
    010 * it under the terms of the GNU General Public License as published by
    011 * the Free Software Foundation, either version 3 of the License, or
    012 * (at your option) any later version.
    013 *
    014 * This program is distributed in the hope that it will be useful,
    015 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    017 * GNU General Public License for more details.
    018 *
    019 * You should have received a copy of the GNU General Public License
    020 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    021 *
    022 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    023 * Other names may be trademarks of their respective owners.]
    024 *
    025 * If you do not wish to be bound by the terms of the GPL, an alternative
    026 * commercial license can be purchased.  For details, please see visit the
    027 * Orson Charts home page:
    028 *
    029 * http://www.object-refinery.com/orsoncharts/index.html
    030 *
    031 */
    032
    033package org.jfree.chart3d;
    034
    035import java.awt.Color;
    036
    037/**
    038 * A utility class that creates and returns color swatches that can be used
    039 * in charts.  The "i want hue" utility has been used to generate a number
    040 * of these color sets.
    041 * See <a href="http://tools.medialab.sciences-po.fr/iwanthue/">
    042 * http://tools.medialab.sciences-po.fr/iwanthue/</a>.
    043 */
    044public class Colors {
    045
    046    private Colors() {
    047        // no need to instantiate this class
    048    }
    049
    050    /**
    051     * Returns the default colors.
    052     *
    053     * @return The default colors.
    054     */
    055    public static Color[] getDefaultColors() {
    056        return createShadesColors();
    057    }
    058
    059    /**
    060     * Returns a palette of ten colors created using the "i want hue" utility,
    061     * using the preset "Fancy (light background)" settings.  A new array
    062     * instance is created for each call to this method.  A link to the
    063     * "i want hue" utility is given in the class description.
    064     *
    065     * @return An array of ten colors (never {@code null}).
    066     *
    067     * @since 1.2
    068     */
    069    public static Color[] createFancyLightColors() {
    070        Color[] result = new Color[10];
    071        result[0] = new Color(239, 164, 127);
    072        result[1] = new Color(140, 228, 139);
    073        result[2] = new Color(155, 208, 227);
    074        result[3] = new Color(221, 228, 95);
    075        result[4] = new Color(118, 223, 194);
    076        result[5] = new Color(240, 166, 184);
    077        result[6] = new Color(231, 185, 98);
    078        result[7] = new Color(186, 214, 150);
    079        result[8] = new Color(217, 184, 226);
    080        result[9] = new Color(201, 212, 116);
    081        return result;
    082    }
    083
    084    /**
    085     * Returns a palette of ten colors created using the "i want hue" utility,
    086     * using the preset "Fancy (dark background)" settings.  A new array
    087     * instance is created for each call to this method.  A link to the
    088     * "i want hue" utility is given in the class description.
    089     *
    090     * @return An array of ten colors (never {@code null}).
    091     *
    092     * @since 1.2
    093     */
    094    public static Color[] createFancyDarkColors() {
    095        Color[] result = new Color[10];
    096        result[0] = new Color(78, 81, 97);
    097        result[1] = new Color(91, 104, 51);
    098        result[2] = new Color(138, 75, 65);
    099        result[3] = new Color(72, 62, 34);
    100        result[4] = new Color(58, 100, 75);
    101        result[5] = new Color(39, 63, 59);
    102        result[6] = new Color(105, 68, 75);
    103        result[7] = new Color(120, 90, 120);
    104        result[8] = new Color(119, 90, 50);
    105        result[9] = new Color(59, 103, 111);
    106        return result;
    107    }
    108
    109    /**
    110     * Returns a palette of ten colors created using the "i want hue" utility,
    111     * using the preset "Shades" settings.  A new array instance is created for
    112     * each call to this method.  A link to the "i want hue" utility is given
    113     * in the class description.
    114     *
    115     * @return An array of ten colors (never {@code null}).
    116     *
    117     * @since 1.2
    118     */
    119    public static Color[] createShadesColors() {
    120        Color[] result = new Color[10];
    121        result[0] = new Color(137, 132, 104);
    122        result[1] = new Color(217, 232, 208);
    123        result[2] = new Color(53, 48, 40);
    124        result[3] = new Color(240, 225, 172);
    125        result[4] = new Color(196, 160, 128);
    126        result[5] = new Color(92, 96, 87);
    127        result[6] = new Color(136, 141, 136);
    128        result[7] = new Color(106, 93, 66);
    129        result[8] = new Color(205, 199, 168);
    130        result[9] = new Color(158, 168, 143);
    131        return result;
    132    }
    133
    134    /**
    135     * Returns a palette of ten colors created using the "i want hue" utility,
    136     * using the preset "Tarnish" settings.  A new array instance is created for
    137     * each call to this method.  A link to the "i want hue" utility is given
    138     * in the class description.
    139     *
    140     * @return An array of ten colors (never {@code null}).
    141     *
    142     * @since 1.2
    143     */
    144    public static Color[] createTarnishColors() {
    145        Color[] result = new Color[10];
    146        result[0] = new Color(148, 129, 121);
    147        result[1] = new Color(179, 181, 136);
    148        result[2] = new Color(204, 163, 140);
    149        result[3] = new Color(102, 93, 80);
    150        result[4] = new Color(164, 178, 159);
    151        result[5] = new Color(156, 130, 100);
    152        result[6] = new Color(129, 142, 124);
    153        result[7] = new Color(186, 168, 159);
    154        result[8] = new Color(144, 148, 108);
    155        result[9] = new Color(189, 169, 131);
    156        return result;
    157    }
    158
    159    /**
    160     * Returns a palette of ten colors created using the "i want hue" utility,
    161     * using the preset "Pastel" settings.  A new array instance is created for
    162     * each call to this method.  A link to the "i want hue" utility is given
    163     * in the class description.
    164     *
    165     * @return An array of ten colors (never {@code null}).
    166     *
    167     * @since 1.2
    168     */
    169    public static Color[] createPastelColors() {
    170        Color[] result = new Color[10];
    171        result[0] = new Color(232, 177, 165);
    172        result[1] = new Color(207, 235, 142);
    173        result[2] = new Color(142, 220, 220);
    174        result[3] = new Color(228, 186, 115);
    175        result[4] = new Color(187, 200, 230);
    176        result[5] = new Color(157, 222, 177);
    177        result[6] = new Color(234, 183, 210);
    178        result[7] = new Color(213, 206, 169);
    179        result[8] = new Color(202, 214, 205);
    180        result[9] = new Color(195, 204, 133);
    181        return result;
    182    }
    183
    184    /**
    185     * Returns a palette of ten colors created using the "i want hue" utility,
    186     * using the preset "Pimp" settings.  A new array instance is created for
    187     * each call to this method.  A link to the "i want hue" utility is given
    188     * in the class description.
    189     *
    190     * @return An array of ten colors (never {@code null}).
    191     *
    192     * @since 1.2
    193     */
    194    public static Color[] createPimpColors() {
    195        Color[] result = new Color[10];
    196        result[0] = new Color(197, 75, 103);
    197        result[1] = new Color(85, 154, 48);
    198        result[2] = new Color(122, 110, 206);
    199        result[3] = new Color(190, 100, 50);
    200        result[4] = new Color(201, 79, 209);
    201        result[5] = new Color(95, 127, 170);
    202        result[6] = new Color(147, 129, 39);
    203        result[7] = new Color(63, 142, 96);
    204        result[8] = new Color(186, 84, 150);
    205        result[9] = new Color(219, 66, 52);
    206        return result;
    207    }
    208
    209    /**
    210     * Returns a palette of ten colors created using the "i want hue" utility,
    211     * using the preset "Intense" settings.  A new array instance is created for
    212     * each call to this method.  A link to the "i want hue" utility is given
    213     * in the class description.
    214     *
    215     * @return An array of ten colors (never {@code null}).
    216     *
    217     * @since 1.2
    218     */
    219    public static Color[] createIntenseColors() {
    220        Color[] result = new Color[10];
    221        result[0] = new Color(107, 122, 160);
    222        result[1] = new Color(99, 176, 67);
    223        result[2] = new Color(214, 85, 52);
    224        result[3] = new Color(202, 79, 200);
    225        result[4] = new Color(184, 149, 57);
    226        result[5] = new Color(82, 168, 146);
    227        result[6] = new Color(194, 84, 128);
    228        result[7] = new Color(77, 102, 50);
    229        result[8] = new Color(132, 108, 197);
    230        result[9] = new Color(144, 74, 61);
    231        return result;
    232    }
    233
    234    /**
    235     * Returns a palette of ten colors created using the "i want hue" utility,
    236     * using the preset "Fluo" settings.  A new array instance is created for
    237     * each call to this method.  A link to the "i want hue" utility is given
    238     * in the class description.
    239     *
    240     * @return An array of ten colors (never {@code null}).
    241     *
    242     * @since 1.2
    243     */
    244    public static Color[] createFluoColors() {
    245        Color[] result = new Color[10];
    246        result[0] = new Color(108, 236, 137);
    247        result[1] = new Color(253, 187, 46);
    248        result[2] = new Color(56, 236, 216);
    249        result[3] = new Color(171, 231, 51);
    250        result[4] = new Color(221, 214, 74);
    251        result[5] = new Color(106, 238, 70);
    252        result[6] = new Color(172, 230, 100);
    253        result[7] = new Color(242, 191, 82);
    254        result[8] = new Color(221, 233, 56);
    255        result[9] = new Color(242, 206, 47);
    256        return result;
    257    }
    258
    259    /**
    260     * Returns a palette of ten colors created using the "i want hue" utility,
    261     * using the preset "Red Roses" settings.  A new array instance is created
    262     * for each call to this method.  A link to the "i want hue" utility is
    263     * given in the class description.
    264     *
    265     * @return An array of ten colors (never {@code null}).
    266     *
    267     * @since 1.2
    268     */
    269    public static Color[] createRedRosesColors() {
    270        Color[] result = new Color[10];
    271        result[0] = new Color(230, 129, 128);
    272        result[1] = new Color(233, 56, 39);
    273        result[2] = new Color(225, 45, 102);
    274        result[3] = new Color(172, 79, 55);
    275        result[4] = new Color(214, 154, 128);
    276        result[5] = new Color(156, 96, 81);
    277        result[6] = new Color(190, 77, 91);
    278        result[7] = new Color(228, 121, 91);
    279        result[8] = new Color(216, 63, 80);
    280        result[9] = new Color(209, 75, 46);
    281        return result;
    282    }
    283
    284    /**
    285     * Returns a palette of ten colors created using the "i want hue" utility,
    286     * using the preset "Ochre Sand" settings.  A new array instance is created
    287     * for each call to this method.  A link to the "i want hue" utility is
    288     * given in the class description.
    289     *
    290     * @return An array of ten colors (never {@code null}).
    291     *
    292     * @since 1.2
    293     */
    294    public static Color[] createOchreSandColors() {
    295        Color[] result = new Color[10];
    296        result[0] = new Color(218, 180, 125);
    297        result[1] = new Color(245, 184, 36);
    298        result[2] = new Color(159, 103, 28);
    299        result[3] = new Color(124, 96, 55);
    300        result[4] = new Color(224, 132, 56);
    301        result[5] = new Color(185, 143, 48);
    302        result[6] = new Color(229, 171, 97);
    303        result[7] = new Color(232, 165, 54);
    304        result[8] = new Color(171, 102, 53);
    305        result[9] = new Color(160, 122, 71);
    306        return result;
    307    }
    308
    309    /**
    310     * Returns a palette of ten colors created using the "i want hue" utility,
    311     * using the preset "Yellow Lime" settings.  A new array instance is created
    312     * for each call to this method.  A link to the "i want hue" utility is
    313     * given in the class description.
    314     *
    315     * @return An array of ten colors (never {@code null}).
    316     *
    317     * @since 1.2
    318     */
    319    public static Color[] createYellowLimeColors() {
    320        Color[] result = new Color[10];
    321        result[0] = new Color(235, 203, 59);
    322        result[1] = new Color(113, 108, 56);
    323        result[2] = new Color(222, 206, 134);
    324        result[3] = new Color(169, 166, 62);
    325        result[4] = new Color(214, 230, 54);
    326        result[5] = new Color(225, 221, 105);
    327        result[6] = new Color(128, 104, 23);
    328        result[7] = new Color(162, 151, 86);
    329        result[8] = new Color(117, 121, 25);
    330        result[9] = new Color(183, 179, 40);
    331        return result;
    332    }
    333
    334    /**
    335     * Returns a palette of ten colors created using the "i want hue" utility,
    336     * using the preset "Green Mint" settings.  A new array instance is created
    337     * for each call to this method.  A link to the "i want hue" utility is
    338     * given in the class description.
    339     *
    340     * @return An array of ten colors (never {@code null}).
    341     *
    342     * @since 1.2
    343     */
    344    public static Color[] createGreenMintColors() {
    345        Color[] result = new Color[10];
    346        result[0] = new Color(99, 224, 113);
    347        result[1] = new Color(98, 132, 83);
    348        result[2] = new Color(145, 234, 49);
    349        result[3] = new Color(181, 215, 158);
    350        result[4] = new Color(95, 171, 43);
    351        result[5] = new Color(100, 208, 142);
    352        result[6] = new Color(172, 222, 84);
    353        result[7] = new Color(75, 139, 53);
    354        result[8] = new Color(177, 216, 123);
    355        result[9] = new Color(83, 223, 60);
    356        return result;
    357    }
    358
    359    /**
    360     * Returns a palette of ten colors created using the "i want hue" utility,
    361     * using the preset "Ice Cube" settings.  A new array instance is created
    362     * for each call to this method.  A link to the "i want hue" utility is
    363     * given in the class description.
    364     *
    365     * @return An array of ten colors (never {@code null}).
    366     *
    367     * @since 1.2
    368     */
    369    public static Color[] createIceCubeColors() {
    370        Color[] result = new Color[10];
    371        result[0] = new Color(112, 235, 233);
    372        result[1] = new Color(54, 110, 100);
    373        result[2] = new Color(211, 232, 208);
    374        result[3] = new Color(94, 230, 191);
    375        result[4] = new Color(76, 154, 155);
    376        result[5] = new Color(156, 181, 157);
    377        result[6] = new Color(67, 152, 126);
    378        result[7] = new Color(112, 135, 119);
    379        result[8] = new Color(155, 213, 192);
    380        result[9] = new Color(80, 195, 190);
    381        return result;
    382    }
    383
    384    /**
    385     * Returns a palette of ten colors created using the "i want hue" utility,
    386     * using the preset "Blue Ocean" settings.  A new array instance is created
    387     * for each call to this method.  A link to the "i want hue" utility is
    388     * given in the class description.
    389     *
    390     * @return An array of ten colors (never {@code null}).
    391     *
    392     * @since 1.2
    393     */
    394    public static Color[] createBlueOceanColors() {
    395        Color[] result = new Color[10];
    396        result[0] = new Color(53, 84, 154);
    397        result[1] = new Color(41, 46, 57);
    398        result[2] = new Color(115, 124, 151);
    399        result[3] = new Color(38, 52, 91);
    400        result[4] = new Color(84, 117, 211);
    401        result[5] = new Color(76, 125, 181);
    402        result[6] = new Color(109, 108, 112);
    403        result[7] = new Color(48, 105, 134);
    404        result[8] = new Color(72, 82, 107);
    405        result[9] = new Color(91, 99, 144);
    406        return result;
    407    }
    408
    409    /**
    410     * Returns a palette of ten colors created using the "i want hue" utility,
    411     * using the preset "Indigo Night" settings.  A new array instance is
    412     * created for each call to this method.  A link to the "i want hue"
    413     * utility is given in the class description.
    414     *
    415     * @return An array of ten colors (never {@code null}).
    416     *
    417     * @since 1.2
    418     */
    419    public static Color[] createIndigoNightColors() {
    420        Color[] result = new Color[10];
    421        result[0] = new Color(127, 88, 147);
    422        result[1] = new Color(201, 67, 217);
    423        result[2] = new Color(112, 97, 218);
    424        result[3] = new Color(219, 134, 222);
    425        result[4] = new Color(154, 80, 172);
    426        result[5] = new Color(170, 106, 231);
    427        result[6] = new Color(142, 111, 210);
    428        result[7] = new Color(194, 149, 235);
    429        result[8] = new Color(152, 118, 188);
    430        result[9] = new Color(214, 101, 237);
    431        return result;
    432    }
    433
    434    /**
    435     * Returns a palette of ten colors created using the "i want hue" utility,
    436     * using the preset "Purple Wine" settings.  A new array instance is created
    437     * for each call to this method.  A link to the "i want hue" utility is
    438     * given in the class description.
    439     *
    440     * @return An array of ten colors (never {@code null}).
    441     *
    442     * @since 1.2
    443     */
    444    public static Color[] createPurpleWineColors() {
    445        Color[] result = new Color[10];
    446        result[0] = new Color(116, 28, 93);
    447        result[1] = new Color(112, 79, 75);
    448        result[2] = new Color(178, 37, 101);
    449        result[3] = new Color(109, 24, 56);
    450        result[4] = new Color(167, 42, 140);
    451        result[5] = new Color(66, 30, 40);
    452        result[6] = new Color(128, 70, 95);
    453        result[7] = new Color(78, 20, 56);
    454        result[8] = new Color(155, 62, 111);
    455        result[9] = new Color(139, 61, 75);
    456        return result;
    457    }
    458
    459    /**
    460     * Returns a palette of 7 colors with earth tones.
    461     *
    462     * @return An array of 7 colors (never {@code null}).
    463     */
    464     public static Color[] getEarthColors() {
    465         Color[] result = new Color[7];
    466         result[0] = new Color(98, 98, 98);
    467         result[1] = new Color(159, 87, 43);
    468         result[2] = new Color(194, 176, 46);
    469         result[3] = new Color(134, 155, 64);
    470         result[4] = new Color(57, 118, 40);
    471         result[5] = new Color(40, 114, 110);
    472         result[6] = new Color(78, 79, 62);
    473         return result;
    474    }
    475
    476    /**
    477     * Returns a newly created array containing 9 colors from the the
    478     * ColorBrewer tool.  This is a high-contrast set of colors, good for
    479     * pie charts.
    480     *
    481     * http://colorbrewer2.org/?type=qualitative&amp;scheme=Set1&amp;n=9
    482     *
    483     * @return A color array.
    484     */
    485    public static Color[] getBrewerQualitativeSet1N9Colors() {
    486        Color[] result = new Color[9];
    487        result[0] = new Color(228, 26, 28);
    488        result[1] = new Color(55, 126, 184);
    489        result[2] = new Color(77, 175, 74);
    490        result[3] = new Color(152, 78, 163);
    491        result[4] = new Color(255, 127, 0);
    492        result[5] = new Color(255, 255, 51);
    493        result[6] = new Color(166, 86, 40);
    494        result[7] = new Color(247, 129, 191);
    495        result[8] = new Color(153, 153, 153);
    496        return result;
    497    }
    498
    499    /**
    500     * Returns a newly created array containing 12 colors from the the
    501     * ColorBrewer tool.
    502     *
    503     * http://colorbrewer2.org/?type=qualitative&amp;scheme=Paired&amp;n=12
    504     *
    505     * @return A color array.
    506     */
    507    public static Color[] getBrewerQualitativePairedN12Colors() {
    508        Color[] result = new Color[12];
    509        result[0] = new Color(166, 206, 227);
    510        result[1] = new Color(31, 120, 180);
    511        result[2] = new Color(178, 223, 138);
    512        result[3] = new Color(51, 160, 44);
    513        result[4] = new Color(251, 154, 153);
    514        result[5] = new Color(227, 26, 28);
    515        result[6] = new Color(253, 191, 111);
    516        result[7] = new Color(255, 127, 0);
    517        result[8] = new Color(202, 178, 214);
    518        result[9] = new Color(106, 61, 154);
    519        result[10] = new Color(255, 255, 153);
    520        result[11] = new Color(177, 89, 40);
    521        return result;
    522    }
    523
    524    /**
    525     * Returns a newly created array containing 11 colors from the the
    526     * ColorBrewer tool.  Good for pie charts and bar charts, not so good for
    527     * scatter plots.
    528     *
    529     * http://colorbrewer2.org/?type=qualitative&amp;scheme=Set3&amp;n=12
    530     *
    531     * @return A color array.
    532     */
    533    public static Color[] getBrewerQualitativeSet3N12Colors() {
    534        Color[] result = new Color[12];
    535        result[0] = new Color(141, 211, 199);
    536        result[1] = new Color(255, 255, 179);
    537        result[2] = new Color(190, 186, 218);
    538        result[3] = new Color(251, 128, 114);
    539        result[4] = new Color(128, 177, 211);
    540        result[5] = new Color(253, 180, 98);
    541        result[6] = new Color(179, 222, 105);
    542        result[7] = new Color(252, 205, 229);
    543        result[8] = new Color(217, 217, 217);
    544        result[9] = new Color(188, 128, 189);
    545        result[10] = new Color(204, 235, 197);
    546        result[11] = new Color(255, 237, 111);
    547        return result;
    548    }
    549
    550    /**
    551     * Returns a set of colors sourced from
    552     * http://www.sapdesignguild.org/goodies/diagram_guidelines/index.html.
    553     *
    554     * @return A color array.
    555     */
    556    public static Color[] getSAPMultiColor() {
    557        return new Color[] {
    558            new Color(255, 248, 163),
    559            new Color(169, 204, 143),
    560            new Color(178, 200, 217),
    561            new Color(190, 163, 122),
    562            new Color(243, 170, 121),
    563            new Color(181, 181, 169),
    564            new Color(230, 165, 164),
    565            new Color(248, 215, 83),
    566            new Color(92, 151, 70),
    567            new Color(62, 117, 167),
    568            new Color(122, 101, 62),
    569            new Color(225, 102, 42),
    570            new Color(116, 121, 111),
    571            new Color(196, 56, 79)
    572        };
    573    }
    574
    575    /**
    576     * Returns an array of four colors.
    577     *
    578     * @return An array of four colors.
    579     */
    580    public static Color[] getColors1() {
    581        return new Color[] { new Color(0, 55, 122),
    582            new Color(24, 123, 58), Color.RED, Color.YELLOW };
    583    }
    584
    585    /**
    586     * Returns an array of four colors.
    587     *
    588     * @return An array of four colors.
    589     */
    590    public static Color[] getColors2() {
    591        return new Color[] {new Color(0x1A9641), new Color(0xA6D96A),
    592                    new Color(0xFDAE61), new Color(0xFFFFBF)};
    593    }
    594
    595    /**
    596     * Returns an array of six colors
    597     * (source: http://blog.design-seeds.com/generating-color/).
    598     *
    599     * @return An array of six colors.
    600     */
    601    public static Color[] getDesignSeedsShells() {
    602        return new Color[] {
    603            new Color(228, 233, 239),
    604            new Color(184, 197, 219),
    605            new Color(111, 122, 143),
    606            new Color(95, 89, 89),
    607            new Color(206, 167, 145),
    608            new Color(188, 182, 173)
    609        };
    610    }
    611
    612    /**
    613     * Returns an array of six colors
    614     * (source: http://blog.design-seeds.com/generating-color/).
    615     *
    616     * @return An array of six colors.
    617     */
    618    public static Color[] getDesignSeedsPepper() {
    619        return new Color[] {
    620            new Color(255, 219, 142),
    621            new Color(220, 21, 20),
    622            new Color(149, 0, 1),
    623            new Color(82, 102, 41),
    624            new Color(142, 101, 72),
    625            new Color(199, 169, 128)
    626        };
    627    }
    628}