java.lang.Object
org.strassburger.tui4j.formatting.layout.FlexText
All Implemented Interfaces:
Renderable

public class FlexText extends Object implements Renderable
A layout component that arranges multiple StyledText parts with flexible justification and spacing.
  • Constructor Details

    • FlexText

      public FlexText()
    • FlexText

      public FlexText(StyledText... part)
      Creates a FlexText with a single part
      Parameters:
      part - the StyledText part to add
  • Method Details

    • getParts

      public List<StyledText> getParts()
    • setParts

      public FlexText setParts(List<StyledText> parts)
    • addPart

      public FlexText addPart(StyledText part)
    • addPart

      public FlexText addPart(String text)
    • getJustify

      public FlexJustify getJustify()
    • setJustify

      public FlexText setJustify(FlexJustify justify)
      Sets the justification mode for arranging parts
      Parameters:
      justify - the FlexJustify mode
      Returns:
      the FlexText instance
    • getGap

      public int getGap()
    • setGap

      public FlexText setGap(int gap)
      Sets the fixed gap size between parts
      Parameters:
      gap - the number of separator characters to insert between parts
      Returns:
      the FlexText instance
    • getSeparatorChar

      public StyledText getSeparatorChar()
    • setSeparatorChar

      public FlexText setSeparatorChar(StyledText separatorChar)
      Sets the character(s) used for spacing between parts
      Parameters:
      separatorChar - the StyledText to use as the separator
      Returns:
      the FlexText instance
    • render

      public void render(Printer printer, int width, int height)
      Description copied from interface: Renderable
      Render the element using the given printer and dimensions
      Specified by:
      render in interface Renderable
      Parameters:
      printer - the printer to use
      width - the available width
      height - the available height
    • keyValue

      public static FlexText keyValue(String key, String value)
      Creates a FlexText representing a key-value pair with a clear line separation
      Parameters:
      key - the key string
      value - the value string
      Returns:
      the constructed FlexText
    • keyValue

      public static FlexText keyValue(StyledText key, StyledText value)
      Creates a FlexText representing a key-value pair with a clear line separation
      Parameters:
      key - the key StyledText
      value - the value StyledText
      Returns:
      the constructed FlexText