Changeset 16619 in josm for trunk


Ignore:
Timestamp:
2020-06-14T12:17:27+02:00 (4 years ago)
Author:
simon04
Message:

fix #19360 - Calculating default zoom offset should use existing code infrastructure for HiDPI (patch by johsin18)

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

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

    r16615 r16619  
    128128import org.openstreetmap.josm.tools.MemoryManager.MemoryHandle;
    129129import org.openstreetmap.josm.tools.MemoryManager.NotEnoughMemoryException;
    130 import org.openstreetmap.josm.tools.PlatformManager;
    131130import org.openstreetmap.josm.tools.Utils;
    132131import org.openstreetmap.josm.tools.bugreport.BugReport;
     
    173172     * lower resolution of imagery useful in "retina" displays, positive values will result in higher resolution
    174173     */
    175     public static final IntegerProperty ZOOM_OFFSET = new IntegerProperty(PREFERENCE_PREFIX + ".zoom_offset",
    176             PlatformManager.getPlatform().isHighDpiDisplay() ? 2 : 0);
     174    public static final IntegerProperty ZOOM_OFFSET = new IntegerProperty(PREFERENCE_PREFIX + ".zoom_offset", 0);
    177175
    178176    private static final BooleanProperty POPUP_MENU_ENABLED = new BooleanProperty(PREFERENCE_PREFIX + ".popupmenu", true);
  • trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileCoordinateConverter.java

    r14505 r16619  
    55import java.awt.Rectangle;
    66import java.awt.Shape;
     7import java.awt.geom.AffineTransform;
    78import java.awt.geom.Point2D;
    89import java.awt.geom.Rectangle2D;
     
    183184            t2 = tileSource.projectedToTileXY(CoordinateConversion.enToProj(botRightEN), zoom);
    184185        }
    185         int screenPixels = mapView.getWidth()*mapView.getHeight();
     186        AffineTransform transform = mapView.getGraphicsConfiguration().getDefaultTransform();
     187        int screenPixels = (int) (mapView.getWidth() * mapView.getHeight() * transform.getScaleX() * transform.getScaleY());
    186188        double tilePixels = Math.abs((t2.getY()-t1.getY())*(t2.getX()-t1.getX())*tileSource.getTileSize()*tileSource.getTileSize());
    187189        if (screenPixels == 0 || tilePixels == 0) return 1;
  • trunk/src/org/openstreetmap/josm/tools/PlatformHook.java

    r15922 r16619  
    138138
    139139    /**
    140      * Determines if the default screen is a high-dpi device such as a mac Retina display.
    141      * @return {@code true} if the default screen is a high-dpi device such as a mac Retina display
    142      * @since 15918
    143      */
    144     default boolean isHighDpiDisplay() {
    145         // https://stackoverflow.com/a/49770313
    146         return !GraphicsEnvironment.isHeadless() &&
    147                 !GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration()
    148                 .getDefaultTransform().isIdentity();
    149     }
    150 
    151     /**
    152140     * Renames a file.
    153141     * @param from Source file
Note: See TracChangeset for help on using the changeset viewer.