Class Gridder
java.lang.Object
uk.ac.starlink.ttools.plot2.layer.Gridder
Maps positions on a 2-d grid to a 1-d index.
- Since:
- 15 Feb 2013
- Author:
- Mark Taylor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
int
Returns grid height.int
getIndex
(int ix, int iy) Returns the 1-d index corresponding to a given x,y position.int
Returns the number of points in the grid and array.int
getWidth()
Returns grid width.int
getX
(int index) Returns the X index corresponding to a pixel index.int
getY
(int index) Returns the Y index corresponding to a pixel index.int
hashCode()
static Gridder
Returns a Gridder instance that is the transpose of the supplied one.
-
Constructor Details
-
Gridder
public Gridder(int nx, int ny) Constructor.- Parameters:
nx
- grid widthny
- grid height
-
-
Method Details
-
getWidth
public int getWidth()Returns grid width.- Returns:
- width
-
getHeight
public int getHeight()Returns grid height.- Returns:
- height
-
getIndex
public int getIndex(int ix, int iy) Returns the 1-d index corresponding to a given x,y position.- Parameters:
ix
- x positioniy
- y position- Returns:
- array index
-
getX
public int getX(int index) Returns the X index corresponding to a pixel index.- Parameters:
index
- 1-d index- Returns:
- X position
-
getY
public int getY(int index) Returns the Y index corresponding to a pixel index.- Parameters:
index
- 1-d index- Returns:
- Y position
-
getLength
public int getLength()Returns the number of points in the grid and array.- Returns:
- size
-
hashCode
public int hashCode() -
equals
-
transpose
Returns a Gridder instance that is the transpose of the supplied one. If the supplied instance does row-major indexing, the result does column-major instead.- Parameters:
base
- input gridder- Returns:
- gridder with X and Y transposed
-