Changeset 42 in josm for src/org/openstreetmap/josm/gui/SelectionManager.java
- Timestamp:
- 2006-01-21T19:02:06+01:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/gui/SelectionManager.java
r30 r42 89 89 private Point mousePos; 90 90 /** 91 * The MapView, the selection rectangle is drawn onto.92 */ 93 private final MapView mv;91 * The Component, the selection rectangle is drawn onto. 92 */ 93 private final NavigatableComponent nc; 94 94 /** 95 95 * Whether the selection rectangle must obtain the aspect ratio of the … … 105 105 * @param aspectRatio If true, the selection window must obtain the aspect 106 106 * ratio of the drawComponent. 107 * @param mapView The view, the rectangle is drawn onto.108 */ 109 public SelectionManager(SelectionEnded selectionEndedListener, boolean aspectRatio, MapView mapView) {107 * @param navComp The component, the rectangle is drawn onto. 108 */ 109 public SelectionManager(SelectionEnded selectionEndedListener, boolean aspectRatio, NavigatableComponent navComp) { 110 110 this.selectionEndedListener = selectionEndedListener; 111 111 this.aspectRatio = aspectRatio; 112 this. mv = mapView;112 this.nc = navComp; 113 113 } 114 114 … … 196 196 if (mousePos == null || mousePosStart == null || mousePos == mousePosStart) 197 197 return; 198 Graphics g = mv.getGraphics();198 Graphics g = nc.getGraphics(); 199 199 g.setColor(Color.BLACK); 200 200 g.setXORMode(Color.WHITE); … … 224 224 if (aspectRatio) { 225 225 // keep the aspect ration by shrinking the rectangle 226 double aspectRatio = (double) mv.getWidth()/mv.getHeight();226 double aspectRatio = (double)nc.getWidth()/nc.getHeight(); 227 227 if ((double)w/h > aspectRatio) { 228 228 int neww = (int)(h*aspectRatio); … … 267 267 268 268 if (clicked) { 269 OsmPrimitive osm = mv.getNearest(center, alt);269 OsmPrimitive osm = nc.getNearest(center, alt); 270 270 if (osm != null) 271 271 selection.add(osm); … … 273 273 // nodes 274 274 for (Node n : Main.main.ds.nodes) { 275 if (r.contains( mv.getScreenPoint(n.coor)))275 if (r.contains(nc.getScreenPoint(n.coor))) 276 276 selection.add(n); 277 277 } … … 310 310 private boolean rectangleContainLineSegment(Rectangle r, boolean alt, LineSegment ls) { 311 311 if (alt) { 312 Point p1 = mv.getScreenPoint(ls.start.coor);313 Point p2 = mv.getScreenPoint(ls.end.coor);312 Point p1 = nc.getScreenPoint(ls.start.coor); 313 Point p2 = nc.getScreenPoint(ls.end.coor); 314 314 if (r.intersectsLine(p1.x, p1.y, p2.x, p2.y)) 315 315 return true; 316 316 } else { 317 if (r.contains( mv.getScreenPoint(ls.start.coor))318 && r.contains( mv.getScreenPoint(ls.end.coor)))317 if (r.contains(nc.getScreenPoint(ls.start.coor)) 318 && r.contains(nc.getScreenPoint(ls.end.coor))) 319 319 return true; 320 320 }
Note:
See TracChangeset
for help on using the changeset viewer.