Ignore:
Timestamp:
2016-02-18T22:06:36+01:00 (4 years ago)
Author:
wiktorn
Message:

Properly support multi-display environments when estimating tile cache size.

Check for a monitor with display with biggest resolution instead of primary display to calculate the size of MemoryTileCache. This fixes problems with tiles on setups, where secondary monitor is bigger than primary, and user decides to work on secondary monitor.

Closes: #12050

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java

    r9778 r9826  
    1010import java.awt.Dialog;
    1111import java.awt.Dimension;
     12import java.awt.DisplayMode;
    1213import java.awt.Font;
     14import java.awt.GraphicsDevice;
    1315import java.awt.GraphicsEnvironment;
    1416import java.awt.GridBagLayout;
     
    424426
    425427    /**
     428     * Gets the size of the screen. On systems with multiple displays,
     429     * contrary to {@link #getScreenSize()}, the biggest display is used.
     430     * This method returns always 800x600 in headless mode (useful for unit tests).
     431     * @return the size of maximum screen, in pixels, or 800x600
     432     * @see Toolkit#getScreenSize
     433     * @since 9576
     434     */
     435
     436    public static Dimension getMaxiumScreenSize() {
     437        if (GraphicsEnvironment.isHeadless()) {
     438            return new Dimension(800, 600);
     439        }
     440
     441        int height = 0;
     442        int width = 0;
     443        for (GraphicsDevice gd: GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) {
     444            DisplayMode dm = gd.getDisplayMode();
     445            height = Math.max(height, dm.getHeight());
     446            width = Math.max(width, dm.getWidth());
     447        }
     448        if (height == 0 || width == 0) {
     449            return new Dimension(800, 600);
     450        }
     451        return new Dimension(width, height);
     452    }
     453
     454    /**
    426455     * Gets the singleton instance of the system selection as a <code>Clipboard</code> object.
    427456     * This allows an application to read and modify the current, system-wide selection.
Note: See TracChangeset for help on using the changeset viewer.