java.awt.Paint
, java.awt.Transparency
, java.io.Serializable
public class ColorWithAlternatives
extends java.awt.Color
Color
class allowing to specify a prioritized list of alternative colors.
The alternative colors shall be the ones that are preferred if an output format supports them.
This is normally used for passing device-specific colors through to the output format.
This class only adds a single reference to a color array which should not increase memory consumption by much if no alternative colors are specified.
Important: Due to a flaw in Color.equals(Object)
, the equals()
method should not be used to compare two colors, especially when used to update the current
color for some output format. Color
only takes the sRGB values into account but not
more the advanced facets of this class. Use ColorUtil.isSameColor(Color, Color)
for
such a check.
Constructor | Description |
---|---|
ColorWithAlternatives(float r,
float g,
float b,
float a,
java.awt.Color[] alternativeColors) |
Constructor for RGBA colors.
|
ColorWithAlternatives(float r,
float g,
float b,
java.awt.Color[] alternativeColors) |
Constructor for RGB colors.
|
ColorWithAlternatives(int rgba,
boolean hasalpha,
java.awt.Color[] alternativeColors) |
Constructor for RGBA colors.
|
ColorWithAlternatives(int r,
int g,
int b,
int a,
java.awt.Color[] alternativeColors) |
Constructor for RGBA colors.
|
ColorWithAlternatives(int r,
int g,
int b,
java.awt.Color[] alternativeColors) |
Constructor for RGB colors.
|
ColorWithAlternatives(int rgb,
java.awt.Color[] alternativeColors) |
Constructor for RGB colors.
|
ColorWithAlternatives(java.awt.color.ColorSpace cspace,
float[] components,
float alpha,
java.awt.Color[] alternativeColors) |
Constructor for colors with an arbitrary color space.
|
Modifier and Type | Method | Description |
---|---|---|
java.awt.Color[] |
getAlternativeColors() |
Returns the list of alternative colors.
|
java.awt.Color |
getFirstAlternativeOfType(int colorSpaceType) |
Returns the first alternative color found with the given color space type.
|
boolean |
hasAlternativeColors() |
Indicates whether alternative colors are available.
|
int |
hashCode() |
|
boolean |
hasSameAlternativeColors(ColorWithAlternatives col) |
Indicates whether another instance has the same alternative colors.
|
brighter, createContext, darker, decode, equals, getAlpha, getBlue, getColor, getColor, getColor, getColorComponents, getColorComponents, getColorSpace, getComponents, getComponents, getGreen, getHSBColor, getRed, getRGB, getRGBColorComponents, getRGBComponents, getTransparency, HSBtoRGB, RGBtoHSB, toString
public ColorWithAlternatives(float r, float g, float b, float a, java.awt.Color[] alternativeColors)
r
- the red componentg
- the green componentb
- the blue componenta
- the alpha componentalternativeColors
- the prioritized list of alternative colors.Color(float, float, float, float)
public ColorWithAlternatives(float r, float g, float b, java.awt.Color[] alternativeColors)
r
- the red componentg
- the green componentb
- the blue componentalternativeColors
- the prioritized list of alternative colors.Color(float, float, float)
public ColorWithAlternatives(int rgba, boolean hasalpha, java.awt.Color[] alternativeColors)
rgba
- the combined RGBA valuehasalpha
- true if the alpha bits are valid, false otherwisealternativeColors
- the prioritized list of alternative colors.Color(int, boolean)
public ColorWithAlternatives(int r, int g, int b, int a, java.awt.Color[] alternativeColors)
r
- the red componentg
- the green componentb
- the blue componenta
- the alpha componentalternativeColors
- the prioritized list of alternative colors.Color(int, int, int, int)
public ColorWithAlternatives(int r, int g, int b, java.awt.Color[] alternativeColors)
r
- the red componentg
- the green componentb
- the blue componentalternativeColors
- the prioritized list of alternative colors.Color(int, int, int)
public ColorWithAlternatives(int rgb, java.awt.Color[] alternativeColors)
rgb
- the combined RGB componentsalternativeColors
- the prioritized list of alternative colors.Color(int)
public ColorWithAlternatives(java.awt.color.ColorSpace cspace, float[] components, float alpha, java.awt.Color[] alternativeColors)
cspace
- the color spacecomponents
- the color componentsalpha
- the alpha componentalternativeColors
- the prioritized list of alternative colors.Color(ColorSpace, float[], float)
public java.awt.Color[] getAlternativeColors()
public boolean hasAlternativeColors()
public boolean hasSameAlternativeColors(ColorWithAlternatives col)
col
- the color to compare the alternatives topublic java.awt.Color getFirstAlternativeOfType(int colorSpaceType)
colorSpaceType
- the color space type (ColorSpace
.TYPE_*).public int hashCode()
hashCode
in class java.awt.Color
Copyright 1999-2016 The Apache Software Foundation. All Rights Reserved.