Class ExcelColor
java.lang.Object
com.northconcepts.datapipeline.excel.ExcelColor
Represents a color that can be used in Excel cells.
Colors can be created from RGB values or from Excel color palette indexes.
Provides methods to darken or lighten colors and convert between different color representations.
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionExcelColor(int red, int green, int blue) Creates an ExcelColor from RGB components.protectedExcelColor(Integer excelColorPaletteIndex, Integer red, Integer green, Integer blue) Creates an ExcelColor with the specified palette index and RGB components. -
Method Summary
Modifier and TypeMethodDescriptiondarken(double factor) Darkens a color.booleanstatic ExcelColorfromIndex(int index) Creates an ExcelColor from an Excel color palette index.static ExcelColorfromRgb(byte[] rgb) Creates an ExcelColor from an RGB byte array.getBlue()Gets the blue component of this color.Gets the Excel color palette index if this color matches a palette color.getGreen()Gets the green component of this color.getHex()Gets the color as a hexadecimal string (e.g., "#RRGGBB").getRed()Gets the red component of this color.getRgb()Gets the RGB value as a single integer (0xRRGGBB format).inthashCode()lighten(double factor) Lightens a color.toString()
-
Constructor Details
-
ExcelColor
Creates an ExcelColor with the specified palette index and RGB components. This is a protected constructor used internally.- Parameters:
excelColorPaletteIndex- the Excel color palette index, may be nullred- the red component (0-255), may be nullgreen- the green component (0-255), may be nullblue- the blue component (0-255), may be null
-
ExcelColor
public ExcelColor(int red, int green, int blue) Creates an ExcelColor from RGB components. Automatically determines the corresponding Excel color palette index if available.- Parameters:
red- the red component (0-255)green- the green component (0-255)blue- the blue component (0-255)
-
-
Method Details
-
fromRgb
Creates an ExcelColor from an RGB byte array.- Parameters:
rgb- a 3-byte array containing red, green, and blue components (0-255)- Returns:
- an ExcelColor instance
- Throws:
DataException- if rgb is null or does not contain exactly 3 bytes
-
fromIndex
Creates an ExcelColor from an Excel color palette index.- Parameters:
index- the Excel color palette index- Returns:
- an ExcelColor instance, or null if the index is not in the palette
-
getExcelColorPaletteIndex
Gets the Excel color palette index if this color matches a palette color.- Returns:
- the palette index, or null if this color is not in the palette
-
getRed
Gets the red component of this color.- Returns:
- the red component (0-255), or null if not set
-
getGreen
Gets the green component of this color.- Returns:
- the green component (0-255), or null if not set
-
getBlue
Gets the blue component of this color.- Returns:
- the blue component (0-255), or null if not set
-
getRgb
Gets the RGB value as a single integer (0xRRGGBB format).- Returns:
- the RGB value, or null if red is not set
-
getHex
Gets the color as a hexadecimal string (e.g., "#RRGGBB").- Returns:
- the hex color string, or null if red is not set
-
hashCode
public int hashCode() -
darken
Darkens a color.- Parameters:
factor- a value between 0.0 and 1.0- Returns:
- a new instance of ExcelColor with the factor applied.
-
lighten
Lightens a color.- Parameters:
factor- a value between 0.0 and 1.0- Returns:
- a new instance of ExcelColor with the factor applied.
-
equals
-
toString
-