Changeset 12108 in josm
- Timestamp:
- 2017-05-11T00:18:51+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java
r12106 r12108 44 44 import org.openstreetmap.josm.gui.Notification; 45 45 import org.openstreetmap.josm.gui.draw.MapViewPath; 46 import org.openstreetmap.josm.gui.layer.AbstractMapViewPaintable; 46 47 import org.openstreetmap.josm.gui.layer.Layer; 47 import org.openstreetmap.josm.gui.layer.MapViewPaintable;48 48 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 49 49 import org.openstreetmap.josm.gui.util.ModifierListener; … … 90 90 * @author Ole Jørgen Brønner (olejorgenb) 91 91 */ 92 public class ParallelWayAction extends MapMode implements ModifierListener , MapViewPaintable{92 public class ParallelWayAction extends MapMode implements ModifierListener { 93 93 94 94 private static final CachingProperty<BasicStroke> HELPER_LINE_STROKE = new StrokeProperty(prefKey("stroke.hepler-line"), "1").cached(); … … 145 145 private EastNorth helperLineEnd; 146 146 147 private final ParallelWayLayer temporaryLayer = new ParallelWayLayer(); 148 147 149 /** 148 150 * Constructs a new {@code ParallelWayAction}. … … 168 170 mv.addMouseListener(this); 169 171 mv.addMouseMotionListener(this); 170 mv.addTemporaryLayer(t his);172 mv.addTemporaryLayer(temporaryLayer); 171 173 172 174 //// Needed to update the mouse cursor if modifiers are changed when the mouse is motionless … … 183 185 mv.removeMouseListener(this); 184 186 mv.removeMouseMotionListener(this); 185 mv.removeTemporaryLayer(t his);187 mv.removeTemporaryLayer(temporaryLayer); 186 188 Main.map.statusLine.setDist(-1); 187 189 Main.map.statusLine.repaint(); … … 334 336 setMode(Mode.NORMAL); 335 337 resetMouseTrackingState(); 336 mv.repaint();338 temporaryLayer.invalidate(); 337 339 } 338 340 … … 431 433 Main.map.statusLine.setDist(Math.abs(snappedRealD)); 432 434 Main.map.statusLine.repaint(); 433 mv.repaint();435 temporaryLayer.invalidate(); 434 436 } 435 437 … … 450 452 } 451 453 return spec.entrySet().stream().allMatch(entry -> modifiers.contains(entry.getKey()) == entry.getValue().booleanValue()); 452 }453 454 @Override455 public void paint(Graphics2D g, MapView mv, Bounds bbox) {456 if (mode == Mode.DRAGGING) {457 CheckParameterUtil.ensureParameterNotNull(mv, "mv");458 459 Color mainColor = MAIN_COLOR.get();460 // FIXME: should clip the line (gets insanely slow when zoomed in on a very long line461 g.setStroke(REF_LINE_STROKE.get());462 g.setColor(mainColor);463 MapViewPath line = new MapViewPath(mv);464 line.moveTo(referenceSegment.getFirstNode());465 line.lineTo(referenceSegment.getSecondNode());466 g.draw(line.computeClippedLine(g.getStroke()));467 468 g.setStroke(HELPER_LINE_STROKE.get());469 g.setColor(mainColor);470 line = new MapViewPath(mv);471 line.moveTo(helperLineStart);472 line.lineTo(helperLineEnd);473 g.draw(line.computeClippedLine(g.getStroke()));474 }475 454 } 476 455 … … 633 612 } 634 613 } 614 615 private class ParallelWayLayer extends AbstractMapViewPaintable { 616 @Override 617 public void paint(Graphics2D g, MapView mv, Bounds bbox) { 618 if (mode == Mode.DRAGGING) { 619 CheckParameterUtil.ensureParameterNotNull(mv, "mv"); 620 621 Color mainColor = MAIN_COLOR.get(); 622 g.setStroke(REF_LINE_STROKE.get()); 623 g.setColor(mainColor); 624 MapViewPath line = new MapViewPath(mv); 625 line.moveTo(referenceSegment.getFirstNode()); 626 line.lineTo(referenceSegment.getSecondNode()); 627 g.draw(line.computeClippedLine(g.getStroke())); 628 629 g.setStroke(HELPER_LINE_STROKE.get()); 630 g.setColor(mainColor); 631 line = new MapViewPath(mv); 632 line.moveTo(helperLineStart); 633 line.lineTo(helperLineEnd); 634 g.draw(line.computeClippedLine(g.getStroke())); 635 } 636 } 637 } 635 638 }
Note:
See TracChangeset
for help on using the changeset viewer.