Top Description Inners Fields Constructors Methods
org.apache.poi.hssf.util

public Class HSSFColor

extends Object
implements Color
Class Inheritance
All Implemented Interfaces
org.apache.poi.ss.usermodel.Color
Known Direct Subclasses
org.apache.poi.hssf.usermodel.HSSFPalette.CustomColor
Imports
java.util.Collections, .EnumMap, .HashMap, .Locale, .Map, .Objects, org.apache.poi.ss.usermodel.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 and Inner Type Summary

Modifier and TypeClass and Description
public static enum
HSSFColor.HSSFColorPredefined

Predefined HSSFColors with their given palette index (and an optional 2nd index)

Field Summary

Modifier and TypeField and Description
private final Color
private static Map<HSSFColor.HSSFColorPredefined, HSSFColor>
private final int
private final int
private static Map<Integer, HSSFColor>

Constructor Summary

AccessConstructor and Description
public
HSSFColor()

Creates a new instance of HSSFColor

public
HSSFColor(int index, int index2, Color color)

Method Summary

Modifier and TypeMethod and Description
private static void
private static Map<String, HSSFColor>
private static Map<Integer, HSSFColor>
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public String

Returns:

a hex string exactly like a gnumeric triplet
getHexString
()

returns colon-delimited hex string "0:0:0"

public short

Returns:

index to the standard palette
getIndex
()

returns color standard palette index

public short

Returns:

alternative index to the standard palette, if -1 this index is not defined
getIndex2
()

returns alternative color standard palette index

public static synchronized Map<Integer, HSSFColor>

Returns:

a Map containing all colours keyed by Integer excel-style palette indexes
getIndexHash
()

This function returns all the colours in an unmodifiable Map.

public static Map<Integer, HSSFColor>
getMutableIndexHash()

This function returns all the Colours, stored in a Map that can be edited.

public short[]

Returns:

triplet representation like that in Excel
getTriplet
()

returns RGB triplet (0, 0, 0)

public static Map<String, HSSFColor>

Returns:

a Map containing all colors keyed by String gnumeric-like triplets
getTripletHash
()

this function returns all colors in a hastable.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

private static synchronized Map<HSSFColor.HSSFColorPredefined, HSSFColor>
mapEnumToColorClass()

Maps the Enums to the HSSFColor, in cases of user code evaluating the classname

public static HSSFColor

Returns:

the type casted color
toHSSFColor
(Color
the color to type cast
color
)

Checked type cast color to an HSSFColor.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

colorback to summary
private final Color color
enumListback to summary
private static Map<HSSFColor.HSSFColorPredefined, HSSFColor> enumList
indexback to summary
private final int index
index2back to summary
private final int index2
indexHashback to summary
private static Map<Integer, HSSFColor> indexHash

Constructor Detail

HSSFColorback to summary
public HSSFColor()

Creates a new instance of HSSFColor

HSSFColorback to summary
public HSSFColor(int index, int index2, Color color)

Method Detail

addHSSFColorPredefinedback to summary
private static void addHSSFColorPredefined(HSSFColor.HSSFColorPredefined color)
createColorsByHexStringMapback to summary
private static Map<String, HSSFColor> createColorsByHexStringMap()
createColorsByIndexMapback to summary
private static Map<Integer, HSSFColor> createColorsByIndexMap()
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getHexStringback to summary
public String getHexString()

returns colon-delimited hex string "0:0:0"

Returns:String

a hex string exactly like a gnumeric triplet

getIndexback to summary
public short getIndex()

returns color standard palette index

Returns:short

index to the standard palette

getIndex2back to summary
public short getIndex2()

returns alternative color standard palette index

Returns:short

alternative index to the standard palette, if -1 this index is not defined

getIndexHashback to summary
public static synchronized Map<Integer, HSSFColor> getIndexHash()

This function returns all the colours in an unmodifiable Map. The map is cached on first use.

Returns:Map<Integer, HSSFColor>

