DESC
osmprim-selected-dont-use
EDESC
---
core-dave/build.xml | 2
core-dave/src/org/openstreetmap/josm/actions/UnGlueAction.java | 2
core-dave/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java | 9 -
core-dave/src/org/openstreetmap/josm/actions/search/SearchAction.java | 9 -
core-dave/src/org/openstreetmap/josm/actions/search/SearchCompiler.java | 2
core-dave/src/org/openstreetmap/josm/data/osm/DataSet.java | 16 ++
core-dave/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java | 5
core-dave/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java | 63 +++++-----
core-dave/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java | 20 +--
core-dave/src/org/openstreetmap/josm/gui/MapStatus.java | 26 ++--
core-dave/src/org/openstreetmap/josm/gui/NavigatableComponent.java | 6
11 files changed, 93 insertions(+), 67 deletions(-)
diff -puN build.xml~deprecate-osmprimitive-selection-methods build.xml
a
|
b
|
|
66 | 66 | <javac srcdir="src" classpathref="classpath" destdir="build" |
67 | 67 | target="1.5" source="1.5" debug="on" encoding="UTF-8"> |
68 | 68 | <compilerarg value="-Xlint:deprecation"/> |
69 | | <compilerarg value="-Xlint:unchecked"/> |
| 69 | <!-- compilerarg value="-Xlint:unchecked"/ --> |
70 | 70 | </javac> |
71 | 71 | </target> |
72 | 72 | |
diff -puN src/org/openstreetmap/josm/actions/search/SearchAction.java~deprecate-osmprimitive-selection-methods src/org/openstreetmap/josm/actions/search/SearchAction.java
a
|
b
|
import org.openstreetmap.josm.gui.Extend
|
25 | 25 | import org.openstreetmap.josm.tools.GBC; |
26 | 26 | import org.openstreetmap.josm.tools.Shortcut; |
27 | 27 | import org.openstreetmap.josm.data.osm.Filter; |
| 28 | import org.openstreetmap.josm.data.osm.DataSet; |
28 | 29 | |
29 | 30 | public class SearchAction extends JosmAction{ |
30 | 31 | |
… |
… |
public class SearchAction extends JosmAc
|
88 | 89 | left.add(label, GBC.eop()); |
89 | 90 | left.add(input, GBC.eop().fill(GBC.HORIZONTAL)); |
90 | 91 | left.add(replace, GBC.eol()); |
| 92 | DataSet ds = Main.main.getCurrentDataSet(); |
91 | 93 | left.add(add, GBC.eol()); |
92 | 94 | left.add(remove, GBC.eol()); |
93 | 95 | left.add(in_selection, GBC.eop()); |
… |
… |
public class SearchAction extends JosmAc
|
236 | 238 | // } |
237 | 239 | // } |
238 | 240 | |
239 | | Collection<OsmPrimitive> sel = Main.main.getCurrentDataSet().getSelected(); |
| 241 | final DataSet ds = Main.main.getCurrentDataSet(); |
| 242 | Collection<OsmPrimitive> sel = ds.getSelected(); |
240 | 243 | int foundMatches = getSelection(s, sel, new Function(){ |
241 | 244 | public Boolean isSomething(OsmPrimitive o){ |
242 | | return o.isSelected(); |
| 245 | return ds.isSelected(o); |
243 | 246 | } |
244 | 247 | }); |
245 | | Main.main.getCurrentDataSet().setSelected(sel); |
| 248 | ds.setSelected(sel); |
246 | 249 | if (foundMatches == 0) { |
247 | 250 | String msg = null; |
248 | 251 | if (s.mode == SearchMode.replace) { |
diff -puN src/org/openstreetmap/josm/actions/search/SearchCompiler.java~deprecate-osmprimitive-selection-methods src/org/openstreetmap/josm/actions/search/SearchCompiler.java
a
|
b
|
public class SearchCompiler {
|
423 | 423 | |
424 | 424 | private static class Selected extends Match { |
425 | 425 | @Override public boolean match(OsmPrimitive osm) { |
426 | | return osm.isSelected(); |
| 426 | return Main.main.getCurrentDataSet().isSelected(osm); |
427 | 427 | } |
428 | 428 | @Override public String toString() {return "selected";} |
429 | 429 | } |
diff -puN src/org/openstreetmap/josm/actions/UnGlueAction.java~deprecate-osmprimitive-selection-methods src/org/openstreetmap/josm/actions/UnGlueAction.java
a
|
b
|
public class UnGlueAction extends JosmAc
|
151 | 151 | |
152 | 152 | Node c = new Node(selectedNode); |
153 | 153 | c.removeAll(); |
154 | | c.setSelected(false); |
| 154 | getCurrentDataSet().clearSelection(c); |
155 | 155 | cmds.add(new ChangeCommand(selectedNode, c)); |
156 | 156 | |
157 | 157 | Node n = new Node(selectedNode); |
diff -puN src/org/openstreetmap/josm/data/osm/DataSet.java~deprecate-osmprimitive-selection-methods src/org/openstreetmap/josm/data/osm/DataSet.java
a
|
b
|
public class DataSet implements Cloneabl
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | |
| 219 | public boolean addSelected(OsmPrimitive osm) { |
| 220 | osm.setSelected(true); |
| 221 | return true; |
| 222 | } |
| 223 | |
| 224 | public boolean toggleSelected(OsmPrimitive osm) { |
| 225 | osm.setSelected(!osm.isSelected()); |
| 226 | return true; |
| 227 | } |
| 228 | public boolean isSelected(OsmPrimitive osm) { |
| 229 | return osm.isSelected(); |
| 230 | } |
| 231 | |
219 | 232 | public void setDisabled(OsmPrimitive... osm) { |
220 | 233 | if (osm.length == 1 && osm[0] == null) { |
221 | 234 | setDisabled(); |
… |
… |
public class DataSet implements Cloneabl
|
282 | 295 | * Remove the selection from every value in the collection. |
283 | 296 | * @param list The collection to remove the selection from. |
284 | 297 | */ |
| 298 | public void clearSelection(OsmPrimitive... osm) { |
| 299 | clearSelection(Arrays.asList(osm)); |
| 300 | } |
285 | 301 | private void clearSelection(Collection<? extends OsmPrimitive> list) { |
286 | 302 | if (list == null) |
287 | 303 | return; |
diff -puN src/org/openstreetmap/josm/data/osm/OsmPrimitive.java~deprecate-osmprimitive-selection-methods src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
a
|
b
|
abstract public class OsmPrimitive imple
|
220 | 220 | * @param selected true, if this primitive is selected; false, otherwise |
221 | 221 | * @since 1899 |
222 | 222 | */ |
223 | | public void setSelected(boolean selected) { |
| 223 | @Deprecated public void setSelected(boolean selected) { |
224 | 224 | if (selected) { |
225 | 225 | flags |= FLAG_SELECTED; |
226 | 226 | } else { |
… |
… |
abstract public class OsmPrimitive imple
|
233 | 233 | * @return true, if this primitive is selected |
234 | 234 | * @since 1899 |
235 | 235 | */ |
236 | | public boolean isSelected() { |
| 236 | @Deprecated public boolean isSelected() { |
237 | 237 | return (flags & FLAG_SELECTED) != 0; |
238 | 238 | } |
239 | 239 | |
… |
… |
abstract public class OsmPrimitive imple
|
773 | 773 | * @return the display name |
774 | 774 | */ |
775 | 775 | public abstract String getDisplayName(NameFormatter formatter); |
776 | | } |
777 | | No newline at end of file |
| 776 | } |
diff -puN src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java~deprecate-osmprimitive-selection-methods src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
a
|
b
|
public class SimplePaintVisitor extends
|
127 | 127 | RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF); |
128 | 128 | } |
129 | 129 | |
| 130 | DataSet ds; |
130 | 131 | public void visitAll(DataSet data, Boolean virtual) { |
| 132 | this.ds = data; |
131 | 133 | //boolean profiler = Main.pref.getBoolean("simplepaint.profiler",false); |
132 | 134 | //long profilerStart = java.lang.System.currentTimeMillis(); |
133 | 135 | //long profilerLast = profilerStart; |
… |
… |
public class SimplePaintVisitor extends
|
148 | 150 | require changing the colour while painting... */ |
149 | 151 | //profilerN = 0; |
150 | 152 | for (final OsmPrimitive osm : data.relations) |
151 | | if (!osm.isDeleted() && !osm.isSelected() && !osm.isFiltered()) |
| 153 | if (!osm.isDeleted() && !ds.isSelected(osm) && !osm.isFiltered()) |
152 | 154 | { |
153 | 155 | osm.visit(this); |
154 | 156 | // profilerN++; |
… |
… |
public class SimplePaintVisitor extends
|
162 | 164 | |
163 | 165 | //profilerN = 0; |
164 | 166 | for (final OsmPrimitive osm : data.ways) |
165 | | if (!osm.isDeleted() && !osm.isSelected() && !osm.isFiltered() && osm.isTagged()) |
| 167 | if (!osm.isDeleted() && !ds.isSelected(osm) && !osm.isFiltered() && osm.isTagged()) |
166 | 168 | { |
167 | 169 | osm.visit(this); |
168 | 170 | // profilerN++; |
… |
… |
public class SimplePaintVisitor extends
|
170 | 172 | displaySegments(); |
171 | 173 | |
172 | 174 | for (final OsmPrimitive osm : data.ways) |
173 | | if (!osm.isDeleted() && !osm.isSelected() && !osm.isFiltered() && !osm.isTagged()) |
| 175 | if (!osm.isDeleted() && !ds.isSelected(osm) && !osm.isFiltered() && !osm.isTagged()) |
174 | 176 | { |
175 | 177 | osm.visit(this); |
176 | 178 | // profilerN++; |
… |
… |
public class SimplePaintVisitor extends
|
201 | 203 | |
202 | 204 | //profilerN = 0; |
203 | 205 | for (final OsmPrimitive osm : data.nodes) |
204 | | if (!osm.isDeleted() && !osm.isSelected() && !osm.isFiltered()) |
| 206 | if (!osm.isDeleted() && !ds.isSelected(osm) && !osm.isFiltered()) |
205 | 207 | { |
206 | 208 | osm.visit(this); |
207 | 209 | // profilerN++; |
… |
… |
public class SimplePaintVisitor extends
|
252 | 254 | drawNode(n, inactiveColor, unselectedNodeSize, unselectedNodeRadius, fillUnselectedNode); |
253 | 255 | } else if (n.highlighted) { |
254 | 256 | drawNode(n, highlightColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); |
255 | | } else if (n.isSelected()) { |
| 257 | } else if (ds.isSelected(n)) { |
256 | 258 | drawNode(n, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); |
257 | 259 | } else if(n.isTagged()) { |
258 | 260 | drawNode(n, nodeColor, taggedNodeSize, taggedNodeRadius, fillUnselectedNode); |
… |
… |
public class SimplePaintVisitor extends
|
304 | 306 | /* show direction arrows, if draw.segment.relevant_directions_only is not set, the way is tagged with a direction key |
305 | 307 | (even if the tag is negated as in oneway=false) or the way is selected */ |
306 | 308 | |
307 | | boolean showThisDirectionArrow = w.isSelected() |
| 309 | boolean showThisDirectionArrow = ds.isSelected(w) |
308 | 310 | || (showDirectionArrow && (!showRelevantDirectionsOnly || w.hasDirectionKeys())); |
309 | 311 | /* head only takes over control if the option is true, |
310 | 312 | the direction should be shown at all and not only because it's selected */ |
311 | | boolean showOnlyHeadArrowOnly = showThisDirectionArrow && !w.isSelected() && showHeadArrowOnly; |
| 313 | boolean showOnlyHeadArrowOnly = showThisDirectionArrow && !ds.isSelected(w) && showHeadArrowOnly; |
312 | 314 | Color wayColor; |
313 | 315 | |
314 | 316 | if (inactive || w.isDisabled()) { |
315 | 317 | wayColor = inactiveColor; |
316 | 318 | } else if(w.highlighted) { |
317 | 319 | wayColor = highlightColor; |
318 | | } else if(w.isSelected()) { |
| 320 | } else if(ds.isSelected(w)) { |
319 | 321 | wayColor = selectedColor; |
320 | 322 | } else if (!w.isTagged()) { |
321 | 323 | wayColor = untaggedWayColor; |
… |
… |
public class SimplePaintVisitor extends
|
346 | 348 | Color col; |
347 | 349 | if (inactive || r.isDisabled()) { |
348 | 350 | col = inactiveColor; |
349 | | } else if (r.isSelected()) { |
| 351 | } else if (ds.isSelected(r)) { |
350 | 352 | col = selectedColor; |
351 | 353 | } else { |
352 | 354 | col = relationColor; |
diff -puN src/org/openstreetmap/josm/gui/NavigatableComponent.java~deprecate-osmprimitive-selection-methods src/org/openstreetmap/josm/gui/NavigatableComponent.java
a
|
b
|
public class NavigatableComponent extend
|
317 | 317 | } |
318 | 318 | // when multiple nodes on one point, prefer new or selected nodes |
319 | 319 | else if(dist == minDistanceSq && minPrimitive != null |
320 | | && ((n.getId() == 0 && n.isSelected()) |
321 | | || (!minPrimitive.isSelected() && (n.isSelected() || n.getId() == 0)))) { |
| 320 | && ((n.getId() == 0 && ds.isSelected(n)) |
| 321 | || (!ds.isSelected(minPrimitive) && (ds.isSelected(n) || n.getId() == 0)))) { |
322 | 322 | minPrimitive = n; |
323 | 323 | } |
324 | 324 | } |
… |
… |
public class NavigatableComponent extend
|
359 | 359 | double b = p.distanceSq(A); |
360 | 360 | double perDist = a-(a-b+c)*(a-b+c)/4/c; // perpendicular distance squared |
361 | 361 | if (perDist < snapDistance && a < c+snapDistance && b < c+snapDistance) { |
362 | | if(w.isSelected()) { |
| 362 | if(ds.isSelected(w)) { |
363 | 363 | perDist -= 0.00001; |
364 | 364 | } |
365 | 365 | List<WaySegment> l; |
diff -puN src/org/openstreetmap/josm/actions/mapmode/DrawAction.java~deprecate-osmprimitive-selection-methods src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
a
|
b
|
public class DrawAction extends MapMode
|
324 | 324 | updateKeyModifiers(e); |
325 | 325 | mousePos = e.getPoint(); |
326 | 326 | |
327 | | Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected(); |
| 327 | DataSet ds = getCurrentDataSet(); |
| 328 | Collection<OsmPrimitive> selection = ds.getSelected(); |
328 | 329 | Collection<Command> cmds = new LinkedList<Command>(); |
329 | 330 | |
330 | 331 | ArrayList<Way> reuseWays = new ArrayList<Way>(), |
… |
… |
public class DrawAction extends MapMode
|
404 | 405 | // but pressing ALT prevents this. Therefore we must de-select the way manually |
405 | 406 | // here so /only/ the new way will be selected after this method finishes. |
406 | 407 | if(alt) { |
407 | | wnew.setSelected(false); |
| 408 | ds.addSelected(wnew); |
408 | 409 | } |
409 | 410 | |
410 | 411 | cmds.add(new ChangeCommand(insertPoint.getKey(), wnew)); |
… |
… |
public class DrawAction extends MapMode
|
518 | 519 | |
519 | 520 | extendedWay = true; |
520 | 521 | getCurrentDataSet().setSelected(way); |
521 | | DataSet.fireSelectionChanged(getCurrentDataSet().getSelected()); |
| 522 | DataSet.fireSelectionChanged(ds.getSelected()); |
522 | 523 | } |
523 | 524 | } |
524 | 525 | |
… |
… |
public class DrawAction extends MapMode
|
531 | 532 | } else { |
532 | 533 | title = tr("Add node into way"); |
533 | 534 | for (Way w : reuseWays) { |
534 | | w.setSelected(false); |
| 535 | ds.clearSelection(w); |
535 | 536 | } |
536 | 537 | } |
537 | 538 | getCurrentDataSet().setSelected(n); |
diff -puN src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java~deprecate-osmprimitive-selection-methods src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
a
|
b
|
public class MapPaintVisitor extends Sim
|
151 | 151 | // return; |
152 | 152 | |
153 | 153 | if (nodeStyle != null && isZoomOk(nodeStyle) && showIcons > dist) { |
154 | | drawNode(n, nodeStyle.icon, nodeStyle.annotate, n.isSelected()); |
| 154 | drawNode(n, nodeStyle.icon, nodeStyle.annotate, data.isSelected(n)); |
155 | 155 | } else if (n.highlighted) { |
156 | 156 | drawNode(n, highlightColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); |
157 | | } else if (n.isSelected()) { |
| 157 | } else if (data.isSelected(n)) { |
158 | 158 | drawNode(n, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); |
159 | 159 | } else if (n.isTagged()) { |
160 | 160 | drawNode(n, nodeColor, taggedNodeSize, taggedNodeRadius, fillUnselectedNode); |
… |
… |
public class MapPaintVisitor extends Sim
|
226 | 226 | /* way without style */ |
227 | 227 | //profilerVisibleWays++; |
228 | 228 | //if(!profilerOmitDraw) |
229 | | drawWay(w, null, untaggedColor, w.isSelected()); |
| 229 | drawWay(w, null, untaggedColor, data.isSelected(w)); |
230 | 230 | } |
231 | 231 | else if(wayStyle instanceof LineElemStyle) |
232 | 232 | { |
233 | 233 | /* way with line style */ |
234 | 234 | //profilerVisibleWays++; |
235 | 235 | //if(!profilerOmitDraw) |
236 | | drawWay(w, (LineElemStyle)wayStyle, untaggedColor, w.isSelected()); |
| 236 | drawWay(w, (LineElemStyle)wayStyle, untaggedColor, data.isSelected(w)); |
237 | 237 | } |
238 | 238 | else if (wayStyle instanceof AreaElemStyle) |
239 | 239 | { |
… |
… |
public class MapPaintVisitor extends Sim
|
244 | 244 | if (fillAreas > dist) |
245 | 245 | { |
246 | 246 | // profilerVisibleAreas++; |
247 | | drawArea(w, w.isSelected() ? selectedColor : areaStyle.color); |
| 247 | drawArea(w, data.isSelected(w) ? selectedColor : areaStyle.color); |
248 | 248 | if(!w.isClosed()) { |
249 | 249 | w.putError(tr("Area style way is not closed."), true); |
250 | 250 | } |
251 | 251 | } |
252 | | drawWay(w, areaStyle.line, areaStyle.color, w.isSelected()); |
| 252 | drawWay(w, areaStyle.line, areaStyle.color, data.isSelected(w)); |
253 | 253 | //} |
254 | 254 | } |
255 | 255 | } |
… |
… |
public class MapPaintVisitor extends Sim
|
258 | 258 | /* show direction arrows, if draw.segment.relevant_directions_only is not set, |
259 | 259 | the way is tagged with a direction key |
260 | 260 | (even if the tag is negated as in oneway=false) or the way is selected */ |
261 | | boolean showDirection = w.isSelected() || ((!useRealWidth) && (showDirectionArrow |
| 261 | boolean showDirection = data.isSelected(w) || ((!useRealWidth) && (showDirectionArrow |
262 | 262 | && (!showRelevantDirectionsOnly || w.hasDirectionKeys()))); |
263 | 263 | /* head only takes over control if the option is true, |
264 | 264 | the direction should be shown at all and not only because it's selected */ |
265 | | boolean showOnlyHeadArrowOnly = showDirection && !w.isSelected() && showHeadArrowOnly; |
| 265 | boolean showOnlyHeadArrowOnly = showDirection && !data.isSelected(w) && showHeadArrowOnly; |
266 | 266 | int width = defaultSegmentWidth; |
267 | 267 | int realWidth = 0; /* the real width of the element in meters */ |
268 | 268 | float dashed[] = new float[0]; |
… |
… |
public class MapPaintVisitor extends Sim
|
306 | 306 | |
307 | 307 | if(w.highlighted) { |
308 | 308 | color = highlightColor; |
309 | | } else if(w.isSelected()) { |
| 309 | } else if(data.isSelected(w)) { |
310 | 310 | color = selectedColor; |
311 | 311 | } else if(w.isDisabled()) { |
312 | 312 | color = inactiveColor; |
… |
… |
public class MapPaintVisitor extends Sim
|
324 | 324 | { |
325 | 325 | if(lastN != null) |
326 | 326 | { |
327 | | drawSeg(lastN, n, s.color != null && !w.isSelected() ? s.color : color, |
| 327 | drawSeg(lastN, n, s.color != null && !data.isSelected(w) ? s.color : color, |
328 | 328 | false, s.getWidth(width), s.dashed, s.dashedColor); |
329 | 329 | } |
330 | 330 | lastN = n; |
… |
… |
public class MapPaintVisitor extends Sim
|
358 | 358 | { |
359 | 359 | if(lastN != null) |
360 | 360 | { |
361 | | drawSeg(lastN, n, s.color != null && !w.isSelected() ? s.color : color, |
| 361 | drawSeg(lastN, n, s.color != null && !data.isSelected(w) ? s.color : color, |
362 | 362 | false, s.getWidth(width), s.dashed, s.dashedColor); |
363 | 363 | } |
364 | 364 | lastN = n; |
… |
… |
public class MapPaintVisitor extends Sim
|
404 | 404 | { |
405 | 405 | Way c = (Way)joinArray[i]; |
406 | 406 | if(w == null) |
407 | | { w = c; selected = w.isSelected(); joinArray[i] = null; --left; } |
| 407 | { w = c; selected = data.isSelected(w); joinArray[i] = null; --left; } |
408 | 408 | else |
409 | 409 | { |
410 | 410 | int mode = 0; |
… |
… |
public class MapPaintVisitor extends Sim
|
440 | 440 | { |
441 | 441 | joinArray[i] = null; |
442 | 442 | joined = true; |
443 | | if(c.isSelected()) { |
| 443 | if(data.isSelected(c)) { |
444 | 444 | selected = true; |
445 | 445 | } |
446 | 446 | --left; |
… |
… |
public class MapPaintVisitor extends Sim
|
473 | 473 | { |
474 | 474 | w = new Way(w); |
475 | 475 | w.setNodes(n); |
476 | | w.setSelected(selected); |
| 476 | if (selected) |
| 477 | data.setSelected(w); |
| 478 | else |
| 479 | data.clearSelection(w); |
477 | 480 | } |
478 | 481 | if(!w.isClosed()) |
479 | 482 | { |
… |
… |
public class MapPaintVisitor extends Sim
|
550 | 553 | drawRestriction(r); |
551 | 554 | } |
552 | 555 | |
553 | | if(r.isSelected()) /* draw ways*/ |
| 556 | if(data.isSelected(r)) /* draw ways*/ |
554 | 557 | { |
555 | 558 | for (RelationMember m : r.getMembers()) |
556 | 559 | { |
… |
… |
public class MapPaintVisitor extends Sim
|
827 | 830 | int w = smallIcon.getIconWidth(), h=smallIcon.getIconHeight(); |
828 | 831 | smallIcon.paintIcon ( Main.map.mapView, g, (int)(pVia.x+vx+vx2)-w/2, (int)(pVia.y+vy+vy2)-h/2 ); |
829 | 832 | |
830 | | if (r.isSelected()) |
| 833 | if (data.isSelected(r)) |
831 | 834 | { |
832 | 835 | g.setColor ( selectedColor ); |
833 | 836 | g.drawRect ((int)(pVia.x+vx+vx2)-w/2-2,(int)(pVia.y+vy+vy2)-h/2-2, w+4, h+4); |
… |
… |
public class MapPaintVisitor extends Sim
|
871 | 874 | m.getRole(), w.getDisplayName(DefaultNameFormatter.getInstance())), true); |
872 | 875 | if(!m.hasRole()) { |
873 | 876 | outer.add(w); |
874 | | } else if(r.isSelected()) { |
| 877 | } else if(data.isSelected(r)) { |
875 | 878 | drawSelectedMember(m.getMember(), styles != null |
876 | 879 | ? getPrimitiveStyle(m.getMember()) : null, true, true); |
877 | 880 | } |
… |
… |
public class MapPaintVisitor extends Sim
|
1051 | 1054 | Polygon p = pd.get(); |
1052 | 1055 | if(isPolygonVisible(p)) |
1053 | 1056 | { |
1054 | | drawAreaPolygon(p, (pd.way.isSelected() || r.isSelected()) ? selectedColor |
| 1057 | drawAreaPolygon(p, (data.isSelected(pd.way) || data.isSelected(r)) ? selectedColor |
1055 | 1058 | : areaStyle.color); |
1056 | 1059 | visible = true; |
1057 | 1060 | } |
… |
… |
public class MapPaintVisitor extends Sim
|
1077 | 1080 | || outer.size() == 0)) |
1078 | 1081 | { |
1079 | 1082 | drawWay(wInner, ((AreaElemStyle)wayStyle).line, |
1080 | | ((AreaElemStyle)wayStyle).color, wInner.isSelected() |
1081 | | || r.isSelected()); |
| 1083 | ((AreaElemStyle)wayStyle).color, data.isSelected(wInner) |
| 1084 | || data.isSelected(r)); |
1082 | 1085 | } |
1083 | 1086 | wInner.mappaintDrawnCode = paintid; |
1084 | 1087 | } |
1085 | 1088 | else |
1086 | 1089 | { |
1087 | | if(r.isSelected()) |
| 1090 | if(data.isSelected(r)) |
1088 | 1091 | { |
1089 | 1092 | drawSelectedMember(wInner, innerStyle, |
1090 | | !wayStyle.equals(innerStyle), wInner.isSelected()); |
| 1093 | !wayStyle.equals(innerStyle), data.isSelected(wInner)); |
1091 | 1094 | } |
1092 | 1095 | if(wayStyle.equals(innerStyle)) |
1093 | 1096 | { |
1094 | 1097 | r.putError(tr("Style for inner way ''{0}'' equals multipolygon.", |
1095 | 1098 | wInner.getDisplayName(DefaultNameFormatter.getInstance())), false); |
1096 | | if(!r.isSelected()) { |
| 1099 | if(!data.isSelected(r)) { |
1097 | 1100 | wInner.mappaintDrawnAreaCode = paintid; |
1098 | 1101 | } |
1099 | 1102 | } |
… |
… |
public class MapPaintVisitor extends Sim
|
1107 | 1110 | if(zoomok) |
1108 | 1111 | { |
1109 | 1112 | drawWay(wOuter, ((AreaElemStyle)wayStyle).line, |
1110 | | ((AreaElemStyle)wayStyle).color, wOuter.isSelected() |
1111 | | || r.isSelected()); |
| 1113 | ((AreaElemStyle)wayStyle).color, data.isSelected(wOuter) |
| 1114 | || data.isSelected(r)); |
1112 | 1115 | } |
1113 | 1116 | wOuter.mappaintDrawnCode = paintid; |
1114 | 1117 | } |
… |
… |
public class MapPaintVisitor extends Sim
|
1120 | 1123 | r.putError(tr("Style for outer way ''{0}'' mismatches.", |
1121 | 1124 | wOuter.getDisplayName(DefaultNameFormatter.getInstance())), true); |
1122 | 1125 | } |
1123 | | if(r.isSelected()) |
| 1126 | if(data.isSelected(r)) |
1124 | 1127 | { |
1125 | 1128 | drawSelectedMember(wOuter, outerStyle, false, false); |
1126 | 1129 | } |
… |
… |
public class MapPaintVisitor extends Sim
|
1325 | 1328 | textColor = Main.pref.getColor (marktr("text"), Color.WHITE); |
1326 | 1329 | } |
1327 | 1330 | |
| 1331 | DataSet data; |
| 1332 | |
1328 | 1333 | /* Shows areas before non-areas */ |
1329 | 1334 | @Override |
1330 | 1335 | public void visitAll(DataSet data, Boolean virtual) { |
1331 | | |
| 1336 | this.data = data; |
1332 | 1337 | //boolean profiler = Main.pref.getBoolean("mappaint.profiler",false); |
1333 | 1338 | //profilerOmitDraw = Main.pref.getBoolean("mappaint.profiler.omitdraw",false); |
1334 | 1339 | |
… |
… |
public class MapPaintVisitor extends Sim
|
1449 | 1454 | /*** WAYS (filling disabled) ***/ |
1450 | 1455 | // profilerN = 0; |
1451 | 1456 | for (final OsmPrimitive osm : data.ways) |
1452 | | if (!osm.incomplete && !osm.isDeleted() && !osm.isFiltered() && !osm.isSelected() |
| 1457 | if (!osm.incomplete && !osm.isDeleted() && !osm.isFiltered() && !data.isSelected(osm) |
1453 | 1458 | && osm.mappaintVisibleCode != viewid ) |
1454 | 1459 | { |
1455 | 1460 | osm.visit(this); |
… |
… |
public class MapPaintVisitor extends Sim
|
1488 | 1493 | /*** NODES ***/ |
1489 | 1494 | //profilerN = 0; |
1490 | 1495 | for (final OsmPrimitive osm : data.nodes) |
1491 | | if (!osm.incomplete && !osm.isDeleted() && (osm.isSelected() || !osm.isFiltered()) |
| 1496 | if (!osm.incomplete && !osm.isDeleted() && (data.isSelected(osm) || !osm.isFiltered()) |
1492 | 1497 | && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) |
1493 | 1498 | { |
1494 | 1499 | osm.visit(this); |
diff -puN src/org/openstreetmap/josm/gui/MapStatus.java~deprecate-osmprimitive-selection-methods src/org/openstreetmap/josm/gui/MapStatus.java
a
|
b
|
public class MapStatus extends JPanel im
|
299 | 299 | * @param mouse modifiers |
300 | 300 | */ |
301 | 301 | private final void popupCycleSelection(Collection<OsmPrimitive> osms, int mods) { |
| 302 | DataSet ds = Main.main.getCurrentDataSet(); |
302 | 303 | // Find some items that are required for cycling through |
303 | 304 | OsmPrimitive firstItem = null; |
304 | 305 | OsmPrimitive firstSelected = null; |
… |
… |
public class MapStatus extends JPanel im
|
310 | 311 | if(firstSelected != null && nextSelected == null) { |
311 | 312 | nextSelected = osm; |
312 | 313 | } |
313 | | if(firstSelected == null && osm.isSelected()) { |
| 314 | if(firstSelected == null && ds.isSelected(osm)) { |
314 | 315 | firstSelected = osm; |
315 | 316 | } |
316 | 317 | } |
… |
… |
public class MapStatus extends JPanel im
|
318 | 319 | // Clear previous selection if SHIFT (add to selection) is not |
319 | 320 | // pressed. Cannot use "setSelected()" because it will cause a |
320 | 321 | // fireSelectionChanged event which is unnecessary at this point. |
321 | | if((mods & MouseEvent.SHIFT_DOWN_MASK) == 0) { |
322 | | for(OsmPrimitive o : Main.main.getCurrentDataSet().getSelected()) { |
323 | | o.setSelected(false); |
324 | | } |
325 | | } |
| 322 | if((mods & MouseEvent.SHIFT_DOWN_MASK) == 0) |
| 323 | ds.clearSelection(); |
326 | 324 | |
327 | 325 | // This will cycle through the available items. |
328 | 326 | if(firstSelected == null) { |
329 | | firstItem.setSelected(true); |
| 327 | ds.addSelected(firstItem); |
330 | 328 | } else { |
331 | | firstSelected.setSelected(false); |
| 329 | ds.clearSelection(firstSelected); |
332 | 330 | if(nextSelected != null) { |
333 | | nextSelected.setSelected(true); |
| 331 | ds.addSelected(nextSelected); |
334 | 332 | } |
335 | 333 | } |
336 | | DataSet.fireSelectionChanged(Main.main.getCurrentDataSet().getSelected()); |
| 334 | DataSet.fireSelectionChanged(ds.getSelected()); |
337 | 335 | } |
338 | 336 | |
339 | 337 | /** |
… |
… |
public class MapStatus extends JPanel im
|
397 | 395 | * @param osm The primitive to derive the colors from |
398 | 396 | */ |
399 | 397 | private final void popupSetLabelColors(JLabel lbl, OsmPrimitive osm) { |
400 | | if(osm.isSelected()) { |
| 398 | DataSet ds = Main.main.getCurrentDataSet(); |
| 399 | if(ds.isSelected(osm)) { |
401 | 400 | lbl.setBackground(SystemColor.textHighlight); |
402 | 401 | lbl.setForeground(SystemColor.textHighlightText); |
403 | 402 | } else { |
… |
… |
public class MapStatus extends JPanel im
|
459 | 458 | popupSetLabelColors(l, osm); |
460 | 459 | } |
461 | 460 | @Override public void mouseClicked(MouseEvent e) { |
| 461 | DataSet ds = Main.main.getCurrentDataSet(); |
462 | 462 | // Let the user toggle the selection |
463 | | osm.setSelected(!osm.isSelected()); |
464 | | DataSet.fireSelectionChanged(Main.main.getCurrentDataSet().getSelected()); |
| 463 | ds.toggleSelected(osm); |
| 464 | DataSet.fireSelectionChanged(ds.getSelected()); |
465 | 465 | l.validate(); |
466 | 466 | } |
467 | 467 | }); |