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