Interface TextGUIGraphics

    • Method Detail

      • getTextGUI

        TextGUI getTextGUI()
        Returns the TextGUI this TextGUIGraphics belongs to
        Returns:
        TextGUI this TextGUIGraphics belongs to
      • newTextGraphics

        TextGUIGraphics newTextGraphics​(TerminalPosition topLeftCorner,
                                        TerminalSize size)
                                 throws java.lang.IllegalArgumentException
        Description copied from interface: TextGraphics
        Creates a new TextGraphics of the same type as this one, using the same underlying subsystem. Using this method, you need to specify a section of the current TextGraphics valid area that this new TextGraphic shall be restricted to. If you call newTextGraphics(TerminalPosition.TOP_LEFT_CORNER, textGraphics.getSize()) then the resulting object will be identical to this one, but having a separated state for colors, position and modifiers.
        Specified by:
        newTextGraphics in interface TextGraphics
        Parameters:
        topLeftCorner - Position of this TextGraphics's writable area that is to become the top-left corner (0x0) of the new TextGraphics
        size - How large area, counted from the topLeftCorner, the new TextGraphics can write to. This cannot be larger than the current TextGraphics's writable area (adjusted by topLeftCorner)
        Returns:
        A new TextGraphics with the same underlying subsystem, that can write to only the specified area
        Throws:
        java.lang.IllegalArgumentException - If the size the of new TextGraphics exceeds the dimensions of this TextGraphics in any way.
      • applyThemeStyle

        TextGUIGraphics applyThemeStyle​(ThemeStyle themeStyle)
        Description copied from interface: ThemedTextGraphics
        Takes a ThemeStyle as applies it to this TextGraphics. This will effectively set the foreground color, the background color and all the SGRs.
        Specified by:
        applyThemeStyle in interface ThemedTextGraphics
        Parameters:
        themeStyle - ThemeStyle to apply
        Returns:
        Itself
      • enableModifiers

        TextGUIGraphics enableModifiers​(SGR... modifiers)
        Description copied from interface: StyleSet
        Adds zero or more modifiers to the set of currently active modifiers
        Specified by:
        enableModifiers in interface StyleSet<TextGraphics>
        Parameters:
        modifiers - Modifiers to add to the set of currently active modifiers
        Returns:
        Itself
      • disableModifiers

        TextGUIGraphics disableModifiers​(SGR... modifiers)
        Description copied from interface: StyleSet
        Removes zero or more modifiers from the set of currently active modifiers
        Specified by:
        disableModifiers in interface StyleSet<TextGraphics>
        Parameters:
        modifiers - Modifiers to remove from the set of currently active modifiers
        Returns:
        Itself
      • setModifiers

        TextGUIGraphics setModifiers​(java.util.EnumSet<SGR> modifiers)
        Description copied from interface: StyleSet
        Sets the active modifiers to exactly the set passed in to this method. Any previous state of which modifiers are enabled doesn't matter.
        Specified by:
        setModifiers in interface StyleSet<TextGraphics>
        Parameters:
        modifiers - Modifiers to set as active
        Returns:
        Itself
      • setTabBehaviour

        TextGUIGraphics setTabBehaviour​(TabBehaviour tabBehaviour)
        Description copied from interface: TextGraphics
        Sets the behaviour to use when expanding tab characters (\t) to spaces
        Specified by:
        setTabBehaviour in interface TextGraphics
        Parameters:
        tabBehaviour - Behaviour to use when expanding tabs to spaces
        Returns:
        Itself
      • fill

        TextGUIGraphics fill​(char c)
        Description copied from interface: TextGraphics
        Fills the entire writable area with a single character, using current foreground color, background color and modifiers.
        Specified by:
        fill in interface TextGraphics
        Parameters:
        c - Character to fill the writable area with
        Returns:
        Itself
      • fillRectangle

        TextGUIGraphics fillRectangle​(TerminalPosition topLeft,
                                      TerminalSize size,
                                      char character)
        Description copied from interface: TextGraphics
        Takes a rectangle and fills it with a particular character (and the currently active colors and modifiers). The topLeft coordinate is inclusive.

        For example, calling fillRectangle with size being the size of the terminal and top-left value being the terminal's top-left (0x0) corner will fill the entire terminal with this character.

        The current foreground color, background color and modifiers will be applied.

        Specified by:
        fillRectangle in interface TextGraphics
        Parameters:
        topLeft - Coordinates of the top-left position of the rectangle
        size - Size (in columns and rows) of the area to draw
        character - What character to use when filling the rectangle
        Returns:
        Itself
      • fillRectangle

        TextGUIGraphics fillRectangle​(TerminalPosition topLeft,
                                      TerminalSize size,
                                      TextCharacter character)
        Description copied from interface: TextGraphics
        Takes a rectangle and fills it using a particular TextCharacter, ignoring the current colors and modifiers of this TextGraphics. The topLeft coordinate is inclusive.

        For example, calling fillRectangle with size being the size of the terminal and top-left value being the terminal's top-left (0x0) corner will fill the entire terminal with this character.

        The current foreground color, background color and modifiers will not be modified by this call.

        Specified by:
        fillRectangle in interface TextGraphics
        Parameters:
        topLeft - Coordinates of the top-left position of the rectangle
        size - Size (in columns and rows) of the area to draw
        character - What character data to use when filling the rectangle
        Returns:
        Itself
      • drawRectangle

        TextGUIGraphics drawRectangle​(TerminalPosition topLeft,
                                      TerminalSize size,
                                      char character)
        Description copied from interface: TextGraphics
        Draws the outline of a rectangle with a particular character (and the currently active colors and modifiers). The topLeft coordinate is inclusive.

        For example, calling drawRectangle with size being the size of the terminal and top-left value being the terminal's top-left (0x0) corner will draw a border around the terminal.

        The current foreground color, background color and modifiers will be applied.

        Specified by:
        drawRectangle in interface TextGraphics
        Parameters:
        topLeft - Coordinates of the top-left position of the rectangle
        size - Size (in columns and rows) of the area to draw
        character - What character to use when drawing the outline of the rectangle
        Returns:
        Itself
      • drawRectangle

        TextGUIGraphics drawRectangle​(TerminalPosition topLeft,
                                      TerminalSize size,
                                      TextCharacter character)
        Description copied from interface: TextGraphics
        Draws the outline of a rectangle with a particular TextCharacter, ignoring the current colors and modifiers of this TextGraphics.

        For example, calling drawRectangle with size being the size of the terminal and top-left value being the terminal's top-left (0x0) corner will draw a border around the terminal.

        The current foreground color, background color and modifiers will not be modified by this call.

        Specified by:
        drawRectangle in interface TextGraphics
        Parameters:
        topLeft - Coordinates of the top-left position of the rectangle
        size - Size (in columns and rows) of the area to draw
        character - What character data to use when drawing the outline of the rectangle
        Returns:
        Itself
      • fillTriangle

        TextGUIGraphics fillTriangle​(TerminalPosition p1,
                                     TerminalPosition p2,
                                     TerminalPosition p3,
                                     char character)
        Description copied from interface: TextGraphics
        Draws a filled triangle, using a supplied character. The triangle will begin at p1, go through p2 and then p3 and then back to p1. The current foreground color, background color and modifiers will be applied.
        Specified by:
        fillTriangle in interface TextGraphics
        Parameters:
        p1 - First point on the screen of the triangle
        p2 - Second point on the screen of the triangle
        p3 - Third point on the screen of the triangle
        character - What character to use when drawing the triangle
        Returns:
        Itself
      • fillTriangle

        TextGUIGraphics fillTriangle​(TerminalPosition p1,
                                     TerminalPosition p2,
                                     TerminalPosition p3,
                                     TextCharacter character)
        Description copied from interface: TextGraphics
        Draws a filled triangle, using a supplied character. The triangle will begin at p1, go through p2 and then p3 and then back to p1. The current foreground color, background color and modifiers of this TextGraphics will not be used and will not be modified by this call.
        Specified by:
        fillTriangle in interface TextGraphics
        Parameters:
        p1 - First point on the screen of the triangle
        p2 - Second point on the screen of the triangle
        p3 - Third point on the screen of the triangle
        character - What character data to use when drawing the triangle
        Returns:
        Itself
      • drawTriangle

        TextGUIGraphics drawTriangle​(TerminalPosition p1,
                                     TerminalPosition p2,
                                     TerminalPosition p3,
                                     char character)
        Description copied from interface: TextGraphics
        Draws the outline of a triangle on the screen, using a supplied character. The triangle will begin at p1, go through p2 and then p3 and then back to p1. The current foreground color, background color and modifiers will be applied.
        Specified by:
        drawTriangle in interface TextGraphics
        Parameters:
        p1 - First point on the screen of the triangle
        p2 - Second point on the screen of the triangle
        p3 - Third point on the screen of the triangle
        character - What character to use when drawing the lines of the triangle
        Returns:
        Itself
      • drawTriangle

        TextGUIGraphics drawTriangle​(TerminalPosition p1,
                                     TerminalPosition p2,
                                     TerminalPosition p3,
                                     TextCharacter character)
        Description copied from interface: TextGraphics
        Draws the outline of a triangle on the screen, using a supplied character. The triangle will begin at p1, go through p2 and then p3 and then back to p1. The current foreground color, background color and modifiers of this TextGraphics will not be used and will not be modified by this call.
        Specified by:
        drawTriangle in interface TextGraphics
        Parameters:
        p1 - First point on the screen of the triangle
        p2 - Second point on the screen of the triangle
        p3 - Third point on the screen of the triangle
        character - What character data to use when drawing the lines of the triangle
        Returns:
        Itself
      • drawLine

        TextGUIGraphics drawLine​(TerminalPosition fromPoint,
                                 TerminalPosition toPoint,
                                 char character)
        Description copied from interface: TextGraphics
        Draws a line from a specified position to a specified position, using a supplied character. The current foreground color, background color and modifiers will be applied.
        Specified by:
        drawLine in interface TextGraphics
        Parameters:
        fromPoint - From where to draw the line
        toPoint - Where to draw the line
        character - Character to use for the line
        Returns:
        Itself
      • drawLine

        TextGUIGraphics drawLine​(TerminalPosition fromPoint,
                                 TerminalPosition toPoint,
                                 TextCharacter character)
        Description copied from interface: TextGraphics
        Draws a line from a specified position to a specified position, using a supplied TextCharacter. The current foreground color, background color and modifiers of this TextGraphics will not be used and will not be modified by this call.
        Specified by:
        drawLine in interface TextGraphics
        Parameters:
        fromPoint - From where to draw the line
        toPoint - Where to draw the line
        character - Character data to use for the line, including character, colors and modifiers
        Returns:
        Itself
      • drawLine

        TextGUIGraphics drawLine​(int fromX,
                                 int fromY,
                                 int toX,
                                 int toY,
                                 char character)
        Description copied from interface: TextGraphics
        Draws a line from a specified position to a specified position, using a supplied character. The current foreground color, background color and modifiers will be applied.
        Specified by:
        drawLine in interface TextGraphics
        Parameters:
        fromX - Column of the starting position to draw the line from (inclusive)
        fromY - Row of the starting position to draw the line from (inclusive)
        toX - Column of the end position to draw the line to (inclusive)
        toY - Row of the end position to draw the line to (inclusive)
        character - Character to use for the line
        Returns:
        Itself
      • drawLine

        TextGUIGraphics drawLine​(int fromX,
                                 int fromY,
                                 int toX,
                                 int toY,
                                 TextCharacter character)
        Description copied from interface: TextGraphics
        Draws a line from a specified position to a specified position, using a supplied character. The current foreground color, background color and modifiers of this TextGraphics will not be used and will not be modified by this call.
        Specified by:
        drawLine in interface TextGraphics
        Parameters:
        fromX - Column of the starting position to draw the line from (inclusive)
        fromY - Row of the starting position to draw the line from (inclusive)
        toX - Column of the end position to draw the line to (inclusive)
        toY - Row of the end position to draw the line to (inclusive)
        character - Character data to use for the line, including character, colors and modifiers
        Returns:
        Itself
      • drawImage

        TextGUIGraphics drawImage​(TerminalPosition topLeft,
                                  TextImage image)
        Description copied from interface: TextGraphics
        Takes a TextImage and draws it on the surface this TextGraphics is targeting, given the coordinates on the target that is specifying where the top-left corner of the image should be drawn. This is equivalent of calling drawImage(topLeft, image, TerminalPosition.TOP_LEFT_CORNER, image.getSize().
        Specified by:
        drawImage in interface TextGraphics
        Parameters:
        topLeft - Position of the top-left corner of the image on the target
        image - Image to draw
        Returns:
        Itself
      • drawImage

        TextGUIGraphics drawImage​(TerminalPosition topLeft,
                                  TextImage image,
                                  TerminalPosition sourceImageTopLeft,
                                  TerminalSize sourceImageSize)
        Description copied from interface: TextGraphics
        Takes a TextImage and draws it on the surface this TextGraphics is targeting, given the coordinates on the target that is specifying where the top-left corner of the image should be drawn. This overload will only draw a portion of the image to the target, as specified by the two last parameters.
        Specified by:
        drawImage in interface TextGraphics
        Parameters:
        topLeft - Position of the top-left corner of the image on the target
        image - Image to draw
        sourceImageTopLeft - Position of the top-left corner in the source image to draw at the topLeft position on the target
        sourceImageSize - How much of the source image to draw on the target, counted from the sourceImageTopLeft position
        Returns:
        Itself
      • setCharacter

        TextGUIGraphics setCharacter​(TerminalPosition position,
                                     char character)
        Description copied from interface: TextGraphics
        Sets the character at the current position to the specified value
        Specified by:
        setCharacter in interface TextGraphics
        Parameters:
        position - position of the location to set the character
        character - Character to set at the current position
        Returns:
        Itself
      • setCharacter

        TextGUIGraphics setCharacter​(TerminalPosition position,
                                     TextCharacter character)
        Description copied from interface: TextGraphics
        Sets the character at the current position to the specified value, without using the current colors and modifiers of this TextGraphics.
        Specified by:
        setCharacter in interface TextGraphics
        Parameters:
        position - position of the location to set the character
        character - Character data to set at the current position
        Returns:
        Itself
      • setCharacter

        TextGUIGraphics setCharacter​(int column,
                                     int row,
                                     char character)
        Description copied from interface: TextGraphics
        Sets the character at the current position to the specified value
        Specified by:
        setCharacter in interface TextGraphics
        Parameters:
        column - column of the location to set the character
        row - row of the location to set the character
        character - Character to set at the current position
        Returns:
        Itself
      • setCharacter

        TextGUIGraphics setCharacter​(int column,
                                     int row,
                                     TextCharacter character)
        Description copied from interface: TextGraphics
        Sets the character at the current position to the specified value, without using the current colors and modifiers of this TextGraphics.
        Specified by:
        setCharacter in interface TextGraphics
        Parameters:
        column - column of the location to set the character
        row - row of the location to set the character
        character - Character data to set at the current position
        Returns:
        Itself
      • putString

        TextGUIGraphics putString​(int column,
                                  int row,
                                  java.lang.String string)
        Description copied from interface: TextGraphics
        Puts a string on the screen at the specified position with the current colors and modifiers. If the string contains newlines (\r and/or \n), the method will stop at the character before that; you have to manage multi-line strings yourself! The current foreground color, background color and modifiers will be applied.
        Specified by:
        putString in interface TextGraphics
        Parameters:
        column - What column to put the string at
        row - What row to put the string at
        string - String to put on the screen
        Returns:
        Itself
      • putString

        TextGUIGraphics putString​(TerminalPosition position,
                                  java.lang.String string)
        Description copied from interface: TextGraphics
        Shortcut to calling:
          putString(position.getColumn(), position.getRow(), string);
         
        Specified by:
        putString in interface TextGraphics
        Parameters:
        position - Position to put the string at
        string - String to put on the screen
        Returns:
        Itself
      • putString

        TextGUIGraphics putString​(int column,
                                  int row,
                                  java.lang.String string,
                                  SGR extraModifier,
                                  SGR... optionalExtraModifiers)
        Description copied from interface: TextGraphics
        Puts a string on the screen at the specified position with the current colors and modifiers. If the string contains newlines (\r and/or \n), the method will stop at the character before that; you have to manage multi-line strings yourself! If you supplied any extra modifiers, they will be applied when writing the string as well but not recorded into the state of the TextGraphics object.
        Specified by:
        putString in interface TextGraphics
        Parameters:
        column - What column to put the string at
        row - What row to put the string at
        string - String to put on the screen
        extraModifier - Modifier to apply to the string
        optionalExtraModifiers - Optional extra modifiers to apply to the string
        Returns:
        Itself
      • putString

        TextGUIGraphics putString​(TerminalPosition position,
                                  java.lang.String string,
                                  SGR extraModifier,
                                  SGR... optionalExtraModifiers)
        Description copied from interface: TextGraphics
        Shortcut to calling:
          putString(position.getColumn(), position.getRow(), string, modifiers, optionalExtraModifiers);
         
        Specified by:
        putString in interface TextGraphics
        Parameters:
        position - Position to put the string at
        string - String to put on the screen
        extraModifier - Modifier to apply to the string
        optionalExtraModifiers - Optional extra modifiers to apply to the string
        Returns:
        Itself
      • putString

        TextGUIGraphics putString​(int column,
                                  int row,
                                  java.lang.String string,
                                  java.util.Collection<SGR> extraModifiers)
        Description copied from interface: TextGraphics
        Puts a string on the screen at the specified position with the current colors and modifiers. If the string contains newlines (\r and/or \n), the method will stop at the character before that; you have to manage multi-line strings yourself! If you supplied any extra modifiers, they will be applied when writing the string as well but not recorded into the state of the TextGraphics object.
        Specified by:
        putString in interface TextGraphics
        Parameters:
        column - What column to put the string at
        row - What row to put the string at
        string - String to put on the screen
        extraModifiers - Modifier to apply to the string
        Returns:
        Itself
      • putCSIStyledString

        TextGUIGraphics putCSIStyledString​(int column,
                                           int row,
                                           java.lang.String string)
        Description copied from interface: TextGraphics
        Puts a string on the screen at the specified position with the current colors and modifiers. If the string contains newlines (\r and/or \n), the method will stop at the character before that; you have to manage multi-line strings yourself!

        This method has an additional functionality to the regular TextGraphics.putString(int, int, String); if you embed ANSI CSI-style control sequences (like modifying text color or controlling SGR status), they will be interpreted as the string is printed and mutates the TextGraphics object. In this version of Lanterna, the following sequences are supported:

        • Set foreground color
        • Set background color
        • Set/Clear bold style
        • Set/Clear underline style
        • Set/Clear blink style
        • Set/Clear reverse style
        • Clear all styles and colors (notice that this will return the state to what it was at the start of the method)
        When the call is complete, the TextGraphics object will return to the color/style state it was in at the start of the call.
        Specified by:
        putCSIStyledString in interface TextGraphics
        Parameters:
        column - What column to put the string at
        row - What row to put the string at
        string - String to put on the screen
        Returns:
        Itself
      • putCSIStyledString

        TextGUIGraphics putCSIStyledString​(TerminalPosition position,
                                           java.lang.String string)
        Description copied from interface: TextGraphics
        Puts a string on the screen at the specified position with the current colors and modifiers. If the string contains newlines (\r and/or \n), the method will stop at the character before that; you have to manage multi-line strings yourself!

        This method has an additional functionality to the regular TextGraphics.putString(int, int, String); if you embed ANSI CSI-style control sequences (like modifying text color or controlling SGR status), they will be interpreted as the string is printed and mutates the TextGraphics object. In this version of Lanterna, the following sequences are supported:

        • Set foreground color
        • Set background color
        • Set/Clear bold style
        • Set/Clear underline style
        • Set/Clear blink style
        • Set/Clear reverse style
        • Clear all styles and colors (notice that this will return the state to what it was at the start of the method)
        When the call is complete, the TextGraphics object will return to the color/style state it was in at the start of the call.
        Specified by:
        putCSIStyledString in interface TextGraphics
        Parameters:
        position - Position to put the string at
        string - String to put on the screen
        Returns:
        Itself