Package uk.ac.starlink.ttools.plot
Class PointIterator
- java.lang.Object
-
- uk.ac.starlink.ttools.plot.PointIterator
-
- Direct Known Subclasses:
PlotDataPointIterator
public abstract class PointIterator extends java.lang.Object
Iterates over the points which have actually been plotted to the screen.- Since:
- 19 Jan 2006
- Author:
- Mark Taylor
-
-
Field Summary
Fields Modifier and Type Field Description static PointIterator
EMPTY
PointIterator instance with no points.
-
Constructor Summary
Constructors Constructor Description PointIterator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.util.BitSet
getAllPoints()
Returns a bit vector with bits set for every point index visited by this iterator.int
getClosestPoint(java.awt.Point p, int error)
Returns the index of the closest plotted point to a given screen point.java.util.BitSet
getContainedPoints(java.awt.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[]
nextPoint()
Returns a triple giving point index, screen X coordinate and screen Y coordinate.boolean
readNextPoint()
Loads the data for the next point if there is one.
-
-
-
Field Detail
-
EMPTY
public static PointIterator EMPTY
PointIterator instance with no points.
-
-
Method Detail
-
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
public java.util.BitSet getContainedPoints(java.awt.Shape shape)
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
public java.util.BitSet getAllPoints()
Returns a bit vector with bits set for every point index visited by this iterator.- Returns:
- bit vector locating included points
-
getClosestPoint
public int getClosestPoint(java.awt.Point p, int error)
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
-
-