Top Description Constructors Methods
org.apache.poi.ss.usermodel

public abstract Class ExtendedColor

extends Object
implements Color
Class Inheritance
All Implemented Interfaces
org.apache.poi.ss.usermodel.Color
Known Direct Subclasses
org.apache.poi.hssf.usermodel.HSSFExtendedColor
Imports
java.util.Locale

Represents a XSSF-style color (based on either a org.apache.poi.xssf.usermodel.XSSFColor or a org.apache.poi.hssf.record.common.ExtendedColor

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static byte
applyTint(int lum, double tint)

public abstract byte[]

Returns:

Standard Alpha Red Green Blue ctColor value (ARGB) bytes.
getARGB
()

public String

Returns:

the ARGB value in hex string format, eg FF00FF00. Works for both regular and indexed colours.
getARGBHex
()

public abstract short

Returns:

Indexed Color index value, if isIndexed() is true
getIndex
()

protected abstract byte[]

Returns:

index color RGB bytes, if isIndexed() == true, null if not indexed or index is invalid
getIndexedRGB
()

public abstract byte[]

Returns:

Standard Red Green Blue ctColor value (RGB) bytes. If there was an A (Alpha) value, it will be stripped.
getRGB
()

protected byte[]

Returns:

RGB or ARGB bytes, either stored or by index
getRGBOrARGB
()

public byte[]

Returns:

Standard Red Green Blue ctColor value (RGB) bytes with applied tint. Alpha values are ignored.
getRGBWithTint
()

protected abstract byte[]

Returns:

RGB or ARGB bytes or null
getStoredRGB
()

public abstract int

Returns:

Index of Theme color, if isThemed() is true
getTheme
()

public abstract double

Returns:

the tint value
getTint
()

Specifies the tint value applied to the ctColor.

public abstract boolean

Returns:

true if the color is automatic
isAuto
()

public abstract boolean

Returns:

true if the color is indexed
isIndexed
()

public abstract boolean

Returns:

true if the color is RGB / ARGB
isRGB
()

public abstract boolean

Returns:

true if the color is from a Theme
isThemed
()

public void
setARGBHex(String
color ARGB hex string
argb
)

Sets the ARGB value from hex format, eg FF0077FF.

protected void
setColor(Color
awt Color to set
clr
)

public abstract void
setRGB(byte[]
bytes
rgb
)

Sets the Red Green Blue or Alpha Red Green Blue

public abstract void
setTint(double
the tint value
tint
)

Specifies the tint value applied to the ctColor.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ExtendedColorback to summary
public ExtendedColor()

Method Detail

applyTintback to summary
private static byte applyTint(int lum, double tint)
getARGBback to summary
public abstract byte[] getARGB()
Returns:byte[]

Standard Alpha Red Green Blue ctColor value (ARGB) bytes.

getARGBHexback to summary
public String getARGBHex()
Returns:String

the ARGB value in hex string format, eg FF00FF00. Works for both regular and indexed colours.

getIndexback to summary
public abstract short getIndex()
Returns:short

Indexed Color index value, if isIndexed() is true

getIndexedRGBback to summary
protected abstract byte[] getIndexedRGB()
Returns:byte[]

index color RGB bytes, if isIndexed() == true, null if not indexed or index is invalid

getRGBback to summary
public abstract byte[] getRGB()
Returns:byte[]

Standard Red Green Blue ctColor value (RGB) bytes. If there was an A (Alpha) value, it will be stripped.

getRGBOrARGBback to summary
protected byte[] getRGBOrARGB()
Returns:byte[]

RGB or ARGB bytes, either stored or by index

getRGBWithTintback to summary
public byte[] getRGBWithTint()
Returns:byte[]

Standard Red Green Blue ctColor value (RGB) bytes with applied tint. Alpha values are ignored.

getStoredRGBback to summary
protected abstract byte[] getStoredRGB()
Returns:byte[]

RGB or ARGB bytes or null

getThemeback to summary
public abstract int getTheme()
Returns:int

Index of Theme color, if isThemed() is true

getTintback to summary
public abstract double getTint()

Specifies the tint value applied to the ctColor.

If tint is supplied, then it is applied to the RGB value of the ctColor to determine the final ctColor applied.

The tint value is stored as a double from -1.0 .. 1.0, where -1.0 means 100% darken and 1.0 means 100% lighten. Also, 0.0 means no change.

In loading the RGB value, it is converted to HLS where HLS values are (0..HLSMAX), where HLSMAX is currently 255.

Here are some examples of how to apply tint to ctColor:
If (tint < 0)
Lum' = Lum * (1.0 + tint)

For example: Lum = 200; tint = -0.5; Darken 50%
Lum' = 200 * (0.5) => 100
For example: Lum = 200; tint = -1.0; Darken 100% (make black)
Lum' = 200 * (1.0-1.0) => 0
If (tint > 0)
Lum' = Lum * (1.0-tint) + (HLSMAX - HLSMAX * (1.0-tint))
For example: Lum = 100; tint = 0.75; Lighten 75%

Lum' = 100 * (1-.75) + (HLSMAX - HLSMAX*(1-.75))
= 100 * .25 + (255 - 255 * .25)
= 25 + (255 - 63) = 25 + 192 = 217
For example: Lum = 100; tint = 1.0; Lighten 100% (make white)
Lum' = 100 * (1-1) + (HLSMAX - HLSMAX*(1-1))
= 100 * 0 + (255 - 255 * 0)
= 0 + (255 - 0) = 255
Returns:double

the tint value

isAutoback to summary
public abstract boolean isAuto()
Returns:boolean

true if the color is automatic

isIndexedback to summary
public abstract boolean isIndexed()
Returns:boolean

true if the color is indexed

isRGBback to summary
public abstract boolean isRGB()
Returns:boolean

true if the color is RGB / ARGB

isThemedback to summary
public abstract boolean isThemed()
Returns:boolean

true if the color is from a Theme

setARGBHexback to summary
public void setARGBHex(String argb)

Sets the ARGB value from hex format, eg FF0077FF. Only works for regular (non-indexed) colours

Parameters
argb:String

color ARGB hex string

setColorback to summary
protected void setColor(Color clr)
Parameters
clr:Color

awt Color to set

setRGBback to summary
public abstract void setRGB(byte[] rgb)

Sets the Red Green Blue or Alpha Red Green Blue

Parameters
rgb:byte[]

bytes

setTintback to summary
public abstract void setTint(double tint)

Specifies the tint value applied to the ctColor.

If tint is supplied, then it is applied to the RGB value of the ctColor to determine the final ctColor applied.

The tint value is stored as a double from -1.0 .. 1.0, where -1.0 means 100% darken and 1.0 means 100% lighten. Also, 0.0 means no change.

In loading the RGB value, it is converted to HLS where HLS values are (0..HLSMAX), where HLSMAX is currently 255.

Here are some examples of how to apply tint to ctColor:
If (tint < 0)
Lum' = Lum * (1.0 + tint)

For example: Lum = 200; tint = -0.5; Darken 50%
Lum' = 200 * (0.5) => 100
For example: Lum = 200; tint = -1.0; Darken 100% (make black)
Lum' = 200 * (1.0-1.0) => 0
If (tint > 0)
Lum' = Lum * (1.0-tint) + (HLSMAX - HLSMAX * (1.0-tint))
For example: Lum = 100; tint = 0.75; Lighten 75%

Lum' = 100 * (1-.75) + (HLSMAX - HLSMAX*(1-.75))
= 100 * .25 + (255 - 255 * .25)
= 25 + (255 - 63) = 25 + 192 = 217
For example: Lum = 100; tint = 1.0; Lighten 100% (make white)
Lum' = 100 * (1-1) + (HLSMAX - HLSMAX*(1-1))
= 100 * 0 + (255 - 255 * 0)
= 0 + (255 - 0) = 255
Parameters
tint:double

the tint value