a Map containing all colours keyed by Integer excel-style palette indexes

getMutableIndexHashback to summary
public static Map<Integer, HSSFColor> 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 call getIndexHash() which returns a statically cached immutable map of colours.

getTripletback to summary
public short[] getTriplet()

returns RGB triplet (0, 0, 0)

Returns:short[]

triplet representation like that in Excel

getTripletHashback to summary
public static Map<String, HSSFColor> 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:Map<String, HSSFColor>

a Map containing all colors keyed by String gnumeric-like triplets

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
mapEnumToColorClassback to summary
private static synchronized Map<HSSFColor.HSSFColorPredefined, HSSFColor> mapEnumToColorClass()

Maps the Enums to the HSSFColor, in cases of user code evaluating the classname

toHSSFColorback to summary
public static HSSFColor toHSSFColor(Color color)

Checked type cast color to an HSSFColor.

Parameters
color:Color

the color to type cast

Returns:HSSFColor

the type casted color

Exceptions
IllegalArgumentException:
if color is null or is not an instance of HSSFColor
org.apache.poi.hssf.util back to summary

public final Enum HSSFColor.HSSFColorPredefined

extends Enum<HSSFColor.HSSFColorPredefined>
Class Inheritance

Predefined HSSFColors with their given palette index (and an optional 2nd index)
Since
POI 3.16 beta 2

Field Summary

Modifier and TypeField and Description
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
AUTOMATIC

Special Default/Normal/Automatic color.

public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
private final HSSFColor
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined
public static final HSSFColor.HSSFColorPredefined

Constructor Summary

AccessConstructor and Description
private
HSSFColorPredefined(int index, int index2, int rgb)

Method Summary

Modifier and TypeMethod and Description
public HSSFColor

Returns:

(a copy of) the HSSFColor assigned to the enum
getColor
()

