Package noaa.coastwatch.util
Class LineIterator
java.lang.Object
noaa.coastwatch.util.LineIterator
- All Implemented Interfaces:
Iterator<Point>
,ResettableIterator
The
LineIterator
class may be used to get the set of
(x,y) points required for drawing a line between start and end
points. For convenience, the iterator is resettable and has a
nextPoint()
method to save allocating a new point each
time. The line drawing algorithm was taken from:
http://www.gamedev.net/reference/articles/article1275.asp
- Since:
- 3.1.7
- Author:
- Peter Hollemans
-
Constructor Details
-
LineIterator
Creates a new line iterator.- Parameters:
start
- the line starting point.end
- the line ending point.
-
-
Method Details
-
reset
public void reset()Description copied from interface:ResettableIterator
Resets the iterator to the first element.- Specified by:
reset
in interfaceResettableIterator
-
nextPoint
Gets the next point in the line.- Parameters:
point
- the point to fill in with coordinates, or null to allocate a new point.- Returns:
- the next point. The point is allocated only if the passed point is null, otherwise the same point is returned.
-
hasNext
public boolean hasNext() -
next
-
remove
public void remove() -
main
Tests this class.- Parameters:
argv
- the array of command line parameters.
-