java.lang.Object
com.googlecode.lanterna.TerminalSize
Terminal dimensions in 2-d space, measured in number of rows and columns. This class is immutable and cannot change
its internal state after creation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int
static final TerminalSize
private final int
static final TerminalSize
-
Constructor Summary
ConstructorsConstructorDescriptionTerminalSize
(int columns, int rows) Creates a new terminal size representation with a given width (columns) and height (rows) -
Method Summary
Modifier and TypeMethodDescriptionboolean
int
int
getRows()
int
hashCode()
max
(TerminalSize other) Takes a different TerminalSize and returns a new TerminalSize that has the largest dimensions of the two, measured separately.min
(TerminalSize other) Takes a different TerminalSize and returns a new TerminalSize that has the smallest dimensions of the two, measured separately.toString()
with
(TerminalSize size) Returns itself if it is equal to the supplied size, otherwise the supplied size.withColumns
(int columns) Creates a new size based on this size, but with a different widthwithRelative
(int deltaColumns, int deltaRows) Creates a new TerminalSize object representing a size based on this object's size but with a delta applied.withRelative
(TerminalSize delta) Creates a new TerminalSize object representing a size based on this object's size but with a delta applied.withRelativeColumns
(int delta) Creates a new TerminalSize object representing a size with the same number of rows, but with a column size offset by a supplied value.withRelativeRows
(int delta) Creates a new TerminalSize object representing a size with the same number of columns, but with a row size offset by a supplied value.withRows
(int rows) Creates a new size based on this size, but with a different height
-
Field Details
-
ZERO
-
ONE
-
columns
private final int columns -
rows
private final int rows
-
-
Constructor Details
-
TerminalSize
public TerminalSize(int columns, int rows) Creates a new terminal size representation with a given width (columns) and height (rows)- Parameters:
columns
- Width, in number of columnsrows
- Height, in number of columns
-
-
Method Details
-
getColumns
public int getColumns()- Returns:
- Returns the width of this size representation, in number of columns
-
withColumns
Creates a new size based on this size, but with a different width- Parameters:
columns
- Width of the new size, in columns- Returns:
- New size based on this one, but with a new width
-
getRows
public int getRows()- Returns:
- Returns the height of this size representation, in number of rows
-
withRows
Creates a new size based on this size, but with a different height- Parameters:
rows
- Height of the new size, in rows- Returns:
- New size based on this one, but with a new height
-
withRelativeColumns
Creates a new TerminalSize object representing a size with the same number of rows, but with a column size offset by a supplied value. Calling this method with delta 0 will return this, calling it with a positive delta will return a terminal size delta number of columns wider and for negative numbers shorter.- Parameters:
delta
- Column offset- Returns:
- New terminal size based off this one but with an applied transformation
-
withRelativeRows
Creates a new TerminalSize object representing a size with the same number of columns, but with a row size offset by a supplied value. Calling this method with delta 0 will return this, calling it with a positive delta will return a terminal size delta number of rows longer and for negative numbers shorter.- Parameters:
delta
- Row offset- Returns:
- New terminal size based off this one but with an applied transformation
-
withRelative
Creates a new TerminalSize object representing a size based on this object's size but with a delta applied. This is the same as callingwithRelativeColumns(delta.getColumns()).withRelativeRows(delta.getRows())
- Parameters:
delta
- Column and row offset- Returns:
- New terminal size based off this one but with an applied resize
-
withRelative
Creates a new TerminalSize object representing a size based on this object's size but with a delta applied. This is the same as callingwithRelativeColumns(deltaColumns).withRelativeRows(deltaRows)
- Parameters:
deltaColumns
- How many extra columns the new TerminalSize will have (negative values are allowed)deltaRows
- How many extra rows the new TerminalSize will have (negative values are allowed)- Returns:
- New terminal size based off this one but with an applied resize
-
max
Takes a different TerminalSize and returns a new TerminalSize that has the largest dimensions of the two, measured separately. So calling 3x5 on a 5x3 will return 5x5.- Parameters:
other
- Other TerminalSize to compare with- Returns:
- TerminalSize that combines the maximum width between the two and the maximum height
-
min
Takes a different TerminalSize and returns a new TerminalSize that has the smallest dimensions of the two, measured separately. So calling 3x5 on a 5x3 will return 3x3.- Parameters:
other
- Other TerminalSize to compare with- Returns:
- TerminalSize that combines the minimum width between the two and the minimum height
-
with
Returns itself if it is equal to the supplied size, otherwise the supplied size. You can use this if you have a size field which is frequently recalculated but often resolves to the same size; it will keep the same object in memory instead of swapping it out every cycle.- Parameters:
size
- Size you want to return- Returns:
- Itself if this size equals the size passed in, otherwise the size passed in
-
toString
-
equals
-
hashCode
public int hashCode()
-