public String
public short
public short
public short[]
public static HSSFColor.HSSFColorPredefined
public static HSSFColor.HSSFColorPredefined[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

AQUAback to summary
public static final HSSFColor.HSSFColorPredefined AQUA
AUTOMATICback to summary
public static final HSSFColor.HSSFColorPredefined AUTOMATIC

Special Default/Normal/Automatic color.

Note

This class is NOT in the default Map returned by HSSFColor. The index is a special case which is interpreted in the various setXXXColor calls.

BLACKback to summary
public static final HSSFColor.HSSFColorPredefined BLACK
BLUEback to summary
public static final HSSFColor.HSSFColorPredefined BLUE
BLUE_GREYback to summary
public static final HSSFColor.HSSFColorPredefined BLUE_GREY
BRIGHT_GREENback to summary
public static final HSSFColor.HSSFColorPredefined BRIGHT_GREEN
BROWNback to summary
public static final HSSFColor.HSSFColorPredefined BROWN
colorback to summary
private final HSSFColor color
CORALback to summary
public static final HSSFColor.HSSFColorPredefined CORAL
CORNFLOWER_BLUEback to summary
public static final HSSFColor.HSSFColorPredefined CORNFLOWER_BLUE
DARK_BLUEback to summary
public static final HSSFColor.HSSFColorPredefined DARK_BLUE
DARK_GREENback to summary
public static final HSSFColor.HSSFColorPredefined DARK_GREEN
DARK_REDback to summary
public static final HSSFColor.HSSFColorPredefined DARK_RED
DARK_TEALback to summary
public static final HSSFColor.HSSFColorPredefined DARK_TEAL
DARK_YELLOWback to summary
public static final HSSFColor.HSSFColorPredefined DARK_YELLOW
GOLDback to summary
public static final HSSFColor.HSSFColorPredefined GOLD
GREENback to summary
public static final HSSFColor.HSSFColorPredefined GREEN
GREY_25_PERCENTback to summary
public static final HSSFColor.HSSFColorPredefined GREY_25_PERCENT
GREY_40_PERCENTback to summary
public static final HSSFColor.HSSFColorPredefined GREY_40_PERCENT
GREY_50_PERCENTback to summary
public static final HSSFColor.HSSFColorPredefined GREY_50_PERCENT
GREY_80_PERCENTback to summary
public static final HSSFColor.HSSFColorPredefined GREY_80_PERCENT
INDIGOback to summary
public static final HSSFColor.HSSFColorPredefined INDIGO
LAVENDERback to summary
public static final HSSFColor.HSSFColorPredefined LAVENDER
LEMON_CHIFFONback to summary
public static final HSSFColor.HSSFColorPredefined LEMON_CHIFFON
LIGHT_BLUEback to summary
public static final HSSFColor.HSSFColorPredefined LIGHT_BLUE
LIGHT_CORNFLOWER_BLUEback to summary
public static final HSSFColor.HSSFColorPredefined LIGHT_CORNFLOWER_BLUE
LIGHT_GREENback to summary
public static final HSSFColor.HSSFColorPredefined LIGHT_GREEN
LIGHT_ORANGEback to summary
public static final HSSFColor.HSSFColorPredefined LIGHT_ORANGE
LIGHT_TURQUOISEback to summary
public static final HSSFColor.HSSFColorPredefined LIGHT_TURQUOISE
LIGHT_YELLOWback to summary
public static final HSSFColor.HSSFColorPredefined LIGHT_YELLOW
LIMEback to summary
public static final HSSFColor.HSSFColorPredefined LIME
MAROONback to summary
public static final HSSFColor.HSSFColorPredefined MAROON
OLIVE_GREENback to summary
public static final HSSFColor.HSSFColorPredefined OLIVE_GREEN
ORANGEback to summary
public static final HSSFColor.HSSFColorPredefined ORANGE
ORCHIDback to summary
public static final HSSFColor.HSSFColorPredefined ORCHID
PALE_BLUEback to summary
public static final HSSFColor.HSSFColorPredefined PALE_BLUE
PINKback to summary
public static final HSSFColor.HSSFColorPredefined PINK
PLUMback to summary
public static final HSSFColor.HSSFColorPredefined PLUM
REDback to summary
public static final HSSFColor.HSSFColorPredefined RED
ROSEback to summary
public static final HSSFColor.HSSFColorPredefined ROSE
ROYAL_BLUEback to summary
public static final HSSFColor.HSSFColorPredefined ROYAL_BLUE
SEA_GREENback to summary
public static final HSSFColor.HSSFColorPredefined SEA_GREEN
SKY_BLUEback to summary
public static final HSSFColor.HSSFColorPredefined SKY_BLUE
TANback to summary
public static final HSSFColor.HSSFColorPredefined TAN
TEALback to summary
public static final HSSFColor.HSSFColorPredefined TEAL
TURQUOISEback to summary
public static final HSSFColor.HSSFColorPredefined TURQUOISE
VIOLETback to summary
public static final HSSFColor.HSSFColorPredefined VIOLET
WHITEback to summary
public static final HSSFColor.HSSFColorPredefined WHITE
YELLOWback to summary
public static final HSSFColor.HSSFColorPredefined YELLOW

Constructor Detail

HSSFColorPredefinedback to summary
private HSSFColorPredefined(int index, int index2, int rgb)

Method Detail

getColorback to summary
public HSSFColor getColor()
Returns:HSSFColor

(a copy of) the HSSFColor assigned to the enum

getHexStringback to summary
public String getHexString()
See Also
HSSFColor#getHexString()
getIndexback to summary
public short getIndex()
See Also
HSSFColor#getIndex()
getIndex2back to summary
public short getIndex2()
See Also
HSSFColor#getIndex2()
getTripletback to summary
public short[] getTriplet()
See Also
HSSFColor#getTriplet()
valueOfback to summary
public static HSSFColor.HSSFColorPredefined valueOf(String name)
valuesback to summary
public static HSSFColor.HSSFColorPredefined[] values()