Ignore:
Timestamp:
2014-05-08T02:40:40+02:00 (9 years ago)
Author:
Don-vip
Message:

Robustness to allow to run more unit tests in headless mode

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

Legend:

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

    r7033 r7075  
    88import java.awt.Graphics;
    99import java.awt.Graphics2D;
    10 import java.awt.GraphicsConfiguration;
    1110import java.awt.GraphicsEnvironment;
    1211import java.awt.Image;
     
    1413import java.awt.RenderingHints;
    1514import java.awt.Toolkit;
    16 import java.awt.Transparency;
    1715import java.awt.image.BufferedImage;
    1816import java.io.ByteArrayInputStream;
     
    793791            img = overlay(img, ImageProvider.get("cursor/modifier/" + overlay), OverlayPosition.SOUTHEAST);
    794792        }
     793        if (GraphicsEnvironment.isHeadless()) {
     794            Main.warn("Cursors are not available in headless mode. Returning null for '"+name+"'");
     795            return null;
     796        }
    795797        return Toolkit.getDefaultToolkit().createCustomCursor(img.getImage(),
    796798                "crosshair".equals(name) ? new Point(10, 10) : new Point(3, 2), "Cursor");
     
    808810     */
    809811    public static ImageIcon overlay(Icon ground, Icon overlay, OverlayPosition pos) {
    810         GraphicsConfiguration conf = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
    811                 .getDefaultConfiguration();
    812812        int w = ground.getIconWidth();
    813813        int h = ground.getIconHeight();
    814814        int wo = overlay.getIconWidth();
    815815        int ho = overlay.getIconHeight();
    816         BufferedImage img = conf.createCompatibleImage(w, h, Transparency.TRANSLUCENT);
     816        BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
    817817        Graphics g = img.createGraphics();
    818818        ground.paintIcon(null, g, 0, 0);
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java

    r7037 r7075  
    9999    @Override
    100100    public boolean canFullscreen() {
    101         return GraphicsEnvironment.getLocalGraphicsEnvironment()
     101        return !GraphicsEnvironment.isHeadless() &&
     102                GraphicsEnvironment.getLocalGraphicsEnvironment()
    102103        .getDefaultScreenDevice().isFullScreenSupported();
    103104    }
     
    328329    }
    329330
    330     // Method kept because strings have already been translated. To enable for Java 8 migration somewhere in 2016 
     331    // Method kept because strings have already been translated. To enable for Java 8 migration somewhere in 2016
    331332    protected void askUpdateJava(final String version, final String url) {
    332333        GuiHelper.runInEDTAndWait(new Runnable() {
Note: See TracChangeset for help on using the changeset viewer.