# Class PointIterator

java.lang.Object
uk.ac.starlink.ttools.plot.PointIterator

Direct Known Subclasses:
  `PlotDataPointIterator`

public abstract class PointIterator extends 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

Modifier and Type
Method
Description
`BitSet`
`getAllPoints()`
Returns 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.
`BitSet`
`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[]`
`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.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### EMPTY

public static PointIterator 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 same `int[]` array with different contents each time. Invoked by `readNextPoint()`.

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 BitSet getContainedPoints(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 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(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 located
  `error` - 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