Changeset 2405 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2009-11-07T20:28:14+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/command/AddPrimitivesCommand.java
r2399 r2405 32 32 33 33 for (int i=0; i<createdPrimitives.size(); i++) { 34 createdPrimitives.get(i).load(data.get(i) , getLayer().data);34 createdPrimitives.get(i).load(data.get(i)); 35 35 } 36 36 getLayer().data.setSelected(createdPrimitives); -
trunk/src/org/openstreetmap/josm/command/Command.java
r2308 r2405 2 2 package org.openstreetmap.josm.command; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 4 6 import java.util.Collection; 5 import static org.openstreetmap.josm.tools.I18n.tr;6 7 import java.util.HashMap; 7 8 import java.util.HashSet; … … 92 93 public void undoCommand() { 93 94 for (Entry<OsmPrimitive, PrimitiveData> e : cloneMap.entrySet()) { 94 e.getKey().load(e.getValue() , layer.data);95 e.getKey().load(e.getValue()); 95 96 } 96 97 } -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r2402 r2405 190 190 } 191 191 allPrimitives.add(primitive); 192 primitive.setDataset(this); 192 193 } 193 194 … … 195 196 OsmPrimitive result; 196 197 if (data instanceof NodeData) { 197 result = new Node( (NodeData)data, this);198 result = new Node(); 198 199 } else if (data instanceof WayData) { 199 result = new Way( (WayData)data, this);200 result = new Way(); 200 201 } else if (data instanceof RelationData) { 201 result = new Relation( (RelationData)data, this);202 result = new Relation(); 202 203 } else 203 204 throw new AssertionError(); 205 result.setDataset(this); 206 result.load(data); 204 207 addPrimitive(result); 205 208 return result; … … 228 231 selectedPrimitives.remove(primitive); 229 232 allPrimitives.remove(primitive); 233 primitive.setDataset(null); 230 234 } 231 235 … … 797 801 selectedPrimitives.remove(primitive); 798 802 allPrimitives.remove(primitive); 803 primitive.setDataset(null); 799 804 changed = true; 800 805 it.remove(); … … 811 816 public void clear() { 812 817 clearSelection(); 818 for (OsmPrimitive primitive:allPrimitives) { 819 primitive.setDataset(null); 820 } 813 821 nodes.clear(); 814 822 ways.clear(); -
trunk/src/org/openstreetmap/josm/data/osm/Node.java
r2399 r2405 85 85 } 86 86 87 public Node(NodeData data, DataSet dataSet) {88 super(data);89 load(data, dataSet);90 }91 92 87 @Override public void visit(Visitor visitor) { 93 88 visitor.visit(this); … … 99 94 } 100 95 101 @Override public void load(PrimitiveData data , DataSet dataSet) {102 super.load(data , dataSet);96 @Override public void load(PrimitiveData data) { 97 super.load(data); 103 98 setCoor(((NodeData)data).getCoor()); 104 99 } -
trunk/src/org/openstreetmap/josm/data/osm/NodeData.java
r2399 r2405 50 50 51 51 @Override 52 public Node makePrimitive(DataSet dataSet) {53 return new Node(this, dataSet);54 }55 56 @Override57 52 public String toString() { 58 53 return super.toString() + " NODE " + coor; -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r2399 r2405 131 131 */ 132 132 private long id = 0; 133 134 private DataSet dataSet; 135 136 /** 137 * This method should never ever by called from somewhere else than Dataset.addPrimitive or removePrimitive methods 138 * @param dataSet 139 */ 140 void setDataset(DataSet dataSet) { 141 if (this.dataSet != null && dataSet != null && this.dataSet != dataSet) 142 throw new DataIntegrityProblemException("Primitive cannot be included in more than one Dataset"); 143 this.dataSet = dataSet; 144 } 145 146 /** 147 * 148 * @return DataSet this primitive is part of. 149 * @throws DataIntegrityProblemException when primitive is not part of any dataset 150 */ 151 public DataSet getDataSet() { 152 if (dataSet == null) 153 throw new DataIntegrityProblemException("Primitive must be part of the dataset"); 154 return dataSet; 155 } 133 156 134 157 private volatile byte flags = FLAG_VISIBLE; // visible per default … … 798 821 * Loads (clone) this primitive from provided PrimitiveData 799 822 * @param data 800 * @param dataSet Dataset this primitive is part of. This parameter is used only 801 * temporarily. OsmPrimitive will have final field dataset in future 802 */ 803 public void load(PrimitiveData data, DataSet dataSet) { 823 */ 824 public void load(PrimitiveData data) { 804 825 setKeys(data.getKeys()); 805 826 timestamp = data.getTimestamp(); -
trunk/src/org/openstreetmap/josm/data/osm/PrimitiveData.java
r2404 r2405 99 99 public abstract PrimitiveData makeCopy(); 100 100 101 public abstract OsmPrimitive makePrimitive(DataSet dataSet);102 103 101 @Override 104 102 public String toString() { -
trunk/src/org/openstreetmap/josm/data/osm/Relation.java
r2404 r2405 136 136 super(id, false); 137 137 } 138 139 public Relation(RelationData data, DataSet dataSet) {140 super(data);141 load(data, dataSet);142 }143 144 138 145 139 @Override public void cloneFrom(OsmPrimitive osm) { … … 153 147 } 154 148 155 @Override public void load(PrimitiveData data , DataSet dataSet) {156 super.load(data , dataSet);149 @Override public void load(PrimitiveData data) { 150 super.load(data); 157 151 158 152 RelationData relationData = (RelationData) data; … … 160 154 List<RelationMember> newMembers = new ArrayList<RelationMember>(); 161 155 for (RelationMemberData member : relationData.getMembers()) { 162 OsmPrimitive primitive = dataSet.getPrimitiveById(member);156 OsmPrimitive primitive = getDataSet().getPrimitiveById(member); 163 157 if (primitive == null) 164 158 throw new AssertionError("Data consistency problem - relation with missing member detected"); -
trunk/src/org/openstreetmap/josm/data/osm/RelationData.java
r2399 r2405 28 28 29 29 @Override 30 public Relation makePrimitive(DataSet dataSet) {31 return new Relation(this, dataSet);32 }33 34 @Override35 30 public String toString() { 36 31 return super.toString() + " REL " + members; -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r2404 r2405 161 161 } 162 162 163 public Way(WayData data, DataSet dataSet) {164 super(data);165 load(data, dataSet);166 }167 168 163 /** 169 164 * 170 165 * @param data 171 * @param dataSet Dataset this way is part of. This parameter will be removed in future172 166 */ 173 167 @Override 174 public void load(PrimitiveData data , DataSet dataSet) {175 super.load(data , dataSet);168 public void load(PrimitiveData data) { 169 super.load(data); 176 170 177 171 WayData wayData = (WayData) data; … … 179 173 List<Node> newNodes = new ArrayList<Node>(wayData.getNodes().size()); 180 174 for (Long nodeId : wayData.getNodes()) { 181 Node node = (Node) dataSet.getPrimitiveById(nodeId, OsmPrimitiveType.NODE);175 Node node = (Node)getDataSet().getPrimitiveById(nodeId, OsmPrimitiveType.NODE); 182 176 if (node != null) { 183 177 newNodes.add(node); -
trunk/src/org/openstreetmap/josm/data/osm/WayData.java
r2399 r2405 28 28 29 29 @Override 30 public OsmPrimitive makePrimitive(DataSet dataSet) {31 return new Way(this, dataSet);32 }33 34 @Override35 30 public String toString() { 36 31 return super.toString() + " WAY" + nodes.toString();
Note:
See TracChangeset
for help on using the changeset viewer.