Package uk.ac.starlink.ttools.plot
Class PointIterator
java.lang.Object
uk.ac.starlink.ttools.plot.PointIterator
- Direct Known Subclasses:
PlotDataPointIterator
Iterates over the points which have actually been plotted to the screen.
- Since:
- 19 Jan 2006
- Author:
- Mark Taylor
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a bit vector with bits set for every point index visited by this iterator.int
getClosestPoint
(Point p, int error) Returns the index of the closest plotted point to a given screen point.getContainedPoints
(Shape shape) Returns a bit vector with bits set for every point index which falls within a given shape on the screen.int
getIndex()
Returns the most recently read point index.int
getX()
Returns the most recently read screen X coordinate.int
getY()
Returns the most recently read Y coordinate.protected abstract int[]
Returns a triple giving point index, screen X coordinate and screen Y coordinate.boolean
Loads the data for the next point if there is one.
-
Field Details
-
EMPTY
PointIterator instance with no points.
-
-
Constructor Details
-
PointIterator
public PointIterator()
-
-
Method Details
-
nextPoint
protected abstract int[] nextPoint()Returns a triple giving point index, screen X coordinate and screen Y coordinate. Returns null if there are no more points. It is permissible to return the sameint[]
array with different contents each time. Invoked byreadNextPoint()
.- Returns:
- ip, xp, yp triple
-
getIndex
public int getIndex()Returns the most recently read point index.- Returns:
- ip
-
getX
public int getX()Returns the most recently read screen X coordinate.- Returns:
- xp
-
getY
public int getY()Returns the most recently read Y coordinate.- Returns:
- yp
-
readNextPoint
public boolean readNextPoint()Loads the data for the next point if there is one.- Returns:
- true if the data are loaded for the next point; false if the iteration is at an end
-
getContainedPoints
Returns a bit vector with bits set for every point index which falls within a given shape on the screen.- Parameters:
shape
- shape defining inclusion criterion- Returns:
- bit vector locating points inside shape
-
getAllPoints
Returns a bit vector with bits set for every point index visited by this iterator.- Returns:
- bit vector locating included points
-
getClosestPoint
Returns the index of the closest plotted point to a given screen point. Only points within a given error box are eligible; if none can be found, -1 is returned.- Parameters:
p
- screen point near which plotted points should be locatederror
- number of pixels in any direction which defines the error box within which a point may be found- Returns:
- index of closest point to p, or -1 if none are nearby
-