Class TextStyle

java.lang.Object
dk.gtz.graphedit.view.log.TextStyle

public class TextStyle extends Object
Holds information about the style of a text fragment.
  • Field Details

    • EMPTY

      public static final TextStyle EMPTY
      A text style with only default values
    • WHITE

      public static final TextStyle WHITE
      A text style using white text color
  • Constructor Details

    • TextStyle

      public TextStyle()
      Construct a new text style instance
    • TextStyle

      public TextStyle(Optional<Boolean> bold, Optional<Boolean> italic, Optional<Boolean> underline, Optional<Boolean> strikethrough, Optional<Integer> fontSize, Optional<String> fontFamily, Optional<String> textColor, Optional<String> backgroundColor)
      Construct a new text style istance
      Parameters:
      bold - Should the text be bold
      italic - Should the text be italic
      underline - Should the text be underlined
      strikethrough - Should the text be strikethrough
      fontSize - Text size of the text style
      fontFamily - The font to use
      textColor - The css color to use
      backgroundColor - The css background color to use
  • Method Details

    • randomTextColor

      public static TextStyle randomTextColor()
      Create a new text style with a random text color
      Returns:
      A new randomly colored text style
    • cssColor

      public static String cssColor(javafx.scene.paint.Color color)
      Create a new text style with a specified text color
      Parameters:
      color - The color to use
      Returns:
      A new colored text style
    • hashCode

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

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toCss

      public String toCss()
      Convert the current settings into one big javafx css expression
      Returns:
      A new css expression string
    • updateWith

      public TextStyle updateWith(TextStyle mixin)
      Mix / merge a different text style with this one.
      Parameters:
      mixin - The other text style to merge with
      Returns:
      A new merged / mixed text style
    • setBold

      public TextStyle setBold(boolean bold)
      Set the bold attribute of the text style
      Parameters:
      bold - Whether or not the text should be bold
      Returns:
      a new text style
    • setItalic

      public TextStyle setItalic(boolean italic)
      Set the italic attribute of the text style
      Parameters:
      italic - Whether or not the text should be italic
      Returns:
      a new text style
    • setUnderline

      public TextStyle setUnderline(boolean underline)
      Set the underline attribute of the text style
      Parameters:
      underline - Whether or not the text should be underlined
      Returns:
      a new text style
    • setStrikethrough

      public TextStyle setStrikethrough(boolean strikethrough)
      Set the strikethrough attribute of the text style
      Parameters:
      strikethrough - Whether or not the text should be strikethrough
      Returns:
      a new text style
    • setFontSize

      public TextStyle setFontSize(int fontSize)
      Set the font size attribute of the text style
      Parameters:
      fontSize - The size (in pt's) of the text
      Returns:
      a new text style
    • setFontFamily

      public TextStyle setFontFamily(String fontFamily)
      Set the font of the text style
      Parameters:
      fontFamily - The font to use
      Returns:
      a new text style
    • setTextColor

      public TextStyle setTextColor(String textColor)
      Set the text color attribute of the text style
      Parameters:
      textColor - The new color of the text
      Returns:
      a new text style
    • setTextColorWeb

      public TextStyle setTextColorWeb(String webColor)
      Set the text color attribute of the text style using hex-codes
      Parameters:
      webColor - Hexcode formatted color of the text
      Returns:
      a new text style
    • setBackgroundColor

      public TextStyle setBackgroundColor(String backgroundColor)
      Set the text background color attribute of the text style
      Parameters:
      backgroundColor - The new background color of the text
      Returns:
      a new text style