Comparable<TerminalPosition>
public class TerminalPosition extends Object implements Comparable<TerminalPosition>
Modifier and Type | Field | Description |
---|---|---|
static TerminalPosition |
OFFSET_1x1 |
Constant for the 1x1 position (one offset in both directions from top-left)
|
static TerminalPosition |
TOP_LEFT_CORNER |
Constant for the top-left corner (0x0)
|
Constructor | Description |
---|---|
TerminalPosition(int column,
int row) |
Creates a new TerminalPosition object, which represents a location on the screen.
|
Modifier and Type | Method | Description |
---|---|---|
int |
compareTo(TerminalPosition o) |
|
boolean |
equals(int columnIndex,
int rowIndex) |
|
boolean |
equals(Object obj) |
|
int |
getColumn() |
Returns the index of the column this position is representing, zero indexed (the first column has index 0).
|
int |
getRow() |
Returns the index of the row this position is representing, zero indexed (the first row has index 0)
|
int |
hashCode() |
|
String |
toString() |
|
TerminalPosition |
with(TerminalPosition position) |
Returns itself if it is equal to the supplied position, otherwise the supplied position.
|
TerminalPosition |
withColumn(int column) |
Creates a new TerminalPosition object representing a position with the same row index as this but with a
supplied column index.
|
TerminalPosition |
withRelative(int deltaColumn,
int deltaRow) |
Creates a new TerminalPosition object that is 'translated' by an amount of rows and columns specified by the two
parameters.
|
TerminalPosition |
withRelative(TerminalPosition translate) |
Creates a new TerminalPosition object that is 'translated' by an amount of rows and columns specified by another
TerminalPosition.
|
TerminalPosition |
withRelativeColumn(int delta) |
Creates a new TerminalPosition object representing a position on the same row, but with a column offset by a
supplied value.
|
TerminalPosition |
withRelativeRow(int delta) |
Creates a new TerminalPosition object representing a position on the same column, but with a row offset by a
supplied value.
|
TerminalPosition |
withRow(int row) |
Creates a new TerminalPosition object representing a position with the same column index as this but with a
supplied row index.
|
public static final TerminalPosition TOP_LEFT_CORNER
public static final TerminalPosition OFFSET_1x1
public TerminalPosition(int column, int row)
column
- Column of the location, or the "x" coordinate, zero indexed (the first column is 0)row
- Row of the location, or the "y" coordinate, zero indexed (the first row is 0)public int getColumn()
public int getRow()
public TerminalPosition withRow(int row)
row
- Index of the row for the new positionpublic TerminalPosition withColumn(int column)
column
- Index of the column for the new positionpublic TerminalPosition withRelativeColumn(int delta)
delta
- Column offsetpublic TerminalPosition withRelativeRow(int delta)
delta
- Row offsetpublic TerminalPosition withRelative(TerminalPosition translate)
withRelativeRow(translate.getRow()).withRelativeColumn(translate.getColumn())
translate
- How many columns and rows to translatepublic TerminalPosition withRelative(int deltaColumn, int deltaRow)
withRelativeRow(deltaRow).withRelativeColumn(deltaColumn)
deltaColumn
- How many columns to move from the current position in the new TerminalPositiondeltaRow
- How many rows to move from the current position in the new TerminalPositionpublic TerminalPosition with(TerminalPosition position)
position
- Position you want to returnpublic int compareTo(TerminalPosition o)
compareTo
in interface Comparable<TerminalPosition>
public boolean equals(int columnIndex, int rowIndex)
Copyright © 2020. All rights reserved.