Interface TextImage

  • All Superinterfaces:
    Scrollable
    All Known Implementing Classes:
    BasicTextImage, ScreenBuffer

    public interface TextImage
    extends Scrollable
    An 'image' build up of text characters with color and style information. These are completely in memory and not visible anyway, but can be used when drawing with a TextGraphics objects.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void copyTo​(TextImage destination)
      Copies this TextImage's content to another TextImage.
      void copyTo​(TextImage destination, int startRowIndex, int rows, int startColumnIndex, int columns, int destinationRowOffset, int destinationColumnOffset)
      Copies this TextImage's content to another TextImage.
      TextCharacter getCharacterAt​(int column, int row)
      Returns the character stored at a particular position in this image
      TextCharacter getCharacterAt​(TerminalPosition position)
      Returns the character stored at a particular position in this image
      TerminalSize getSize()
      Returns the dimensions of this TextImage, in columns and rows
      TextGraphics newTextGraphics()
      Creates a TextGraphics object that targets this TextImage for all its drawing operations.
      TextImage resize​(TerminalSize newSize, TextCharacter filler)
      Returns a copy of this image resized to a new size and using a specified filler character if the new size is larger than the old and we need to fill in empty areas.
      void scrollLines​(int firstLine, int lastLine, int distance)
      Scroll a range of lines of this TextImage according to given distance.
      void setAll​(TextCharacter character)
      Sets the text image content to one specified character (including color and style)
      void setCharacterAt​(int column, int row, TextCharacter character)
      Sets the character at a specific position in the image to a particular TextCharacter.
      void setCharacterAt​(TerminalPosition position, TextCharacter character)
      Sets the character at a specific position in the image to a particular TextCharacter.
    • Method Detail

      • getSize

        TerminalSize getSize()
        Returns the dimensions of this TextImage, in columns and rows
        Returns:
        Size of this TextImage
      • getCharacterAt

        TextCharacter getCharacterAt​(TerminalPosition position)
        Returns the character stored at a particular position in this image
        Parameters:
        position - Coordinates of the character
        Returns:
        TextCharacter stored at the specified position
      • getCharacterAt

        TextCharacter getCharacterAt​(int column,
                                     int row)
        Returns the character stored at a particular position in this image
        Parameters:
        column - Column coordinate of the character
        row - Row coordinate of the character
        Returns:
        TextCharacter stored at the specified position
      • setCharacterAt

        void setCharacterAt​(TerminalPosition position,
                            TextCharacter character)
        Sets the character at a specific position in the image to a particular TextCharacter. If the position is outside of the image's size, this method does nothing.
        Parameters:
        position - Coordinates of the character
        character - What TextCharacter to assign at the specified position
      • setCharacterAt

        void setCharacterAt​(int column,
                            int row,
                            TextCharacter character)
        Sets the character at a specific position in the image to a particular TextCharacter. If the position is outside of the image's size, this method does nothing.
        Parameters:
        column - Column coordinate of the character
        row - Row coordinate of the character
        character - What TextCharacter to assign at the specified position
      • setAll

        void setAll​(TextCharacter character)
        Sets the text image content to one specified character (including color and style)
        Parameters:
        character - The character to fill the image with
      • newTextGraphics

        TextGraphics newTextGraphics()
        Creates a TextGraphics object that targets this TextImage for all its drawing operations.
        Returns:
        TextGraphics object for this TextImage
      • resize

        TextImage resize​(TerminalSize newSize,
                         TextCharacter filler)
        Returns a copy of this image resized to a new size and using a specified filler character if the new size is larger than the old and we need to fill in empty areas. The copy will be independent from the one this method is invoked on, so modifying one will not affect the other.
        Parameters:
        newSize - Size of the new image
        filler - Filler character to use on the new areas when enlarging the image (is not used when shrinking)
        Returns:
        Copy of this image, but resized
      • copyTo

        void copyTo​(TextImage destination)
        Copies this TextImage's content to another TextImage. If the destination TextImage is larger than this ScreenBuffer, the areas outside of the area that is written to will be untouched.
        Parameters:
        destination - TextImage to copy to
      • copyTo

        void copyTo​(TextImage destination,
                    int startRowIndex,
                    int rows,
                    int startColumnIndex,
                    int columns,
                    int destinationRowOffset,
                    int destinationColumnOffset)
        Copies this TextImage's content to another TextImage. If the destination TextImage is larger than this TextImage, the areas outside of the area that is written to will be untouched.
        Parameters:
        destination - TextImage to copy to
        startRowIndex - Which row in this image to copy from
        rows - How many rows to copy
        startColumnIndex - Which column in this image to copy from
        columns - How many columns to copy
        destinationRowOffset - Offset (in number of rows) in the target image where we want to first copied row to be
        destinationColumnOffset - Offset (in number of columns) in the target image where we want to first copied column to be
      • scrollLines

        void scrollLines​(int firstLine,
                         int lastLine,
                         int distance)
        Scroll a range of lines of this TextImage according to given distance. TextImage implementations of this method do not throw IOException.
        Specified by:
        scrollLines in interface Scrollable
        Parameters:
        firstLine - first line of the range to be scrolled (top line is 0)
        lastLine - last (inclusive) line of the range to be scrolled
        distance - if > 0: move lines up, else if < 0: move lines down.