jdk/src/java.desktop/share/classes/java/awt/SplashScreen.java
author rchamyal
Fri, 11 Mar 2016 11:00:38 +0530
changeset 36869 f8ef78f4157d
parent 35667 ed476aba94de
child 41776 71e2575dd727
permissions -rw-r--r--
8145174: HiDPI splash screen support on Linux Reviewed-by: serb, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
28231
b608ffcaed74 8066621: Suppress deprecation warnings in java.desktop module
darcy
parents: 26745
diff changeset
     2
 * Copyright (c) 2005, 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
package java.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.image.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.net.URL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.net.URLConnection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.io.File;
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2
diff changeset
    32
import sun.util.logging.PlatformLogger;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import sun.awt.image.SunWritableRaster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/**
7765
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    36
 * The splash screen can be displayed at application startup, before the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * Java Virtual Machine (JVM) starts. The splash screen is displayed as an
7765
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    38
 * undecorated window containing an image. You can use GIF, JPEG, or PNG files
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    39
 * for the image. Animation is supported for the GIF format, while transparency
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    40
 * is supported both for GIF and PNG.  The window is positioned at the center
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    41
 * of the screen. The position on multi-monitor systems is not specified. It is
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    42
 * platform and implementation dependent.  The splash screen window is closed
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    43
 * automatically as soon as the first window is displayed by Swing/AWT (may be
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    44
 * also closed manually using the Java API, see below).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <P>
7765
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    46
 * If your application is packaged in a jar file, you can use the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * "SplashScreen-Image" option in a manifest file to show a splash screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * Place the image in the jar archive and specify the path in the option.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * The path should not have a leading slash.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <BR>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
    51
 * For example, in the {@code manifest.mf} file:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * Manifest-Version: 1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * Main-Class: Test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * SplashScreen-Image: filename.gif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * </PRE>
7765
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    57
 * <P>
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    58
 * If the Java implementation provides the command-line interface and you run
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    59
 * your application by using the command line or a shortcut, use the Java
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    60
 * application launcher option to show a splash screen. The Oracle reference
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    61
 * implementation allows you to specify the splash screen image location with
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    62
 * the {@code -splash:} option.
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    63
 * <BR>
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    64
 * For example:
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    65
 * <PRE>
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    66
 * java -splash:filename.gif Test
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    67
 * </PRE>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * The command line interface has higher precedence over the manifest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * setting.
7765
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    70
 * <p>
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    71
 * The splash screen will be displayed as faithfully as possible to present the
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    72
 * whole splash screen image given the limitations of the target platform and
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    73
 * display.
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    74
 * <p>
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    75
 * It is implied that the specified image is presented on the screen "as is",
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    76
 * i.e. preserving the exact color values as specified in the image file. Under
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    77
 * certain circumstances, though, the presented image may differ, e.g. when
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    78
 * applying color dithering to present a 32 bits per pixel (bpp) image on a 16
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    79
 * or 8 bpp screen. The native platform display configuration may also affect
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    80
 * the colors of the displayed image (e.g.  color profiles, etc.)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * The {@code SplashScreen} class provides the API for controlling the splash
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * screen. This class may be used to close the splash screen, change the splash
7765
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    84
 * screen image, get the splash screen native window position/size, and paint
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    85
 * in the splash screen. It cannot be used to create the splash screen. You
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    86
 * should use the options provided by the Java implementation for that.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * This class cannot be instantiated. Only a single instance of this class
7765
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
    89
 * can exist, and it may be obtained by using the {@link #getSplashScreen()}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * static method. In case the splash screen has not been created at
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * application startup via the command line or manifest file option,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
    92
 * the {@code getSplashScreen} method returns {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * @author Oleg Semenov
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
public final class SplashScreen {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    SplashScreen(long ptr) { // non-public constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        splashPtr = ptr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * Returns the {@code SplashScreen} object used for
7765
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
   105
     * Java startup splash screen control on systems that support display.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * @throws UnsupportedOperationException if the splash screen feature is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     *         supported by the current toolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *         returns true
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   111
     * @return the {@link SplashScreen} instance, or {@code null} if there is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *         none or it has already been closed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    public static  SplashScreen getSplashScreen() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        synchronized (SplashScreen.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            if (GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                throw new HeadlessException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            // SplashScreen class is now a singleton
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            if (!wasClosed && theInstance == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                java.security.AccessController.doPrivileged(
12559
9456ceada8b1 7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents: 7775
diff changeset
   122
                    new java.security.PrivilegedAction<Void>() {
9456ceada8b1 7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents: 7775
diff changeset
   123
                        public Void run() {
9456ceada8b1 7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents: 7775
diff changeset
   124
                            System.loadLibrary("splashscreen");
9456ceada8b1 7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents: 7775
diff changeset
   125
                            return null;
9456ceada8b1 7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents: 7775
diff changeset
   126
                        }
9456ceada8b1 7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary
mchung
parents: 7775
diff changeset
   127
                    });
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                long ptr = _getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                if (ptr != 0 && _isVisible(ptr)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                    theInstance = new SplashScreen(ptr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            return theInstance;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * Changes the splash screen image. The new image is loaded from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * specified URL; GIF, JPEG and PNG image formats are supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * The method returns after the image has finished loading and the window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * has been updated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * The splash screen window is resized according to the size of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * the image and is centered on the screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   145
     * @param imageURL the non-{@code null} URL for the new
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     *        splash screen image
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   147
     * @throws NullPointerException if {@code imageURL} is {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @throws IOException if there was an error while loading the image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @throws IllegalStateException if the splash screen has already been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *         closed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    public void setImageURL(URL imageURL) throws NullPointerException, IOException, IllegalStateException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        checkVisible();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        URLConnection connection = imageURL.openConnection();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        connection.connect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        int length = connection.getContentLength();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        java.io.InputStream stream = connection.getInputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        byte[] buf = new byte[length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        int off = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        while(true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            // check for available data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            int available = stream.available();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            if (available <= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                // no data available... well, let's try reading one byte
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                // we'll see what happens then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                available = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            // check for enough room in buffer, realloc if needed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            // the buffer always grows in size 2x minimum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            if (off + available > length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                length = off*2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                if (off + available > length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                    length = available+off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                byte[] oldBuf = buf;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                buf = new byte[length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                System.arraycopy(oldBuf, 0, buf, 0, off);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            // now read the data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            int result = stream.read(buf, off, available);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            if (result < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            off += result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        synchronized(SplashScreen.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            checkVisible();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            if (!_setImageData(splashPtr, buf)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                throw new IOException("Bad image format or i/o error when loading image");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            this.imageURL = imageURL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    private void checkVisible() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        if (!isVisible()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            throw new IllegalStateException("no splash screen available");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * Returns the current splash screen image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * @return URL for the current splash screen image file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * @throws IllegalStateException if the splash screen has already been closed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     */
28231
b608ffcaed74 8066621: Suppress deprecation warnings in java.desktop module
darcy
parents: 26745
diff changeset
   206
    @SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    public URL getImageURL() throws IllegalStateException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        synchronized (SplashScreen.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            checkVisible();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            if (imageURL == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                    String fileName = _getImageFileName(splashPtr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                    String jarName = _getImageJarName(splashPtr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                    if (fileName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                        if (jarName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                            imageURL = new URL("jar:"+(new File(jarName).toURL().toString())+"!/"+fileName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                            imageURL = new File(fileName).toURL();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                catch(java.net.MalformedURLException e) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 12559
diff changeset
   223
                    if (log.isLoggable(PlatformLogger.Level.FINE)) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2
diff changeset
   224
                        log.fine("MalformedURLException caught in the getImageURL() method", e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            return imageURL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * Returns the bounds of the splash screen window as a {@link Rectangle}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * This may be useful if, for example, you want to replace the splash
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * screen with your window at the same location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * You cannot control the size or position of the splash screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * The splash screen size is adjusted automatically when the image changes.
7765
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
   239
     * <p>
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
   240
     * The image may contain transparent areas, and thus the reported bounds may
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
   241
     * be larger than the visible splash screen image on the screen.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * @return a {@code Rectangle} containing the splash screen bounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * @throws IllegalStateException if the splash screen has already been closed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    public Rectangle getBounds() throws IllegalStateException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        synchronized (SplashScreen.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            checkVisible();
25552
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 23010
diff changeset
   249
            float scale = _getScaleFactor(splashPtr);
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 23010
diff changeset
   250
            Rectangle bounds = _getBounds(splashPtr);
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 23010
diff changeset
   251
            assert scale > 0;
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 23010
diff changeset
   252
            if (scale > 0 && scale != 1) {
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 23010
diff changeset
   253
                bounds.setSize((int) (bounds.getWidth() / scale),
36869
f8ef78f4157d 8145174: HiDPI splash screen support on Linux
rchamyal
parents: 35667
diff changeset
   254
                        (int) (bounds.getHeight() / scale));
25552
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 23010
diff changeset
   255
            }
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 23010
diff changeset
   256
            return bounds;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * Returns the size of the splash screen window as a {@link Dimension}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * This may be useful if, for example,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * you want to draw on the splash screen overlay surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * You cannot control the size or position of the splash screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * The splash screen size is adjusted automatically when the image changes.
7765
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
   267
     * <p>
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
   268
     * The image may contain transparent areas, and thus the reported size may
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
   269
     * be larger than the visible splash screen image on the screen.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * @return a {@link Dimension} object indicating the splash screen size
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * @throws IllegalStateException if the splash screen has already been closed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    public Dimension getSize() throws IllegalStateException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        return getBounds().getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * Creates a graphics context (as a {@link Graphics2D} object) for the splash
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * screen overlay image, which allows you to draw over the splash screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * Note that you do not draw on the main image but on the image that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * displayed over the main image using alpha blending. Also note that drawing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * on the overlay image does not necessarily update the contents of splash
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * screen window. You should call {@code update()} on the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   285
     * {@code SplashScreen} when you want the splash screen to be
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * updated immediately.
7765
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
   287
     * <p>
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
   288
     * The pixel (0, 0) in the coordinate space of the graphics context
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
   289
     * corresponds to the origin of the splash screen native window bounds (see
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
   290
     * {@link #getBounds()}).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * @return graphics context for the splash screen overlay surface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * @throws IllegalStateException if the splash screen has already been closed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    public Graphics2D createGraphics() throws IllegalStateException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        synchronized (SplashScreen.class) {
26745
91ffd43ffc17 8058136: Test api/java_awt/SplashScreen/index.html\#ClosedSplashScreenTests fails because of java.lang.IllegalStateException was not thrown
serb
parents: 25859
diff changeset
   297
            checkVisible();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
            if (image==null) {
25552
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 23010
diff changeset
   299
                // get unscaled splash image size
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 23010
diff changeset
   300
                Dimension dim = _getBounds(splashPtr).getSize();
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 23010
diff changeset
   301
                image = new BufferedImage(dim.width, dim.height,
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 23010
diff changeset
   302
                        BufferedImage.TYPE_INT_ARGB);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            }
25552
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 23010
diff changeset
   304
            float scale = _getScaleFactor(splashPtr);
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 23010
diff changeset
   305
            Graphics2D g = image.createGraphics();
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 23010
diff changeset
   306
            assert (scale > 0);
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 23010
diff changeset
   307
            if (scale <= 0) {
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 23010
diff changeset
   308
                scale = 1;
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 23010
diff changeset
   309
            }
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 23010
diff changeset
   310
            g.scale(scale, scale);
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 23010
diff changeset
   311
            return g;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * Updates the splash window with current contents of the overlay image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * @throws IllegalStateException if the overlay image does not exist;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     *         for example, if {@code createGraphics} has never been called,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     *         or if the splash screen has already been closed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    public void update() throws IllegalStateException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        BufferedImage image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        synchronized (SplashScreen.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
            checkVisible();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
            image = this.image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        if (image == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            throw new IllegalStateException("no overlay image available");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        DataBuffer buf = image.getRaster().getDataBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        if (!(buf instanceof DataBufferInt)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
            throw new AssertionError("Overlay image DataBuffer is of invalid type == "+buf.getClass().getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        int numBanks = buf.getNumBanks();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        if (numBanks!=1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
            throw new AssertionError("Invalid number of banks =="+numBanks+" in overlay image DataBuffer");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        if (!(image.getSampleModel() instanceof SinglePixelPackedSampleModel)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
            throw new AssertionError("Overlay image has invalid sample model == "+image.getSampleModel().getClass().getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        SinglePixelPackedSampleModel sm = (SinglePixelPackedSampleModel)image.getSampleModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        int scanlineStride = sm.getScanlineStride();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        Rectangle rect = image.getRaster().getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        // Note that we steal the data array here, but just for reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        // so we do not need to mark the DataBuffer dirty...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        int[] data = SunWritableRaster.stealData((DataBufferInt)buf, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        synchronized(SplashScreen.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
            checkVisible();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            _update(splashPtr, data, rect.x, rect.y, rect.width, rect.height, scanlineStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * Hides the splash screen, closes the window, and releases all associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * resources.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * @throws IllegalStateException if the splash screen has already been closed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    public void close() throws IllegalStateException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        synchronized (SplashScreen.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            checkVisible();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
            _close(splashPtr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
            image = null;
6823
cff6c85026c4 6990352: SplashScreen.getSplashScreen() does not return null for implicitly closed splash screen
anthony
parents: 5506
diff changeset
   365
            SplashScreen.markClosed();
cff6c85026c4 6990352: SplashScreen.getSplashScreen() does not return null for implicitly closed splash screen
anthony
parents: 5506
diff changeset
   366
        }
cff6c85026c4 6990352: SplashScreen.getSplashScreen() does not return null for implicitly closed splash screen
anthony
parents: 5506
diff changeset
   367
    }
cff6c85026c4 6990352: SplashScreen.getSplashScreen() does not return null for implicitly closed splash screen
anthony
parents: 5506
diff changeset
   368
cff6c85026c4 6990352: SplashScreen.getSplashScreen() does not return null for implicitly closed splash screen
anthony
parents: 5506
diff changeset
   369
    static void markClosed() {
cff6c85026c4 6990352: SplashScreen.getSplashScreen() does not return null for implicitly closed splash screen
anthony
parents: 5506
diff changeset
   370
        synchronized (SplashScreen.class) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            wasClosed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
            theInstance = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * Determines whether the splash screen is visible. The splash screen may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * be hidden using {@link #close()}, it is also hidden automatically when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * the first AWT/Swing window is made visible.
7765
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
   381
     * <p>
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
   382
     * Note that the native platform may delay presenting the splash screen
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
   383
     * native window on the screen. The return value of {@code true} for this
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
   384
     * method only guarantees that the conditions to hide the splash screen
a9e4a2c0600e 6993803: Request to update SplashScreen specification
anthony
parents: 6823
diff changeset
   385
     * window have not occurred yet.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * @return true if the splash screen is visible (has not been closed yet),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     *         false otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    public boolean isVisible() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        synchronized (SplashScreen.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
            return !wasClosed && _isVisible(splashPtr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    private BufferedImage image; // overlay image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    private final long splashPtr; // pointer to native Splash structure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    private static boolean wasClosed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    private URL imageURL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * The instance reference for the singleton.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   405
     * ({@code null} if no instance exists yet.)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * @see #getSplashScreen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * @see #close
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    private static SplashScreen theInstance = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2
diff changeset
   412
    private static final PlatformLogger log = PlatformLogger.getLogger("java.awt.SplashScreen");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 28231
diff changeset
   414
    private static native void _update(long splashPtr, int[] data, int x, int y, int width, int height, int scanlineStride);
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 28231
diff changeset
   415
    private static native boolean _isVisible(long splashPtr);
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 28231
diff changeset
   416
    private static native Rectangle _getBounds(long splashPtr);
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 28231
diff changeset
   417
    private static native long _getInstance();
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 28231
diff changeset
   418
    private static native void _close(long splashPtr);
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 28231
diff changeset
   419
    private static native String _getImageFileName(long splashPtr);
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 28231
diff changeset
   420
    private static native String _getImageJarName(long SplashPtr);
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 28231
diff changeset
   421
    private static native boolean _setImageData(long SplashPtr, byte[] data);
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 28231
diff changeset
   422
    private static native float _getScaleFactor(long SplashPtr);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
26745
91ffd43ffc17 8058136: Test api/java_awt/SplashScreen/index.html\#ClosedSplashScreenTests fails because of java.lang.IllegalStateException was not thrown
serb
parents: 25859
diff changeset
   424
}