Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6633275
Votes 0
Synopsis Need to support shaped/translucent windows
Category java:classes_awt
Reported Against 1.2 , 1.3 , 1.4 , 1.1.3 , 1.3.1 , 1.4.1 , tiger , 1.0beta , mustang , 1.1beta3 , merlin-rc1 , hopper-beta , merlin-beta
Release Fixed 6u10(b12), 7(b55) (Bug ID:2172125)
State 10-Fix Delivered, request for enhancement
Priority: 3-Medium
Related Bugs 6504874 , 6589865 , 2151902 , 2151903 , 6594127 , 6594131 , 6646289 , 6648996 , 6655001 , 6656412 , 6661196 , 6661319 , 6661455 , 6661484 , 6661657 , 6662532 , 6680240 , 6683728 , 6687141 , 6693253 , 6702458 , 6722162 , 6725023 , 6725365 , 6797195 , 6800023 , 6802853 , 2177803 , 5062995 , 4735828 , 4479178
Submit Date 22-NOV-2007
Description
The Consumer JRE should support shaped/translucent windows. The following API is proposed for this:

package com. xxxxx .awt;

/**
 * <b>WARNING</b>: This class is an implementation detail and only meant
 * for use within the core platform. You should NOT depend upon it! This
 * API may change drastically between dot dot release, and it may even be
 * removed.
 */
public final class AWTUtilities {

    /** 
     * The AWTUtilities class should not be instantiated
     */
    private AWTUtilities() {
    }

    public static enum Translucency {
        /** 
         * Represents image data that is guaranteed to be completely opaque,
         * meaning that all pixels have an alpha value of 1.0.
         */
        OPAQUE,

        /**
         * Represents image data each pixel of which is guaranteed to be either 
         * completely opaque, with an alpha value of 1.0, or completely transparent,
         * with an alpha value of 0.0.
         */
        PERPIXEL_OPAQUE,

        /**
         * Represents image data all of the pixels of which have the same alpha value
         * between or including 0.0 and 1.0.
         */
        TRANSLUCENT,

        /**
         * Represents image data that contains or might contain pixels with arbitrary
         * alpha values between and including 0.0 and 1.0.
         */
        PERPIXEL_TRANSLUCENT;
    }


    /**
     * Returns whether the given level of translucency is supported by
     * the current configuration.
     *
     * The translucencyKind argument is one of the OPAQUE, PERPIXEL_OPAQUE, 
     * TRANSLUCENT, or PERPIXEL_TRANSLUCENT constants. Passing any other value
     * (or any bitwise combination of the constants) results in
     * return value of false.
     *
     * The level of support depends on the capabilities of the native system.
     *
     * Note that this method may sometimes return the value 
     * indicating that the particular level is supported, but 
     * the native windowing system may still not support the 
     * given level of translucency (due to the bugs in 
     * the windowing system).
     *
     * @param translucencyKind a kind of translucency support 
     *                         (either OPAQUE, PERPIXEL_OPAQUE, 
     *                         TRANSLUCENT, or PERPIXEL_TRANSLUCENT)
     * @return whether the given translucency kind is supported
     * @throws IllegalArgumentException if the translucencyKind argument is not one of the defined constants.
     */
    public static boolean isTranslucencySupported(Translucency translucencyKind);


    /**
     * Set the opacity of the window. The opacity is at the range [0..1].
     * Note that setting the opacity level of 0 may or may not disable
     * the mouse event handling on this window. This is 
     * a platform-dependent behavior.
     *
     * In order for this method to enable the translucency effect,
     * the isTranslucencySupported() method should indicate that the 
     * TRANSLUCENT level of translucency is supported.
     *
     * @param window the window to set the opacity level to
     * @param opacity the opacity level to set to the window
     * @throws NullPointerException if the window argument is null
     * @throws IllegalArgumentException if the opacity is out of the range [0..1]
     * @throws UnsupportedOperationException if the TRANSLUCENT translucency kind is not supported
     */
    public static void setWindowOpacity(Window window, float opacity);

    /**
     * Get the opacity of the window. If the opacity has not
     * yet being set, this method returns 1.0.
     *
     * @param window the window to get the opacity level from
     * @throws NullPointerException if the window argument is null
     */
    public static float getWindowOpacity(Window window);

