- Timestamp:
- 2009-10-10T14:14:28+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java
r2256 r2264 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 -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r2120 r2264 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 … … 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 … … 519 520 extendedWay = true; 520 521 getCurrentDataSet().setSelected(way); 521 DataSet.fireSelectionChanged( getCurrentDataSet().getSelected());522 DataSet.fireSelectionChanged(ds.getSelected()); 522 523 } 523 524 } … … 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 } -
trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
r2262 r2264 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{ … … 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()); … … 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; -
trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r2166 r2264 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";} -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r2263 r2264 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) { … … 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) -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r2252 r2264 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; … … 234 234 * @since 1899 235 235 */ 236 public boolean isSelected() {236 @Deprecated public boolean isSelected() { 237 237 return (flags & FLAG_SELECTED) != 0; 238 238 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r2206 r2264 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()) { … … 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) … … 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) … … 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 } … … 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) && (showDirectionArrow261 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 */ … … 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()) { … … 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 } … … 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 } … … 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 { … … 441 441 joinArray[i] = null; 442 442 joined = true; 443 if( c.isSelected()) {443 if(data.isSelected(c)) { 444 444 selected = true; 445 445 } … … 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()) … … 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()) … … 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 ); … … 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); … … 1052 1055 if(isPolygonVisible(p)) 1053 1056 { 1054 drawAreaPolygon(p, ( pd.way.isSelected() || r.isSelected()) ? selectedColor1057 drawAreaPolygon(p, (data.isSelected(pd.way) || data.isSelected(r)) ? selectedColor 1055 1058 : areaStyle.color); 1056 1059 visible = true; … … 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; … … 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)) … … 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 } … … 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; … … 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); … … 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); … … 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 { … … 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 { -
trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
r2120 r2264 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(); … … 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); … … 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); … … 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); … … 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); … … 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()) { … … 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 … … 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()) { … … 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 { -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r2252 r2264 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; … … 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 } … … 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);334 } 335 } 336 DataSet.fireSelectionChanged( Main.main.getCurrentDataSet().getSelected());331 ds.addSelected(nextSelected); 332 } 333 } 334 DataSet.fireSelectionChanged(ds.getSelected()); 337 335 } 338 336 … … 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); … … 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 } -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r2252 r2264 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 } … … 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 }
Note:
See TracChangeset
for help on using the changeset viewer.