1 /*
   2  * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javafx.scene.paint;
  27 
  28 import javafx.animation.Interpolatable;
  29 import java.util.HashMap;
  30 import java.util.Locale;
  31 import java.util.Map;
  32 import com.sun.javafx.util.Utils;
  33 import com.sun.javafx.tk.Toolkit;
  34 import javafx.beans.NamedArg;
  35 
  36 // NOTE: this definition, while correct, contains a lot of information which
  37 // is irrelevant to most developers. We should get to the basic definition and
  38 // usage patterns sooner.
  39 
  40 /**
  41  * The Color class is used to encapsulate colors in the default sRGB color space.
  42  * Every color has an implicit alpha value of 1.0 or an explicit one provided
  43  * in the constructor. The alpha value defines the transparency of a color
  44  * and can be  represented by a double value in the range 0.0-1.0 or 0-255.
  45  * An alpha value of 1.0 or 255 means that the color is completely opaque
  46  * and an alpha value of 0 or 0.0 means that the color is completely transparent.
  47  * When constructing a {@code Color} with an explicit alpha or getting
  48  * the color/alpha components of a Color,
  49  * the color components are never premultiplied by the alpha component.
  50  *
  51  *
  52  * <p>{@code Color}s can be created with the constructor or with one of several
  53  * utility methods.  The following lines of code all create the same
  54  * blue color:</p>
  55  *
  56  * <pre><code>
  57  * {@literal
  58  * Color c = Color.BLUE;   //use the blue constant
  59  * Color c = new Color(0,0,1,1.0); // standard constructor, use 0->1.0 values, explicit alpha of 1.0
  60  *
  61  * Color c = Color.color(0,0,1.0); //use 0->1.0 values. implicit alpha of 1.0
  62  * Color c = Color.color(0,0,1.0,1.0); //use 0->1.0 values, explicit alpha of 1.0
  63  *
  64  * Color c = Color.rgb(0,0,255); //use 0->255 integers, implicit alpha of 1.0
  65  * Color c = Color.rgb(0,0,255,1.0); //use 0->255 integers, explicit alpha of 1.0
  66  *
  67  * Color c = Color.hsb(270,1.0,1.0); //hue = 270, saturation & value = 1.0. inplicit alpha of 1.0
  68  * Color c = Color.hsb(270,1.0,1.0,1.0); //hue = 270, saturation & value = 1.0, explicit alpha of 1.0
  69  *
  70  * Color c = Color.web("0x0000FF",1.0);// blue as a hex web value, explicit alpha
  71  * Color c = Color.web("0x0000FF");// blue as a hex web value, implicit alpha
  72  * Color c = Color.web("0x00F");// blue as a short hex web value, implicit alpha
  73  * Color c = Color.web("#0000FF",1.0);// blue as a hex web value, explicit alpha
  74  * Color c = Color.web("#0000FF");// blue as a hex web value, implicit alpha
  75  * Color c = Color.web("#00F");// blue as a short hex web value, implicit alpha
  76  * Color c = Color.web("0000FF",1.0);// blue as a hex web value, explicit alpha
  77  * Color c = Color.web("0000FF");// blue as a hex web value, implicit alpha
  78  * Color c = Color.web("00F");// blue as a short hex web value, implicit alpha
  79  * Color c = Color.web("rgba(0,0,255,1.0)");// blue as an rgb web value, explicit alpha
  80  * Color c = Color.web("rgb(0,0,255)");// blue as an rgb web value, implicit alpha
  81  * Color c = Color.web("rgba(0,0,100%,1.0)");// blue as an rgb percent web value, explicit alpha
  82  * Color c = Color.web("rgb(0,0,100%)");// blue as an rgb percent web value, implicit alpha
  83  * Color c = Color.web("hsla(270,100%,100%,1.0)");// blue as an hsl web value, explicit alpha
  84  * Color c = Color.web("hsl(270,100%,100%)");// blue as an hsl web value, implicit alpha
  85  * }
  86  * </code></pre>
  87  *
  88  * <p>
  89  * The creation of a {@code Color} will throw {@code IllegalArgumentException} if any
  90  * of the values are out of range.
  91  * </p>
  92  *
  93  * <p>
  94  * For example:
  95  * <pre>{@code
  96  * Rectangle rec1 = new Rectangle(5, 5, 50, 40);
  97  * rec1.setFill(Color.RED);
  98  * rec1.setStroke(Color.GREEN);
  99  * rec1.setStrokeWidth(3);
 100  *
 101  * Rectangle rec2 = new Rectangle(65, 5, 50, 40);
 102  * rec2.setFill(Color.rgb(91, 127, 255));
 103  * rec2.setStroke(Color.hsb(40, 0.7, 0.8));
 104  * rec2.setStrokeWidth(3);
 105  * }</pre>
 106  *
 107  * @since JavaFX 2.0
 108  */
 109 public final class Color extends Paint implements Interpolatable<Color> {
 110 
 111     /**
 112      * Brightness change factor for darker() and brighter() methods.
 113      */
 114     private static final double DARKER_BRIGHTER_FACTOR = 0.7;
 115 
 116     /**
 117      * Saturation change factor for saturate() and desaturate() methods.
 118      */
 119     private static final double SATURATE_DESATURATE_FACTOR = 0.7;
 120 
 121     /**
 122      * Creates an sRGB color with the specified red, green and blue values
 123      * in the range {@code 0.0-1.0}, and a given opacity.
 124      *
 125      * @param red the red component, in the range {@code 0.0-1.0}
 126      * @param green the green component, in the range {@code 0.0-1.0}
 127      * @param blue the blue component, in the range {@code 0.0-1.0}
 128      * @param opacity the opacity component, in the range {@code 0.0-1.0}
 129      * @return the {@code Color}
 130      * @throws IllegalArgumentException if any value is out of range
 131      */
 132     public static Color color(double red, double green, double blue, double opacity) {
 133         return new Color(red, green, blue, opacity);
 134     }
 135 
 136     /**
 137      * Creates an opaque sRGB color with the specified red, green and blue values
 138      * in the range {@code 0.0-1.0}.
 139      *
 140      * @param red the red component, in the range {@code 0.0-1.0}
 141      * @param green the green component, in the range {@code 0.0-1.0}
 142      * @param blue the blue component, in the range {@code 0.0-1.0}
 143      * @return the {@code Color}
 144      * @throws IllegalArgumentException if any value is out of range
 145      */
 146     public static Color color(double red, double green, double blue) {
 147         return new Color(red, green, blue, 1);
 148     }
 149 
 150     /**
 151      * Creates an sRGB color with the specified RGB values in the range {@code 0-255},
 152      * and a given opacity.
 153      *
 154      * @param red the red component, in the range {@code 0-255}
 155      * @param green the green component, in the range {@code 0-255}
 156      * @param blue the blue component, in the range {@code 0-255}
 157      * @param opacity the opacity component, in the range {@code 0.0-1.0}
 158      * @return the {@code Color}
 159      * @throws IllegalArgumentException if any value is out of range
 160      */
 161     public static Color rgb(int red, int green, int blue, double opacity) {
 162         checkRGB(red, green, blue);
 163         return new Color(
 164             red / 255.0,
 165             green / 255.0,
 166             blue / 255.0,
 167             opacity);
 168     }
 169 
 170     /**
 171      * Creates an opaque sRGB color with the specified RGB values in the range {@code 0-255}.
 172      *
 173      * @param red the red component, in the range {@code 0-255}
 174      * @param green the green component, in the range {@code 0-255}
 175      * @param blue the blue component, in the range {@code 0-255}
 176      * @return the {@code Color}
 177      * @throws IllegalArgumentException if any value is out of range
 178      */
 179     public static Color rgb(int red, int green, int blue) {
 180         checkRGB(red, green, blue);
 181         return new Color(
 182             red / 255.0,
 183             green / 255.0,
 184             blue / 255.0,
 185             1.0);
 186     }
 187 
 188 
 189     /**
 190      * This is a shortcut for {@code rgb(gray, gray, gray)}.
 191      * @param gray the gray component, in the range {@code 0-255}
 192      * @return the {@code Color}
 193      */
 194     public static Color grayRgb(int gray) {
 195         return rgb(gray, gray, gray);
 196     }
 197 
 198     /**
 199      * This is a shortcut for {@code rgb(gray, gray, gray, opacity)}.
 200      * @param gray the gray component, in the range {@code 0-255}
 201      * @param opacity the opacity component, in the range {@code 0.0-1.0}
 202      * @return the {@code Color}
 203      */
 204     public static Color grayRgb(int gray, double opacity) {
 205         return rgb(gray, gray, gray, opacity);
 206     }
 207 
 208     /**
 209      * Creates a grey color.
 210      * @param gray color on gray scale in the range
 211      *             {@code 0.0} (black) - {@code 1.0} (white).
 212      * @param opacity the opacity component, in the range {@code 0.0-1.0}
 213      * @return the {@code Color}
 214      * @throws IllegalArgumentException if any value is out of range
 215      */
 216     public static Color gray(double gray, double opacity) {
 217         return new Color(gray, gray, gray, opacity);
 218     }
 219 
 220     /**
 221      * Creates an opaque grey color.
 222      * @param gray color on gray scale in the range
 223      *             {@code 0.0} (black) - {@code 1.0} (white).
 224      * @return the {@code Color}
 225      * @throws IllegalArgumentException if any value is out of range
 226      */
 227     public static Color gray(double gray) {
 228         return gray(gray, 1.0);
 229     }
 230 
 231     private static void checkRGB(int red, int green, int blue) {
 232         if (red < 0 || red > 255) {
 233             throw new IllegalArgumentException("Color.rgb's red parameter (" + red + ") expects color values 0-255");
 234         }
 235         if (green < 0 || green > 255) {
 236             throw new IllegalArgumentException("Color.rgb's green parameter (" + green + ") expects color values 0-255");
 237         }
 238         if (blue < 0 || blue > 255) {
 239             throw new IllegalArgumentException("Color.rgb's blue parameter (" + blue + ") expects color values 0-255");
 240         }
 241     }
 242 
 243     /**
 244      * Creates a {@code Color} based on the specified values in the HSB color model,
 245      * and a given opacity.
 246      *
 247      * @param hue the hue, in degrees
 248      * @param saturation the saturation, {@code 0.0 to 1.0}
 249      * @param brightness the brightness, {@code 0.0 to 1.0}
 250      * @param opacity the opacity, {@code 0.0 to 1.0}
 251      * @return the {@code Color}
 252      * @throws IllegalArgumentException if {@code saturation}, {@code brightness} or
 253      *         {@code opacity} are out of range
 254      */
 255     public static Color hsb(double hue, double saturation, double brightness, double opacity) {
 256         checkSB(saturation, brightness);
 257         double[] rgb = Utils.HSBtoRGB(hue, saturation, brightness);
 258         Color result = new Color(rgb[0], rgb[1], rgb[2], opacity);
 259         return result;
 260     }
 261 
 262     /**
 263      * Creates an opaque {@code Color} based on the specified values in the HSB color model.
 264      *
 265      * @param hue the hue, in degrees
 266      * @param saturation the saturation, {@code 0.0 to 1.0}
 267      * @param brightness the brightness, {@code 0.0 to 1.0}
 268      * @return the {@code Color}
 269      * @throws IllegalArgumentException if {@code saturation} or {@code brightness} are
 270      *         out of range
 271      */
 272     public static Color hsb(double hue, double saturation, double brightness) {
 273         return hsb(hue, saturation, brightness, 1.0);
 274     }
 275 
 276     private static void checkSB(double saturation, double brightness) {
 277         if (saturation < 0.0 || saturation > 1.0) {
 278             throw new IllegalArgumentException("Color.hsb's saturation parameter (" + saturation + ") expects values 0.0-1.0");
 279         }
 280         if (brightness < 0.0 || brightness > 1.0) {
 281             throw new IllegalArgumentException("Color.hsb's brightness parameter (" + brightness + ") expects values 0.0-1.0");
 282         }
 283     }
 284 
 285     /**
 286      * Creates an RGB color specified with an HTML or CSS attribute string.
 287      *
 288      * <p>
 289      * This method supports the following formats:
 290      * <ul>
 291      * <li>Any standard HTML color name
 292      * <li>An HTML long or short format hex string with an optional hex alpha
 293      * channel.
 294      * Hexadecimal values may be preceded by either {@code "0x"} or {@code "#"}
 295      * and can either be 2 digits in the range {@code 00} to {@code 0xFF} or a
 296      * single digit in the range {@code 0} to {@code F}.
 297      * <li>An {@code rgb(r,g,b)} or {@code rgba(r,g,b,a)} format string.
 298      * Each of the {@code r}, {@code g}, or {@code b} values can be an integer
 299      * from 0 to 255 or a floating point percentage value from 0.0 to 100.0
 300      * followed by the percent ({@code %}) character.
 301      * The alpha component, if present, is a
 302      * floating point value from 0.0 to 1.0.  Spaces are allowed before or
 303      * after the numbers and between the percentage number and its percent
 304      * sign ({@code %}).
 305      * <li>An {@code hsl(h,s,l)} or {@code hsla(h,s,l,a)} format string.
 306      * The {@code h} value is a floating point number from 0.0 to 360.0
 307      * representing the hue angle on a color wheel in degrees with
 308      * {@code 0.0} or {@code 360.0} representing red, {@code 120.0}
 309      * representing green, and {@code 240.0} representing blue.  The
 310      * {@code s} value is the saturation of the desired color represented
 311      * as a floating point percentage from gray ({@code 0.0}) to
 312      * the fully saturated color ({@code 100.0}) and the {@code l} value
 313      * is the desired lightness or brightness of the desired color represented
 314      * as a floating point percentage from black ({@code 0.0}) to the full
 315      * brightness of the color ({@code 100.0}).
 316      * The alpha component, if present, is a floating
 317      * point value from 0.0 to 1.0.  Spaces are allowed before or
 318      * after the numbers and between the percentage number and its percent
 319      * sign ({@code %}).
 320      * </ul>
 321      *
 322      * <p>For formats without an alpha component and for named colors, opacity
 323      * is set according to the {@code opacity} argument. For colors specified
 324      * with an alpha component, the resulting opacity is a combination of the
 325      * parsed alpha component and the {@code opacity} argument, so a
 326      * transparent color becomes more transparent by specifying opacity.</p>
 327      *
 328      * <p>Examples:</p>
 329      * <div class="classUseContainer">
 330      * <table class="overviewSummary">
 331      * <caption>Web Color Format Table</caption>
 332      * <tr>
 333      * <th scope="col" class="colFirst">Web Format String</th>
 334      * <th scope="col" class="colLast">Equivalent constructor or factory call</th>
 335      * </tr>
 336      * <tr class="rowColor">
 337      * <th scope="row" class="colFirst"><code>Color.web("orange", 0.5);</code></th>
 338      * <td class="colLast"><code>new Color(1.0, 0xA5/255.0, 0.0, 0.5)</code></td>
 339      * </tr>
 340      * <tr class="altColor">
 341      * <th scope="row" class="colFirst"><code>Color.web("0xff66cc33", 0.5);</code></th>
 342      * <td class="colLast"><code>new Color(1.0, 0.4, 0.8, 0.1)</code></td>
 343      * </tr>
 344      * <tr class="rowColor">
 345      * <th scope="row" class="colFirst"><code>Color.web("0xff66cc", 0.5);</code></th>
 346      * <td class="colLast"><code>new Color(1.0, 0.4, 0.8, 0.5)</code></td>
 347      * </tr>
 348      * <tr class="altColor">
 349      * <th scope="row" class="colFirst"><code>Color.web("#ff66cc", 0.5);</code></th>
 350      * <td class="colLast"><code>new Color(1.0, 0.4, 0.8, 0.5)</code></td>
 351      * </tr>
 352      * <tr class="rowColor">
 353      * <th scope="row" class="colFirst"><code>Color.web("#f68", 0.5);</code></th>
 354      * <td class="colLast"><code>new Color(1.0, 0.4, 0.8, 0.5)</code></td>
 355      * </tr>
 356      * <tr class="altColor">
 357      * <th scope="row" class="colFirst"><code>Color.web("rgb(255,102,204)", 0.5);</code></th>
 358      * <td class="colLast"><code>new Color(1.0, 0.4, 0.8, 0.5)</code></td>
 359      * </tr>
 360      * <tr class="rowColor">
 361      * <th scope="row" class="colFirst"><code>Color.web("rgb(100%,50%,50%)", 0.5);</code></th>
 362      * <td class="colLast"><code>new Color(1.0, 0.5, 0.5, 0.5)</code></td>
 363      * </tr>
 364      * <tr class="altColor">
 365      * <th scope="row" class="colFirst"><code>Color.web("rgb(255,50%,50%,0.25)", 0.5);</code></th>
 366      * <td class="colLast"><code>new Color(1.0, 0.5, 0.5, 0.125)</code></td>
 367      * </tr>
 368      * <tr class="rowColor">
 369      * <th scope="row" class="colFirst"><code>Color.web("hsl(240,100%,100%)", 0.5);</code></th>
 370      * <td class="colLast"><code>Color.hsb(240.0, 1.0, 1.0, 0.5)</code></td>
 371      * </tr>
 372      * <tr class="altColor">
 373      * <th scope="row" style="border-bottom:1px solid" class="colFirst">
 374      *     <code>Color.web("hsla(120,0%,0%,0.25)", 0.5);</code>
 375      * </th>
 376      * <td style="border-bottom:1px solid" class="colLast">
 377      *     <code>Color.hsb(120.0, 0.0, 0.0, 0.125)</code>
 378      * </td>
 379      * </tr>
 380      * </table>
 381      * </div>
 382      *
 383      * @param colorString the name or numeric representation of the color
 384      *                    in one of the supported formats
 385      * @param opacity the opacity component in range from 0.0 (transparent)
 386      *                to 1.0 (opaque)
 387      * @return the RGB color specified with the colorString
 388      * @throws NullPointerException if {@code colorString} is {@code null}
 389      * @throws IllegalArgumentException if {@code colorString} specifies
 390      *      an unsupported color name or contains an illegal numeric value
 391      */
 392     public static Color web(String colorString, double opacity) {
 393         if (colorString == null) {
 394             throw new NullPointerException(
 395                     "The color components or name must be specified");
 396         }
 397         if (colorString.isEmpty()) {
 398             throw new IllegalArgumentException("Invalid color specification");
 399         }
 400 
 401         String color = colorString.toLowerCase(Locale.ROOT);
 402 
 403         if (color.startsWith("#")) {
 404             color = color.substring(1);
 405         } else if (color.startsWith("0x")) {
 406             color = color.substring(2);
 407         } else if (color.startsWith("rgb")) {
 408             if (color.startsWith("(", 3)) {
 409                 return parseRGBColor(color, 4, false, opacity);
 410             } else if (color.startsWith("a(", 3)) {
 411                 return parseRGBColor(color, 5, true, opacity);
 412             }
 413         } else if (color.startsWith("hsl")) {
 414             if (color.startsWith("(", 3)) {
 415                 return parseHSLColor(color, 4, false, opacity);
 416             } else if (color.startsWith("a(", 3)) {
 417                 return parseHSLColor(color, 5, true, opacity);
 418             }
 419         } else {
 420             Color col = NamedColors.get(color);
 421             if (col != null) {
 422                 if (opacity == 1.0) {
 423                     return col;
 424                 } else {
 425                     return Color.color(col.red, col.green, col.blue, opacity);
 426                 }
 427             }
 428         }
 429 
 430         int len = color.length();
 431 
 432         try {
 433             int r;
 434             int g;
 435             int b;
 436             int a;
 437 
 438             if (len == 3) {
 439                 r = Integer.parseInt(color.substring(0, 1), 16);
 440                 g = Integer.parseInt(color.substring(1, 2), 16);
 441                 b = Integer.parseInt(color.substring(2, 3), 16);
 442                 return Color.color(r / 15.0, g / 15.0, b / 15.0, opacity);
 443             } else if (len == 4) {
 444                 r = Integer.parseInt(color.substring(0, 1), 16);
 445                 g = Integer.parseInt(color.substring(1, 2), 16);
 446                 b = Integer.parseInt(color.substring(2, 3), 16);
 447                 a = Integer.parseInt(color.substring(3, 4), 16);
 448                 return Color.color(r / 15.0, g / 15.0, b / 15.0,
 449                         opacity * a / 15.0);
 450             } else if (len == 6) {
 451                 r = Integer.parseInt(color.substring(0, 2), 16);
 452                 g = Integer.parseInt(color.substring(2, 4), 16);
 453                 b = Integer.parseInt(color.substring(4, 6), 16);
 454                 return Color.rgb(r, g, b, opacity);
 455             } else if (len == 8) {
 456                 r = Integer.parseInt(color.substring(0, 2), 16);
 457                 g = Integer.parseInt(color.substring(2, 4), 16);
 458                 b = Integer.parseInt(color.substring(4, 6), 16);
 459                 a = Integer.parseInt(color.substring(6, 8), 16);
 460                 return Color.rgb(r, g, b, opacity * a / 255.0);
 461             }
 462         } catch (NumberFormatException nfe) {}
 463 
 464         throw new IllegalArgumentException("Invalid color specification");
 465     }
 466 
 467     private static Color parseRGBColor(String color, int roff,
 468                                        boolean hasAlpha, double a)
 469     {
 470         try {
 471             int rend = color.indexOf(',', roff);
 472             int gend = rend < 0 ? -1 : color.indexOf(',', rend+1);
 473             int bend = gend < 0 ? -1 : color.indexOf(hasAlpha ? ',' : ')', gend+1);
 474             int aend = hasAlpha ? (bend < 0 ? -1 : color.indexOf(')', bend+1)) : bend;
 475             if (aend >= 0) {
 476                 double r = parseComponent(color, roff, rend, PARSE_COMPONENT);
 477                 double g = parseComponent(color, rend+1, gend, PARSE_COMPONENT);
 478                 double b = parseComponent(color, gend+1, bend, PARSE_COMPONENT);
 479                 if (hasAlpha) {
 480                     a *= parseComponent(color, bend+1, aend, PARSE_ALPHA);
 481                 }
 482                 return new Color(r, g, b, a);
 483             }
 484         } catch (NumberFormatException nfe) {}
 485 
 486         throw new IllegalArgumentException("Invalid color specification");
 487     }
 488 
 489     private static Color parseHSLColor(String color, int hoff,
 490                                        boolean hasAlpha, double a)
 491     {
 492         try {
 493             int hend = color.indexOf(',', hoff);
 494             int send = hend < 0 ? -1 : color.indexOf(',', hend+1);
 495             int lend = send < 0 ? -1 : color.indexOf(hasAlpha ? ',' : ')', send+1);
 496             int aend = hasAlpha ? (lend < 0 ? -1 : color.indexOf(')', lend+1)) : lend;
 497             if (aend >= 0) {
 498                 double h = parseComponent(color, hoff, hend, PARSE_ANGLE);
 499                 double s = parseComponent(color, hend+1, send, PARSE_PERCENT);
 500                 double l = parseComponent(color, send+1, lend, PARSE_PERCENT);
 501                 if (hasAlpha) {
 502                     a *= parseComponent(color, lend+1, aend, PARSE_ALPHA);
 503                 }
 504                 return Color.hsb(h, s, l, a);
 505             }
 506         } catch (NumberFormatException nfe) {}
 507 
 508         throw new IllegalArgumentException("Invalid color specification");
 509     }
 510 
 511     private static final int PARSE_COMPONENT = 0; // percent, or clamped to [0,255] => [0,1]
 512     private static final int PARSE_PERCENT = 1; // clamped to [0,100]% => [0,1]
 513     private static final int PARSE_ANGLE = 2; // clamped to [0,360]
 514     private static final int PARSE_ALPHA = 3; // clamped to [0.0,1.0]
 515     private static double parseComponent(String color, int off, int end, int type) {
 516         color = color.substring(off, end).trim();
 517         if (color.endsWith("%")) {
 518             if (type > PARSE_PERCENT) {
 519                 throw new IllegalArgumentException("Invalid color specification");
 520             }
 521             type = PARSE_PERCENT;
 522             color = color.substring(0, color.length()-1).trim();
 523         } else if (type == PARSE_PERCENT) {
 524             throw new IllegalArgumentException("Invalid color specification");
 525         }
 526         double c = ((type == PARSE_COMPONENT)
 527                     ? Integer.parseInt(color)
 528                     : Double.parseDouble(color));
 529         switch (type) {
 530             case PARSE_ALPHA:
 531                 return (c < 0.0) ? 0.0 : ((c > 1.0) ? 1.0 : c);
 532             case PARSE_PERCENT:
 533                 return (c <= 0.0) ? 0.0 : ((c >= 100.0) ? 1.0 : (c / 100.0));
 534             case PARSE_COMPONENT:
 535                 return (c <= 0.0) ? 0.0 : ((c >= 255.0) ? 1.0 : (c / 255.0));
 536             case PARSE_ANGLE:
 537                 return ((c < 0.0)
 538                         ? ((c % 360.0) + 360.0)
 539                         : ((c > 360.0)
 540                             ? (c % 360.0)
 541                             : c));
 542         }
 543 
 544         throw new IllegalArgumentException("Invalid color specification");
 545     }
 546 
 547     /**
 548      * Creates an RGB color specified with an HTML or CSS attribute string.
 549      *
 550      * <p>
 551      * This method supports the following formats:
 552      * <ul>
 553      * <li>Any standard HTML color name
 554      * <li>An HTML long or short format hex string with an optional hex alpha
 555      * channel.
 556      * Hexadecimal values may be preceded by either {@code "0x"} or {@code "#"}
 557      * and can either be 2 digits in the range {@code 00} to {@code 0xFF} or a
 558      * single digit in the range {@code 0} to {@code F}.
 559      * <li>An {@code rgb(r,g,b)} or {@code rgba(r,g,b,a)} format string.
 560      * Each of the {@code r}, {@code g}, or {@code b} values can be an integer
 561      * from 0 to 255 or a floating point percentage value from 0.0 to 100.0
 562      * followed by the percent ({@code %}) character.
 563      * The alpha component, if present, is a
 564      * floating point value from 0.0 to 1.0.  Spaces are allowed before or
 565      * after the numbers and between the percentage number and its percent
 566      * sign ({@code %}).
 567      * <li>An {@code hsl(h,s,l)} or {@code hsla(h,s,l,a)} format string.
 568      * The {@code h} value is a floating point number from 0.0 to 360.0
 569      * representing the hue angle on a color wheel in degrees with
 570      * {@code 0.0} or {@code 360.0} representing red, {@code 120.0}
 571      * representing green, and {@code 240.0} representing blue.  The
 572      * {@code s} value is the saturation of the desired color represented
 573      * as a floating point percentage from gray ({@code 0.0}) to
 574      * the fully saturated color ({@code 100.0}) and the {@code l} value
 575      * is the desired lightness or brightness of the desired color represented
 576      * as a floating point percentage from black ({@code 0.0}) to the full
 577      * brightness of the color ({@code 100.0}).
 578      * The alpha component, if present, is a floating
 579      * point value from 0.0 to 1.0.  Spaces are allowed before or
 580      * after the numbers and between the percentage number and its percent
 581      * sign ({@code %}).
 582      * </ul>
 583      *
 584      * <p>Examples:</p>
 585      * <div class="classUseContainer">
 586      * <table class="overviewSummary">
 587      * <caption>Web Color Format Table</caption>
 588      * <tr>
 589      * <th scope="col" class="colFirst">Web Format String</th>
 590      * <th scope="col" class="colLast">Equivalent constant or factory call</th>
 591      * </tr>
 592      * <tr class="rowColor">
 593      * <th scope="row" class="colFirst"><code>Color.web("orange");</code></th>
 594      * <td class="colLast"><code>Color.ORANGE</code></td>
 595      * </tr>
 596      * <tr class="altColor">
 597      * <th scope="row" class="colFirst"><code>Color.web("0xff668840");</code></th>
 598      * <td class="colLast"><code>Color.rgb(255, 102, 136, 0.25)</code></td>
 599      * </tr>
 600      * <tr class="rowColor">
 601      * <th scope="row" class="colFirst"><code>Color.web("0xff6688");</code></th>
 602      * <td class="colLast"><code>Color.rgb(255, 102, 136, 1.0)</code></td>
 603      * </tr>
 604      * <tr class="altColor">
 605      * <th scope="row" class="colFirst"><code>Color.web("#ff6688");</code></th>
 606      * <td class="colLast"><code>Color.rgb(255, 102, 136, 1.0)</code></td>
 607      * </tr>
 608      * <tr class="rowColor">
 609      * <th scope="row" class="colFirst"><code>Color.web("#f68");</code></th>
 610      * <td class="colLast"><code>Color.rgb(255, 102, 136, 1.0)</code></td>
 611      * </tr>
 612      * <tr class="altColor">
 613      * <th scope="row" class="colFirst"><code>Color.web("rgb(255,102,136)");</code></th>
 614      * <td class="colLast"><code>Color.rgb(255, 102, 136, 1.0)</code></td>
 615      * </tr>
 616      * <tr class="rowColor">
 617      * <th scope="row" class="colFirst"><code>Color.web("rgb(100%,50%,50%)");</code></th>
 618      * <td class="colLast"><code>Color.rgb(255, 128, 128, 1.0)</code></td>
 619      * </tr>
 620      * <tr class="altColor">
 621      * <th scope="row" class="colFirst"><code>Color.web("rgb(255,50%,50%,0.25)");</code></th>
 622      * <td class="colLast"><code>Color.rgb(255, 128, 128, 0.25)</code></td>
 623      * </tr>
 624      * <tr class="rowColor">
 625      * <th scope="row" class="colFirst"><code>Color.web("hsl(240,100%,100%)");</code></th>
 626      * <td class="colLast"><code>Color.hsb(240.0, 1.0, 1.0, 1.0)</code></td>
 627      * </tr>
 628      * <tr class="altColor">
 629      * <th scope="row" style="border-bottom:1px solid" class="colFirst">
 630      *     <code>Color.web("hsla(120,0%,0%,0.25)");</code>
 631      * </th>
 632      * <td style="border-bottom:1px solid" class="colLast">
 633      *     <code>Color.hsb(120.0, 0.0, 0.0, 0.25)</code>
 634      * </td>
 635      * </tr>
 636      * </table>
 637      * </div>
 638      *
 639      * @param colorString the name or numeric representation of the color
 640      *                    in one of the supported formats
 641      * @return an RGB color
 642      * @throws NullPointerException if {@code colorString} is {@code null}
 643      * @throws IllegalArgumentException if {@code colorString} specifies
 644      *      an unsupported color name or contains an illegal numeric value
 645      */
 646     public static Color web(String colorString) {
 647         return web(colorString, 1.0);
 648     }
 649 
 650     /**
 651      * Creates a color value from a string representation. The format
 652      * of the string representation is the same as in {@link #web(String)}.
 653      *
 654      * @param value the string to convert
 655      * @throws NullPointerException if the {@code value} is {@code null}
 656      * @throws IllegalArgumentException if the {@code value} specifies
 657      *      an unsupported color name or illegal hexadecimal value
 658      * @return a {@code Color} object holding the value represented
 659      * by the string argument
 660      * @see #web(String)
 661      * @since JavaFX 2.1
 662      */
 663     public static Color valueOf(String value) {
 664         if (value == null) {
 665             throw new NullPointerException("color must be specified");
 666         }
 667 
 668         return web(value);
 669     }
 670 
 671     private static int to32BitInteger(int red, int green, int blue, int alpha) {
 672         int i = red;
 673         i = i << 8;
 674         i = i | green;
 675         i = i << 8;
 676         i = i | blue;
 677         i = i << 8;
 678         i = i | alpha;
 679         return i;
 680     }
 681 
 682     /**
 683      * Gets the hue component of this {@code Color}.
 684      * @return Hue value in the range in the range {@code 0.0-360.0}.
 685      */
 686     public double getHue() {
 687         return Utils.RGBtoHSB(red, green, blue)[0];
 688     }
 689 
 690     /**
 691      * Gets the saturation component of this {@code Color}.
 692      * @return Saturation value in the range in the range {@code 0.0-1.0}.
 693      */
 694     public double getSaturation() {
 695         return Utils.RGBtoHSB(red, green, blue)[1];
 696     }
 697 
 698     /**
 699      * Gets the brightness component of this {@code Color}.
 700      * @return Brightness value in the range in the range {@code 0.0-1.0}.
 701      */
 702     public double getBrightness() {
 703         return Utils.RGBtoHSB(red, green, blue)[2];
 704     }
 705 
 706     /**
 707      * Creates a new {@code Color} based on this {@code Color} with hue,
 708      * saturation, brightness and opacity values altered. Hue is shifted
 709      * about the given value and normalized into its natural range, the
 710      * other components' values are multiplied by the given factors and
 711      * clipped into their ranges.
 712      *
 713      * Increasing brightness of black color is allowed by using an arbitrary,
 714      * very small source brightness instead of zero.
 715      * @param hueShift the hue shift
 716      * @param saturationFactor the saturation factor
 717      * @param brightnessFactor the brightness factor
 718      * @param opacityFactor the opacity factor
 719      * @return a {@code Color} based based on this {@code Color} with hue,
 720      * saturation, brightness and opacity values altered.
 721      */
 722     public Color deriveColor(double hueShift, double saturationFactor,
 723                              double brightnessFactor, double opacityFactor) {
 724 
 725         double[] hsb = Utils.RGBtoHSB(red, green, blue);
 726 
 727         /* Allow brightness increase of black color */
 728         double b = hsb[2];
 729         if (b == 0 && brightnessFactor > 1.0) {
 730             b = 0.05;
 731         }
 732 
 733         /* the tail "+ 360) % 360" solves shifts into negative numbers */
 734         double h = (((hsb[0] + hueShift) % 360) + 360) % 360;
 735         double s = Math.max(Math.min(hsb[1] * saturationFactor, 1.0), 0.0);
 736         b = Math.max(Math.min(b * brightnessFactor, 1.0), 0.0);
 737         double a = Math.max(Math.min(opacity * opacityFactor, 1.0), 0.0);
 738         return hsb(h, s, b, a);
 739     }
 740 
 741     /**
 742      * Creates a new Color that is a brighter version of this Color.
 743      * @return a Color that is a brighter version of this Color
 744      */
 745     public Color brighter() {
 746         return deriveColor(0, 1.0, 1.0 / DARKER_BRIGHTER_FACTOR, 1.0);
 747     }
 748 
 749     /**
 750      * Creates a new Color that is a darker version of this Color.
 751      * @return a Color that is a darker version of this Color
 752      */
 753     public Color darker() {
 754         return deriveColor(0, 1.0, DARKER_BRIGHTER_FACTOR, 1.0);
 755     }
 756 
 757     /**
 758      * Creates a new Color that is a more saturated version of this Color.
 759      * @return a Color that is a more saturated version of this Color
 760      */
 761     public Color saturate() {
 762         return deriveColor(0, 1.0 / SATURATE_DESATURATE_FACTOR, 1.0, 1.0);
 763     }
 764 
 765     /**
 766      * Creates a new Color that is a less saturated version of this Color.
 767      * @return a Color that is a less saturated version of this Color
 768      */
 769     public Color desaturate() {
 770         return deriveColor(0, SATURATE_DESATURATE_FACTOR, 1.0, 1.0);
 771     }
 772 
 773     /**
 774      * Creates a new Color that is grayscale equivalent of this Color.
 775      * Opacity is preserved.
 776      * @return a Color that is grayscale equivalent of this Color
 777      */
 778     public Color grayscale() {
 779         double gray = 0.21 * red + 0.71 * green + 0.07 * blue;
 780         return Color.color(gray, gray, gray, opacity);
 781     }
 782 
 783     /**
 784      * Creates a new Color that is inversion of this Color.
 785      * Opacity is preserved.
 786      * @return a Color that is inversion of this Color
 787      */
 788     public Color invert() {
 789         return Color.color(1.0 - red, 1.0 - green, 1.0 - blue, opacity);
 790     }
 791 
 792     /**
 793      * A fully transparent color with an ARGB value of #00000000.
 794      */
 795     public static final Color TRANSPARENT          = new Color(0f, 0f, 0f, 0f);
 796 
 797     /**
 798      * The color alice blue with an RGB value of #F0F8FF
 799      * <div style="border:1px solid black;width:40px;height:20px;background-color:#F0F8FF;float:right;margin: 0 10px 0 0"></div>
 800      */
 801     public static final Color ALICEBLUE = new Color(0.9411765f, 0.972549f, 1.0f);
 802 
 803     /**
 804      * The color antique white with an RGB value of #FAEBD7
 805      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FAEBD7;float:right;margin: 0 10px 0 0"></div>
 806      */
 807     public static final Color ANTIQUEWHITE = new Color(0.98039216f, 0.92156863f, 0.84313726f);
 808 
 809     /**
 810      * The color aqua with an RGB value of #00FFFF
 811      * <div style="border:1px solid black;width:40px;height:20px;background-color:#00FFFF;float:right;margin: 0 10px 0 0"></div>
 812      */
 813     public static final Color AQUA = new Color(0.0f, 1.0f, 1.0f);
 814 
 815     /**
 816      * The color aquamarine with an RGB value of #7FFFD4
 817      * <div style="border:1px solid black;width:40px;height:20px;background-color:#7FFFD4;float:right;margin: 0 10px 0 0"></div>
 818      */
 819     public static final Color AQUAMARINE = new Color(0.49803922f, 1.0f, 0.83137256f);
 820 
 821     /**
 822      * The color azure with an RGB value of #F0FFFF
 823      * <div style="border:1px solid black;width:40px;height:20px;background-color:#F0FFFF;float:right;margin: 0 10px 0 0"></div>
 824      */
 825     public static final Color AZURE = new Color(0.9411765f, 1.0f, 1.0f);
 826 
 827     /**
 828      * The color beige with an RGB value of #F5F5DC
 829      * <div style="border:1px solid black;width:40px;height:20px;background-color:#F5F5DC;float:right;margin: 0 10px 0 0"></div>
 830      */
 831     public static final Color BEIGE = new Color(0.9607843f, 0.9607843f, 0.8627451f);
 832 
 833     /**
 834      * The color bisque with an RGB value of #FFE4C4
 835      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FFE4C4;float:right;margin: 0 10px 0 0"></div>
 836      */
 837     public static final Color BISQUE = new Color(1.0f, 0.89411765f, 0.76862746f);
 838 
 839     /**
 840      * The color black with an RGB value of #000000
 841      * <div style="border:1px solid black;width:40px;height:20px;background-color:#000000;float:right;margin: 0 10px 0 0"></div>
 842      */
 843     public static final Color BLACK = new Color(0.0f, 0.0f, 0.0f);
 844 
 845     /**
 846      * The color blanched almond with an RGB value of #FFEBCD
 847      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FFEBCD;float:right;margin: 0 10px 0 0"></div>
 848      */
 849     public static final Color BLANCHEDALMOND = new Color(1.0f, 0.92156863f, 0.8039216f);
 850 
 851     /**
 852      * The color blue with an RGB value of #0000FF
 853      * <div style="border:1px solid black;width:40px;height:20px;background-color:#0000FF;float:right;margin: 0 10px 0 0"></div>
 854      */
 855     public static final Color BLUE = new Color(0.0f, 0.0f, 1.0f);
 856 
 857     /**
 858      * The color blue violet with an RGB value of #8A2BE2
 859      * <div style="border:1px solid black;width:40px;height:20px;background-color:#8A2BE2;float:right;margin: 0 10px 0 0"></div>
 860      */
 861     public static final Color BLUEVIOLET = new Color(0.5411765f, 0.16862746f, 0.8862745f);
 862 
 863     /**
 864      * The color brown with an RGB value of #A52A2A
 865      * <div style="border:1px solid black;width:40px;height:20px;background-color:#A52A2A;float:right;margin: 0 10px 0 0"></div>
 866      */
 867     public static final Color BROWN = new Color(0.64705884f, 0.16470589f, 0.16470589f);
 868 
 869     /**
 870      * The color burly wood with an RGB value of #DEB887
 871      * <div style="border:1px solid black;width:40px;height:20px;background-color:#DEB887;float:right;margin: 0 10px 0 0"></div>
 872      */
 873     public static final Color BURLYWOOD = new Color(0.87058824f, 0.72156864f, 0.5294118f);
 874 
 875     /**
 876      * The color cadet blue with an RGB value of #5F9EA0
 877      * <div style="border:1px solid black;width:40px;height:20px;background-color:#5F9EA0;float:right;margin: 0 10px 0 0"></div>
 878      */
 879     public static final Color CADETBLUE = new Color(0.37254903f, 0.61960787f, 0.627451f);
 880 
 881     /**
 882      * The color chartreuse with an RGB value of #7FFF00
 883      * <div style="border:1px solid black;width:40px;height:20px;background-color:#7FFF00;float:right;margin: 0 10px 0 0"></div>
 884      */
 885     public static final Color CHARTREUSE = new Color(0.49803922f, 1.0f, 0.0f);
 886 
 887     /**
 888      * The color chocolate with an RGB value of #D2691E
 889      * <div style="border:1px solid black;width:40px;height:20px;background-color:#D2691E;float:right;margin: 0 10px 0 0"></div>
 890      */
 891     public static final Color CHOCOLATE = new Color(0.8235294f, 0.4117647f, 0.11764706f);
 892 
 893     /**
 894      * The color coral with an RGB value of #FF7F50
 895      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FF7F50;float:right;margin: 0 10px 0 0"></div>
 896      */
 897     public static final Color CORAL = new Color(1.0f, 0.49803922f, 0.3137255f);
 898 
 899     /**
 900      * The color cornflower blue with an RGB value of #6495ED
 901      * <div style="border:1px solid black;width:40px;height:20px;background-color:#6495ED;float:right;margin: 0 10px 0 0"></div>
 902      */
 903     public static final Color CORNFLOWERBLUE = new Color(0.39215687f, 0.58431375f, 0.92941177f);
 904 
 905     /**
 906      * The color cornsilk with an RGB value of #FFF8DC
 907      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FFF8DC;float:right;margin: 0 10px 0 0"></div>
 908      */
 909     public static final Color CORNSILK = new Color(1.0f, 0.972549f, 0.8627451f);
 910 
 911     /**
 912      * The color crimson with an RGB value of #DC143C
 913      * <div style="border:1px solid black;width:40px;height:20px;background-color:#DC143C;float:right;margin: 0 10px 0 0"></div>
 914      */
 915     public static final Color CRIMSON = new Color(0.8627451f, 0.078431375f, 0.23529412f);
 916 
 917     /**
 918      * The color cyan with an RGB value of #00FFFF
 919      * <div style="border:1px solid black;width:40px;height:20px;background-color:#00FFFF;float:right;margin: 0 10px 0 0"></div>
 920      */
 921     public static final Color CYAN = new Color(0.0f, 1.0f, 1.0f);
 922 
 923     /**
 924      * The color dark blue with an RGB value of #00008B
 925      * <div style="border:1px solid black;width:40px;height:20px;background-color:#00008B;float:right;margin: 0 10px 0 0"></div>
 926      */
 927     public static final Color DARKBLUE = new Color(0.0f, 0.0f, 0.54509807f);
 928 
 929     /**
 930      * The color dark cyan with an RGB value of #008B8B
 931      * <div style="border:1px solid black;width:40px;height:20px;background-color:#008B8B;float:right;margin: 0 10px 0 0"></div>
 932      */
 933     public static final Color DARKCYAN = new Color(0.0f, 0.54509807f, 0.54509807f);
 934 
 935     /**
 936      * The color dark goldenrod with an RGB value of #B8860B
 937      * <div style="border:1px solid black;width:40px;height:20px;background-color:#B8860B;float:right;margin: 0 10px 0 0"></div>
 938      */
 939     public static final Color DARKGOLDENROD = new Color(0.72156864f, 0.5254902f, 0.043137256f);
 940 
 941     /**
 942      * The color dark gray with an RGB value of #A9A9A9
 943      * <div style="border:1px solid black;width:40px;height:20px;background-color:#A9A9A9;float:right;margin: 0 10px 0 0"></div>
 944      */
 945     public static final Color DARKGRAY = new Color(0.6627451f, 0.6627451f, 0.6627451f);
 946 
 947     /**
 948      * The color dark green with an RGB value of #006400
 949      * <div style="border:1px solid black;width:40px;height:20px;background-color:#006400;float:right;margin: 0 10px 0 0"></div>
 950      */
 951     public static final Color DARKGREEN = new Color(0.0f, 0.39215687f, 0.0f);
 952 
 953     /**
 954      * The color dark grey with an RGB value of #A9A9A9
 955      * <div style="border:1px solid black;width:40px;height:20px;background-color:#A9A9A9;float:right;margin: 0 10px 0 0"></div>
 956      */
 957     public static final Color DARKGREY             = DARKGRAY;
 958 
 959     /**
 960      * The color dark khaki with an RGB value of #BDB76B
 961      * <div style="border:1px solid black;width:40px;height:20px;background-color:#BDB76B;float:right;margin: 0 10px 0 0"></div>
 962      */
 963     public static final Color DARKKHAKI = new Color(0.7411765f, 0.7176471f, 0.41960785f);
 964 
 965     /**
 966      * The color dark magenta with an RGB value of #8B008B
 967      * <div style="border:1px solid black;width:40px;height:20px;background-color:#8B008B;float:right;margin: 0 10px 0 0"></div>
 968      */
 969     public static final Color DARKMAGENTA = new Color(0.54509807f, 0.0f, 0.54509807f);
 970 
 971     /**
 972      * The color dark olive green with an RGB value of #556B2F
 973      * <div style="border:1px solid black;width:40px;height:20px;background-color:#556B2F;float:right;margin: 0 10px 0 0"></div>
 974      */
 975     public static final Color DARKOLIVEGREEN = new Color(0.33333334f, 0.41960785f, 0.18431373f);
 976 
 977     /**
 978      * The color dark orange with an RGB value of #FF8C00
 979      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FF8C00;float:right;margin: 0 10px 0 0"></div>
 980      */
 981     public static final Color DARKORANGE = new Color(1.0f, 0.54901963f, 0.0f);
 982 
 983     /**
 984      * The color dark orchid with an RGB value of #9932CC
 985      * <div style="border:1px solid black;width:40px;height:20px;background-color:#9932CC;float:right;margin: 0 10px 0 0"></div>
 986      */
 987     public static final Color DARKORCHID = new Color(0.6f, 0.19607843f, 0.8f);
 988 
 989     /**
 990      * The color dark red with an RGB value of #8B0000
 991      * <div style="border:1px solid black;width:40px;height:20px;background-color:#8B0000;float:right;margin: 0 10px 0 0"></div>
 992      */
 993     public static final Color DARKRED = new Color(0.54509807f, 0.0f, 0.0f);
 994 
 995     /**
 996      * The color dark salmon with an RGB value of #E9967A
 997      * <div style="border:1px solid black;width:40px;height:20px;background-color:#E9967A;float:right;margin: 0 10px 0 0"></div>
 998      */
 999     public static final Color DARKSALMON = new Color(0.9137255f, 0.5882353f, 0.47843137f);
1000 
1001     /**
1002      * The color dark sea green with an RGB value of #8FBC8F
1003      * <div style="border:1px solid black;width:40px;height:20px;background-color:#8FBC8F;float:right;margin: 0 10px 0 0"></div>
1004      */
1005     public static final Color DARKSEAGREEN = new Color(0.56078434f, 0.7372549f, 0.56078434f);
1006 
1007     /**
1008      * The color dark slate blue with an RGB value of #483D8B
1009      * <div style="border:1px solid black;width:40px;height:20px;background-color:#483D8B;float:right;margin: 0 10px 0 0"></div>
1010      */
1011     public static final Color DARKSLATEBLUE = new Color(0.28235295f, 0.23921569f, 0.54509807f);
1012 
1013     /**
1014      * The color dark slate gray with an RGB value of #2F4F4F
1015      * <div style="border:1px solid black;width:40px;height:20px;background-color:#2F4F4F;float:right;margin: 0 10px 0 0"></div>
1016      */
1017     public static final Color DARKSLATEGRAY = new Color(0.18431373f, 0.30980393f, 0.30980393f);
1018 
1019     /**
1020      * The color dark slate grey with an RGB value of #2F4F4F
1021      * <div style="border:1px solid black;width:40px;height:20px;background-color:#2F4F4F;float:right;margin: 0 10px 0 0"></div>
1022      */
1023     public static final Color DARKSLATEGREY        = DARKSLATEGRAY;
1024 
1025     /**
1026      * The color dark turquoise with an RGB value of #00CED1
1027      * <div style="border:1px solid black;width:40px;height:20px;background-color:#00CED1;float:right;margin: 0 10px 0 0"></div>
1028      */
1029     public static final Color DARKTURQUOISE = new Color(0.0f, 0.80784315f, 0.81960785f);
1030 
1031     /**
1032      * The color dark violet with an RGB value of #9400D3
1033      * <div style="border:1px solid black;width:40px;height:20px;background-color:#9400D3;float:right;margin: 0 10px 0 0"></div>
1034      */
1035     public static final Color DARKVIOLET = new Color(0.5803922f, 0.0f, 0.827451f);
1036 
1037     /**
1038      * The color deep pink with an RGB value of #FF1493
1039      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FF1493;float:right;margin: 0 10px 0 0"></div>
1040      */
1041     public static final Color DEEPPINK = new Color(1.0f, 0.078431375f, 0.5764706f);
1042 
1043     /**
1044      * The color deep sky blue with an RGB value of #00BFFF
1045      * <div style="border:1px solid black;width:40px;height:20px;background-color:#00BFFF;float:right;margin: 0 10px 0 0"></div>
1046      */
1047     public static final Color DEEPSKYBLUE = new Color(0.0f, 0.7490196f, 1.0f);
1048 
1049     /**
1050      * The color dim gray with an RGB value of #696969
1051      * <div style="border:1px solid black;width:40px;height:20px;background-color:#696969;float:right;margin: 0 10px 0 0"></div>
1052      */
1053     public static final Color DIMGRAY = new Color(0.4117647f, 0.4117647f, 0.4117647f);
1054 
1055     /**
1056      * The color dim grey with an RGB value of #696969
1057      * <div style="border:1px solid black;width:40px;height:20px;background-color:#696969;float:right;margin: 0 10px 0 0"></div>
1058      */
1059     public static final Color DIMGREY              = DIMGRAY;
1060 
1061     /**
1062      * The color dodger blue with an RGB value of #1E90FF
1063      * <div style="border:1px solid black;width:40px;height:20px;background-color:#1E90FF;float:right;margin: 0 10px 0 0"></div>
1064      */
1065     public static final Color DODGERBLUE = new Color(0.11764706f, 0.5647059f, 1.0f);
1066 
1067     /**
1068      * The color firebrick with an RGB value of #B22222
1069      * <div style="border:1px solid black;width:40px;height:20px;background-color:#B22222;float:right;margin: 0 10px 0 0"></div>
1070      */
1071     public static final Color FIREBRICK = new Color(0.69803923f, 0.13333334f, 0.13333334f);
1072 
1073     /**
1074      * The color floral white with an RGB value of #FFFAF0
1075      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FFFAF0;float:right;margin: 0 10px 0 0"></div>
1076      */
1077     public static final Color FLORALWHITE = new Color(1.0f, 0.98039216f, 0.9411765f);
1078 
1079     /**
1080      * The color forest green with an RGB value of #228B22
1081      * <div style="border:1px solid black;width:40px;height:20px;background-color:#228B22;float:right;margin: 0 10px 0 0"></div>
1082      */
1083     public static final Color FORESTGREEN = new Color(0.13333334f, 0.54509807f, 0.13333334f);
1084 
1085     /**
1086      * The color fuchsia with an RGB value of #FF00FF
1087      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FF00FF;float:right;margin: 0 10px 0 0"></div>
1088      */
1089     public static final Color FUCHSIA = new Color(1.0f, 0.0f, 1.0f);
1090 
1091     /**
1092      * The color gainsboro with an RGB value of #DCDCDC
1093      * <div style="border:1px solid black;width:40px;height:20px;background-color:#DCDCDC;float:right;margin: 0 10px 0 0"></div>
1094      */
1095     public static final Color GAINSBORO = new Color(0.8627451f, 0.8627451f, 0.8627451f);
1096 
1097     /**
1098      * The color ghost white with an RGB value of #F8F8FF
1099      * <div style="border:1px solid black;width:40px;height:20px;background-color:#F8F8FF;float:right;margin: 0 10px 0 0"></div>
1100      */
1101     public static final Color GHOSTWHITE = new Color(0.972549f, 0.972549f, 1.0f);
1102 
1103     /**
1104      * The color gold with an RGB value of #FFD700
1105      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FFD700;float:right;margin: 0 10px 0 0"></div>
1106      */
1107     public static final Color GOLD = new Color(1.0f, 0.84313726f, 0.0f);
1108 
1109     /**
1110      * The color goldenrod with an RGB value of #DAA520
1111      * <div style="border:1px solid black;width:40px;height:20px;background-color:#DAA520;float:right;margin: 0 10px 0 0"></div>
1112      */
1113     public static final Color GOLDENROD = new Color(0.85490197f, 0.64705884f, 0.1254902f);
1114 
1115     /**
1116      * The color gray with an RGB value of #808080
1117      * <div style="border:1px solid black;width:40px;height:20px;background-color:#808080;float:right;margin: 0 10px 0 0"></div>
1118      */
1119     public static final Color GRAY = new Color(0.5019608f, 0.5019608f, 0.5019608f);
1120 
1121     /**
1122      * The color green with an RGB value of #008000
1123      * <div style="border:1px solid black;width:40px;height:20px;background-color:#008000;float:right;margin: 0 10px 0 0"></div>
1124      */
1125     public static final Color GREEN = new Color(0.0f, 0.5019608f, 0.0f);
1126 
1127     /**
1128      * The color green yellow with an RGB value of #ADFF2F
1129      * <div style="border:1px solid black;width:40px;height:20px;background-color:#ADFF2F;float:right;margin: 0 10px 0 0"></div>
1130      */
1131     public static final Color GREENYELLOW = new Color(0.6784314f, 1.0f, 0.18431373f);
1132 
1133     /**
1134      * The color grey with an RGB value of #808080
1135      * <div style="border:1px solid black;width:40px;height:20px;background-color:#808080;float:right;margin: 0 10px 0 0"></div>
1136      */
1137     public static final Color GREY                 = GRAY;
1138 
1139     /**
1140      * The color honeydew with an RGB value of #F0FFF0
1141      * <div style="border:1px solid black;width:40px;height:20px;background-color:#F0FFF0;float:right;margin: 0 10px 0 0"></div>
1142      */
1143     public static final Color HONEYDEW = new Color(0.9411765f, 1.0f, 0.9411765f);
1144 
1145     /**
1146      * The color hot pink with an RGB value of #FF69B4
1147      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FF69B4;float:right;margin: 0 10px 0 0"></div>
1148      */
1149     public static final Color HOTPINK = new Color(1.0f, 0.4117647f, 0.7058824f);
1150 
1151     /**
1152      * The color indian red with an RGB value of #CD5C5C
1153      * <div style="border:1px solid black;width:40px;height:20px;background-color:#CD5C5C;float:right;margin: 0 10px 0 0"></div>
1154      */
1155     public static final Color INDIANRED = new Color(0.8039216f, 0.36078432f, 0.36078432f);
1156 
1157     /**
1158      * The color indigo with an RGB value of #4B0082
1159      * <div style="border:1px solid black;width:40px;height:20px;background-color:#4B0082;float:right;margin: 0 10px 0 0"></div>
1160      */
1161     public static final Color INDIGO = new Color(0.29411766f, 0.0f, 0.50980395f);
1162 
1163     /**
1164      * The color ivory with an RGB value of #FFFFF0
1165      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FFFFF0;float:right;margin: 0 10px 0 0"></div>
1166      */
1167     public static final Color IVORY = new Color(1.0f, 1.0f, 0.9411765f);
1168 
1169     /**
1170      * The color khaki with an RGB value of #F0E68C
1171      * <div style="border:1px solid black;width:40px;height:20px;background-color:#F0E68C;float:right;margin: 0 10px 0 0"></div>
1172      */
1173     public static final Color KHAKI = new Color(0.9411765f, 0.9019608f, 0.54901963f);
1174 
1175     /**
1176      * The color lavender with an RGB value of #E6E6FA
1177      * <div style="border:1px solid black;width:40px;height:20px;background-color:#E6E6FA;float:right;margin: 0 10px 0 0"></div>
1178      */
1179     public static final Color LAVENDER = new Color(0.9019608f, 0.9019608f, 0.98039216f);
1180 
1181     /**
1182      * The color lavender blush with an RGB value of #FFF0F5
1183      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FFF0F5;float:right;margin: 0 10px 0 0"></div>
1184      */
1185     public static final Color LAVENDERBLUSH = new Color(1.0f, 0.9411765f, 0.9607843f);
1186 
1187     /**
1188      * The color lawn green with an RGB value of #7CFC00
1189      * <div style="border:1px solid black;width:40px;height:20px;background-color:#7CFC00;float:right;margin: 0 10px 0 0"></div>
1190      */
1191     public static final Color LAWNGREEN = new Color(0.4862745f, 0.9882353f, 0.0f);
1192 
1193     /**
1194      * The color lemon chiffon with an RGB value of #FFFACD
1195      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FFFACD;float:right;margin: 0 10px 0 0"></div>
1196      */
1197     public static final Color LEMONCHIFFON = new Color(1.0f, 0.98039216f, 0.8039216f);
1198 
1199     /**
1200      * The color light blue with an RGB value of #ADD8E6
1201      * <div style="border:1px solid black;width:40px;height:20px;background-color:#ADD8E6;float:right;margin: 0 10px 0 0"></div>
1202      */
1203     public static final Color LIGHTBLUE = new Color(0.6784314f, 0.84705883f, 0.9019608f);
1204 
1205     /**
1206      * The color light coral with an RGB value of #F08080
1207      * <div style="border:1px solid black;width:40px;height:20px;background-color:#F08080;float:right;margin: 0 10px 0 0"></div>
1208      */
1209     public static final Color LIGHTCORAL = new Color(0.9411765f, 0.5019608f, 0.5019608f);
1210 
1211     /**
1212      * The color light cyan with an RGB value of #E0FFFF
1213      * <div style="border:1px solid black;width:40px;height:20px;background-color:#E0FFFF;float:right;margin: 0 10px 0 0"></div>
1214      */
1215     public static final Color LIGHTCYAN = new Color(0.8784314f, 1.0f, 1.0f);
1216 
1217     /**
1218      * The color light goldenrod yellow with an RGB value of #FAFAD2
1219      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FAFAD2;float:right;margin: 0 10px 0 0"></div>
1220      */
1221     public static final Color LIGHTGOLDENRODYELLOW = new Color(0.98039216f, 0.98039216f, 0.8235294f);
1222 
1223     /**
1224      * The color light gray with an RGB value of #D3D3D3
1225      * <div style="border:1px solid black;width:40px;height:20px;background-color:#D3D3D3;float:right;margin: 0 10px 0 0"></div>
1226      */
1227     public static final Color LIGHTGRAY = new Color(0.827451f, 0.827451f, 0.827451f);
1228 
1229     /**
1230      * The color light green with an RGB value of #90EE90
1231      * <div style="border:1px solid black;width:40px;height:20px;background-color:#90EE90;float:right;margin: 0 10px 0 0"></div>
1232      */
1233     public static final Color LIGHTGREEN = new Color(0.5647059f, 0.93333334f, 0.5647059f);
1234 
1235     /**
1236      * The color light grey with an RGB value of #D3D3D3
1237      * <div style="border:1px solid black;width:40px;height:20px;background-color:#D3D3D3;float:right;margin: 0 10px 0 0"></div>
1238      */
1239     public static final Color LIGHTGREY            = LIGHTGRAY;
1240 
1241     /**
1242      * The color light pink with an RGB value of #FFB6C1
1243      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FFB6C1;float:right;margin: 0 10px 0 0"></div>
1244      */
1245     public static final Color LIGHTPINK = new Color(1.0f, 0.7137255f, 0.75686276f);
1246 
1247     /**
1248      * The color light salmon with an RGB value of #FFA07A
1249      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FFA07A;float:right;margin: 0 10px 0 0"></div>
1250      */
1251     public static final Color LIGHTSALMON = new Color(1.0f, 0.627451f, 0.47843137f);
1252 
1253     /**
1254      * The color light sea green with an RGB value of #20B2AA
1255      * <div style="border:1px solid black;width:40px;height:20px;background-color:#20B2AA;float:right;margin: 0 10px 0 0"></div>
1256      */
1257     public static final Color LIGHTSEAGREEN = new Color(0.1254902f, 0.69803923f, 0.6666667f);
1258 
1259     /**
1260      * The color light sky blue with an RGB value of #87CEFA
1261      * <div style="border:1px solid black;width:40px;height:20px;background-color:#87CEFA;float:right;margin: 0 10px 0 0"></div>
1262      */
1263     public static final Color LIGHTSKYBLUE = new Color(0.5294118f, 0.80784315f, 0.98039216f);
1264 
1265     /**
1266      * The color light slate gray with an RGB value of #778899
1267      * <div style="border:1px solid black;width:40px;height:20px;background-color:#778899;float:right;margin: 0 10px 0 0"></div>
1268      */
1269     public static final Color LIGHTSLATEGRAY = new Color(0.46666667f, 0.53333336f, 0.6f);
1270 
1271     /**
1272      * The color light slate grey with an RGB value of #778899
1273      * <div style="border:1px solid black;width:40px;height:20px;background-color:#778899;float:right;margin: 0 10px 0 0"></div>
1274      */
1275     public static final Color LIGHTSLATEGREY       = LIGHTSLATEGRAY;
1276 
1277     /**
1278      * The color light steel blue with an RGB value of #B0C4DE
1279      * <div style="border:1px solid black;width:40px;height:20px;background-color:#B0C4DE;float:right;margin: 0 10px 0 0"></div>
1280      */
1281     public static final Color LIGHTSTEELBLUE = new Color(0.6901961f, 0.76862746f, 0.87058824f);
1282 
1283     /**
1284      * The color light yellow with an RGB value of #FFFFE0
1285      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FFFFE0;float:right;margin: 0 10px 0 0"></div>
1286      */
1287     public static final Color LIGHTYELLOW = new Color(1.0f, 1.0f, 0.8784314f);
1288 
1289     /**
1290      * The color lime with an RGB value of #00FF00
1291      * <div style="border:1px solid black;width:40px;height:20px;background-color:#00FF00;float:right;margin: 0 10px 0 0"></div>
1292      */
1293     public static final Color LIME = new Color(0.0f, 1.0f, 0.0f);
1294 
1295     /**
1296      * The color lime green with an RGB value of #32CD32
1297      * <div style="border:1px solid black;width:40px;height:20px;background-color:#32CD32;float:right;margin: 0 10px 0 0"></div>
1298      */
1299     public static final Color LIMEGREEN = new Color(0.19607843f, 0.8039216f, 0.19607843f);
1300 
1301     /**
1302      * The color linen with an RGB value of #FAF0E6
1303      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FAF0E6;float:right;margin: 0 10px 0 0"></div>
1304      */
1305     public static final Color LINEN = new Color(0.98039216f, 0.9411765f, 0.9019608f);
1306 
1307     /**
1308      * The color magenta with an RGB value of #FF00FF
1309      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FF00FF;float:right;margin: 0 10px 0 0"></div>
1310      */
1311     public static final Color MAGENTA = new Color(1.0f, 0.0f, 1.0f);
1312 
1313     /**
1314      * The color maroon with an RGB value of #800000
1315      * <div style="border:1px solid black;width:40px;height:20px;background-color:#800000;float:right;margin: 0 10px 0 0"></div>
1316      */
1317     public static final Color MAROON = new Color(0.5019608f, 0.0f, 0.0f);
1318 
1319     /**
1320      * The color medium aquamarine with an RGB value of #66CDAA
1321      * <div style="border:1px solid black;width:40px;height:20px;background-color:#66CDAA;float:right;margin: 0 10px 0 0"></div>
1322      */
1323     public static final Color MEDIUMAQUAMARINE = new Color(0.4f, 0.8039216f, 0.6666667f);
1324 
1325     /**
1326      * The color medium blue with an RGB value of #0000CD
1327      * <div style="border:1px solid black;width:40px;height:20px;background-color:#0000CD;float:right;margin: 0 10px 0 0"></div>
1328      */
1329     public static final Color MEDIUMBLUE = new Color(0.0f, 0.0f, 0.8039216f);
1330 
1331     /**
1332      * The color medium orchid with an RGB value of #BA55D3
1333      * <div style="border:1px solid black;width:40px;height:20px;background-color:#BA55D3;float:right;margin: 0 10px 0 0"></div>
1334      */
1335     public static final Color MEDIUMORCHID = new Color(0.7294118f, 0.33333334f, 0.827451f);
1336 
1337     /**
1338      * The color medium purple with an RGB value of #9370DB
1339      * <div style="border:1px solid black;width:40px;height:20px;background-color:#9370DB;float:right;margin: 0 10px 0 0"></div>
1340      */
1341     public static final Color MEDIUMPURPLE = new Color(0.5764706f, 0.4392157f, 0.85882354f);
1342 
1343     /**
1344      * The color medium sea green with an RGB value of #3CB371
1345      * <div style="border:1px solid black;width:40px;height:20px;background-color:#3CB371;float:right;margin: 0 10px 0 0"></div>
1346      */
1347     public static final Color MEDIUMSEAGREEN = new Color(0.23529412f, 0.7019608f, 0.44313726f);
1348 
1349     /**
1350      * The color medium slate blue with an RGB value of #7B68EE
1351      * <div style="border:1px solid black;width:40px;height:20px;background-color:#7B68EE;float:right;margin: 0 10px 0 0"></div>
1352      */
1353     public static final Color MEDIUMSLATEBLUE = new Color(0.48235294f, 0.40784314f, 0.93333334f);
1354 
1355     /**
1356      * The color medium spring green with an RGB value of #00FA9A
1357      * <div style="border:1px solid black;width:40px;height:20px;background-color:#00FA9A;float:right;margin: 0 10px 0 0"></div>
1358      */
1359     public static final Color MEDIUMSPRINGGREEN = new Color(0.0f, 0.98039216f, 0.6039216f);
1360 
1361     /**
1362      * The color medium turquoise with an RGB value of #48D1CC
1363      * <div style="border:1px solid black;width:40px;height:20px;background-color:#48D1CC;float:right;margin: 0 10px 0 0"></div>
1364      */
1365     public static final Color MEDIUMTURQUOISE = new Color(0.28235295f, 0.81960785f, 0.8f);
1366 
1367     /**
1368      * The color medium violet red with an RGB value of #C71585
1369      * <div style="border:1px solid black;width:40px;height:20px;background-color:#C71585;float:right;margin: 0 10px 0 0"></div>
1370      */
1371     public static final Color MEDIUMVIOLETRED = new Color(0.78039217f, 0.08235294f, 0.52156866f);
1372 
1373     /**
1374      * The color midnight blue with an RGB value of #191970
1375      * <div style="border:1px solid black;width:40px;height:20px;background-color:#191970;float:right;margin: 0 10px 0 0"></div>
1376      */
1377     public static final Color MIDNIGHTBLUE = new Color(0.09803922f, 0.09803922f, 0.4392157f);
1378 
1379     /**
1380      * The color mint cream with an RGB value of #F5FFFA
1381      * <div style="border:1px solid black;width:40px;height:20px;background-color:#F5FFFA;float:right;margin: 0 10px 0 0"></div>
1382      */
1383     public static final Color MINTCREAM = new Color(0.9607843f, 1.0f, 0.98039216f);
1384 
1385     /**
1386      * The color misty rose with an RGB value of #FFE4E1
1387      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FFE4E1;float:right;margin: 0 10px 0 0"></div>
1388      */
1389     public static final Color MISTYROSE = new Color(1.0f, 0.89411765f, 0.88235295f);
1390 
1391     /**
1392      * The color moccasin with an RGB value of #FFE4B5
1393      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FFE4B5;float:right;margin: 0 10px 0 0"></div>
1394      */
1395     public static final Color MOCCASIN = new Color(1.0f, 0.89411765f, 0.70980394f);
1396 
1397     /**
1398      * The color navajo white with an RGB value of #FFDEAD
1399      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FFDEAD;float:right;margin: 0 10px 0 0"></div>
1400      */
1401     public static final Color NAVAJOWHITE = new Color(1.0f, 0.87058824f, 0.6784314f);
1402 
1403     /**
1404      * The color navy with an RGB value of #000080
1405      * <div style="border:1px solid black;width:40px;height:20px;background-color:#000080;float:right;margin: 0 10px 0 0"></div>
1406      */
1407     public static final Color NAVY = new Color(0.0f, 0.0f, 0.5019608f);
1408 
1409     /**
1410      * The color old lace with an RGB value of #FDF5E6
1411      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FDF5E6;float:right;margin: 0 10px 0 0"></div>
1412      */
1413     public static final Color OLDLACE = new Color(0.99215686f, 0.9607843f, 0.9019608f);
1414 
1415     /**
1416      * The color olive with an RGB value of #808000
1417      * <div style="border:1px solid black;width:40px;height:20px;background-color:#808000;float:right;margin: 0 10px 0 0"></div>
1418      */
1419     public static final Color OLIVE = new Color(0.5019608f, 0.5019608f, 0.0f);
1420 
1421     /**
1422      * The color olive drab with an RGB value of #6B8E23
1423      * <div style="border:1px solid black;width:40px;height:20px;background-color:#6B8E23;float:right;margin: 0 10px 0 0"></div>
1424      */
1425     public static final Color OLIVEDRAB = new Color(0.41960785f, 0.5568628f, 0.13725491f);
1426 
1427     /**
1428      * The color orange with an RGB value of #FFA500
1429      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FFA500;float:right;margin: 0 10px 0 0"></div>
1430      */
1431     public static final Color ORANGE = new Color(1.0f, 0.64705884f, 0.0f);
1432 
1433     /**
1434      * The color orange red with an RGB value of #FF4500
1435      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FF4500;float:right;margin: 0 10px 0 0"></div>
1436      */
1437     public static final Color ORANGERED = new Color(1.0f, 0.27058825f, 0.0f);
1438 
1439     /**
1440      * The color orchid with an RGB value of #DA70D6
1441      * <div style="border:1px solid black;width:40px;height:20px;background-color:#DA70D6;float:right;margin: 0 10px 0 0"></div>
1442      */
1443     public static final Color ORCHID = new Color(0.85490197f, 0.4392157f, 0.8392157f);
1444 
1445     /**
1446      * The color pale goldenrod with an RGB value of #EEE8AA
1447      * <div style="border:1px solid black;width:40px;height:20px;background-color:#EEE8AA;float:right;margin: 0 10px 0 0"></div>
1448      */
1449     public static final Color PALEGOLDENROD = new Color(0.93333334f, 0.9098039f, 0.6666667f);
1450 
1451     /**
1452      * The color pale green with an RGB value of #98FB98
1453      * <div style="border:1px solid black;width:40px;height:20px;background-color:#98FB98;float:right;margin: 0 10px 0 0"></div>
1454      */
1455     public static final Color PALEGREEN = new Color(0.59607846f, 0.9843137f, 0.59607846f);
1456 
1457     /**
1458      * The color pale turquoise with an RGB value of #AFEEEE
1459      * <div style="border:1px solid black;width:40px;height:20px;background-color:#AFEEEE;float:right;margin: 0 10px 0 0"></div>
1460      */
1461     public static final Color PALETURQUOISE = new Color(0.6862745f, 0.93333334f, 0.93333334f);
1462 
1463     /**
1464      * The color pale violet red with an RGB value of #DB7093
1465      * <div style="border:1px solid black;width:40px;height:20px;background-color:#DB7093;float:right;margin: 0 10px 0 0"></div>
1466      */
1467     public static final Color PALEVIOLETRED = new Color(0.85882354f, 0.4392157f, 0.5764706f);
1468 
1469     /**
1470      * The color papaya whip with an RGB value of #FFEFD5
1471      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FFEFD5;float:right;margin: 0 10px 0 0"></div>
1472      */
1473     public static final Color PAPAYAWHIP = new Color(1.0f, 0.9372549f, 0.8352941f);
1474 
1475     /**
1476      * The color peach puff with an RGB value of #FFDAB9
1477      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FFDAB9;float:right;margin: 0 10px 0 0"></div>
1478      */
1479     public static final Color PEACHPUFF = new Color(1.0f, 0.85490197f, 0.7254902f);
1480 
1481     /**
1482      * The color peru with an RGB value of #CD853F
1483      * <div style="border:1px solid black;width:40px;height:20px;background-color:#CD853F;float:right;margin: 0 10px 0 0"></div>
1484      */
1485     public static final Color PERU = new Color(0.8039216f, 0.52156866f, 0.24705882f);
1486 
1487     /**
1488      * The color pink with an RGB value of #FFC0CB
1489      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FFC0CB;float:right;margin: 0 10px 0 0"></div>
1490      */
1491     public static final Color PINK = new Color(1.0f, 0.7529412f, 0.79607844f);
1492 
1493     /**
1494      * The color plum with an RGB value of #DDA0DD
1495      * <div style="border:1px solid black;width:40px;height:20px;background-color:#DDA0DD;float:right;margin: 0 10px 0 0"></div>
1496      */
1497     public static final Color PLUM = new Color(0.8666667f, 0.627451f, 0.8666667f);
1498 
1499     /**
1500      * The color powder blue with an RGB value of #B0E0E6
1501      * <div style="border:1px solid black;width:40px;height:20px;background-color:#B0E0E6;float:right;margin: 0 10px 0 0"></div>
1502      */
1503     public static final Color POWDERBLUE = new Color(0.6901961f, 0.8784314f, 0.9019608f);
1504 
1505     /**
1506      * The color purple with an RGB value of #800080
1507      * <div style="border:1px solid black;width:40px;height:20px;background-color:#800080;float:right;margin: 0 10px 0 0"></div>
1508      */
1509     public static final Color PURPLE = new Color(0.5019608f, 0.0f, 0.5019608f);
1510 
1511     /**
1512      * The color red with an RGB value of #FF0000
1513      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FF0000;float:right;margin: 0 10px 0 0"></div>
1514      */
1515     public static final Color RED = new Color(1.0f, 0.0f, 0.0f);
1516 
1517     /**
1518      * The color rosy brown with an RGB value of #BC8F8F
1519      * <div style="border:1px solid black;width:40px;height:20px;background-color:#BC8F8F;float:right;margin: 0 10px 0 0"></div>
1520      */
1521     public static final Color ROSYBROWN = new Color(0.7372549f, 0.56078434f, 0.56078434f);
1522 
1523     /**
1524      * The color royal blue with an RGB value of #4169E1
1525      * <div style="border:1px solid black;width:40px;height:20px;background-color:#4169E1;float:right;margin: 0 10px 0 0"></div>
1526      */
1527     public static final Color ROYALBLUE = new Color(0.25490198f, 0.4117647f, 0.88235295f);
1528 
1529     /**
1530      * The color saddle brown with an RGB value of #8B4513
1531      * <div style="border:1px solid black;width:40px;height:20px;background-color:#8B4513;float:right;margin: 0 10px 0 0"></div>
1532      */
1533     public static final Color SADDLEBROWN = new Color(0.54509807f, 0.27058825f, 0.07450981f);
1534 
1535     /**
1536      * The color salmon with an RGB value of #FA8072
1537      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FA8072;float:right;margin: 0 10px 0 0"></div>
1538      */
1539     public static final Color SALMON = new Color(0.98039216f, 0.5019608f, 0.44705883f);
1540 
1541     /**
1542      * The color sandy brown with an RGB value of #F4A460
1543      * <div style="border:1px solid black;width:40px;height:20px;background-color:#F4A460;float:right;margin: 0 10px 0 0"></div>
1544      */
1545     public static final Color SANDYBROWN = new Color(0.95686275f, 0.6431373f, 0.3764706f);
1546 
1547     /**
1548      * The color sea green with an RGB value of #2E8B57
1549      * <div style="border:1px solid black;width:40px;height:20px;background-color:#2E8B57;float:right;margin: 0 10px 0 0"></div>
1550      */
1551     public static final Color SEAGREEN = new Color(0.18039216f, 0.54509807f, 0.34117648f);
1552 
1553     /**
1554      * The color sea shell with an RGB value of #FFF5EE
1555      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FFF5EE;float:right;margin: 0 10px 0 0"></div>
1556      */
1557     public static final Color SEASHELL = new Color(1.0f, 0.9607843f, 0.93333334f);
1558 
1559     /**
1560      * The color sienna with an RGB value of #A0522D
1561      * <div style="border:1px solid black;width:40px;height:20px;background-color:#A0522D;float:right;margin: 0 10px 0 0"></div>
1562      */
1563     public static final Color SIENNA = new Color(0.627451f, 0.32156864f, 0.1764706f);
1564 
1565     /**
1566      * The color silver with an RGB value of #C0C0C0
1567      * <div style="border:1px solid black;width:40px;height:20px;background-color:#C0C0C0;float:right;margin: 0 10px 0 0"></div>
1568      */
1569     public static final Color SILVER = new Color(0.7529412f, 0.7529412f, 0.7529412f);
1570 
1571     /**
1572      * The color sky blue with an RGB value of #87CEEB
1573      * <div style="border:1px solid black;width:40px;height:20px;background-color:#87CEEB;float:right;margin: 0 10px 0 0"></div>
1574      */
1575     public static final Color SKYBLUE = new Color(0.5294118f, 0.80784315f, 0.92156863f);
1576 
1577     /**
1578      * The color slate blue with an RGB value of #6A5ACD
1579      * <div style="border:1px solid black;width:40px;height:20px;background-color:#6A5ACD;float:right;margin: 0 10px 0 0"></div>
1580      */
1581     public static final Color SLATEBLUE = new Color(0.41568628f, 0.3529412f, 0.8039216f);
1582 
1583     /**
1584      * The color slate gray with an RGB value of #708090
1585      * <div style="border:1px solid black;width:40px;height:20px;background-color:#708090;float:right;margin: 0 10px 0 0"></div>
1586      */
1587     public static final Color SLATEGRAY = new Color(0.4392157f, 0.5019608f, 0.5647059f);
1588 
1589     /**
1590      * The color slate grey with an RGB value of #708090
1591      * <div style="border:1px solid black;width:40px;height:20px;background-color:#708090;float:right;margin: 0 10px 0 0"></div>
1592      */
1593     public static final Color SLATEGREY            = SLATEGRAY;
1594 
1595     /**
1596      * The color snow with an RGB value of #FFFAFA
1597      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FFFAFA;float:right;margin: 0 10px 0 0"></div>
1598      */
1599     public static final Color SNOW = new Color(1.0f, 0.98039216f, 0.98039216f);
1600 
1601     /**
1602      * The color spring green with an RGB value of #00FF7F
1603      * <div style="border:1px solid black;width:40px;height:20px;background-color:#00FF7F;float:right;margin: 0 10px 0 0"></div>
1604      */
1605     public static final Color SPRINGGREEN = new Color(0.0f, 1.0f, 0.49803922f);
1606 
1607     /**
1608      * The color steel blue with an RGB value of #4682B4
1609      * <div style="border:1px solid black;width:40px;height:20px;background-color:#4682B4;float:right;margin: 0 10px 0 0"></div>
1610      */
1611     public static final Color STEELBLUE = new Color(0.27450982f, 0.50980395f, 0.7058824f);
1612 
1613     /**
1614      * The color tan with an RGB value of #D2B48C
1615      * <div style="border:1px solid black;width:40px;height:20px;background-color:#D2B48C;float:right;margin: 0 10px 0 0"></div>
1616      */
1617     public static final Color TAN = new Color(0.8235294f, 0.7058824f, 0.54901963f);
1618 
1619     /**
1620      * The color teal with an RGB value of #008080
1621      * <div style="border:1px solid black;width:40px;height:20px;background-color:#008080;float:right;margin: 0 10px 0 0"></div>
1622      */
1623     public static final Color TEAL = new Color(0.0f, 0.5019608f, 0.5019608f);
1624 
1625     /**
1626      * The color thistle with an RGB value of #D8BFD8
1627      * <div style="border:1px solid black;width:40px;height:20px;background-color:#D8BFD8;float:right;margin: 0 10px 0 0"></div>
1628      */
1629     public static final Color THISTLE = new Color(0.84705883f, 0.7490196f, 0.84705883f);
1630 
1631     /**
1632      * The color tomato with an RGB value of #FF6347
1633      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FF6347;float:right;margin: 0 10px 0 0"></div>
1634      */
1635     public static final Color TOMATO = new Color(1.0f, 0.3882353f, 0.2784314f);
1636 
1637     /**
1638      * The color turquoise with an RGB value of #40E0D0
1639      * <div style="border:1px solid black;width:40px;height:20px;background-color:#40E0D0;float:right;margin: 0 10px 0 0"></div>
1640      */
1641     public static final Color TURQUOISE = new Color(0.2509804f, 0.8784314f, 0.8156863f);
1642 
1643     /**
1644      * The color violet with an RGB value of #EE82EE
1645      * <div style="border:1px solid black;width:40px;height:20px;background-color:#EE82EE;float:right;margin: 0 10px 0 0"></div>
1646      */
1647     public static final Color VIOLET = new Color(0.93333334f, 0.50980395f, 0.93333334f);
1648 
1649     /**
1650      * The color wheat with an RGB value of #F5DEB3
1651      * <div style="border:1px solid black;width:40px;height:20px;background-color:#F5DEB3;float:right;margin: 0 10px 0 0"></div>
1652      */
1653     public static final Color WHEAT = new Color(0.9607843f, 0.87058824f, 0.7019608f);
1654 
1655     /**
1656      * The color white with an RGB value of #FFFFFF
1657      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FFFFFF;float:right;margin: 0 10px 0 0"></div>
1658      */
1659     public static final Color WHITE = new Color(1.0f, 1.0f, 1.0f);
1660 
1661     /**
1662      * The color white smoke with an RGB value of #F5F5F5
1663      * <div style="border:1px solid black;width:40px;height:20px;background-color:#F5F5F5;float:right;margin: 0 10px 0 0"></div>
1664      */
1665     public static final Color WHITESMOKE = new Color(0.9607843f, 0.9607843f, 0.9607843f);
1666 
1667     /**
1668      * The color yellow with an RGB value of #FFFF00
1669      * <div style="border:1px solid black;width:40px;height:20px;background-color:#FFFF00;float:right;margin: 0 10px 0 0"></div>
1670      */
1671     public static final Color YELLOW = new Color(1.0f, 1.0f, 0.0f);
1672 
1673     /**
1674      * The color yellow green with an RGB value of #9ACD32
1675      * <div style="border:1px solid black;width:40px;height:20px;background-color:#9ACD32;float:right;margin: 0 10px 0 0"></div>
1676      */
1677     public static final Color YELLOWGREEN = new Color(0.6039216f, 0.8039216f, 0.19607843f);
1678 
1679     /*
1680      * Named colors moved to nested class to initialize them only when they
1681      * are needed.
1682      */
1683     private static final class NamedColors {
1684         private static final Map<String, Color> namedColors =
1685                 createNamedColors();
1686 
1687         private NamedColors() {
1688         }
1689 
1690         private static Color get(String name) {
1691             return namedColors.get(name);
1692         }
1693 
1694         private static Map<String, Color> createNamedColors() {
1695             Map<String, Color> colors = new HashMap<String,Color>(256);
1696 
1697             colors.put("aliceblue",            ALICEBLUE);
1698             colors.put("antiquewhite",         ANTIQUEWHITE);
1699             colors.put("aqua",                 AQUA);
1700             colors.put("aquamarine",           AQUAMARINE);
1701             colors.put("azure",                AZURE);
1702             colors.put("beige",                BEIGE);
1703             colors.put("bisque",               BISQUE);
1704             colors.put("black",                BLACK);
1705             colors.put("blanchedalmond",       BLANCHEDALMOND);
1706             colors.put("blue",                 BLUE);
1707             colors.put("blueviolet",           BLUEVIOLET);
1708             colors.put("brown",                BROWN);
1709             colors.put("burlywood",            BURLYWOOD);
1710             colors.put("cadetblue",            CADETBLUE);
1711             colors.put("chartreuse",           CHARTREUSE);
1712             colors.put("chocolate",            CHOCOLATE);
1713             colors.put("coral",                CORAL);
1714             colors.put("cornflowerblue",       CORNFLOWERBLUE);
1715             colors.put("cornsilk",             CORNSILK);
1716             colors.put("crimson",              CRIMSON);
1717             colors.put("cyan",                 CYAN);
1718             colors.put("darkblue",             DARKBLUE);
1719             colors.put("darkcyan",             DARKCYAN);
1720             colors.put("darkgoldenrod",        DARKGOLDENROD);
1721             colors.put("darkgray",             DARKGRAY);
1722             colors.put("darkgreen",            DARKGREEN);
1723             colors.put("darkgrey",             DARKGREY);
1724             colors.put("darkkhaki",            DARKKHAKI);
1725             colors.put("darkmagenta",          DARKMAGENTA);
1726             colors.put("darkolivegreen",       DARKOLIVEGREEN);
1727             colors.put("darkorange",           DARKORANGE);
1728             colors.put("darkorchid",           DARKORCHID);
1729             colors.put("darkred",              DARKRED);
1730             colors.put("darksalmon",           DARKSALMON);
1731             colors.put("darkseagreen",         DARKSEAGREEN);
1732             colors.put("darkslateblue",        DARKSLATEBLUE);
1733             colors.put("darkslategray",        DARKSLATEGRAY);
1734             colors.put("darkslategrey",        DARKSLATEGREY);
1735             colors.put("darkturquoise",        DARKTURQUOISE);
1736             colors.put("darkviolet",           DARKVIOLET);
1737             colors.put("deeppink",             DEEPPINK);
1738             colors.put("deepskyblue",          DEEPSKYBLUE);
1739             colors.put("dimgray",              DIMGRAY);
1740             colors.put("dimgrey",              DIMGREY);
1741             colors.put("dodgerblue",           DODGERBLUE);
1742             colors.put("firebrick",            FIREBRICK);
1743             colors.put("floralwhite",          FLORALWHITE);
1744             colors.put("forestgreen",          FORESTGREEN);
1745             colors.put("fuchsia",              FUCHSIA);
1746             colors.put("gainsboro",            GAINSBORO);
1747             colors.put("ghostwhite",           GHOSTWHITE);
1748             colors.put("gold",                 GOLD);
1749             colors.put("goldenrod",            GOLDENROD);
1750             colors.put("gray",                 GRAY);
1751             colors.put("green",                GREEN);
1752             colors.put("greenyellow",          GREENYELLOW);
1753             colors.put("grey",                 GREY);
1754             colors.put("honeydew",             HONEYDEW);
1755             colors.put("hotpink",              HOTPINK);
1756             colors.put("indianred",            INDIANRED);
1757             colors.put("indigo",               INDIGO);
1758             colors.put("ivory",                IVORY);
1759             colors.put("khaki",                KHAKI);
1760             colors.put("lavender",             LAVENDER);
1761             colors.put("lavenderblush",        LAVENDERBLUSH);
1762             colors.put("lawngreen",            LAWNGREEN);
1763             colors.put("lemonchiffon",         LEMONCHIFFON);
1764             colors.put("lightblue",            LIGHTBLUE);
1765             colors.put("lightcoral",           LIGHTCORAL);
1766             colors.put("lightcyan",            LIGHTCYAN);
1767             colors.put("lightgoldenrodyellow", LIGHTGOLDENRODYELLOW);
1768             colors.put("lightgray",            LIGHTGRAY);
1769             colors.put("lightgreen",           LIGHTGREEN);
1770             colors.put("lightgrey",            LIGHTGREY);
1771             colors.put("lightpink",            LIGHTPINK);
1772             colors.put("lightsalmon",          LIGHTSALMON);
1773             colors.put("lightseagreen",        LIGHTSEAGREEN);
1774             colors.put("lightskyblue",         LIGHTSKYBLUE);
1775             colors.put("lightslategray",       LIGHTSLATEGRAY);
1776             colors.put("lightslategrey",       LIGHTSLATEGREY);
1777             colors.put("lightsteelblue",       LIGHTSTEELBLUE);
1778             colors.put("lightyellow",          LIGHTYELLOW);
1779             colors.put("lime",                 LIME);
1780             colors.put("limegreen",            LIMEGREEN);
1781             colors.put("linen",                LINEN);
1782             colors.put("magenta",              MAGENTA);
1783             colors.put("maroon",               MAROON);
1784             colors.put("mediumaquamarine",     MEDIUMAQUAMARINE);
1785             colors.put("mediumblue",           MEDIUMBLUE);
1786             colors.put("mediumorchid",         MEDIUMORCHID);
1787             colors.put("mediumpurple",         MEDIUMPURPLE);
1788             colors.put("mediumseagreen",       MEDIUMSEAGREEN);
1789             colors.put("mediumslateblue",      MEDIUMSLATEBLUE);
1790             colors.put("mediumspringgreen",    MEDIUMSPRINGGREEN);
1791             colors.put("mediumturquoise",      MEDIUMTURQUOISE);
1792             colors.put("mediumvioletred",      MEDIUMVIOLETRED);
1793             colors.put("midnightblue",         MIDNIGHTBLUE);
1794             colors.put("mintcream",            MINTCREAM);
1795             colors.put("mistyrose",            MISTYROSE);
1796             colors.put("moccasin",             MOCCASIN);
1797             colors.put("navajowhite",          NAVAJOWHITE);
1798             colors.put("navy",                 NAVY);
1799             colors.put("oldlace",              OLDLACE);
1800             colors.put("olive",                OLIVE);
1801             colors.put("olivedrab",            OLIVEDRAB);
1802             colors.put("orange",               ORANGE);
1803             colors.put("orangered",            ORANGERED);
1804             colors.put("orchid",               ORCHID);
1805             colors.put("palegoldenrod",        PALEGOLDENROD);
1806             colors.put("palegreen",            PALEGREEN);
1807             colors.put("paleturquoise",        PALETURQUOISE);
1808             colors.put("palevioletred",        PALEVIOLETRED);
1809             colors.put("papayawhip",           PAPAYAWHIP);
1810             colors.put("peachpuff",            PEACHPUFF);
1811             colors.put("peru",                 PERU);
1812             colors.put("pink",                 PINK);
1813             colors.put("plum",                 PLUM);
1814             colors.put("powderblue",           POWDERBLUE);
1815             colors.put("purple",               PURPLE);
1816             colors.put("red",                  RED);
1817             colors.put("rosybrown",            ROSYBROWN);
1818             colors.put("royalblue",            ROYALBLUE);
1819             colors.put("saddlebrown",          SADDLEBROWN);
1820             colors.put("salmon",               SALMON);
1821             colors.put("sandybrown",           SANDYBROWN);
1822             colors.put("seagreen",             SEAGREEN);
1823             colors.put("seashell",             SEASHELL);
1824             colors.put("sienna",               SIENNA);
1825             colors.put("silver",               SILVER);
1826             colors.put("skyblue",              SKYBLUE);
1827             colors.put("slateblue",            SLATEBLUE);
1828             colors.put("slategray",            SLATEGRAY);
1829             colors.put("slategrey",            SLATEGREY);
1830             colors.put("snow",                 SNOW);
1831             colors.put("springgreen",          SPRINGGREEN);
1832             colors.put("steelblue",            STEELBLUE);
1833             colors.put("tan",                  TAN);
1834             colors.put("teal",                 TEAL);
1835             colors.put("thistle",              THISTLE);
1836             colors.put("tomato",               TOMATO);
1837             colors.put("transparent",          TRANSPARENT);
1838             colors.put("turquoise",            TURQUOISE);
1839             colors.put("violet",               VIOLET);
1840             colors.put("wheat",                WHEAT);
1841             colors.put("white",                WHITE);
1842             colors.put("whitesmoke",           WHITESMOKE);
1843             colors.put("yellow",               YELLOW);
1844             colors.put("yellowgreen",          YELLOWGREEN);
1845 
1846             return colors;
1847         }
1848     }
1849 
1850     /**
1851      * The red component of the {@code Color}, in the range {@code 0.0-1.0}.
1852      *
1853      * @return the red component of the {@code Color}, in the range {@code 0.0-1.0}
1854      * @defaultValue 0.0
1855      */
1856     public final double getRed() { return red; }
1857     private float red;
1858 
1859     /**
1860      * The green component of the {@code Color}, in the range {@code 0.0-1.0}.
1861      *
1862      * @return the green component of the {@code Color}, in the range {@code 0.0-1.0}
1863      * @defaultValue 0.0
1864      */
1865     public final double getGreen() { return green; }
1866     private float green;
1867 
1868     /**
1869      * The blue component of the {@code Color}, in the range {@code 0.0-1.0}.
1870      *
1871      * @return the blue component of the {@code Color}, in the range {@code 0.0-1.0}
1872      * @defaultValue 0.0
1873      */
1874     public final double getBlue() { return blue; }
1875     private float blue;
1876 
1877     /**
1878      * The opacity of the {@code Color}, in the range {@code 0.0-1.0}.
1879      *
1880      * @return the opacity of the {@code Color}, in the range {@code 0.0-1.0}
1881      * @defaultValue 1.0
1882      */
1883     public final double getOpacity() { return opacity; }
1884     private float opacity = 1;
1885 
1886     /**
1887      * {@inheritDoc}
1888      * @since JavaFX 8.0
1889      */
1890     @Override public final boolean isOpaque() {
1891         return opacity >= 1f;
1892     }
1893 
1894     private Object platformPaint;
1895 
1896     /**
1897      * Creates a new instance of color
1898      * @param red red component ranging from {@code 0} to {@code 1}
1899      * @param green green component ranging from {@code 0} to {@code 1}
1900      * @param blue blue component ranging from {@code 0} to {@code 1}
1901      * @param opacity opacity ranging from {@code 0} to {@code 1}
1902      */
1903     public Color(@NamedArg("red") double red, @NamedArg("green") double green, @NamedArg("blue") double blue, @NamedArg(value="opacity", defaultValue="1") double opacity) {
1904         if (red < 0 || red > 1) {
1905             throw new IllegalArgumentException("Color's red value (" + red + ") must be in the range 0.0-1.0");
1906         }
1907         if (green < 0 || green > 1) {
1908             throw new IllegalArgumentException("Color's green value (" + green + ") must be in the range 0.0-1.0");
1909         }
1910         if (blue < 0 || blue > 1) {
1911             throw new IllegalArgumentException("Color's blue value (" + blue + ") must be in the range 0.0-1.0");
1912         }
1913         if (opacity < 0 || opacity > 1) {
1914             throw new IllegalArgumentException("Color's opacity value (" + opacity + ") must be in the range 0.0-1.0");
1915         }
1916 
1917         this.red = (float) red;
1918         this.green = (float) green;
1919         this.blue = (float) blue;
1920         this.opacity = (float) opacity;
1921     }
1922 
1923     /**
1924      * Creates a new instance of color. This constructor performs no integrity
1925      * checks, and thus should ONLY be used by internal code in Color which
1926      * knows that the hard-coded values are correct.
1927      *
1928      * @param red red component ranging from {@code 0} to {@code 1}
1929      * @param green green component ranging from {@code 0} to {@code 1}
1930      * @param blue blue component ranging from {@code 0} to {@code 1}
1931      * @param opacity opacity ranging from {@code 0} to {@code 1}
1932      */
1933     private Color(float red, float green, float blue) {
1934         this.red = red;
1935         this.green = green;
1936         this.blue = blue;
1937     }
1938 
1939     @Override
1940     Object acc_getPlatformPaint() {
1941         if (platformPaint == null) {
1942             platformPaint = Toolkit.getToolkit().getPaint(this);
1943         }
1944         return platformPaint;
1945     }
1946 
1947     /**
1948      * {@inheritDoc}
1949      */
1950     @Override public Color interpolate(Color endValue, double t) {
1951         if (t <= 0.0) return this;
1952         if (t >= 1.0) return endValue;
1953         float ft = (float) t;
1954         return new Color(
1955             red     + (endValue.red     - red)     * ft,
1956             green   + (endValue.green   - green)   * ft,
1957             blue    + (endValue.blue    - blue)    * ft,
1958             opacity + (endValue.opacity - opacity) * ft
1959         );
1960     }
1961 
1962     /**
1963      * Indicates whether some other object is "equal to" this one.
1964      * @param obj the reference object with which to compare.
1965      * @return {@code true} if this object is equal to the {@code obj} argument; {@code false} otherwise.
1966      */
1967     @Override public boolean equals(Object obj) {
1968         if (obj == this) return true;
1969         if (obj instanceof Color) {
1970             Color other = (Color) obj;
1971             return red == other.red
1972                 && green == other.green
1973                 && blue == other.blue
1974                 && opacity == other.opacity;
1975         } else return false;
1976     }
1977 
1978     /**
1979      * Returns a hash code for this {@code Color} object.
1980      * @return a hash code for this {@code Color} object.
1981      */
1982     @Override public int hashCode() {
1983         // construct the 32bit integer representation of this color
1984         int r = (int)Math.round(red * 255.0);
1985         int g = (int)Math.round(green * 255.0);
1986         int b = (int)Math.round(blue * 255.0);
1987         int a = (int)Math.round(opacity * 255.0);
1988         return to32BitInteger(r, g, b, a);
1989     }
1990 
1991     /**
1992      * Returns a string representation of this {@code Color}.
1993      * This method is intended to be used only for informational purposes.
1994      * The content and format of the returned string might vary between implementations.
1995      * The returned string might be empty but cannot be {@code null}.
1996      *
1997      * @return the string representation
1998      */
1999     @Override public String toString() {
2000         int r = (int)Math.round(red * 255.0);
2001         int g = (int)Math.round(green * 255.0);
2002         int b = (int)Math.round(blue * 255.0);
2003         int o = (int)Math.round(opacity * 255.0);
2004         return String.format("0x%02x%02x%02x%02x" , r, g, b, o);
2005     }
2006 }