src/share/classes/java/awt/SplashScreen.java

Print this page




 228         }
 229     }
 230 
 231     /**
 232      * Returns the bounds of the splash screen window as a {@link Rectangle}.
 233      * This may be useful if, for example, you want to replace the splash
 234      * screen with your window at the same location.
 235      * <p>
 236      * You cannot control the size or position of the splash screen.
 237      * The splash screen size is adjusted automatically when the image changes.
 238      * <p>
 239      * The image may contain transparent areas, and thus the reported bounds may
 240      * be larger than the visible splash screen image on the screen.
 241      *
 242      * @return a {@code Rectangle} containing the splash screen bounds
 243      * @throws IllegalStateException if the splash screen has already been closed
 244      */
 245     public Rectangle getBounds() throws IllegalStateException {
 246         synchronized (SplashScreen.class) {
 247             checkVisible();
 248             return _getBounds(splashPtr);






 249         }
 250     }
 251 
 252     /**
 253      * Returns the size of the splash screen window as a {@link Dimension}.
 254      * This may be useful if, for example,
 255      * you want to draw on the splash screen overlay surface.
 256      * <p>
 257      * You cannot control the size or position of the splash screen.
 258      * The splash screen size is adjusted automatically when the image changes.
 259      * <p>
 260      * The image may contain transparent areas, and thus the reported size may
 261      * be larger than the visible splash screen image on the screen.
 262      *
 263      * @return a {@link Dimension} object indicating the splash screen size
 264      * @throws IllegalStateException if the splash screen has already been closed
 265      */
 266     public Dimension getSize() throws IllegalStateException {
 267         return getBounds().getSize();
 268     }


 270     /**
 271      * Creates a graphics context (as a {@link Graphics2D} object) for the splash
 272      * screen overlay image, which allows you to draw over the splash screen.
 273      * Note that you do not draw on the main image but on the image that is
 274      * displayed over the main image using alpha blending. Also note that drawing
 275      * on the overlay image does not necessarily update the contents of splash
 276      * screen window. You should call {@code update()} on the
 277      * <code>SplashScreen</code> when you want the splash screen to be
 278      * updated immediately.
 279      * <p>
 280      * The pixel (0, 0) in the coordinate space of the graphics context
 281      * corresponds to the origin of the splash screen native window bounds (see
 282      * {@link #getBounds()}).
 283      *
 284      * @return graphics context for the splash screen overlay surface
 285      * @throws IllegalStateException if the splash screen has already been closed
 286      */
 287     public Graphics2D createGraphics() throws IllegalStateException {
 288         synchronized (SplashScreen.class) {
 289             if (image==null) {
 290                 Dimension dim = getSize();
 291                 image = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_ARGB);
 292             }
 293             return image.createGraphics();





 294         }
 295     }
 296 
 297     /**
 298      * Updates the splash window with current contents of the overlay image.
 299      *
 300      * @throws IllegalStateException if the overlay image does not exist;
 301      *         for example, if {@code createGraphics} has never been called,
 302      *         or if the splash screen has already been closed
 303      */
 304     public void update() throws IllegalStateException {
 305         BufferedImage image;
 306         synchronized (SplashScreen.class) {
 307             checkVisible();
 308             image = this.image;
 309         }
 310         if (image == null) {
 311             throw new IllegalStateException("no overlay image available");
 312         }
 313         DataBuffer buf = image.getRaster().getDataBuffer();


 384 
 385     /**
 386      * The instance reference for the singleton.
 387      * (<code>null</code> if no instance exists yet.)
 388      *
 389      * @see #getSplashScreen
 390      * @see #close
 391      */
 392     private static SplashScreen theInstance = null;
 393 
 394     private static final PlatformLogger log = PlatformLogger.getLogger("java.awt.SplashScreen");
 395 
 396     private native static void _update(long splashPtr, int[] data, int x, int y, int width, int height, int scanlineStride);
 397     private native static boolean _isVisible(long splashPtr);
 398     private native static Rectangle _getBounds(long splashPtr);
 399     private native static long _getInstance();
 400     private native static void _close(long splashPtr);
 401     private native static String _getImageFileName(long splashPtr);
 402     private native static String _getImageJarName(long SplashPtr);
 403     private native static boolean _setImageData(long SplashPtr, byte[] data);

 404 
 405 };


 228         }
 229     }
 230 
 231     /**
 232      * Returns the bounds of the splash screen window as a {@link Rectangle}.
 233      * This may be useful if, for example, you want to replace the splash
 234      * screen with your window at the same location.
 235      * <p>
 236      * You cannot control the size or position of the splash screen.
 237      * The splash screen size is adjusted automatically when the image changes.
 238      * <p>
 239      * The image may contain transparent areas, and thus the reported bounds may
 240      * be larger than the visible splash screen image on the screen.
 241      *
 242      * @return a {@code Rectangle} containing the splash screen bounds
 243      * @throws IllegalStateException if the splash screen has already been closed
 244      */
 245     public Rectangle getBounds() throws IllegalStateException {
 246         synchronized (SplashScreen.class) {
 247             checkVisible();
 248             float scale = _getScaleFactor(splashPtr);
 249             Rectangle bounds = _getBounds(splashPtr);
 250             if (scale != 1) {
 251                 bounds.setSize((int) (bounds.getWidth() / scale),
 252                         (int) (bounds.getWidth() / scale));
 253             }
 254             return bounds;
 255         }
 256     }
 257 
 258     /**
 259      * Returns the size of the splash screen window as a {@link Dimension}.
 260      * This may be useful if, for example,
 261      * you want to draw on the splash screen overlay surface.
 262      * <p>
 263      * You cannot control the size or position of the splash screen.
 264      * The splash screen size is adjusted automatically when the image changes.
 265      * <p>
 266      * The image may contain transparent areas, and thus the reported size may
 267      * be larger than the visible splash screen image on the screen.
 268      *
 269      * @return a {@link Dimension} object indicating the splash screen size
 270      * @throws IllegalStateException if the splash screen has already been closed
 271      */
 272     public Dimension getSize() throws IllegalStateException {
 273         return getBounds().getSize();
 274     }


 276     /**
 277      * Creates a graphics context (as a {@link Graphics2D} object) for the splash
 278      * screen overlay image, which allows you to draw over the splash screen.
 279      * Note that you do not draw on the main image but on the image that is
 280      * displayed over the main image using alpha blending. Also note that drawing
 281      * on the overlay image does not necessarily update the contents of splash
 282      * screen window. You should call {@code update()} on the
 283      * <code>SplashScreen</code> when you want the splash screen to be
 284      * updated immediately.
 285      * <p>
 286      * The pixel (0, 0) in the coordinate space of the graphics context
 287      * corresponds to the origin of the splash screen native window bounds (see
 288      * {@link #getBounds()}).
 289      *
 290      * @return graphics context for the splash screen overlay surface
 291      * @throws IllegalStateException if the splash screen has already been closed
 292      */
 293     public Graphics2D createGraphics() throws IllegalStateException {
 294         synchronized (SplashScreen.class) {
 295             if (image==null) {
 296                 // get unscaled splash image size
 297                 Dimension dim = _getBounds(splashPtr).getSize();
 298                 image = new BufferedImage(dim.width, dim.height,
 299                         BufferedImage.TYPE_INT_ARGB);
 300             }
 301             float scale = _getScaleFactor(splashPtr);
 302             Graphics2D g = image.createGraphics();
 303             g.scale(scale, scale);
 304             return g;
 305         }
 306     }
 307 
 308     /**
 309      * Updates the splash window with current contents of the overlay image.
 310      *
 311      * @throws IllegalStateException if the overlay image does not exist;
 312      *         for example, if {@code createGraphics} has never been called,
 313      *         or if the splash screen has already been closed
 314      */
 315     public void update() throws IllegalStateException {
 316         BufferedImage image;
 317         synchronized (SplashScreen.class) {
 318             checkVisible();
 319             image = this.image;
 320         }
 321         if (image == null) {
 322             throw new IllegalStateException("no overlay image available");
 323         }
 324         DataBuffer buf = image.getRaster().getDataBuffer();


 395 
 396     /**
 397      * The instance reference for the singleton.
 398      * (<code>null</code> if no instance exists yet.)
 399      *
 400      * @see #getSplashScreen
 401      * @see #close
 402      */
 403     private static SplashScreen theInstance = null;
 404 
 405     private static final PlatformLogger log = PlatformLogger.getLogger("java.awt.SplashScreen");
 406 
 407     private native static void _update(long splashPtr, int[] data, int x, int y, int width, int height, int scanlineStride);
 408     private native static boolean _isVisible(long splashPtr);
 409     private native static Rectangle _getBounds(long splashPtr);
 410     private native static long _getInstance();
 411     private native static void _close(long splashPtr);
 412     private native static String _getImageFileName(long splashPtr);
 413     private native static String _getImageJarName(long SplashPtr);
 414     private native static boolean _setImageData(long SplashPtr, byte[] data);
 415     private native static float _getScaleFactor(long SplashPtr);
 416 
 417 };