source: josm/trunk/src/org/openstreetmap/josm/data/osm/WayData.java@ 11992

Last change on this file since 11992 was 9891, checked in by simon04, 8 years ago

see #12300 - Make Drag and Drop work between different JOSM instances

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm;
3
4import java.util.ArrayList;
5import java.util.List;
6
7import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor;
8
9public class WayData extends PrimitiveData implements IWay {
10
11 private static final long serialVersionUID = 106944939313286415L;
12 private List<Long> nodes = new ArrayList<>();
13
14 /**
15 * Constructs a new {@code NodeData}.
16 */
17 public WayData() {
18 // contents can be set later with setters
19 }
20
21 /**
22 * Constructs a new {@code WayData}.
23 * @param data way data to copy
24 */
25 public WayData(WayData data) {
26 super(data);
27 nodes.addAll(data.getNodes());
28 }
29
30 public List<Long> getNodes() {
31 return nodes;
32 }
33
34 @Override
35 public int getNodesCount() {
36 return nodes.size();
37 }
38
39 @Override
40 public long getNodeId(int idx) {
41 return nodes.get(idx);
42 }
43
44 @Override
45 public boolean isClosed() {
46 if (isIncomplete()) return false;
47 return nodes.get(0).equals(nodes.get(nodes.size() - 1));
48 }
49
50 public void setNodes(List<Long> nodes) {
51 this.nodes = new ArrayList<>(nodes);
52 }
53
54 @Override
55 public WayData makeCopy() {
56 return new WayData(this);
57 }
58
59 @Override
60 public String toString() {
61 return super.toString() + " WAY" + nodes;
62 }
63
64 @Override
65 public OsmPrimitiveType getType() {
66 return OsmPrimitiveType.WAY;
67 }
68
69 @Override
70 public void accept(PrimitiveVisitor visitor) {
71 visitor.visit(this);
72 }
73
74}
Note: See TracBrowser for help on using the repository browser.