src/share/classes/java/awt/Color.java

Print this page


   1 /*
   2  * Copyright (c) 1995, 2013, 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


  33 
  34 /**
  35  * The <code>Color</code> class is used to encapsulate colors in the default
  36  * sRGB color space or colors in arbitrary color spaces identified by a
  37  * {@link ColorSpace}.  Every color has an implicit alpha value of 1.0 or
  38  * an explicit one provided in the constructor.  The alpha value
  39  * defines the transparency of a color and can be represented by
  40  * a float value in the range 0.0&nbsp;-&nbsp;1.0 or 0&nbsp;-&nbsp;255.
  41  * An alpha value of 1.0 or 255 means that the color is completely
  42  * opaque and an alpha value of 0 or 0.0 means that the color is
  43  * completely transparent.
  44  * When constructing a <code>Color</code> with an explicit alpha or
  45  * getting the color/alpha components of a <code>Color</code>, the color
  46  * components are never premultiplied by the alpha component.
  47  * <p>
  48  * The default color space for the Java 2D(tm) API is sRGB, a proposed
  49  * standard RGB color space.  For further information on sRGB,
  50  * see <A href="http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html">
  51  * http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html
  52  * </A>.
  53  * <p>
  54  * @version     10 Feb 1997
  55  * @author      Sami Shaio
  56  * @author      Arthur van Hoff
  57  * @see         ColorSpace
  58  * @see         AlphaComposite
  59  */
  60 public class Color implements Paint, java.io.Serializable {
  61 
  62     /**
  63      * The color white.  In the default sRGB space.
  64      */
  65     public final static Color white     = new Color(255, 255, 255);
  66 
  67     /**
  68      * The color white.  In the default sRGB space.
  69      * @since 1.4
  70      */
  71     public final static Color WHITE = white;
  72 
  73     /**


   1 /*
   2  * Copyright (c) 1995, 2014, 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


  33 
  34 /**
  35  * The <code>Color</code> class is used to encapsulate colors in the default
  36  * sRGB color space or colors in arbitrary color spaces identified by a
  37  * {@link ColorSpace}.  Every color has an implicit alpha value of 1.0 or
  38  * an explicit one provided in the constructor.  The alpha value
  39  * defines the transparency of a color and can be represented by
  40  * a float value in the range 0.0&nbsp;-&nbsp;1.0 or 0&nbsp;-&nbsp;255.
  41  * An alpha value of 1.0 or 255 means that the color is completely
  42  * opaque and an alpha value of 0 or 0.0 means that the color is
  43  * completely transparent.
  44  * When constructing a <code>Color</code> with an explicit alpha or
  45  * getting the color/alpha components of a <code>Color</code>, the color
  46  * components are never premultiplied by the alpha component.
  47  * <p>
  48  * The default color space for the Java 2D(tm) API is sRGB, a proposed
  49  * standard RGB color space.  For further information on sRGB,
  50  * see <A href="http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html">
  51  * http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html
  52  * </A>.
  53  *
  54  * @version     10 Feb 1997
  55  * @author      Sami Shaio
  56  * @author      Arthur van Hoff
  57  * @see         ColorSpace
  58  * @see         AlphaComposite
  59  */
  60 public class Color implements Paint, java.io.Serializable {
  61 
  62     /**
  63      * The color white.  In the default sRGB space.
  64      */
  65     public final static Color white     = new Color(255, 255, 255);
  66 
  67     /**
  68      * The color white.  In the default sRGB space.
  69      * @since 1.4
  70      */
  71     public final static Color WHITE = white;
  72 
  73     /**