Package ch.rabanti.nanoxlsx4j.styles
Class Fill
java.lang.Object
ch.rabanti.nanoxlsx4j.styles.AbstractStyle
ch.rabanti.nanoxlsx4j.styles.Fill
- All Implemented Interfaces:
Comparable<AbstractStyle>
Class representing a Fill (background) entry. The Fill entry is used to define background colors and fill patterns
- Author:
- Raphael Stoeckli
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum for the type of the fillstatic enumEnum for the type of the fill pattern -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault Color (foreground or background)static final intDefault index colorstatic final Fill.PatternValueDefault patternint -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopy()Method to copy the current object to a new oneGets the Background color of the fill.Gets the foreground color of the fill.intGets the indexed color (Default is 64)Gets the pattern type of the fill (Default is none)static StringgetPatternName(Fill.PatternValue pattern) Gets the pattern name from the enuminthashCode()Override method to calculate the hash of this componentvoidsetBackgroundColor(String backgroundColor) Sets the background color of the fill.voidsetColor(String value, Fill.FillType fillType) Sets the color and the depending on fill typevoidsetForegroundColor(String foregroundColor) Sets the foreground color of the fill.voidsetIndexedColor(int indexedColor) Sets the indexed color (Default is 64)voidsetPatternFill(Fill.PatternValue patternFill) Sets the pattern type of the fill (Default is none)toString()Override toString methodstatic voidvalidateColor(String hexCode, boolean useAlpha) Validates the passed string, whether it is a valid RGB value that can be used for Fills or Fontsstatic voidvalidateColor(String hexCode, boolean useAlpha, boolean allowEmpty) Validates the passed string, whether it is a valid RGB value that can be used for Fills or FontsMethods inherited from class ch.rabanti.nanoxlsx4j.styles.AbstractStyle
compareTo, equals, getInternalID, setInternalID
-
Field Details
-
DEFAULT_COLOR
Default Color (foreground or background)- See Also:
-
DEFAULT_INDEXED_COLOR
public static final int DEFAULT_INDEXED_COLORDefault index color- See Also:
-
DEFAULT_PATTERN_FILL
Default pattern -
indexedColor
public int indexedColor -
patternFill
-
foregroundColor
-
backgroundColor
-
-
Constructor Details
-
Fill
public Fill()Default constructor -
Fill
Constructor with foreground and background color- Parameters:
foreground- Foreground color of the fillbackground- Background color of the fill
-
Fill
Constructor with color value and fill type- Parameters:
value- Color valuefillType- Fill type (fill or pattern)
-
-
Method Details
-
getIndexedColor
public int getIndexedColor()Gets the indexed color (Default is 64)- Returns:
- Indexed color
-
setIndexedColor
public void setIndexedColor(int indexedColor) Sets the indexed color (Default is 64)- Parameters:
indexedColor- Indexed color
-
getPatternFill
Gets the pattern type of the fill (Default is none)- Returns:
- Pattern type of the fill
-
setPatternFill
Sets the pattern type of the fill (Default is none)- Parameters:
patternFill- Pattern type of the fill
-
getForegroundColor
Gets the foreground color of the fill. The value is expressed as hex string with the format AARRGGBB. AA (Alpha) is usually FF- Returns:
- Foreground color of the fill
-
setForegroundColor
Sets the foreground color of the fill. The value is expressed as hex string with the format AARRGGBB. AA (Alpha) is usually FF- Parameters:
foregroundColor- Foreground color of the fill
-
getBackgroundColor
Gets the Background color of the fill. The value is expressed as hex string with the format AARRGGBB. AA (Alpha) is usually FF- Returns:
- Background color of the fill
-
setBackgroundColor
Sets the background color of the fill. The value is expressed as hex string with the format AARRGGBB. AA (Alpha) is usually FF- Parameters:
backgroundColor- Background color of the fill
-
setColor
Sets the color and the depending on fill type- Parameters:
value- Color valuefillType- Fill type (fill or pattern)
-
toString
Override toString method -
copy
Method to copy the current object to a new one- Specified by:
copyin classAbstractStyle- Returns:
- Copy of the current object without the internal ID
-
hashCode
public int hashCode()Override method to calculate the hash of this component -
getPatternName
Gets the pattern name from the enum- Parameters:
pattern- Enum to process- Returns:
- The valid value of the pattern as String
-
validateColor
Validates the passed string, whether it is a valid RGB value that can be used for Fills or Fonts- Parameters:
hexCode- Hex string to checkuseAlpha- If true, two additional characters (total 8) are expected as alpha value- Throws:
StyleException- thrown if an invalid hex value is passed
-
validateColor
Validates the passed string, whether it is a valid RGB value that can be used for Fills or Fonts- Parameters:
hexCode- Hex string to checkuseAlpha- If true, two additional characters (total 8) are expected as alpha valueallowEmpty- Optional parameter that allows null or empty as valid values- Throws:
StyleException- thrown if an invalid hex value is passed
-