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

code refactoring for unit tests / headless mode

File:
1 edited

Legend:

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

    r9246 r9576  
    1111import java.awt.Dimension;
    1212import java.awt.Font;
     13import java.awt.GraphicsEnvironment;
    1314import java.awt.GridBagLayout;
    1415import java.awt.Image;
     
    1617import java.awt.Toolkit;
    1718import java.awt.Window;
     19import java.awt.datatransfer.Clipboard;
    1820import java.awt.event.ActionListener;
    1921import java.awt.event.HierarchyEvent;
     
    383385        c.setForeground(ColorHelper.getForegroundColor(background));
    384386    }
     387
     388    /**
     389     * Gets the size of the screen. On systems with multiple displays, the primary display is used.
     390     * This method returns always 800x600 in headless mode (useful for unit tests).
     391     * @return the size of this toolkit's screen, in pixels, or 800x600
     392     * @see Toolkit#getScreenSize
     393     * @since 9576
     394     */
     395    public static Dimension getScreenSize() {
     396        return GraphicsEnvironment.isHeadless() ? new Dimension(800, 600) : Toolkit.getDefaultToolkit().getScreenSize();
     397    }
     398
     399    /**
     400     * Gets the singleton instance of the system selection as a <code>Clipboard</code> object.
     401     * This allows an application to read and modify the current, system-wide selection.
     402     * @return the system selection as a <code>Clipboard</code>, or <code>null</code> if the native platform does not
     403     *         support a system selection <code>Clipboard</code> or if GraphicsEnvironment.isHeadless() returns true
     404     * @see Toolkit#getSystemSelection
     405     * @since 9576
     406     */
     407    public static Clipboard getSystemSelection() {
     408        return GraphicsEnvironment.isHeadless() ? null : Toolkit.getDefaultToolkit().getSystemSelection();
     409    }
    385410}
Note: See TracChangeset for help on using the changeset viewer.