Class UI

java.lang.Object
javatro.display.UI

public class UI extends Object
The UI class is responsible for managing and displaying different screens in the application. It handles user input, manages screen transitions, and notifies observers of user actions. This class follows the Singleton pattern to ensure a single instance manages all display-related operations.
  • Field Details

  • Constructor Details

    • UI

      public UI()
  • Method Details

    • printBlackB

      public static void printBlackB(String input)
      Prints text with a black background using ANSI escape codes.
      Parameters:
      input - The text to be printed with black background
    • printBorderedContent

      public static void printBorderedContent(String title, List<String> content)
      Prints a bordered message or menu with a title and dynamically generated content.
      Parameters:
      title - The title of the message or menu
      content - A list of content lines
    • printBorderedContent

      public static void printBorderedContent(String title, List<String> content, int titleWidth, int contentWidth)
      Prints a bordered message or menu with customizable widths for title and content.
      Parameters:
      title - The title of the message or menu
      content - A list of content lines
      titleWidth - The width of the title section
      contentWidth - The width of the content section
    • centerText

      public static String centerText(String text, int width)
      Centers text within a specified width, accounting for ANSI codes and Unicode characters.
      Parameters:
      text - The text to center
      width - The total available width
      Returns:
      The centered text surrounded by border characters
    • padToWidth

      public static String padToWidth(String text, int width)
      Truncates or pads a string to exactly the specified display width.
      Parameters:
      text - The input text
      width - The desired display width
      Returns:
      The adjusted string
    • getDisplayLength

      public static int getDisplayLength(String text)
      Calculates the visible length of text, ignoring ANSI codes and special Unicode characters.
      Parameters:
      text - The text to measure
      Returns:
      The effective display length
    • getCardArtLines

      public static List<String> getCardArtLines(List<Card> holdingHand)
      Generates ASCII art lines for displaying cards.
      Parameters:
      holdingHand - The list of cards to render
      Returns:
      List of strings representing card art lines
    • printANSI

      public static void printANSI(String fileName)
      Prints ANSI art from a resource file.
      Parameters:
      fileName - The name of the file in the ansi resources directory
    • setCurrentScreen

      public void setCurrentScreen(Screen screen) throws JavatroException
      Transitions to a new screen and updates display.
      Parameters:
      screen - The screen to display
      Throws:
      JavatroException - if the screen is null
    • clearScreen

      public static void clearScreen()
      Clears the console using ANSI escape codes.
    • getCurrentScreen

      public static Screen getCurrentScreen()
      Returns:
      The current active screen
    • getPreviousScreen

      public static Screen getPreviousScreen()
      Returns:
      The previously active screen
    • getParser

      public static Parser getParser()
      Returns:
      The input parser instance
    • getDiscardScreen

      public static DiscardCardScreen getDiscardScreen()
    • getPlayScreen

      public static PlayCardScreen getPlayScreen()
    • getGameScreen

      public static GameScreen getGameScreen()
    • getStartScreen

      public static StartScreen getStartScreen()
    • getHelpScreen

      public static HelpScreen getHelpScreen()
    • getPokerHandScreen

      public static PokerHandScreen getPokerHandScreen()
    • getDeckViewScreen

      public static DeckViewScreen getDeckViewScreen()
    • getDeckSelectScreen

      public static DeckSelectScreen getDeckSelectScreen()
    • getWinRoundScreen

      public static WinRoundScreen getWinRoundScreen()
    • getWinGameScreen

      public static WinGameScreen getWinGameScreen()
    • getLoseScreen

      public static LoseScreen getLoseScreen()
    • getRunSelectScreen

      public static RunSelectScreen getRunSelectScreen()
    • reloadRunSelectScreen

      public static void reloadRunSelectScreen()
    • reloadJumpToRunScreen

      public static void reloadJumpToRunScreen()
    • getJumpToRunScreen

      public static RunListScreen getJumpToRunScreen()
    • getBlindScreen

      public static BlindSelectScreen getBlindScreen()
      Returns:
      The blind selection screen instance