Package org.apache.poi.hssf.util
Class HSSFColor
java.lang.Object
org.apache.poi.hssf.util.HSSFColor
- All Implemented Interfaces:
Color
Intends to provide support for the very evil index to triplet issue and
will likely replace the color constants interface for HSSF 2.0.
This class contains static inner class members for representing colors.
Each color has an index (for the standard palette in Excel (tm) ),
native (RGB) triplet and string triplet. The string triplet is as the
color would be represented by Gnumeric. Having (string) this here is a bit of a
collision of function between HSSF and the HSSFSerializer but I think its
a reasonable one in this case.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Predefined HSSFColors with their given palette index (and an optional 2nd index) -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
returns colon-delimited hex string "0:0:0"short
getIndex()
returns color standard palette indexshort
returns alternative color standard palette indexThis function returns all the colours in an unmodifiable Map.This function returns all the Colours, stored in a Map that can be edited.short[]
returns RGB triplet (0, 0, 0)this function returns all colors in a hastable.int
hashCode()
static HSSFColor
toHSSFColor
(Color color) Checked type cast color to an HSSFColor.
-
Constructor Details
-
HSSFColor
public HSSFColor()Creates a new instance of HSSFColor -
HSSFColor
-
-
Method Details
-
getIndexHash
This function returns all the colours in an unmodifiable Map. The map is cached on first use.- Returns:
- a Map containing all colours keyed by Integer excel-style palette indexes
-
getMutableIndexHash
This function returns all the Colours, stored in a Map that can be edited. No caching is performed. If you don't need to edit the table, then callgetIndexHash()
which returns a statically cached immutable map of colours. -
getTripletHash
this function returns all colors in a hastable. It's not implemented as a static member/statically initialized because that would be dirty in a server environment as it is intended. This means you'll eat the time it takes to create it once per request but you will not hold onto it if you have none of those requests.- Returns:
- a Map containing all colors keyed by String gnumeric-like triplets
-
getIndex
public short getIndex()returns color standard palette index- Returns:
- index to the standard palette
-
getIndex2
public short getIndex2()returns alternative color standard palette index- Returns:
- alternative index to the standard palette, if -1 this index is not defined
-
getTriplet
public short[] getTriplet()returns RGB triplet (0, 0, 0)- Returns:
- triplet representation like that in Excel
-
getHexString
returns colon-delimited hex string "0:0:0"- Returns:
- a hex string exactly like a gnumeric triplet
-
equals
-
hashCode
public int hashCode() -
toHSSFColor
Checked type cast color to an HSSFColor.- Parameters:
color
- the color to type cast- Returns:
- the type casted color
- Throws:
IllegalArgumentException
- if color is null or is not an instance of HSSFColor
-