Class TerminalRectangle


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

      • 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 Detail

      • 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 Detail

      • 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,
                                    java.lang.Runnable op)
      • whenContains

        public boolean whenContains​(int x,
                                    int y,
                                    java.lang.Runnable op)
      • toString

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

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object