Changeset 19701 in josm
- Timestamp:
- 2026-11-22T16:16:43+01:00 (less than one hour ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 8 edited
-
actions/mapmode/DeleteAction.java (modified) (1 diff)
-
actions/mapmode/DrawAction.java (modified) (1 diff)
-
actions/mapmode/MapMode.java (modified) (1 diff)
-
actions/mapmode/SelectAction.java (modified) (1 diff)
-
gui/MapMover.java (modified) (2 diffs)
-
gui/MapView.java (modified) (8 diffs)
-
gui/layer/AbstractTileSourceLayer.java (modified) (6 diffs)
-
gui/layer/OsmDataLayer.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java
r19050 r19701 189 189 @Override 190 190 public void mouseMoved(MouseEvent e) { 191 if (isPanning()) { 192 return; 193 } 191 194 oldEvent = e; 192 195 giveUserFeedback(e); -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r17896 r19701 802 802 @Override 803 803 public void mouseMoved(MouseEvent e) { 804 if (!MainApplication.getMap().mapView.isActiveLayerDrawable()) 804 if (isPanning() || !MainApplication.getMap().mapView.isActiveLayerDrawable()) 805 805 return; 806 806 -
trunk/src/org/openstreetmap/josm/actions/mapmode/MapMode.java
r19525 r19701 264 264 return l instanceof OsmDataLayer && !((OsmDataLayer) l).isLocked(); 265 265 } 266 267 /** 268 * Determines if the user is currently panning the map. 269 * @return {@code true} if a pan is in progress 270 * @since 19701 271 */ 272 protected static boolean isPanning() { 273 return MainApplication.isDisplayingMapView() && MainApplication.getMap().mapView.isPanning(); 274 } 266 275 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r19567 r19701 272 272 */ 273 273 private boolean giveUserFeedback(MouseEvent e, int modifiers) { 274 if (isPanning()) { 275 return false; 276 } 274 277 Optional<OsmPrimitive> c = Optional.ofNullable( 275 278 mv.getNearestNodeOrWay(e.getPoint(), mv.isSelectablePredicate, true)); -
trunk/src/org/openstreetmap/josm/gui/MapMover.java
r19656 r19701 22 22 import org.openstreetmap.josm.data.preferences.BooleanProperty; 23 23 import org.openstreetmap.josm.gui.MapViewState.MapViewPoint; 24 import org.openstreetmap.josm.gui.layer.Layer;25 24 import org.openstreetmap.josm.spi.preferences.Config; 26 25 import org.openstreetmap.josm.spi.preferences.PreferenceChangeEvent; … … 251 250 nc.resetCursor(this); 252 251 mousePosMoveStart = null; 253 MainApplication.getLayerManager().getLayers().forEach(Layer::invalidate); 252 // Repaint only. Labels refresh on the next still frame 253 nc.repaint(); 254 254 } 255 255 -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r19592 r19701 54 54 import org.openstreetmap.josm.data.osm.visitor.paint.Rendering; 55 55 import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache; 56 import org.openstreetmap.josm.data.projection.Projection; 56 57 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 57 58 import org.openstreetmap.josm.gui.MapViewState.MapViewRectangle; 58 59 import org.openstreetmap.josm.gui.autofilter.AutoFilterManager; 59 60 import org.openstreetmap.josm.gui.datatransfer.OsmTransferHandler; 61 import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer; 60 62 import org.openstreetmap.josm.gui.layer.Layer; 61 63 import org.openstreetmap.josm.gui.layer.LayerManager; … … 237 239 private transient BufferedImage nonChangedLayersBuffer; 238 240 private transient BufferedImage offscreenBuffer; 239 // Layers that wasn't changed since last paint240 private final transient List<Layer> nonChangedLayers = new ArrayList<>();241 241 private int lastViewID; 242 private double lastPaintedScale; 243 private EastNorth lastPaintedCenter; 244 private Projection lastPaintedProjection; 245 private List<Layer> lastPaintedLayers; 246 // Composite baked without labels during a pan. 247 private transient boolean panLabelsHidden; 242 248 private final AtomicBoolean paintPreferencesChanged = new AtomicBoolean(true); 243 249 private Rectangle lastClipBounds = new Rectangle(); … … 490 496 BugReport.intercept(t).put("layer", layer).warn(); 491 497 } 498 } 499 500 /** 501 * Determines if a pan is in progress. 502 * @return {@code true} if a pan is in progress 503 * @since 19701 504 */ 505 public boolean isPanning() { 506 return mapMover != null && mapMover.movementInProgress(); 492 507 } 493 508 … … 552 567 } 553 568 554 boolean canUseBuffer = !paintPreferencesChanged.getAndSet(false) 555 && nonChangedLayers.size() <= nonChangedLayersCount 556 && lastViewID == getViewID() 557 && lastClipBounds.contains(g.getClipBounds()) 558 && nonChangedLayers.equals(visibleLayers.subList(0, nonChangedLayers.size())); 559 569 boolean paintPrefsChanged = paintPreferencesChanged.getAndSet(false); 570 boolean sameLayerSet = lastPaintedLayers != null && lastPaintedLayers.equals(visibleLayers); 571 int viewID = getViewID(); 572 boolean viewMoved = lastViewID != viewID; 573 boolean panning = isPanning(); 574 boolean hideLabels = OsmDataLayer.PROPERTY_HIDE_LABELS_WHILE_DRAGGING.get(); 575 EastNorth center = getCenter(); 576 double scale = getScale(); 577 Rectangle clip = g.getClipBounds(); 578 boolean fullClip = clip.contains(0, 0, getWidth(), getHeight()); 579 // Partial clips must not rebuild the buffer or clear the label flag 580 boolean needLabelRefresh = panLabelsHidden && !viewMoved && fullClip && !panning; 581 if (needLabelRefresh) { 582 panLabelsHidden = false; 583 } 584 boolean canUseBuffer = !paintPrefsChanged 585 && !needLabelRefresh 586 && !viewMoved 587 && sameLayerSet 588 && nonChangedLayersCount == visibleLayers.size() 589 && lastClipBounds.contains(clip); 590 591 boolean canReusePan = !paintPrefsChanged 592 && viewMoved 593 && sameLayerSet 594 && Utils.equalsEpsilon(scale, lastPaintedScale) 595 && lastPaintedProjection == getProjection() 596 && lastClipBounds.contains(0, 0, getWidth(), getHeight()) 597 && hideLabels 598 && nonChangedLayersBuffer != null 599 && nonChangedLayersBuffer.getWidth() == width && nonChangedLayersBuffer.getHeight() == height; 600 int blitDX = 0; 601 int blitDY = 0; 602 if (canReusePan) { 603 blitDX = (int) Math.round((lastPaintedCenter.east() - center.east()) / lastPaintedScale * uiScaleX); 604 blitDY = (int) Math.round((center.north() - lastPaintedCenter.north()) / lastPaintedScale * uiScaleY); 605 // Zero or off-screen blits must fall back to full paint 606 canReusePan = (blitDX != 0 || blitDY != 0) && Math.abs(blitDX) < width && Math.abs(blitDY) < height; 607 } 608 if (hideLabels && (canReusePan || panning)) { 609 panLabelsHidden = true; 610 } 560 611 if (null == offscreenBuffer || offscreenBuffer.getWidth() != width || offscreenBuffer.getHeight() != height) { 561 612 offscreenBuffer = getAcceleratedImage(this, width, height); 562 613 } 563 614 564 if (!canUseBuffer || nonChangedLayersBuffer == null) { 615 if (!canReusePan && (!canUseBuffer || nonChangedLayersBuffer == null)) { 565 616 if (null == nonChangedLayersBuffer 566 617 || nonChangedLayersBuffer.getWidth() != width || nonChangedLayersBuffer.getHeight() != height) { 567 618 nonChangedLayersBuffer = getAcceleratedImage(this, width, height); 568 619 } 569 Graphics2D g2 = nonChangedLayersBuffer.createGraphics(); 570 g2.setClip(scaledClip); 571 g2.setTransform(trDef); 572 g2.setColor(PaintColors.getBackgroundColor()); 573 g2.fillRect(0, 0, width, height); 574 575 for (int i = 0; i < nonChangedLayersCount; i++) { 576 paintLayer(visibleLayers.get(i), g2); 577 } 578 } else { 579 // Maybe there were more unchanged layers then last time - draw them to buffer 580 if (nonChangedLayers.size() != nonChangedLayersCount) { 620 if (fullClip) { 581 621 Graphics2D g2 = nonChangedLayersBuffer.createGraphics(); 582 622 g2.setClip(scaledClip); 583 623 g2.setTransform(trDef); 584 for (int i = nonChangedLayers.size(); i < nonChangedLayersCount; i++) { 624 g2.setColor(PaintColors.getBackgroundColor()); 625 g2.fillRect(0, 0, width, height); 626 627 for (int i = 0; i < nonChangedLayersCount; i++) { 585 628 paintLayer(visibleLayers.get(i), g2); 586 629 } 587 } 588 } 589 590 nonChangedLayers.clear(); 591 if (nonChangedLayersCount > 0) 592 nonChangedLayers.addAll(visibleLayers.subList(0, nonChangedLayersCount)); 593 lastViewID = getViewID(); 594 lastClipBounds = g.getClipBounds(); 630 g2.dispose(); 631 } 632 } 633 634 lastViewID = viewID; 635 lastClipBounds = clip; 636 lastPaintedScale = scale; 637 lastPaintedCenter = center; 638 lastPaintedProjection = getProjection(); 639 lastPaintedLayers = new ArrayList<>(visibleLayers); 595 640 596 641 Graphics2D tempG = offscreenBuffer.createGraphics(); 597 642 tempG.setClip(scaledClip); 598 643 tempG.setTransform(new AffineTransform()); 599 tempG.drawImage(nonChangedLayersBuffer, 0, 0, null); 644 if (canReusePan) { 645 tempG.drawImage(nonChangedLayersBuffer, blitDX, blitDY, null); 646 if (blitDX != 0) { 647 paintPanStrip(tempG, blitDX > 0 ? 0 : width + blitDX, 0, 648 Math.abs(blitDX), height, visibleLayers, trDef); 649 } 650 if (blitDY != 0) { 651 paintPanStrip(tempG, 0, blitDY > 0 ? 0 : height + blitDY, 652 width, Math.abs(blitDY), visibleLayers, trDef); 653 } 654 tempG.setClip(scaledClip); 655 } else { 656 tempG.drawImage(nonChangedLayersBuffer, 0, 0, null); 657 } 600 658 tempG.setTransform(trDef); 601 659 602 for (int i = nonChangedLayersCount; i < visibleLayers.size(); i++) { 603 paintLayer(visibleLayers.get(i), tempG); 660 // Skip during a pan: repainting over the shifted composite would 661 // duplicate and stack translucent layers. Changes appear after pan stops 662 if (!canReusePan) { 663 for (int i = nonChangedLayersCount; i < visibleLayers.size(); i++) { 664 paintLayer(visibleLayers.get(i), tempG); 665 } 666 } 667 if (fullClip && !canUseBuffer) { 668 Graphics2D g2 = nonChangedLayersBuffer.createGraphics(); 669 g2.drawImage(offscreenBuffer, 0, 0, null); 670 g2.dispose(); 671 } 672 673 // Viewport-fixed overlay which must not go into the reused composite 674 for (Layer layer : visibleLayers) { 675 if (layer instanceof AbstractTileSourceLayer) { 676 ((AbstractTileSourceLayer<?>) layer).paintAttribution(tempG, this); 677 } 604 678 } 605 679 606 680 try { 607 681 drawTemporaryLayers(tempG, getLatLonBounds(new Rectangle( 608 (int) Math.round( g.getClipBounds().x * uiScaleX),609 (int) Math.round( g.getClipBounds().y * uiScaleY))));682 (int) Math.round(clip.x * uiScaleX), 683 (int) Math.round(clip.y * uiScaleY)))); 610 684 } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) { 611 685 BugReport.intercept(e).put("temporaryLayers", temporaryLayers).warn(); … … 630 704 playHeadMarker.paint(tempG, this); 631 705 } 706 tempG.dispose(); 632 707 633 708 try { … … 664 739 } 665 740 741 /** Icon overhang covered by the pan-strip band in logical pixels */ 742 private static final int PAN_STRIP_MARGIN = 16; 743 744 private void paintPanStrip(Graphics2D g, int x, int y, int w, int h, List<Layer> layers, AffineTransform trDef) { 745 // Fill first so translucent content does not double stack 746 int mx = (int) Math.ceil(PAN_STRIP_MARGIN * trDef.getScaleX()); 747 int my = (int) Math.ceil(PAN_STRIP_MARGIN * trDef.getScaleY()); 748 Rectangle band = new Rectangle(x - mx, y - my, w + 2 * mx, h + 2 * my); 749 g.setTransform(new AffineTransform()); 750 g.setClip(band); 751 g.setColor(PaintColors.getBackgroundColor()); 752 g.fillRect(band.x, band.y, band.width, band.height); 753 g.setTransform(trDef); 754 for (Layer layer : layers) { 755 paintLayer(layer, g); 756 } 757 } 758 666 759 private void drawTemporaryLayers(Graphics2D tempG, Bounds box) { 667 760 synchronized (temporaryLayers) { … … 824 917 mapMover.destroy(); 825 918 } 826 nonChangedLayers.clear();827 919 synchronized (temporaryLayers) { 828 920 temporaryLayers.clear(); … … 830 922 nonChangedLayersBuffer = null; 831 923 offscreenBuffer = null; 924 lastPaintedLayers = null; 925 lastPaintedCenter = null; 926 lastPaintedProjection = null; 832 927 setTransferHandler(null); 833 928 GuiHelper.destroyComponents(this, false); -
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r19692 r19701 15 15 import java.awt.GridBagLayout; 16 16 import java.awt.Image; 17 import java.awt.Rectangle; 17 18 import java.awt.Shape; 19 import java.awt.Stroke; 18 20 import java.awt.Toolkit; 19 import java.awt.Stroke;20 21 import java.awt.event.ActionEvent; 21 22 import java.awt.event.MouseAdapter; … … 176 177 /** Zoomlevel at which tiles is currently downloaded. Initial zoom lvl is set to bestZoom */ 177 178 private int currentZoomLevel; 179 /** Zoom level the tiles were actually displayed at (auto-zoom fallback) for attribution */ 180 private int lastDisplayZoomLevel; 178 181 179 182 private final AttributionSupport attribution = new AttributionSupport(); … … 294 297 295 298 currentZoomLevel = getBestZoom(); 299 lastDisplayZoomLevel = currentZoomLevel; 296 300 297 301 Map<String, String> headers = getHeaders(tileSource); … … 1585 1589 } 1586 1590 1591 /** 1592 * Paints the imagery attribution as a viewport-fixed overlay. 1593 * @param g the graphics context to paint on 1594 * @param mv the map view to paint for 1595 * @since 19701 1596 */ 1597 public void paintAttribution(Graphics2D g, MapView mv) { 1598 ProjectionBounds pb = mv.getState().getViewArea(new Rectangle(0, 0, mv.getWidth(), mv.getHeight())) 1599 .getProjectionBounds(); 1600 attribution.paintAttribution(g, mv.getWidth(), mv.getHeight(), getShiftedCoord(pb.getMin()), 1601 getShiftedCoord(pb.getMax()), lastDisplayZoomLevel, this); 1602 } 1603 1587 1604 private void drawInViewArea(Graphics2D g, MapView mv, ProjectionBounds pb) { 1588 1605 int zoom = currentZoomLevel; … … 1635 1652 } 1636 1653 TileSet ts = dts.getTileSet(zoom); 1654 lastDisplayZoomLevel = displayZoomLevel; 1637 1655 1638 1656 // try to load tiles from desired zoom level, no matter what we will show (for example, tiles from previous zoom level … … 1682 1700 this.paintTileText(t, g); 1683 1701 } 1684 1685 EastNorth min = pb.getMin();1686 EastNorth max = pb.getMax();1687 attribution.paintAttribution(g, mv.getWidth(), mv.getHeight(), getShiftedCoord(min), getShiftedCoord(max),1688 displayZoomLevel, this);1689 1702 1690 1703 g.setColor(Color.lightGray); -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r19387 r19701 1508 1508 @Override 1509 1509 public void primitiveHovered(PrimitiveHoverEvent e) { 1510 MapFrame map = MainApplication.getMap(); 1511 // Skip hover highlight while panning, otherwise would invalidate on every feature 1512 if (map != null && map.mapView != null && map.mapView.isPanning()) { 1513 return; 1514 } 1510 1515 List<IPrimitive> primitives = new ArrayList<>(2); 1511 1516 primitives.add(e.getHoveredPrimitive());
Note:
See TracChangeset
for help on using the changeset viewer.
