- java.lang.Object
-
- com.googlecode.lanterna.TerminalRectangle
-
public class TerminalRectangle extends java.lang.ObjectThis class is immutable and cannot change its internal state after creation.
-
-
Field Summary
Fields Modifier and Type Field Description intheightTerminalPositionpositionTerminalSizesizeintwidthintxintxAndWidthintyintyAndHeight
-
Constructor Summary
Constructors Constructor Description 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)intgetColumns()intgetRows()inthashCode()java.lang.StringtoString()booleanwhenContains(int x, int y, java.lang.Runnable op)booleanwhenContains(TerminalPosition p, java.lang.Runnable op)TerminalRectanglewithColumns(int columns)Creates a new rect based on this rect, but with a different widthTerminalRectanglewithRows(int rows)Creates a new rect based on this rect, but with a different height
-
-
-
Field Detail
-
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 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 columnsheight- 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:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-