Class XSSFColor
- All Implemented Interfaces:
Color
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.as of 4.0.0, we want to have the indexed map, and all calling contexts have access to it.XSSFColor(byte[] rgb, IndexedColorMap colorMap) Deprecated.3.17 beta 1 - pass the workbook styles indexed color map, if anyXSSFColor(Color clr, IndexedColorMap map) TEST ONLYXSSFColor(IndexedColors indexedColor, IndexedColorMap colorMap) XSSFColor(IndexedColorMap colorMap) new color with the given indexed color mapXSSFColor(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor color) Deprecated.3.17 beta 1 - pass the workbook styles indexed color map, if anyXSSFColor(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor color, IndexedColorMap map) Deprecated.4.0.0 - use the factoryfrom(CTColor, IndexedColorMap)method instead to check for null CTColor instances. -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic XSSFColorfrom(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor color, IndexedColorMap map) byte[]getARGB()Standard Alpha Red Green Blue ctColor value (ARGB).org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColorReturns the underlying XML beanshortgetIndex()Indexed ctColor value.shortprotected byte[]byte[]getRGB()Standard Red Green Blue ctColor value (RGB).protected byte[]intgetTheme()Index into thecollection, referencing a particular or value expressed in the Theme part. doublegetTint()Specifies the tint value applied to the ctColor.booleanhasAlpha()inthashCode()booleanhasTint()booleanisAuto()A boolean value indicating the ctColor is automatic and system ctColor dependent.booleanA boolean value indicating the ctColor is IndexedbooleanisRGB()booleanisThemed()voidsetAuto(boolean auto) voidsetIndexed(int indexed) Indexed ctColor value.voidsetRGB(byte[] rgb) Standard Alpha Red Green Blue ctColor value (ARGB).voidsetTheme(int theme) Index into thecollection, referencing a particular or value expressed in the Theme part. voidsetTint(double tint) Specifies the tint value applied to the ctColor.static XSSFColortoXSSFColor(Color color) Checked type cast color to an XSSFColor.Methods inherited from class org.apache.poi.ss.usermodel.ExtendedColor
getARGBHex, getRGBOrARGB, getRGBWithTint, setARGBHex, setColor
-
Constructor Details
-
XSSFColor
@Deprecated @Removal(version="4.2") public XSSFColor(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor color) Deprecated.3.17 beta 1 - pass the workbook styles indexed color map, if anyCreate an instance of XSSFColor from the supplied XML bean, with default color indexes- Parameters:
color- TheCTColorto use as color-value.
-
XSSFColor
@Deprecated @Removal(version="4.2") public XSSFColor(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor color, IndexedColorMap map) Deprecated.4.0.0 - use the factoryfrom(CTColor, IndexedColorMap)method instead to check for null CTColor instances. Make private eventuallyCreate an instance of XSSFColor from the supplied XML bean, with the given color indexes- Parameters:
color- TheCTColorto use as color-value.map- The IndexedColorMap to use instead of the default one
-
XSSFColor
Deprecated.as of 4.0.0, we want to have the indexed map, and all calling contexts have access to it.Create an new instance of XSSFColor, without knowledge of any custom indexed colors. This is OK for just transiently setting indexes, etc. but is discouraged in read/get uses -
XSSFColor
new color with the given indexed color map- Parameters:
colorMap-
-
XSSFColor
Deprecated.3.17 beta 1 - pass the workbook styles indexed color map, if anyCreate an instance of XSSFColor from the awt Color- Parameters:
clr- awt Color
-
XSSFColor
TEST ONLY- Parameters:
clr- awt Colormap-
-
XSSFColor
- Parameters:
rgb- The RGB-byte-values for the ColorcolorMap- The IndexedColorMap to use instead of the default one
-
XSSFColor
- Parameters:
indexedColor- color index (Enum named for default colors)colorMap- The IndexedColorMap to use instead of the default one
-
-
Method Details
-
from
public static XSSFColor from(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor color, IndexedColorMap map) - Parameters:
color-map-- Returns:
- null if color is null, new instance otherwise
-
isAuto
public boolean isAuto()A boolean value indicating the ctColor is automatic and system ctColor dependent.- Specified by:
isAutoin classExtendedColor- Returns:
- true if the color is automatic
-
setAuto
public void setAuto(boolean auto) - Parameters:
auto- true if the ctColor is automatic and system ctColor dependent.
-
isIndexed
public boolean isIndexed()A boolean value indicating the ctColor is Indexed- Specified by:
isIndexedin classExtendedColor- Returns:
- true if the color is indexed
-
isRGB
public boolean isRGB()- Specified by:
isRGBin classExtendedColor- Returns:
- true if the ctColor is RGB or ARGB based
-
isThemed
public boolean isThemed()- Specified by:
isThemedin classExtendedColor- Returns:
- true if the ctColor is Theme based
-
hasAlpha
public boolean hasAlpha()- Returns:
- true if the ctColor has a alpha
-
hasTint
public boolean hasTint()- Returns:
- true if the ctColor has a tint
-
getIndex
public short getIndex()Indexed ctColor value. Only used for backwards compatibility. References a ctColor in indexedColors.- Specified by:
getIndexin classExtendedColor- Returns:
- Indexed Color index value, if
ExtendedColor.isIndexed()is true
-
getIndexed
public short getIndexed()- Returns:
- Indexed ctColor value. Only used for backwards compatibility. References a ctColor in indexedColors.
-
setIndexed
public void setIndexed(int indexed) Indexed ctColor value. Only used for backwards compatibility. References a ctColor in indexedColors.- Parameters:
indexed- color index
-
getRGB
public byte[] getRGB()Standard Red Green Blue ctColor value (RGB). If there was an A (Alpha) value, it will be stripped.- Specified by:
getRGBin classExtendedColor- Returns:
- Standard Red Green Blue ctColor value (RGB) bytes. If there was an A (Alpha) value, it will be stripped.
-
getARGB
public byte[] getARGB()Standard Alpha Red Green Blue ctColor value (ARGB).- Specified by:
getARGBin classExtendedColor- Returns:
- Standard Alpha Red Green Blue ctColor value (ARGB) bytes.
-
getStoredRBG
protected byte[] getStoredRBG()- Specified by:
getStoredRBGin classExtendedColor- Returns:
- RGB or ARGB bytes or null
-
getIndexedRGB
protected byte[] getIndexedRGB()- Specified by:
getIndexedRGBin classExtendedColor- Returns:
- index color RGB bytes, if
ExtendedColor.isIndexed()== true, null if not indexed or index is invalid
-
setRGB
public void setRGB(byte[] rgb) Standard Alpha Red Green Blue ctColor value (ARGB).- Specified by:
setRGBin classExtendedColor- Parameters:
rgb- bytes
-
getTheme
public int getTheme()Index into thecollection, referencing a particular or value expressed in the Theme part. - Specified by:
getThemein classExtendedColor- Returns:
- Index of Theme color, if
ExtendedColor.isThemed()is true
-
setTheme
public void setTheme(int theme) Index into thecollection, referencing a particular or value expressed in the Theme part. - Parameters:
theme- index
-
getTint
public 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
- Specified by:
getTintin classExtendedColor- Returns:
- the tint value
-
setTint
public 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
- Specified by:
setTintin classExtendedColor- Parameters:
tint- the tint value
-
getCTColor
Returns the underlying XML bean- Returns:
- the underlying XML bean
-
toXSSFColor
Checked type cast color to an XSSFColor.- Parameters:
color- the color to type cast- Returns:
- the type casted color
- Throws:
IllegalArgumentException- if color is null or is not an instance of XSSFColor
-
hashCode
public int hashCode() -
equals
-