Ignore:
Timestamp:
2005-10-02T20:32:00+02:00 (19 years ago)
Author:
imi
Message:

added mapmodes for adding and combining stuff. Reorganized images

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/data/osm/Track.java

    r1 r7  
    22
    33import java.util.ArrayList;
     4import java.util.Collection;
    45import java.util.List;
    56
     
    1415         * All track segments in this track
    1516         */
    16         public List<LineSegment> segments = new ArrayList<LineSegment>();
     17        public final List<LineSegment> segments = new ArrayList<LineSegment>();
     18
     19        /**
     20         * Return a merge of getAllNodes - calls to the line segments.
     21         */
     22        @Override
     23        public Collection<Node> getAllNodes() {
     24                ArrayList<Node> nodes = new ArrayList<Node>();
     25                for (LineSegment ls : segments)
     26                        nodes.addAll(ls.getAllNodes());
     27                return nodes;
     28        }
     29
     30        /**
     31         * Tracks are equal, when all segments and the keys are equal
     32         */
     33        @Override
     34        public boolean equals(Object obj) {
     35                if (!(obj instanceof Track))
     36                        return false;
     37                if (!super.equals(obj))
     38                        return false;
     39                Track t = (Track)obj;
     40                int size = segments.size();
     41                if (size != t.segments.size())
     42                        return false;
     43                for (int i = 0; i < size; ++i)
     44                        if (!segments.get(i).equals(t.segments.get(i)))
     45                                return false;
     46                return true;
     47        }
     48
     49        @Override
     50        public int hashCode() {
     51                int hash = super.hashCode();
     52                for (LineSegment ls : segments)
     53                        hash += ls.hashCode();
     54                return hash;
     55        }
     56
     57        /**
     58         * Return the last node in the track. This is the node, which no line segment
     59         * has as start, but at least one has it as end. If there are not exact one
     60         * such nodes found, <code>null</code> is returned.
     61         *
     62         * TODO Currently does return just the end node in the list.
     63         *
     64         * @return The ending node, if there is one.
     65         */
     66        public Node getEndingNode() {
     67                if (segments.isEmpty())
     68                        return null;
     69                return segments.get(segments.size()-1).end;
     70        }
     71
     72        /**
     73         * Return the first node in the track. This is the node, which no line segment
     74         * has as end, but at least one as starting node. If there are not exact one
     75         * such nodes found, <code>null</code> is returned.
     76         *
     77         * TODO Currently does return just the first node in the list.
     78         *
     79         * @return The starting node, if there is one.
     80         */
     81        public Node getStartingNode() {
     82                if (segments.isEmpty())
     83                        return null;
     84                return segments.get(0).start;
     85        }
    1786}
Note: See TracChangeset for help on using the changeset viewer.