Changeset 16620 in josm


Ignore:
Timestamp:
2020-06-14T14:55:11+02:00 (8 weeks ago)
Author:
simon04
Message:

see #19360 - Fix NPE in TileCoordinateConverter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileCoordinateConverter.java

    r16619 r16620  
    22package org.openstreetmap.josm.gui.layer.imagery;
    33
     4import java.awt.GraphicsConfiguration;
    45import java.awt.Polygon;
    56import java.awt.Rectangle;
     
    910import java.awt.geom.Rectangle2D;
    1011import java.util.Objects;
     12import java.util.Optional;
    1113
    1214import org.openstreetmap.gui.jmapviewer.Tile;
     
    3537    private final TileSourceDisplaySettings settings;
    3638    private final TileSource tileSource;
     39    private final AffineTransform transform;
    3740
    3841    /**
     
    4750        this.tileSource = Objects.requireNonNull(tileSource, "tileSource");
    4851        this.settings = Objects.requireNonNull(settings, "settings");
     52        this.transform = Optional.ofNullable(mapView.getGraphicsConfiguration())
     53                .map(GraphicsConfiguration::getDefaultTransform)
     54                .orElseGet(AffineTransform::new);
    4955    }
    5056
     
    184190            t2 = tileSource.projectedToTileXY(CoordinateConversion.enToProj(botRightEN), zoom);
    185191        }
    186         AffineTransform transform = mapView.getGraphicsConfiguration().getDefaultTransform();
    187192        int screenPixels = (int) (mapView.getWidth() * mapView.getHeight() * transform.getScaleX() * transform.getScaleY());
    188193        double tilePixels = Math.abs((t2.getY()-t1.getY())*(t2.getX()-t1.getX())*tileSource.getTileSize()*tileSource.getTileSize());
Note: See TracChangeset for help on using the changeset viewer.