Class VertAlignTextBuilder

java.lang.Object
org.refcodes.textual.VertAlignTextBuilder
All Implemented Interfaces:
org.refcodes.mixin.RowHeightAccessor, org.refcodes.mixin.RowHeightAccessor.RowHeightBuilder<VertAlignTextBuilder>, org.refcodes.mixin.RowHeightAccessor.RowHeightMutator, org.refcodes.mixin.RowHeightAccessor.RowHeightProperty, Text<VertAlignTextBuilder>, TextAccessor, TextAccessor.TextBuilder<Text<VertAlignTextBuilder>>, TextAccessor.TextMutator, TextAccessor.TextProperty, TextAccessor.TextProvider, VertAlignTextModeAccessor, VertAlignTextModeAccessor.VertAlignTextModeBuilder<VertAlignTextBuilder>, VertAlignTextModeAccessor.VertAlignTextModeMutator, VertAlignTextModeAccessor.VertAlignTextModeProperty

public class VertAlignTextBuilder
extends Object
implements org.refcodes.mixin.RowHeightAccessor.RowHeightBuilder<VertAlignTextBuilder>, org.refcodes.mixin.RowHeightAccessor.RowHeightProperty, Text<VertAlignTextBuilder>, VertAlignTextModeAccessor.VertAlignTextModeProperty, VertAlignTextModeAccessor.VertAlignTextModeBuilder<VertAlignTextBuilder>
Fills a text up on by appending the given char to the left or to the the right or inbetween till the given length is reached. How the text is aligned depends on the setting of the VertAlignTextMode attribute.
  • Constructor Details

    • VertAlignTextBuilder

      public VertAlignTextBuilder()
  • Method Details

    • withFillChar

      public VertAlignTextBuilder withFillChar​(char aFillChar)
      Sets the fill char for the fill char property.
      Parameters:
      aFillChar - The fill char to be stored by the align text mode property.
      Returns:
      The builder for applying multiple build operations.
    • withVertAlignTextMode

      public VertAlignTextBuilder withVertAlignTextMode​(VertAlignTextMode aVertAlignTextMode)
      Sets the align text mode for the align text mode property.
      Specified by:
      withVertAlignTextMode in interface VertAlignTextModeAccessor.VertAlignTextModeBuilder<VertAlignTextBuilder>
      Parameters:
      aVertAlignTextMode - The align text mode to be stored by the align text mode property.
      Returns:
      The builder for applying multiple build operations.
    • build

      public VertAlignTextBuilder build()
      This is a convenience method for easily instantiating the according builder.
      Returns:
      an instance (using a default implementation) of this builder
    • withRowHeight

      public VertAlignTextBuilder withRowHeight​(int aRowHeight)
      Specified by:
      withRowHeight in interface org.refcodes.mixin.RowHeightAccessor.RowHeightBuilder<VertAlignTextBuilder>
    • setRowHeight

      public void setRowHeight​(int aRowHeight)
      Specified by:
      setRowHeight in interface org.refcodes.mixin.RowHeightAccessor.RowHeightMutator
    • getRowHeight

      public int getRowHeight()
      Specified by:
      getRowHeight in interface org.refcodes.mixin.RowHeightAccessor
    • setVertAlignTextMode

      public void setVertAlignTextMode​(VertAlignTextMode aVertAlignTextMode)
      Sets the vertical align text mode for the vertical align text mode property.
      Specified by:
      setVertAlignTextMode in interface VertAlignTextModeAccessor.VertAlignTextModeMutator
      Parameters:
      aVertAlignTextMode - The vertical align text mode to be stored by the font style property.
    • getVertAlignTextMode

      public VertAlignTextMode getVertAlignTextMode()
      Retrieves the vertical align text mode from the vertical align text mode property.
      Specified by:
      getVertAlignTextMode in interface VertAlignTextModeAccessor
      Returns:
      The vertical align text mode stored by the vertical align text mode property.
    • getFillChar

      public char getFillChar()
      Retrieves the fill char from the fill char property.
      Returns:
      The fill char stored by the fill char property.
    • setFillChar

      public void setFillChar​(char aFillChar)
      Sets the fill char for the fill char property.
      Parameters:
      aFillChar - The fill char to be stored by the align text mode property.
    • toStrings

      public String[] toStrings()
      The Strings being build by the builder upon the settings of the attributes.
      Specified by:
      toStrings in interface TextAccessor.TextProvider
      Returns:
      The according resulting String array
    • toStrings

      public String[] toStrings​(String... aText)
      Race condition safe shortcut for using Text.withText(String...) followed by TextAccessor.TextProvider.toStrings(). Implementation requirements: This method must not(!) be implemented by calling Text.withText(String...) followed by TextAccessor.TextProvider.toStrings() (do not change the text property) as this would not be thread safe!
      Specified by:
      toStrings in interface Text<VertAlignTextBuilder>
      Parameters:
      aText - The text to be processed.
      Returns:
      The according resulting String array
    • toTextBlock

      protected static String[] toTextBlock​(String[] aTextBlock, int aHeight, char aFillChar, VertAlignTextMode aVertAlignTextMode)
      Fills up or truncates a given text block to the provided height; filling up or truncating depends on the VertAlignTextMode specified, the default is VertAlignTextMode.TOP. When filling up a line, a String filled with space (" ") characters the length of the first element in the array is used.
      Parameters:
      aTextBlock - The text block to be filled up / truncated.
      aHeight - The height of the resulting text block.
      aFillChar - the fill char
      aVertAlignTextMode - The mode on how to fill up the text block. The mode can be VertAlignTextMode.BOTTOM, VertAlignTextMode.MIDDLE or VertAlignTextMode.TOP
      Returns:
      The text block filled up / truncated to the required height.
    • getText

      public String[] getText()
      Retrieves the text from the text property.
      Specified by:
      getText in interface TextAccessor
      Returns:
      The text stored by the text property.
    • setText

      public void setText​(String... aText)
      Sets the text for the text property.
      Specified by:
      setText in interface TextAccessor.TextMutator
      Parameters:
      aText - The text to be stored by the text property.
    • withText

      public VertAlignTextBuilder withText​(String... aText)
      With text.
      Specified by:
      withText in interface Text<B extends Text<B>>
      Specified by:
      withText in interface TextAccessor.TextBuilder<B extends Text<B>>
      Parameters:
      aText - the text
      Returns:
      the b
    • withText

      public VertAlignTextBuilder withText​(Collection<String> aText)
      With text.
      Specified by:
      withText in interface TextAccessor.TextBuilder<B extends Text<B>>
      Parameters:
      aText - the text
      Returns:
      the b
    • toString

      public String toString()
      The String being build by the builder upon the settings of the attributes. In case more then one line has been set as input and the functionality of the builder is applied to each line in separate, then this method returns all of them lines concatenated with a line break between each of them (implementation depended).
      Specified by:
      toString in interface TextAccessor.TextProvider
      Overrides:
      toString in class Object
      Returns:
      The according resulting String
    • toString

      public String toString​(String... aText)
      Race condition safe shortcut for using Text.withText(String...) followed by TextAccessor.TextProvider.toString(). Implementation requirements: This method must not(!) be implemented by calling Text.withText(String...) followed by TextAccessor.TextProvider.toString() (do not change the text property) as this would not be thread safe!
      Specified by:
      toString in interface Text<B extends Text<B>>
      Parameters:
      aText - The text to be processed.
      Returns:
      The according resulting String