    /**
     * Returns the  customer  implementing the Shape interface previously
     * set with the call to the setWindowShape() method.
     * If no shape has been set yet, this method returns null.
     * @param window the window to get the shape from
     * @throws NullPointerException if the window argument is null
     */
    public static Shape getWindowShape(Window window);

    /**
     * Sets a shape  customer  for the given window.
     * If the shape argument is null, this methods restores
     * the default shape making the window rectangular.
     * Note that in order to set a shape, the window must be undecorated.
     * @param window the window to set the shape to
     * @param shape the shape to set to the window
     * @throws NullPointerException if the window argument is null
     * @throws UnsupportedOperationException if the PERPIXEL_OPAQUE translucency kind is not supported
     */
    public static void setWindowShape(Window window, Shape shape);

    /**
     * Enables the per-pixel alpha support for the given window.
     * Once the window becomes non-opaque (the isOpaque is set to false),
     * the drawing sub-system is starting to respect the alpha value of each 
     * separate pixel. If a pixel gets painted with alpha color component
     * equal to zero, it becomes visually transparent, if the alpha of the 
     * pixel is equal to 255, the pixel is fully opaque. Interim values
     * of the alpha color component make the pixel semi-transparent (i.e.
     * translucent).
     * <p>Note that in order for the window to support the per-pixel alpha
     * mode, the window must be created using the GraphicsConfiguration
     * obtained with the {@link getTranslucencyCompatibleGraphicsConfiguration}
     * method. 
     * <p>Also note that some native systems enable the per-pixel translucency
     * mode for any window created using the translucency-compatible
     * graphics configuration. However, it is highly recommended to always
     * invoke the setWindowOpaque() method for these windows, at least for the sake of
     * cross-platform compatibility reasons.
     * 
     * @param window the window to set the shape to
     * @param isOpaque whether the window must be opaque (true), or translucent (false)
     * @throws NullPointerException if the window argument is null
     * @throws IllegalArgumentException if the window uses a GraphicsConfiguration other than returned by the getTranslucencyCompatibleGraphicsConfiguration() method.
     * @throws UnsupportedOperationException if the PERPIXEL_TRANSLUCENT translucency kind is not supported
     */
    public static void setWindowOpaque(Window window, boolean isOpaque);

    /**
     * Returns whether the window is opaque or translucent.
     *
     * @param window the window to set the shape to
     * @return whether the window is currently opaque (true) or translucent (false)
     * @throws NullPointerException if the window argument is null
     */
    public static boolean isWindowOpaque(Window window);

    /**
     * Returns a GraphicsConfigurations that are capable of displaying translucent windows.
     * All windows that are intended to be used with setWindowOpaque() method
     * must be created using one of the GraphicsConfiguration returned with this method.
     * <p>Note that some native systems enable the per-pixel translucency
     * mode for any window created using the translucency-compatible
     * graphics configuration. However, it is highly recommended to always
     * invoke the setWindowOpaque() method for these windows, at least for the sake of
     * cross-platform compatibility reasons.
     *
     * @return a GraphicsConfiguration capable of displaying translucent windows.
     */
    public static Set<GraphicsConfiguration> getTranslucencyCompatibleGraphicsConfigurations();
}
Posted Date : 2007-11-22 12:37:41.0
Work Around
N/A
Evaluation
Native platform support:

Shaped windows:
* MS Windows: since Win95
* X11: since 1989 (the XSHAPE extenstion)

Translucency:
* MS Windows: since Window 2000
* X11: if running a composite (or compositing window-) manager (like Compiz) which supports (and reports as supported) the desired effects.
Posted Date : 2008-11-21 14:59:12.0

This also includes back porting of a number of Java2D fixes from the JDK7 source tree, notably: 6589865 and 6504874.
It is decided to keep the whole fix under this CR, so these back ports are combined together.
Posted Date : 2007-11-23 11:30:38.0

The feature and the API are described in details at:

http://java.sun.com/developer/technicalArticles/GUI/translucent_shaped_windows/
Posted Date : 2009-09-22 11:36:35.0
Comments
  
  Include a link with my name & email   

Submitted On 23-APR-2008
Greate!!


Submitted On 15-SEP-2009
lambdav
Too complicated and difficult to use.
Not integrated in standard API.
Doesn't work with Windows 2000.
getTranslucencyCompatibleGraphicsConfigurations -> symbol not found

W/A : use C#



PLEASE NOTE: JDK6 is formerly known as Project Mustang