Changeset 23 in josm for src/org/openstreetmap/josm/data/osm/Track.java
- Timestamp:
- 2005-10-27T00:38:03+02:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/data/osm/Track.java
r21 r23 2 2 3 3 import java.util.ArrayList; 4 import java.util.Collection;5 import java.util.Collections;6 4 import java.util.List; 7 5 … … 18 16 * All track segments in this track 19 17 */ 20 p rivatefinal List<LineSegment> segments = new ArrayList<LineSegment>();18 public final List<LineSegment> segments = new ArrayList<LineSegment>(); 21 19 22 20 … … 26 24 public void add(LineSegment ls) { 27 25 segments.add(ls); 28 ls.parent.add(this);29 }30 31 /**32 * Add the line segment at first position to the track. First position means,33 * the line segment's start becomes the starting node.34 * @param ls The line segment to add at starting position.35 * @see #getStartingNode()36 */37 public void addStart(LineSegment ls) {38 segments.add(ls);39 ls.parent.add(this);40 }41 42 /**43 * Add all LineSegment's to the list of segments.44 * @param lineSegments The line segments to add.45 */46 public void addAll(Collection<? extends LineSegment> lineSegments) {47 segments.addAll(lineSegments);48 for (LineSegment ls : lineSegments)49 ls.parent.add(this);50 }51 52 /**53 * Remove the line segment from the track.54 */55 public void remove(LineSegment ls) {56 if (segments.remove(ls))57 if (!ls.parent.remove(this))58 throw new IllegalStateException("Parent violation detected.");59 }60 61 /**62 * Return an read-only collection. Do not alter the object returned.63 * @return The read-only Collection of all segments.64 */65 public Collection<LineSegment> segments() {66 return Collections.unmodifiableCollection(segments);67 }68 69 /**70 * Return a merge of getAllNodes - calls to the line segments.71 */72 @Override73 public Collection<Node> getAllNodes() {74 ArrayList<Node> nodes = new ArrayList<Node>();75 for (LineSegment ls : segments)76 nodes.addAll(ls.getAllNodes());77 return nodes;78 }79 /**80 * The track is going to be destroyed. Unlink all back references.81 */82 public void destroy() {83 for (LineSegment ls : segments) {84 ls.parent.remove(this);85 if (ls.parent.isEmpty())86 ls.destroy();87 }88 segments.clear();89 26 } 90 27 … … 101 38 if (segments.isEmpty()) 102 39 return null; 103 return segments.get(segments.size()-1). getEnd();40 return segments.get(segments.size()-1).end; 104 41 } 105 42 … … 126 63 if (segments.isEmpty()) 127 64 return null; 128 return segments.get(0). getStart();65 return segments.get(0).start; 129 66 } 130 67
Note:
See TracChangeset
for help on using the changeset viewer.