Class TerminalRectangle

java.lang.Object
com.googlecode.lanterna.TerminalRectangle

public class TerminalRectangle extends Object
This class is immutable and cannot change its internal state after creation.
  • Field Details

    • position

      public final TerminalPosition position
    • size

      public final TerminalSize size
    • x

      public final int x
    • y

      public final int y
    • width

      public final int width
    • height

      public final int height
    • xAndWidth

      public final int xAndWidth
    • yAndHeight

      public final int yAndHeight
  • Constructor Details

    • TerminalRectangle

      public TerminalRectangle(int x, int y, int width, int height)
      Creates a new terminal rect representation at the supplied x y position with the supplied width and height. Both width and height must be at least zero (non negative) as checked in TerminalSize.
      Parameters:
      width - number of columns
      height - number of rows
  • Method Details

    • getColumns

      public int getColumns()
      Returns:
      Returns the width of this rect, in number of columns
    • getRows

      public int getRows()
      Returns:
      Returns the height of this rect representation, in number of rows
    • withColumns

      public TerminalRectangle withColumns(int columns)
      Creates a new rect based on this rect, but with a different width
      Parameters:
      columns - Width of the new rect, in columns
      Returns:
      New rect based on this one, but with a new width
    • withRows

      public TerminalRectangle withRows(int rows)
      Creates a new rect based on this rect, but with a different height
      Parameters:
      rows - Height of the new rect, in rows
      Returns:
      New rect based on this one, but with a new height
    • whenContains

      public boolean whenContains(TerminalPosition p, Runnable op)
    • whenContains

      public boolean whenContains(int x, int y, Runnable op)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object