Package com.github.miachm.sods
Class Style
java.lang.Object
com.github.miachm.sods.Style
- All Implemented Interfaces:
Cloneable
This a class which represents the formatting of a cell (background color, font size, font style, etc...)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDefines the text position of a Cellstatic enumDefines the text position of a Cell in a vertical axis -
Constructor Summary
ConstructorsConstructorDescriptionStyle()Constructs an empty-default Style.Style(boolean bold, boolean italic, boolean underline, Color fontColor, Color backgroundColor, int fontSize) Deprecated.Style(boolean bold, boolean italic, boolean underline, Color fontColor, Color backgroundColor, int fontSize, Borders borders, boolean wrap) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCondition(ConditionalFormat format) Add a conditional format subrule in the style.clone()booleanReturns the cell background color.Returns the borders properties.Get a list of all conditional format rules Conditional format rules are specific properties which are applied if the cell fullfills a specific conditionReturns a Map representing this class as css-styles.Returns the data style.Returns the font color.intReturns the font sizeGet text aligment of the cellGet the vertical text aligment of the cellbooleanTells if the style has any border.inthashCode()booleanTells whether the style has table cell properties.booleanisBold()Determines if the font has bold style or not.booleanDetermine if this has default rules or notbooleanisItalic()Determines if the font has italic style or not.booleanReturns if the font has a underline style or notbooleanisWrap()Gets the wrapping nature.voidremoveCondition(int i) Remove a specific condition rule in an indexvoidsetBackgroundColor(Color backgroundColor) Set the background colorvoidsetBold(boolean bold) Set a bold font stylevoidsetBorders(Borders borders) Sets the borders properties.voidsetDataStyle(String dataStyle) Sets the data style that tells office software how to interpret and format content entered into a cell.voidsetFontColor(Color fontColor) Set the font colorvoidsetFontSize(int fontSize) Sets the font sizevoidsetItalic(boolean italic) Set a italic font stylevoidSet text's aligment of the cell's text.voidsetUnderline(boolean underline) Set a underline font stylevoidSet text's aligment of the cell's text in a vertical axis.voidsetWrap(boolean wrap) Sets the wrapping nature.toString()Returns a String of this class in a CSS way.Overloaded method of toString(), it allows a slight customization in the output.
-
Constructor Details
-
Style
public Style()Constructs an empty-default Style. -
Style
@Deprecated public Style(boolean bold, boolean italic, boolean underline, Color fontColor, Color backgroundColor, int fontSize) Deprecated. -
Style
@Deprecated public Style(boolean bold, boolean italic, boolean underline, Color fontColor, Color backgroundColor, int fontSize, Borders borders, boolean wrap) Deprecated.
-
-
Method Details
-
isDefault
public boolean isDefault()Determine if this has default rules or not- Returns:
- True if the style is not modified.
-
isBold
public boolean isBold()Determines if the font has bold style or not.- Returns:
- True if the font has bold style
-
isItalic
public boolean isItalic()Determines if the font has italic style or not.- Returns:
- True if the font has italic style
-
getFontColor
Returns the font color.- Returns:
- The font color. It can be null if it doesn't have a setted font color
-
getBackgroundColor
Returns the cell background color.- Returns:
- The background color. It can be null if it doesn't have a setted background color
-
getFontSize
public int getFontSize()Returns the font size- Returns:
- The font size. It will be -1 if it doesn't have a setted font size
-
addCondition
Add a conditional format subrule in the style. Conditional format rules are specific properties which are applied if the cell fullfills a specific condition- Parameters:
format- The conditional format rule to be added
-
getConditions
Get a list of all conditional format rules Conditional format rules are specific properties which are applied if the cell fullfills a specific condition- Returns:
- The list of conditional format rule to be added
-
removeCondition
public void removeCondition(int i) Remove a specific condition rule in an index- Parameters:
i- The index of the condition rule.- Throws:
IndexOutOfBoundsException- if the index is invalid
-
setBackgroundColor
Set the background color- Parameters:
backgroundColor- The background color of the cell. It can be null.
-
setFontColor
Set the font color- Parameters:
fontColor- The font color of the cell. It can be null.
-
setBold
public void setBold(boolean bold) Set a bold font style- Parameters:
bold- True for sets a bold style font.
-
setItalic
public void setItalic(boolean italic) Set a italic font style- Parameters:
italic- True for sets a italic style font.
-
isUnderline
public boolean isUnderline()Returns if the font has a underline style or not- Returns:
- Returns true if the font has an underline style
-
setUnderline
public void setUnderline(boolean underline) Set a underline font style- Parameters:
underline- True for sets a underline style font.
-
setFontSize
public void setFontSize(int fontSize) Sets the font size- Parameters:
fontSize- The font size to set. It must be greater of -1, a -1 value indicates no font size.- Throws:
IllegalArgumentException- if the font size is less of -1
-
getBorders
Returns the borders properties.- Returns:
- Borders properties
-
setBorders
Sets the borders properties.- Parameters:
borders- Borders properties.
-
isWrap
public boolean isWrap()Gets the wrapping nature.- Returns:
- true if the text must be wrapped inside the cell, false otherwise.
-
setWrap
public void setWrap(boolean wrap) Sets the wrapping nature.- Parameters:
wrap- Specifies if the text must be wrapped inside the cell.
-
hasTableCellProperties
public boolean hasTableCellProperties()Tells whether the style has table cell properties.- Returns:
- true if the style has table cell properties, false otherwise.
-
hasBorders
public boolean hasBorders()Tells if the style has any border.- Returns:
- true if the style has any border, false otherwise.
-
setTextAligment
Set text's aligment of the cell's text.- Parameters:
p-Style.TEXT_ALIGMENTLeft, Center, Right
-
getTextAligment
Get text aligment of the cell- Returns:
- p
Style.TEXT_ALIGMENTLeft, Center, Right
-
setVerticalTextAligment
Set text's aligment of the cell's text in a vertical axis.- Parameters:
p-Style.VERTICAL_TEXT_ALIGMENTTop, Middle, Bottom
-
getVerticalTextAligment
Get the vertical text aligment of the cell- Returns:
- p
Style.VERTICAL_TEXT_ALIGMENTTop, Middle, Bottom
-
getDataStyle
Returns the data style. This property is not populated when reading a spreadsheet.- Returns:
null,@, orYYYY-MM-DD- See Also:
-
setDataStyle
Sets the data style that tells office software how to interpret and format content entered into a cell. At the moment, only the following data styles are supported:null, which is the default value and permits interpretation.@, which forces all content to be interpreted as plain text.YYYY-MM-DD, which formats dates in the ISO style.
- Parameters:
dataStyle-null,@, orYYYY-MM-DD
-
clone
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
equals
-
hashCode
public int hashCode() -
getCssStyles
Returns a Map representing this class as css-styles. For example, if you setted a bold font and a italic font. You will get a Map with 2 keys: font-weight = bold font-style = italic- Returns:
- A map with the CSS representation of this class
-
toString
Returns a String of this class in a CSS way. For example, if you setted a bold font and a italic font. You will get: font-weight: bold; font-style: italic; -
toString
Overloaded method of toString(), it allows a slight customization in the output.style.setBold(true); style.setItalic(true); style.toString("-fx-"); // It returns: // // -fx-font-weight: bold; // -fx-font-style: italic;- Parameters:
prefix- a prefix to add in every CSS key. For example: "-fx-"- Returns:
- A String with the CSS representation of this class
-