jdk/src/java.desktop/share/classes/sun/java2d/SunGraphicsEnvironment.java
author lbourges
Mon, 23 Nov 2015 15:02:19 -0800
changeset 34419 14108cfd0823
parent 34394 259d6e4e0978
child 35667 ed476aba94de
permissions -rw-r--r--
8143849: Integrate Marlin renderer per JEP 265 Reviewed-by: flar, prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 20434
diff changeset
     2
 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.java2d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
20434
19c5cdb0d7a2 8025652: [macos] build failed
malenkov
parents: 20433
diff changeset
    28
import java.awt.AWTError;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.Color;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.Font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.Graphics2D;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.GraphicsConfiguration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.GraphicsDevice;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.GraphicsEnvironment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.Insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.awt.Rectangle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.awt.Toolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.awt.font.TextAttribute;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.awt.image.BufferedImage;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
    40
import java.awt.peer.ComponentPeer;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.io.BufferedReader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.io.File;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.io.FileInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import java.io.FilenameFilter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import java.io.InputStreamReader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import java.text.AttributedCharacterIterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import java.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import java.util.HashSet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
import java.util.Iterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import java.util.Locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
import java.util.NoSuchElementException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
import java.util.Set;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
import java.util.StringTokenizer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
import java.util.TreeMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
import java.util.concurrent.ConcurrentHashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
import sun.awt.AppContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
import sun.awt.DisplayChangedListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
import sun.awt.FontConfiguration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
import sun.awt.SunDisplayChanger;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
import sun.font.CompositeFontDescriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
import sun.font.Font2D;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
import sun.font.FontManager;
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
    66
import sun.font.FontManagerFactory;
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
    67
import sun.font.FontManagerForSGE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
import sun.font.NativeFont;
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
    69
import java.security.AccessController;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
    70
