- java.lang.Object
-
- com.googlecode.lanterna.TerminalRectangle
-
public class TerminalRectangle extends java.lang.Object
This class is immutable and cannot change its internal state after creation.
-
-
Field Summary
Fields Modifier and Type Field Description int
height
TerminalPosition
position
TerminalSize
size
int
width
int
x
int
xAndWidth
int
y
int
yAndHeight
-
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 boolean
equals(java.lang.Object obj)
int
getColumns()
int
getRows()
int
hashCode()
java.lang.String
toString()
boolean
whenContains(int x, int y, java.lang.Runnable op)
boolean
whenContains(TerminalPosition p, java.lang.Runnable op)
TerminalRectangle
withColumns(int columns)
Creates a new rect based on this rect, but with a different widthTerminalRectangle
withRows(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:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-