public class OleColor extends Color
OleColor
class extends
class java.awt.Color
in order to support OLE color formats in
addition to all Color
capabilities.
An OLE color value, whose C/C++ type is named OLE_COLOR
,
basically is an int
value, that stores color information in
different formats. One format stores a color's red, green and blue components
explicitly, whereas the other format simply holds an predefined index into
the operating system's system color table.
Among many analogies, there are two major differences between OLE colors and Java colors:
int
value containing an
OLE color with explicit color components looks like 0x00bbggrr
.
The second form of an OLE color simply stores an index of a well-known system
color. These are the colors that are defined in the Windows display control
panel. Actually, a single byte is sufficient to store any system color index,
so the index is stored in bits 0-7 of the int
value that holds
an OLE color. To distinguish between an OLE color that explicitly stores
blue, green and red components, 0x80
is put into bits 24-31. So,
an int
value containing an OLE color that refers to a system
color looks like 0x800000ss
, whereas ss
is the
index of the system color.
Modifier and Type | Field and Description |
---|---|
static int |
INVALID_SYSTEM_COLOR_INDEX
Represents an invalid system color index.
|
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
BITMASK, OPAQUE, TRANSLUCENT
Constructor and Description |
---|
OleColor(Color color)
Creates a
OleColor sRGB color with the values of the
specified Color object. |
OleColor(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. |
OleColor(float r,
float g,
float b)
Creates an opaque sRGB color with the specified red, green, and blue
values in the range (0.0 - 1.0).
|
OleColor(float r,
float g,
float b,
float a)
Creates a sRGB color with the specified red, green, blue, and alpha
values in the range (0.0 - 1.0).
|
OleColor(int bgr)
Creates an opaque sRGB color with the specified combined BGR value
consisting of the blue component in bits 16-23, the green component in
bits 8-15, and the red component in bits 0-7.
|
OleColor(int rgba,
boolean hasalpha)
Creates a sRGB color with the specified combined RGBA value consisting of
the alpha component in bits 24-31, the red component in bits 16-23, the
green component in bits 8-15, and the blue component in bits 0-7.
|
OleColor(int r,
int g,
int b)
Creates an opaque sRGB color with the specified red, green, and blue
values in the range (0 - 255).
|
OleColor(int r,
int g,
int b,
int a)
Creates a sRGB color with the specified red, green, blue, and alpha
values in the range (0 - 255).
|
OleColor(NativeSystemColor systemColor)
Creates an opaque sRGB color with the specified native system color.
|
Modifier and Type | Method and Description |
---|---|
int |
getBGR()
Returns the value of this
OleColor as a combined BGR color
value. |
Color |
getColor()
Returns the value of this
OleColor as a real
java.awt.Color type. |
Color |
getColor(float alpha)
Returns the value of this
OleColor as a real
java.awt.Color type with the specified alpha value. |
Color |
getColor(int alpha)
Returns the value of this
OleColor as a real
java.awt.Color type with the specified alpha value. |
int |
getOleColorValue()
Returns the value of this
OleColor as a OLE color value. |
static int |
getRGB(int bgr)
Returns a combined RGB value, created from the specified combined BGR
value consisting of the blue component in bits 16-23, the green component
in bits 8-15, and the red component in bits 0-7.
|
int |
getSystemColorIndex()
Returns the system color index of this
OleColor or -1 if
this instance does not represent a system color. |
boolean |
isSystemColor()
Returns a value indicating whether this
OleColor represents
a system color. |
brighter, createContext, darker, decode, equals, getAlpha, getBlue, getColor, getColor, getColor, getColorComponents, getColorComponents, getColorSpace, getComponents, getComponents, getGreen, getHSBColor, getRed, getRGB, getRGBColorComponents, getRGBComponents, getTransparency, hashCode, HSBtoRGB, RGBtoHSB, toString
public static final int INVALID_SYSTEM_COLOR_INDEX
getSystemColorIndex
.public OleColor(int bgr)
0x80000000
.bgr
- the combined BGR components or a native system color in OLE
color formatIndexOutOfBoundsException
- if bgr
denotes a system color in OLE color
format (aka contains 0x80
in bits 24-31), whose
index (bits 0-7) does not specify an existing system color.public OleColor(NativeSystemColor systemColor)
systemColor
- the native system colorpublic OleColor(Color color)
OleColor
sRGB color with the values of the
specified Color
object.color
- the color object to take color values frompublic OleColor(int r, int g, int b)
r
- the red componentg
- the green componentb
- the blue componentIllegalArgumentException
- if r
, g
or b
are
outside of the range 0 to 255, inclusiveColor.getRed()
,
Color.getGreen()
,
Color.getBlue()
,
getRGB(int)
,
getBGR()
public OleColor(int r, int g, int b, int a)
r
- the red componentg
- the green componentb
- the blue componenta
- the alpha componentIllegalArgumentException
- if r
, g
, b
or
a
are outside of the range 0 to 255, inclusiveColor.getRed()
,
Color.getGreen()
,
Color.getBlue()
,
Color.getAlpha()
,
getRGB(int)
,
getBGR()
public OleColor(int rgba, boolean hasalpha)
hasalpha
argument is false
, alpha is defaulted
to 255.rgba
- the combined RGBA componentshasalpha
- true
if the alpha bits are valid;
false
otherwiseColorModel.getRGBdefault()
,
Color.getRed()
,
Color.getGreen()
,
Color.getBlue()
,
Color.getAlpha()
,
getRGB(int)
,
getBGR()
public OleColor(float r, float g, float b)
r
- the red componentg
- the green componentb
- the blue componentIllegalArgumentException
- if r
, g
or b
are
outside of the range 0.0 to 1.0, inclusiveColor.getRed()
,
Color.getGreen()
,
Color.getBlue()
,
getRGB(int)
,
getBGR()
public OleColor(float r, float g, float b, float a)
r
- the red componentg
- the green componentb
- the blue componenta
- the alpha componentIllegalArgumentException
- if r
, g
b
or
a
are outside of the range 0.0 to 1.0, inclusiveColor.getRed()
,
Color.getGreen()
,
Color.getBlue()
,
Color.getAlpha()
,
getRGB(int)
,
getBGR()
public OleColor(ColorSpace cspace, float[] components, float alpha)
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.cspace
- the ColorSpace
to be used to interpret the
componentscomponents
- an arbitrary number of color components that is compatible
with thealpha
- alpha valueIllegalArgumentException
- if any of the values in the components
array or
alpha
is outside of the range 0.0 to 1.0Color.getComponents(float[])
,
Color.getColorComponents(float[])
public static int getRGB(int bgr)
0x80000000
.bgr
- the combined BGR components or a native system color in OLE
color formatIndexOutOfBoundsException
- if bgr
denotes a system color in OLE color
format (aka contains 0x80
in bits 24-31), whose
index (bits 0-7) does not specify an existing system color.public boolean isSystemColor()
OleColor
represents
a system color.true
if this OleColor
represents a
system color; false
otherwisegetSystemColorIndex()
public int getSystemColorIndex()
OleColor
or -1 if
this instance does not represent a system color.OleColor
or -1 if
this instance does not represent a system colorpublic int getBGR()
OleColor
as a combined BGR color
value.OleColor
as a combined BGR color
valuepublic int getOleColorValue()
OleColor
as a OLE color value.
That is an OLE color encoded system color index, if this
OleColor
represents a system color or a combined BGR color
value for all other colors.OleColor
as a OLE color valuepublic Color getColor()
OleColor
as a real
java.awt.Color
type.OleColor
as a real
java.awt.Color
type.public Color getColor(int alpha)
OleColor
as a real
java.awt.Color
type with the specified alpha value.alpha
- the alpha value to be used for the returned Color
OleColor
as a real
java.awt.Color
type.public Color getColor(float alpha)
OleColor
as a real
java.awt.Color
type with the specified alpha value.alpha
- the alpha value to be used for the returned Color
OleColor
as a real
java.awt.Color
type.Copyright © 2009 - 2016 DataGis. All Rights Reserved.