Class Style

java.lang.Object
com.github.miachm.sods.Style
All Implemented Interfaces:
Cloneable

public final class Style extends Object implements Cloneable
This a class which represents the formatting of a cell (background color, font size, font style, etc...)
  • 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

      public Color getFontColor()
      Returns the font color.
      Returns:
      The font color. It can be null if it doesn't have a setted font color
    • getBackgroundColor

      public 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

      public void addCondition(ConditionalFormat format)
      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

      public List<ConditionalFormat> 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

      public void setBackgroundColor(Color backgroundColor)
      Set the background color
      Parameters:
      backgroundColor - The background color of the cell. It can be null.
    • setFontColor

      public void setFontColor(Color fontColor)
      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

      public Borders getBorders()
      Returns the borders properties.
      Returns:
      Borders properties
    • setBorders

      public void setBorders(Borders borders)
      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

      public void setTextAligment(Style.TEXT_ALIGMENT p)
      Set text's aligment of the cell's text.
      Parameters:
      p - Style.TEXT_ALIGMENT Left, Center, Right
    • getTextAligment

      public Style.TEXT_ALIGMENT getTextAligment()
      Get text aligment of the cell
      Returns:
      p Style.TEXT_ALIGMENT Left, Center, Right
    • setVerticalTextAligment

      public void setVerticalTextAligment(Style.VERTICAL_TEXT_ALIGMENT p)
      Set text's aligment of the cell's text in a vertical axis.
      Parameters:
      p - Style.VERTICAL_TEXT_ALIGMENT Top, Middle, Bottom
    • getVerticalTextAligment

      public Style.VERTICAL_TEXT_ALIGMENT getVerticalTextAligment()
      Get the vertical text aligment of the cell
      Returns:
      p Style.VERTICAL_TEXT_ALIGMENT Top, Middle, Bottom
    • getDataStyle

      public String getDataStyle()
      Returns the data style. This property is not populated when reading a spreadsheet.
      Returns:
      null, @, or YYYY-MM-DD
      See Also:
    • setDataStyle

      public void setDataStyle(String dataStyle)
      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, @, or YYYY-MM-DD
    • clone

      public Object clone() throws CloneNotSupportedException
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getCssStyles

      public Map<String,String> 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

      public String 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;
      Overrides:
      toString in class Object
      Returns:
      A String with the CSS representation of this class
    • toString

      public String toString(String prefix)
      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