org.apache.poi.hssf.usermodel
Class HSSFExtendedColor

java.lang.Object
  extended by org.apache.poi.ss.usermodel.ExtendedColor
      extended by org.apache.poi.hssf.usermodel.HSSFExtendedColor
All Implemented Interfaces:
Color

public class HSSFExtendedColor
extends ExtendedColor

The HSSF file format normally stores Color information in the Palette (see PaletteRecord), but for a few cases (eg Conditional Formatting, Sheet Extensions), this XSSF-style color record can be used.


Constructor Summary
HSSFExtendedColor(ExtendedColor color)
           
 
Method Summary
 byte[] getARGB()
           
protected  ExtendedColor getExtendedColor()
           
 short getIndex()
           
protected  byte[] getIndexedRGB()
           
 byte[] getRGB()
           
protected  byte[] getStoredRBG()
           
 int getTheme()
           
 double getTint()
          Specifies the tint value applied to the ctColor.
 boolean isAuto()
           
 boolean isIndexed()
           
 boolean isRGB()
           
 boolean isThemed()
           
 void setRGB(byte[] rgb)
          Sets the Red Green Blue or Alpha Red Green Blue
 void setTint(double tint)
          Specifies the tint value applied to the ctColor.
 
Methods inherited from class org.apache.poi.ss.usermodel.ExtendedColor
getARGBHex, getRGBOrARGB, getRGBWithTint, setARGBHex, setColor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HSSFExtendedColor

public HSSFExtendedColor(ExtendedColor color)
Method Detail

getExtendedColor

protected ExtendedColor getExtendedColor()

isAuto

public boolean isAuto()
Specified by:
isAuto in class ExtendedColor
Returns:
true if the color is automatic

isIndexed

public boolean isIndexed()
Specified by:
isIndexed in class ExtendedColor
Returns:
true if the color is indexed

isRGB

public boolean isRGB()
Specified by:
isRGB in class ExtendedColor
Returns:
true if the color is RGB / ARGB

isThemed

public boolean isThemed()
Specified by:
isThemed in class ExtendedColor
Returns:
true if the color is from a Theme

getIndex

public short getIndex()
Specified by:
getIndex in class ExtendedColor
Returns:
Indexed Color index value, if ExtendedColor.isIndexed() is true

getTheme

public int getTheme()
Specified by:
getTheme in class ExtendedColor
Returns:
Index of Theme color, if ExtendedColor.isThemed() is true

getRGB

public byte[] getRGB()
Specified by:
getRGB in class ExtendedColor
Returns:
Standard Red Green Blue ctColor value (RGB) bytes. If there was an A (Alpha) value, it will be stripped.

getARGB

public byte[] getARGB()
Specified by:
getARGB in class ExtendedColor
Returns:
Standard Alpha Red Green Blue ctColor value (ARGB) bytes.

getStoredRBG

protected byte[] getStoredRBG()
Specified by:
getStoredRBG in class ExtendedColor
Returns:
RGB or ARGB bytes or null

setRGB

public void setRGB(byte[] rgb)
Description copied from class: ExtendedColor
Sets the Red Green Blue or Alpha Red Green Blue

Specified by:
setRGB in class ExtendedColor
Parameters:
rgb - bytes

getTint

public double getTint()
Description copied from class: ExtendedColor
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
 

Specified by:
getTint in class ExtendedColor
Returns:
the tint value

setTint

public void setTint(double tint)
Description copied from class: ExtendedColor
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
 

Specified by:
setTint in class ExtendedColor
Parameters:
tint - the tint value

getIndexedRGB

protected byte[] getIndexedRGB()
Specified by:
getIndexedRGB in class ExtendedColor
Returns:
index color RGB bytes, if ExtendedColor.isIndexed() == true, null if not indexed or index is invalid