2 Copyright (C) 2001, 2006 United States Government
3 as represented by the Administrator of the
4 National Aeronautics and Space Administration.
7 package gov
.nasa
.worldwind
;
15 public class TrackPointIteratorImpl
implements TrackPointIterator
17 private java
.util
.List
<Track
> tracksList
;
18 private java
.util
.Iterator
<Track
> tracks
;
19 private java
.util
.Iterator
<TrackSegment
> segments
;
20 private java
.util
.Iterator
<TrackPoint
> positions
;
22 public TrackPointIteratorImpl(java
.util
.List
<Track
> tracksList
)
24 this.tracksList
= tracksList
;
28 public TrackPointIteratorImpl
reset()
30 if (this.tracksList
== null)
32 String msg
= WorldWind
.retrieveErrMsg("nullValue.TracksIsNull");
33 WorldWind
.logger().log(java
.util
.logging
.Level
.FINE
, msg
);
34 throw new IllegalArgumentException(msg
);
37 this.tracks
= this.tracksList
.iterator();
39 this.positions
= null;
40 this.loadNextPositions();
45 public boolean hasNext()
47 if (this.positions
!= null && this.positions
.hasNext())
50 this.loadNextPositions();
52 return (this.positions
!= null && this.positions
.hasNext());
55 private void loadNextPositions()
57 if (this.segments
!= null && this.segments
.hasNext())
59 TrackSegment segment
= this.segments
.next();
60 this.positions
= segment
.getPoints().iterator();
64 if (this.tracks
.hasNext())
66 Track track
= this.tracks
.next();
67 this.segments
= track
.getSegments().iterator();
68 this.loadNextPositions();
72 public TrackPoint
next()
76 String msg
= WorldWind
.retrieveErrMsg("iterator.NoMoreTrackPoints");
77 WorldWind
.logger().log(java
.util
.logging
.Level
.FINE
, msg
);
78 throw new NoSuchElementException(msg
);
81 return this.positions
.next();
86 String msg
= WorldWind
.retrieveErrMsg("iterator.RemoveNotSupported");
87 WorldWind
.logger().log(java
.util
.logging
.Level
.FINE
, msg
);
88 throw new UnsupportedOperationException(msg
);
91 public int getNumPoints()
94 for (numPoints
= 0; this.hasNext(); this.next())