JHotDraw 7.6

org.jhotdraw.color
Class CompositeColor

java.lang.Object
  extended by java.awt.Color
      extended by org.jhotdraw.color.CompositeColor
All Implemented Interfaces:
java.awt.Paint, java.awt.Transparency, java.io.Serializable

public class CompositeColor
extends java.awt.Color

CompositeColor is identical to java.awt.Color with the exception that it allows to construct an instance with color components outside of the range of 0 and 1.

Version:
$Id: CompositeColor.java 717 2010-11-21 12:30:57Z rawcoder $
Author:
Werner Randelshofer
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.awt.Color
black, BLACK, blue, BLUE, cyan, CYAN, DARK_GRAY, darkGray, gray, GRAY, green, GREEN, LIGHT_GRAY, lightGray, magenta, MAGENTA, orange, ORANGE, pink, PINK, red, RED, white, WHITE, yellow, YELLOW
 
Fields inherited from interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT
 
Constructor Summary
CompositeColor(java.awt.color.ColorSpace cspace, float[] components, float alpha)
          Creates a color in the specified ColorSpace with the color components specified in the float array and the specified alpha.
 
Method Summary
 float[] getColorComponents(java.awt.color.ColorSpace cspace, float[] compArray)
          Returns a float array containing only the color components of the Color in the ColorSpace specified by the cspace parameter.
 float[] getColorComponents(float[] compArray)
          Returns a float array containing only the color components of the Color, in the ColorSpace of the Color.
 java.awt.color.ColorSpace getColorSpace()
          Returns the ColorSpace of this Color.
 float[] getComponents(java.awt.color.ColorSpace cspace, float[] compArray)
          Returns a float array containing the color and alpha components of the Color, in the ColorSpace specified by the cspace parameter.
 float[] getComponents(float[] compArray)
          Returns a float array containing the color and alpha components of the Color, in the ColorSpace of the Color.
 
Methods inherited from class java.awt.Color
brighter, createContext, darker, decode, equals, getAlpha, getBlue, getColor, getColor, getColor, getGreen, getHSBColor, getRed, getRGB, getRGBColorComponents, getRGBComponents, getTransparency, hashCode, HSBtoRGB, RGBtoHSB, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CompositeColor

public CompositeColor(java.awt.color.ColorSpace cspace,
                      float[] components,
                      float alpha)
Creates a color in the specified ColorSpace with the color components specified in the float array and the specified alpha. The number of components is determined by the type of the ColorSpace. For example, RGB requires 3 components, but CMYK requires 4 components.

Parameters:
cspace - the ColorSpace to be used to interpret the components
components - an arbitrary number of color components that is compatible with the ColorSpace
alpha - alpha value
Throws:
java.lang.IllegalArgumentException - if any of the values in the components array or alpha is outside of the range supported by cspace.
See Also:
getComponents(float[]), getColorComponents(float[])
Method Detail

getComponents

public float[] getComponents(float[] compArray)
Returns a float array containing the color and alpha components of the Color, in the ColorSpace of the Color. If compArray is null, an array with length equal to the number of components in the associated ColorSpace plus one is created for the return value. Otherwise, compArray must have at least this length and it is filled in with the components and returned.

Overrides:
getComponents in class java.awt.Color
Parameters:
compArray - an array that this method fills with the color and alpha components of this Color in its ColorSpace and returns
Returns:
the color and alpha components in a float array.

getColorComponents

public float[] getColorComponents(float[] compArray)
Returns a float array containing only the color components of the Color, in the ColorSpace of the Color. If compArray is null, an array with length equal to the number of components in the associated ColorSpace is created for the return value. Otherwise, compArray must have at least this length and it is filled in with the components and returned.

Overrides:
getColorComponents in class java.awt.Color
Parameters:
compArray - an array that this method fills with the color components of this Color in its ColorSpace and returns
Returns:
the color components in a float array.

getComponents

public float[] getComponents(java.awt.color.ColorSpace cspace,
                             float[] compArray)
Returns a float array containing the color and alpha components of the Color, in the ColorSpace specified by the cspace parameter. If compArray is null, an array with length equal to the number of components in cspace plus one is created for the return value. Otherwise, compArray must have at least this length, and it is filled in with the components and returned.

Overrides:
getComponents in class java.awt.Color
Parameters:
cspace - a specified ColorSpace
compArray - an array that this method fills with the color and alpha components of this Color in the specified ColorSpace and returns
Returns:
the color and alpha components in a float array.

getColorComponents

public float[] getColorComponents(java.awt.color.ColorSpace cspace,
                                  float[] compArray)
Returns a float array containing only the color components of the Color in the ColorSpace specified by the cspace parameter. If compArray is null, an array with length equal to the number of components in cspace is created for the return value. Otherwise, compArray must have at least this length, and it is filled in with the components and returned.

Overrides:
getColorComponents in class java.awt.Color
Parameters:
cspace - a specified ColorSpace
compArray - an array that this method fills with the color components of this Color in the specified ColorSpace
Returns:
the color components in a float array.

getColorSpace

public java.awt.color.ColorSpace getColorSpace()
Returns the ColorSpace of this Color.

Overrides:
getColorSpace in class java.awt.Color
Returns:
this Color object's ColorSpace.

Copyright 1996-2010 (c) by the authors and contributors of the JHotDraw project.
Some rights reserved.