import sun.security.action.GetPropertyAction;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * This is an implementation of a GraphicsEnvironment object for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * default local GraphicsEnvironment.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * @see GraphicsDevice
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * @see GraphicsConfiguration
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
public abstract class SunGraphicsEnvironment extends GraphicsEnvironment
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
    80
    implements DisplayChangedListener {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
    82
    public static boolean isOpenSolaris;
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
    83
    private static Font defaultFont;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
    85
    private static final boolean uiScaleEnabled;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
    86
    private static final double debugScale;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
    87
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
    88
    static {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
    89
        uiScaleEnabled = "true".equals(AccessController.doPrivileged(
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
    90
                new GetPropertyAction("sun.java2d.uiScale.enabled", "true")));
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
    91
        debugScale = uiScaleEnabled ? getScaleFactor("sun.java2d.uiScale") : -1;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
    92
    }
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
    93
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    public SunGraphicsEnvironment() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        java.security.AccessController.doPrivileged(
24522
3a0bbf9f5e81 8038644: Fix raw and unchecked warnings in sun.java2d.*
henryjen
parents: 22584
diff changeset
    96
                                    new java.security.PrivilegedAction<Object>() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            public Object run() {
31900
b6961b1116d0 8132408: Check os.name before os.version in SunGraphicsEnvironment constructor
simonis
parents: 25859
diff changeset
    98
                String osName = System.getProperty("os.name");
b6961b1116d0 8132408: Check os.name before os.version in SunGraphicsEnvironment constructor
simonis
parents: 25859
diff changeset
    99
                if ("SunOS".equals(osName)) {
883
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 2
diff changeset
   100
                    String version = System.getProperty("os.version", "0.0");
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 2
diff changeset
   101
                    try {
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 2
diff changeset
   102
                        float ver = Float.parseFloat(version);
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 2
diff changeset
   103
                        if (ver > 5.10f) {
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 2
diff changeset
   104
                            File f = new File("/etc/release");
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 2
diff changeset
   105
                            FileInputStream fis = new FileInputStream(f);
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 2
diff changeset
   106
                            InputStreamReader isr
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 2
diff changeset
   107
                                = new InputStreamReader(fis, "ISO-8859-1");
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 2
diff changeset
   108
                            BufferedReader br = new BufferedReader(isr);
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 2
diff changeset
   109
                            String line = br.readLine();
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 2
diff changeset
   110
                            if (line.indexOf("OpenSolaris") >= 0) {
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 2
diff changeset
   111
                                isOpenSolaris = true;
8128
4980e459a3a7 6940890: Java doesn't pick up the correct fontconfig files in latest Solaris Next builds
prr
parents: 7947
diff changeset
   112
                            } else {
4980e459a3a7 6940890: Java doesn't pick up the correct fontconfig files in latest Solaris Next builds
prr
parents: 7947
diff changeset
   113
                                /* We are using isOpenSolaris as meaning
4980e459a3a7 6940890: Java doesn't pick up the correct fontconfig files in latest Solaris Next builds
prr
parents: 7947
diff changeset
   114
                                 * we know the Solaris commercial fonts aren't
4980e459a3a7 6940890: Java doesn't pick up the correct fontconfig files in latest Solaris Next builds
prr
parents: 7947
diff changeset
   115
                                 * present. "Solaris Next" (03/10) did not
4980e459a3a7 6940890: Java doesn't pick up the correct fontconfig files in latest Solaris Next builds
prr
parents: 7947
diff changeset
   116
                                 * include these even though its was not
4980e459a3a7 6940890: Java doesn't pick up the correct fontconfig files in latest Solaris Next builds
prr
parents: 7947
diff changeset
   117
                                 * OpenSolaris. Need to revisit how this is
4980e459a3a7 6940890: Java doesn't pick up the correct fontconfig files in latest Solaris Next builds
prr
parents: 7947
diff changeset
   118
                                 * handled but for now as in 6ux, we'll use
4980e459a3a7 6940890: Java doesn't pick up the correct fontconfig files in latest Solaris Next builds
prr
parents: 7947
diff changeset
   119
                                 * the test for a standard font resource as
4980e459a3a7 6940890: Java doesn't pick up the correct fontconfig files in latest Solaris Next builds
prr
parents: 7947
diff changeset
   120
                                 * being an indicator as to whether we need
4980e459a3a7 6940890: Java doesn't pick up the correct fontconfig files in latest Solaris Next builds
prr
parents: 7947
diff changeset
   121
                                 * to treat this as OpenSolaris from a font
4980e459a3a7 6940890: Java doesn't pick up the correct fontconfig files in latest Solaris Next builds
prr
parents: 7947
diff changeset
   122
                                 * config perspective.
4980e459a3a7 6940890: Java doesn't pick up the correct fontconfig files in latest Solaris Next builds
prr
parents: 7947
diff changeset
   123
                                 */
4980e459a3a7 6940890: Java doesn't pick up the correct fontconfig files in latest Solaris Next builds
prr
parents: 7947
diff changeset
   124
                                String courierNew =
4980e459a3a7 6940890: Java doesn't pick up the correct fontconfig files in latest Solaris Next builds
prr
parents: 7947
diff changeset
   125
                                    "/usr/openwin/lib/X11/fonts/TrueType/CourierNew.ttf";
4980e459a3a7 6940890: Java doesn't pick up the correct fontconfig files in latest Solaris Next builds
prr
parents: 7947
diff changeset
   126
                                File courierFile = new File(courierNew);
4980e459a3a7 6940890: Java doesn't pick up the correct fontconfig files in latest Solaris Next builds
prr
parents: 7947
diff changeset
   127
                                isOpenSolaris = !courierFile.exists();
883
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 2
diff changeset
   128
                            }
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 2
diff changeset
   129
                            fis.close();
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 2
diff changeset
   130
                        }
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 2
diff changeset
   131
                    } catch (Exception e) {
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 2
diff changeset
   132
                    }
31900
b6961b1116d0 8132408: Check os.name before os.version in SunGraphicsEnvironment constructor
simonis
parents: 25859
diff changeset
   133
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                /* Establish the default font to be used by SG2D etc */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    protected GraphicsDevice[] screens;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * Returns an array of all of the screen devices.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    public synchronized GraphicsDevice[] getScreenDevices() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        GraphicsDevice[] ret = screens;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        if (ret == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            int num = getNumScreens();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            ret = new GraphicsDevice[num];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            for (int i = 0; i < num; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                ret[i] = makeScreenDevice(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            screens = ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   160
    /**
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   161
     * Returns the number of screen devices of this graphics environment.
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   162
     *
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   163
     * @return the number of screen devices of this graphics environment
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   164
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    protected abstract int getNumScreens();
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   166
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   167
    /**
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   168
     * Create and return the screen device with the specified number. The
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   169
     * device with number <code>0</code> will be the default device (returned
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   170
     * by {@link #getDefaultScreenDevice()}.
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   171
     *
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   172
     * @param screennum the number of the screen to create
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   173
     *
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   174
     * @return the created screen device
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   175
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    protected abstract GraphicsDevice makeScreenDevice(int screennum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * Returns the default screen graphics device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    public GraphicsDevice getDefaultScreenDevice() {
20433
f6d501f12376 7117595: ArrayIndexOutOfBoundsException in Win32GraphicsEnvironment if display is removed
malenkov
parents: 9050
diff changeset
   182
        GraphicsDevice[] screens = getScreenDevices();
f6d501f12376 7117595: ArrayIndexOutOfBoundsException in Win32GraphicsEnvironment if display is removed
malenkov
parents: 9050
diff changeset
   183
        if (screens.length == 0) {
f6d501f12376 7117595: ArrayIndexOutOfBoundsException in Win32GraphicsEnvironment if display is removed
malenkov
parents: 9050
diff changeset
   184
            throw new AWTError("no screen devices");
f6d501f12376 7117595: ArrayIndexOutOfBoundsException in Win32GraphicsEnvironment if display is removed
malenkov
parents: 9050
diff changeset
   185
        }
f6d501f12376 7117595: ArrayIndexOutOfBoundsException in Win32GraphicsEnvironment if display is removed
malenkov
parents: 9050
diff changeset
   186
        return screens[0];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * Returns a Graphics2D object for rendering into the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * given BufferedImage.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * @throws NullPointerException if BufferedImage argument is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    public Graphics2D createGraphics(BufferedImage img) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        if (img == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            throw new NullPointerException("BufferedImage cannot be null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        SurfaceData sd = SurfaceData.getPrimarySurfaceData(img);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        return new SunGraphics2D(sd, Color.white, Color.black, defaultFont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
7947
236cfb73d510 6980204: closed/java/awt/font/LogicalFonts/MappingTest.java fails
prr
parents: 5506
diff changeset
   202
    public static FontManagerForSGE getFontManagerForSGE() {
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   203
        FontManager fm = FontManagerFactory.getInstance();
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   204
        return (FontManagerForSGE) fm;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    }
8945
4718885476ee 7032930: A way to specify MS Mincho to be used in dialoginput on windows JA locale
prr
parents: 8128
diff changeset
   206
4718885476ee 7032930: A way to specify MS Mincho to be used in dialoginput on windows JA locale
prr
parents: 8128
diff changeset
   207
    /* Modifies the behaviour of a subsequent call to preferLocaleFonts()
4718885476ee 7032930: A way to specify MS Mincho to be used in dialoginput on windows JA locale
prr
parents: 8128
diff changeset
   208
     * to use Mincho instead of Gothic for dialoginput in JA locales
4718885476ee 7032930: A way to specify MS Mincho to be used in dialoginput on windows JA locale
prr
parents: 8128
diff changeset
   209
     * on windows. Not needed on other platforms.
4718885476ee 7032930: A way to specify MS Mincho to be used in dialoginput on windows JA locale
prr
parents: 8128
diff changeset
   210
     *
4718885476ee 7032930: A way to specify MS Mincho to be used in dialoginput on windows JA locale
prr
parents: 8128
diff changeset
   211
     * DO NOT MOVE OR RENAME OR OTHERWISE ALTER THIS METHOD.
4718885476ee 7032930: A way to specify MS Mincho to be used in dialoginput on windows JA locale
prr
parents: 8128
diff changeset
   212
     * ITS USED BY SOME NON-JRE INTERNAL CODE.
4718885476ee 7032930: A way to specify MS Mincho to be used in dialoginput on windows JA locale
prr
parents: 8128
diff changeset
   213
     */
4718885476ee 7032930: A way to specify MS Mincho to be used in dialoginput on windows JA locale
prr
parents: 8128
diff changeset
   214
    public static void useAlternateFontforJALocales() {
4718885476ee 7032930: A way to specify MS Mincho to be used in dialoginput on windows JA locale
prr
parents: 8128
diff changeset
   215
        getFontManagerForSGE().useAlternateFontforJALocales();
4718885476ee 7032930: A way to specify MS Mincho to be used in dialoginput on windows JA locale
prr
parents: 8128
diff changeset
   216
    }
4718885476ee 7032930: A way to specify MS Mincho to be used in dialoginput on windows JA locale
prr
parents: 8128
diff changeset
   217
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * Returns all fonts available in this environment.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    public Font[] getAllFonts() {
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   222
        FontManagerForSGE fm = getFontManagerForSGE();
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   223
        Font[] installedFonts = fm.getAllInstalledFonts();
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   224
        Font[] created = fm.getCreatedFonts();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        if (created == null || created.length == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            return installedFonts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            int newlen = installedFonts.length + created.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            Font [] fonts = java.util.Arrays.copyOf(installedFonts, newlen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            System.arraycopy(created, 0, fonts,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                             installedFonts.length, created.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            return fonts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    public String[] getAvailableFontFamilyNames(Locale requestedLocale) {
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   237
        FontManagerForSGE fm = getFontManagerForSGE();
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   238
        String[] installed = fm.getInstalledFontFamilyNames(requestedLocale);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        /* Use a new TreeMap as used in getInstalledFontFamilyNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
         * and insert all the keys in lower case, so that the sort order
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
         * is the same as the installed families. This preserves historical
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
         * behaviour and inserts new families in the right place.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
         * It would have been marginally more efficient to directly obtain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
         * the tree map and just insert new entries, but not so much as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
         * to justify the extra internal interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
         */
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 1724
diff changeset
   247
        TreeMap<String, String> map = fm.getCreatedFontFamilyNames();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        if (map == null || map.size() == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            return installed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            for (int i=0; i<installed.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                map.put(installed[i].toLowerCase(requestedLocale),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                        installed[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            String[] retval =  new String[map.size()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            Object [] keyNames = map.keySet().toArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            for (int i=0; i < keyNames.length; i++) {
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 20434
diff changeset
   258
                retval[i] = map.get(keyNames[i]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            return retval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    public String[] getAvailableFontFamilyNames() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        return getAvailableFontFamilyNames(Locale.getDefault());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * Return the bounds of a GraphicsDevice, less its screen insets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * See also java.awt.GraphicsEnvironment.getUsableBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    public static Rectangle getUsableBounds(GraphicsDevice gd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        Rectangle usableBounds = gc.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        usableBounds.x += insets.left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        usableBounds.y += insets.top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        usableBounds.width -= (insets.left + insets.right);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        usableBounds.height -= (insets.top + insets.bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        return usableBounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * From the DisplayChangedListener interface; called
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * when the display mode has been changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    public void displayChanged() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        // notify screens in device array to do display update stuff
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        for (GraphicsDevice gd : getScreenDevices()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            if (gd instanceof DisplayChangedListener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                ((DisplayChangedListener) gd).displayChanged();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        // notify SunDisplayChanger list (e.g. VolatileSurfaceManagers and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        // SurfaceDataProxies) about the display change event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        displayChanger.notifyListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * Part of the DisplayChangedListener interface:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * propagate this event to listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    public void paletteChanged() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        displayChanger.notifyPaletteChanged();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
1724
a22a286aa16f 6748082: remove platform-specific code from SwingUtilities2.isDisplayLocal
tdv
parents: 1716
diff changeset
   310
    /**
a22a286aa16f 6748082: remove platform-specific code from SwingUtilities2.isDisplayLocal
tdv
parents: 1716
diff changeset
   311
     * Returns true when the display is local, false for remote displays.
a22a286aa16f 6748082: remove platform-specific code from SwingUtilities2.isDisplayLocal
tdv
parents: 1716
diff changeset
   312
     *
a22a286aa16f 6748082: remove platform-specific code from SwingUtilities2.isDisplayLocal
tdv
parents: 1716
diff changeset
   313
     * @return true when the display is local, false for remote displays
a22a286aa16f 6748082: remove platform-specific code from SwingUtilities2.isDisplayLocal
tdv
parents: 1716
diff changeset
   314
     */
a22a286aa16f 6748082: remove platform-specific code from SwingUtilities2.isDisplayLocal
tdv
parents: 1716
diff changeset
   315
    public abstract boolean isDisplayLocal();
a22a286aa16f 6748082: remove platform-specific code from SwingUtilities2.isDisplayLocal
tdv
parents: 1716
diff changeset
   316
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * ----DISPLAY CHANGE SUPPORT----
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    protected SunDisplayChanger displayChanger = new SunDisplayChanger();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * Add a DisplayChangeListener to be notified when the display settings
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * are changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    public void addDisplayChangedListener(DisplayChangedListener client) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        displayChanger.add(client);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * Remove a DisplayChangeListener from Win32GraphicsEnvironment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    public void removeDisplayChangedListener(DisplayChangedListener client) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        displayChanger.remove(client);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * ----END DISPLAY CHANGE SUPPORT----
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     */
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   341
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   342
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   343
     * Returns true if FlipBufferStrategy with COPIED buffer contents
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   344
     * is preferred for this peer's GraphicsConfiguration over
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   345
     * BlitBufferStrategy, false otherwise.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   346
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   347
     * The reason FlipBS could be preferred is that in some configurations
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   348
     * an accelerated copy to the screen is supported (like Direct3D 9)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   349
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   350
     * @return true if flip strategy should be used, false otherwise
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   351
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   352
    public boolean isFlipStrategyPreferred(ComponentPeer peer) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   353
        return false;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   354
    }
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   355
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   356
    public static boolean isUIScaleEnabled() {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   357
        return uiScaleEnabled;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   358
    }
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   359
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   360
    public static double getDebugScale() {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   361
        return debugScale;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   362
    }
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   363
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   364
    public static double getScaleFactor(String propertyName) {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   365
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   366
        String scaleFactor = AccessController.doPrivileged(
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   367
                new GetPropertyAction(propertyName, "-1"));
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   368
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   369
        if (scaleFactor == null || scaleFactor.equals("-1")) {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   370
            return -1;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   371
        }
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   372
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   373
        try {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   374
            double units = 1.0;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   375
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   376
            if (scaleFactor.endsWith("x")) {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   377
                scaleFactor = scaleFactor.substring(0, scaleFactor.length() - 1);
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   378
            } else if (scaleFactor.endsWith("dpi")) {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   379
                units = 96;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   380
                scaleFactor = scaleFactor.substring(0, scaleFactor.length() - 3);
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   381
            } else if (scaleFactor.endsWith("%")) {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   382
                units = 100;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   383
                scaleFactor = scaleFactor.substring(0, scaleFactor.length() - 1);
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   384
            }
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   385
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   386
            double scale = Double.parseDouble(scaleFactor);
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   387
            return scale <= 0 ? -1 : scale / units;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   388
        } catch (NumberFormatException ignored) {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   389
            return -1;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   390
        }
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31900
diff changeset
   391
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
}