Ignore:
Timestamp:
2016-01-23T04:49:01+01:00 (4 years ago)
Author:
Don-vip
Message:

code refactoring for unit tests / headless mode

Location:
trunk/src/org/openstreetmap/josm/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java

    r9230 r9576  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.awt.HeadlessException;
    7 import java.awt.Toolkit;
     6import java.awt.Dimension;
    87import java.util.HashMap;
    98import java.util.Map;
     
    1312import org.openstreetmap.josm.data.coor.LatLon;
    1413import org.openstreetmap.josm.data.projection.Ellipsoid;
     14import org.openstreetmap.josm.gui.util.GuiHelper;
    1515
    1616public final class OsmUrlToBounds {
     
    191191    public static Bounds positionToBounds(final double lat, final double lon, final int zoom) {
    192192        int tileSizeInPixels = 256;
    193         int height;
    194         int width;
    195         try {
    196             height = Toolkit.getDefaultToolkit().getScreenSize().height;
    197             width = Toolkit.getDefaultToolkit().getScreenSize().width;
    198             if (Main.isDisplayingMapView()) {
    199                 height = Main.map.mapView.getHeight();
    200                 width = Main.map.mapView.getWidth();
    201             }
    202         } catch (HeadlessException he) {
    203             // in headless mode, when running tests
    204             height = 480;
    205             width = 640;
     193        Dimension screenSize = GuiHelper.getScreenSize();
     194        int height = screenSize.height;
     195        int width = screenSize.width;
     196        if (Main.isDisplayingMapView()) {
     197            height = Main.map.mapView.getHeight();
     198            width = Main.map.mapView.getWidth();
    206199        }
    207200        double scale = (1 << zoom) * tileSizeInPixels / (2 * Math.PI * Ellipsoid.WGS84.a);
  • trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java

    r9062 r9576  
    1212import java.awt.Point;
    1313import java.awt.Rectangle;
    14 import java.awt.Toolkit;
    1514import java.awt.Window;
    1615import java.util.regex.Matcher;
     
    2019
    2120import org.openstreetmap.josm.Main;
     21import org.openstreetmap.josm.gui.util.GuiHelper;
    2222
    2323/**
     
    468468     */
    469469    public static Rectangle getFullScreenInfo() {
    470         return new Rectangle(new Point(0, 0), Toolkit.getDefaultToolkit().getScreenSize());
     470        return new Rectangle(new Point(0, 0), GuiHelper.getScreenSize());
    471471    }
    472472
Note: See TracChangeset for help on using the changeset viewer.