java.awt.peer.WindowPeer#applyShape ( )源码实例Demo

下面列出了java.awt.peer.WindowPeer#applyShape ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jdk1.8-source-analysis   文件: Window.java
/**
 * Sets the shape of the window.
 * <p>
 * Setting a shape cuts off some parts of the window. Only the parts that
 * belong to the given {@link Shape} remain visible and clickable. If
 * the shape argument is {@code null}, this method restores the default
 * shape, making the window rectangular on most platforms.
 * <p>
 * The following conditions must be met to set a non-null shape:
 * <ul>
 * <li>The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 * PERPIXEL_TRANSPARENT} translucency must be supported by the
 * underlying system
 * <li>The window must be undecorated (see {@link Frame#setUndecorated}
 * and {@link Dialog#setUndecorated})
 * <li>The window must not be in full-screen mode (see {@link
 * GraphicsDevice#setFullScreenWindow(Window)})
 * </ul>
 * <p>
 * If the requested shape is not {@code null}, and any of the above
 * conditions are not met, the shape of this window will not change,
 * and either the {@code UnsupportedOperationException} or {@code
 * IllegalComponentStateException} will be thrown.
 * <p>
 * The translucency levels of individual pixels may also be effected by the
 * alpha component of their color (see {@link Window#setBackground(Color)}) and the
 * opacity value (see {@link #setOpacity(float)}). See {@link
 * GraphicsDevice.WindowTranslucency} for more details.
 *
 * @param shape the shape to set to the window
 *
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is decorated
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is in full-screen mode
 * @throws UnsupportedOperationException if the shape is not {@code
 *     null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 *     PERPIXEL_TRANSPARENT} translucency is not supported
 *
 * @see Window#getShape()
 * @see Window#setBackground(Color)
 * @see Window#setOpacity(float)
 * @see Frame#isUndecorated
 * @see Dialog#isUndecorated
 * @see GraphicsDevice.WindowTranslucency
 * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
 *
 * @since 1.7
 */
public void setShape(Shape shape) {
    synchronized (getTreeLock()) {
        if (shape != null) {
            GraphicsConfiguration gc = getGraphicsConfiguration();
            GraphicsDevice gd = gc.getDevice();
            if (gc.getDevice().getFullScreenWindow() == this) {
                throw new IllegalComponentStateException(
                    "Setting shape for full-screen window is not supported.");
            }
            if (!gd.isWindowTranslucencySupported(
                    GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
            {
                throw new UnsupportedOperationException(
                    "PERPIXEL_TRANSPARENT translucency is not supported.");
            }
        }
        this.shape = (shape == null) ? null : new Path2D.Float(shape);
        WindowPeer peer = (WindowPeer)getPeer();
        if (peer != null) {
            peer.applyShape(shape == null ? null : Region.getInstance(shape, null));
        }
    }
}
 
源代码2 项目: dragonwell8_jdk   文件: Window.java
/**
 * Sets the shape of the window.
 * <p>
 * Setting a shape cuts off some parts of the window. Only the parts that
 * belong to the given {@link Shape} remain visible and clickable. If
 * the shape argument is {@code null}, this method restores the default
 * shape, making the window rectangular on most platforms.
 * <p>
 * The following conditions must be met to set a non-null shape:
 * <ul>
 * <li>The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 * PERPIXEL_TRANSPARENT} translucency must be supported by the
 * underlying system
 * <li>The window must be undecorated (see {@link Frame#setUndecorated}
 * and {@link Dialog#setUndecorated})
 * <li>The window must not be in full-screen mode (see {@link
 * GraphicsDevice#setFullScreenWindow(Window)})
 * </ul>
 * <p>
 * If the requested shape is not {@code null}, and any of the above
 * conditions are not met, the shape of this window will not change,
 * and either the {@code UnsupportedOperationException} or {@code
 * IllegalComponentStateException} will be thrown.
 * <p>
 * The translucency levels of individual pixels may also be effected by the
 * alpha component of their color (see {@link Window#setBackground(Color)}) and the
 * opacity value (see {@link #setOpacity(float)}). See {@link
 * GraphicsDevice.WindowTranslucency} for more details.
 *
 * @param shape the shape to set to the window
 *
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is decorated
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is in full-screen mode
 * @throws UnsupportedOperationException if the shape is not {@code
 *     null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 *     PERPIXEL_TRANSPARENT} translucency is not supported
 *
 * @see Window#getShape()
 * @see Window#setBackground(Color)
 * @see Window#setOpacity(float)
 * @see Frame#isUndecorated
 * @see Dialog#isUndecorated
 * @see GraphicsDevice.WindowTranslucency
 * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
 *
 * @since 1.7
 */
public void setShape(Shape shape) {
    synchronized (getTreeLock()) {
        if (shape != null) {
            GraphicsConfiguration gc = getGraphicsConfiguration();
            GraphicsDevice gd = gc.getDevice();
            if (gc.getDevice().getFullScreenWindow() == this) {
                throw new IllegalComponentStateException(
                    "Setting shape for full-screen window is not supported.");
            }
            if (!gd.isWindowTranslucencySupported(
                    GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
            {
                throw new UnsupportedOperationException(
                    "PERPIXEL_TRANSPARENT translucency is not supported.");
            }
        }
        this.shape = (shape == null) ? null : new Path2D.Float(shape);
        WindowPeer peer = (WindowPeer)getPeer();
        if (peer != null) {
            peer.applyShape(shape == null ? null : Region.getInstance(shape, null));
        }
    }
}
 
源代码3 项目: TencentKona-8   文件: Window.java
/**
 * Sets the shape of the window.
 * <p>
 * Setting a shape cuts off some parts of the window. Only the parts that
 * belong to the given {@link Shape} remain visible and clickable. If
 * the shape argument is {@code null}, this method restores the default
 * shape, making the window rectangular on most platforms.
 * <p>
 * The following conditions must be met to set a non-null shape:
 * <ul>
 * <li>The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 * PERPIXEL_TRANSPARENT} translucency must be supported by the
 * underlying system
 * <li>The window must be undecorated (see {@link Frame#setUndecorated}
 * and {@link Dialog#setUndecorated})
 * <li>The window must not be in full-screen mode (see {@link
 * GraphicsDevice#setFullScreenWindow(Window)})
 * </ul>
 * <p>
 * If the requested shape is not {@code null}, and any of the above
 * conditions are not met, the shape of this window will not change,
 * and either the {@code UnsupportedOperationException} or {@code
 * IllegalComponentStateException} will be thrown.
 * <p>
 * The translucency levels of individual pixels may also be effected by the
 * alpha component of their color (see {@link Window#setBackground(Color)}) and the
 * opacity value (see {@link #setOpacity(float)}). See {@link
 * GraphicsDevice.WindowTranslucency} for more details.
 *
 * @param shape the shape to set to the window
 *
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is decorated
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is in full-screen mode
 * @throws UnsupportedOperationException if the shape is not {@code
 *     null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 *     PERPIXEL_TRANSPARENT} translucency is not supported
 *
 * @see Window#getShape()
 * @see Window#setBackground(Color)
 * @see Window#setOpacity(float)
 * @see Frame#isUndecorated
 * @see Dialog#isUndecorated
 * @see GraphicsDevice.WindowTranslucency
 * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
 *
 * @since 1.7
 */
public void setShape(Shape shape) {
    synchronized (getTreeLock()) {
        if (shape != null) {
            GraphicsConfiguration gc = getGraphicsConfiguration();
            GraphicsDevice gd = gc.getDevice();
            if (gc.getDevice().getFullScreenWindow() == this) {
                throw new IllegalComponentStateException(
                    "Setting shape for full-screen window is not supported.");
            }
            if (!gd.isWindowTranslucencySupported(
                    GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
            {
                throw new UnsupportedOperationException(
                    "PERPIXEL_TRANSPARENT translucency is not supported.");
            }
        }
        this.shape = (shape == null) ? null : new Path2D.Float(shape);
        WindowPeer peer = (WindowPeer)getPeer();
        if (peer != null) {
            peer.applyShape(shape == null ? null : Region.getInstance(shape, null));
        }
    }
}
 
源代码4 项目: jdk8u60   文件: Window.java
/**
 * Sets the shape of the window.
 * <p>
 * Setting a shape cuts off some parts of the window. Only the parts that
 * belong to the given {@link Shape} remain visible and clickable. If
 * the shape argument is {@code null}, this method restores the default
 * shape, making the window rectangular on most platforms.
 * <p>
 * The following conditions must be met to set a non-null shape:
 * <ul>
 * <li>The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 * PERPIXEL_TRANSPARENT} translucency must be supported by the
 * underlying system
 * <li>The window must be undecorated (see {@link Frame#setUndecorated}
 * and {@link Dialog#setUndecorated})
 * <li>The window must not be in full-screen mode (see {@link
 * GraphicsDevice#setFullScreenWindow(Window)})
 * </ul>
 * <p>
 * If the requested shape is not {@code null}, and any of the above
 * conditions are not met, the shape of this window will not change,
 * and either the {@code UnsupportedOperationException} or {@code
 * IllegalComponentStateException} will be thrown.
 * <p>
 * The translucency levels of individual pixels may also be effected by the
 * alpha component of their color (see {@link Window#setBackground(Color)}) and the
 * opacity value (see {@link #setOpacity(float)}). See {@link
 * GraphicsDevice.WindowTranslucency} for more details.
 *
 * @param shape the shape to set to the window
 *
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is decorated
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is in full-screen mode
 * @throws UnsupportedOperationException if the shape is not {@code
 *     null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 *     PERPIXEL_TRANSPARENT} translucency is not supported
 *
 * @see Window#getShape()
 * @see Window#setBackground(Color)
 * @see Window#setOpacity(float)
 * @see Frame#isUndecorated
 * @see Dialog#isUndecorated
 * @see GraphicsDevice.WindowTranslucency
 * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
 *
 * @since 1.7
 */
public void setShape(Shape shape) {
    synchronized (getTreeLock()) {
        if (shape != null) {
            GraphicsConfiguration gc = getGraphicsConfiguration();
            GraphicsDevice gd = gc.getDevice();
            if (gc.getDevice().getFullScreenWindow() == this) {
                throw new IllegalComponentStateException(
                    "Setting shape for full-screen window is not supported.");
            }
            if (!gd.isWindowTranslucencySupported(
                    GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
            {
                throw new UnsupportedOperationException(
                    "PERPIXEL_TRANSPARENT translucency is not supported.");
            }
        }
        this.shape = (shape == null) ? null : new Path2D.Float(shape);
        WindowPeer peer = (WindowPeer)getPeer();
        if (peer != null) {
            peer.applyShape(shape == null ? null : Region.getInstance(shape, null));
        }
    }
}
 
源代码5 项目: JDKSourceCode1.8   文件: Window.java
/**
 * Sets the shape of the window.
 * <p>
 * Setting a shape cuts off some parts of the window. Only the parts that
 * belong to the given {@link Shape} remain visible and clickable. If
 * the shape argument is {@code null}, this method restores the default
 * shape, making the window rectangular on most platforms.
 * <p>
 * The following conditions must be met to set a non-null shape:
 * <ul>
 * <li>The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 * PERPIXEL_TRANSPARENT} translucency must be supported by the
 * underlying system
 * <li>The window must be undecorated (see {@link Frame#setUndecorated}
 * and {@link Dialog#setUndecorated})
 * <li>The window must not be in full-screen mode (see {@link
 * GraphicsDevice#setFullScreenWindow(Window)})
 * </ul>
 * <p>
 * If the requested shape is not {@code null}, and any of the above
 * conditions are not met, the shape of this window will not change,
 * and either the {@code UnsupportedOperationException} or {@code
 * IllegalComponentStateException} will be thrown.
 * <p>
 * The translucency levels of individual pixels may also be effected by the
 * alpha component of their color (see {@link Window#setBackground(Color)}) and the
 * opacity value (see {@link #setOpacity(float)}). See {@link
 * GraphicsDevice.WindowTranslucency} for more details.
 *
 * @param shape the shape to set to the window
 *
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is decorated
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is in full-screen mode
 * @throws UnsupportedOperationException if the shape is not {@code
 *     null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 *     PERPIXEL_TRANSPARENT} translucency is not supported
 *
 * @see Window#getShape()
 * @see Window#setBackground(Color)
 * @see Window#setOpacity(float)
 * @see Frame#isUndecorated
 * @see Dialog#isUndecorated
 * @see GraphicsDevice.WindowTranslucency
 * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
 *
 * @since 1.7
 */
public void setShape(Shape shape) {
    synchronized (getTreeLock()) {
        if (shape != null) {
            GraphicsConfiguration gc = getGraphicsConfiguration();
            GraphicsDevice gd = gc.getDevice();
            if (gc.getDevice().getFullScreenWindow() == this) {
                throw new IllegalComponentStateException(
                    "Setting shape for full-screen window is not supported.");
            }
            if (!gd.isWindowTranslucencySupported(
                    GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
            {
                throw new UnsupportedOperationException(
                    "PERPIXEL_TRANSPARENT translucency is not supported.");
            }
        }
        this.shape = (shape == null) ? null : new Path2D.Float(shape);
        WindowPeer peer = (WindowPeer)getPeer();
        if (peer != null) {
            peer.applyShape(shape == null ? null : Region.getInstance(shape, null));
        }
    }
}
 
源代码6 项目: openjdk-jdk8u   文件: Window.java
/**
 * Sets the shape of the window.
 * <p>
 * Setting a shape cuts off some parts of the window. Only the parts that
 * belong to the given {@link Shape} remain visible and clickable. If
 * the shape argument is {@code null}, this method restores the default
 * shape, making the window rectangular on most platforms.
 * <p>
 * The following conditions must be met to set a non-null shape:
 * <ul>
 * <li>The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 * PERPIXEL_TRANSPARENT} translucency must be supported by the
 * underlying system
 * <li>The window must be undecorated (see {@link Frame#setUndecorated}
 * and {@link Dialog#setUndecorated})
 * <li>The window must not be in full-screen mode (see {@link
 * GraphicsDevice#setFullScreenWindow(Window)})
 * </ul>
 * <p>
 * If the requested shape is not {@code null}, and any of the above
 * conditions are not met, the shape of this window will not change,
 * and either the {@code UnsupportedOperationException} or {@code
 * IllegalComponentStateException} will be thrown.
 * <p>
 * The translucency levels of individual pixels may also be effected by the
 * alpha component of their color (see {@link Window#setBackground(Color)}) and the
 * opacity value (see {@link #setOpacity(float)}). See {@link
 * GraphicsDevice.WindowTranslucency} for more details.
 *
 * @param shape the shape to set to the window
 *
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is decorated
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is in full-screen mode
 * @throws UnsupportedOperationException if the shape is not {@code
 *     null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 *     PERPIXEL_TRANSPARENT} translucency is not supported
 *
 * @see Window#getShape()
 * @see Window#setBackground(Color)
 * @see Window#setOpacity(float)
 * @see Frame#isUndecorated
 * @see Dialog#isUndecorated
 * @see GraphicsDevice.WindowTranslucency
 * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
 *
 * @since 1.7
 */
public void setShape(Shape shape) {
    synchronized (getTreeLock()) {
        if (shape != null) {
            GraphicsConfiguration gc = getGraphicsConfiguration();
            GraphicsDevice gd = gc.getDevice();
            if (gc.getDevice().getFullScreenWindow() == this) {
                throw new IllegalComponentStateException(
                    "Setting shape for full-screen window is not supported.");
            }
            if (!gd.isWindowTranslucencySupported(
                    GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
            {
                throw new UnsupportedOperationException(
                    "PERPIXEL_TRANSPARENT translucency is not supported.");
            }
        }
        this.shape = (shape == null) ? null : new Path2D.Float(shape);
        WindowPeer peer = (WindowPeer)getPeer();
        if (peer != null) {
            peer.applyShape(shape == null ? null : Region.getInstance(shape, null));
        }
    }
}
 
源代码7 项目: openjdk-jdk8u-backup   文件: Window.java
/**
 * Sets the shape of the window.
 * <p>
 * Setting a shape cuts off some parts of the window. Only the parts that
 * belong to the given {@link Shape} remain visible and clickable. If
 * the shape argument is {@code null}, this method restores the default
 * shape, making the window rectangular on most platforms.
 * <p>
 * The following conditions must be met to set a non-null shape:
 * <ul>
 * <li>The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 * PERPIXEL_TRANSPARENT} translucency must be supported by the
 * underlying system
 * <li>The window must be undecorated (see {@link Frame#setUndecorated}
 * and {@link Dialog#setUndecorated})
 * <li>The window must not be in full-screen mode (see {@link
 * GraphicsDevice#setFullScreenWindow(Window)})
 * </ul>
 * <p>
 * If the requested shape is not {@code null}, and any of the above
 * conditions are not met, the shape of this window will not change,
 * and either the {@code UnsupportedOperationException} or {@code
 * IllegalComponentStateException} will be thrown.
 * <p>
 * The translucency levels of individual pixels may also be effected by the
 * alpha component of their color (see {@link Window#setBackground(Color)}) and the
 * opacity value (see {@link #setOpacity(float)}). See {@link
 * GraphicsDevice.WindowTranslucency} for more details.
 *
 * @param shape the shape to set to the window
 *
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is decorated
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is in full-screen mode
 * @throws UnsupportedOperationException if the shape is not {@code
 *     null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 *     PERPIXEL_TRANSPARENT} translucency is not supported
 *
 * @see Window#getShape()
 * @see Window#setBackground(Color)
 * @see Window#setOpacity(float)
 * @see Frame#isUndecorated
 * @see Dialog#isUndecorated
 * @see GraphicsDevice.WindowTranslucency
 * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
 *
 * @since 1.7
 */
public void setShape(Shape shape) {
    synchronized (getTreeLock()) {
        if (shape != null) {
            GraphicsConfiguration gc = getGraphicsConfiguration();
            GraphicsDevice gd = gc.getDevice();
            if (gc.getDevice().getFullScreenWindow() == this) {
                throw new IllegalComponentStateException(
                    "Setting shape for full-screen window is not supported.");
            }
            if (!gd.isWindowTranslucencySupported(
                    GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
            {
                throw new UnsupportedOperationException(
                    "PERPIXEL_TRANSPARENT translucency is not supported.");
            }
        }
        this.shape = (shape == null) ? null : new Path2D.Float(shape);
        WindowPeer peer = (WindowPeer)getPeer();
        if (peer != null) {
            peer.applyShape(shape == null ? null : Region.getInstance(shape, null));
        }
    }
}
 
源代码8 项目: Bytecoder   文件: Window.java
/**
 * Sets the shape of the window.
 * <p>
 * Setting a shape cuts off some parts of the window. Only the parts that
 * belong to the given {@link Shape} remain visible and clickable. If
 * the shape argument is {@code null}, this method restores the default
 * shape, making the window rectangular on most platforms.
 * <p>
 * The following conditions must be met to set a non-null shape:
 * <ul>
 * <li>The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 * PERPIXEL_TRANSPARENT} translucency must be supported by the
 * underlying system
 * <li>The window must be undecorated (see {@link Frame#setUndecorated}
 * and {@link Dialog#setUndecorated})
 * <li>The window must not be in full-screen mode (see {@link
 * GraphicsDevice#setFullScreenWindow(Window)})
 * </ul>
 * <p>
 * If the requested shape is not {@code null}, and any of the above
 * conditions are not met, the shape of this window will not change,
 * and either the {@code UnsupportedOperationException} or {@code
 * IllegalComponentStateException} will be thrown.
 * <p>
 * The translucency levels of individual pixels may also be effected by the
 * alpha component of their color (see {@link Window#setBackground(Color)}) and the
 * opacity value (see {@link #setOpacity(float)}). See {@link
 * GraphicsDevice.WindowTranslucency} for more details.
 *
 * @param shape the shape to set to the window
 *
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is decorated
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is in full-screen mode
 * @throws UnsupportedOperationException if the shape is not {@code
 *     null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 *     PERPIXEL_TRANSPARENT} translucency is not supported
 *
 * @see Window#getShape()
 * @see Window#setBackground(Color)
 * @see Window#setOpacity(float)
 * @see Frame#isUndecorated
 * @see Dialog#isUndecorated
 * @see GraphicsDevice.WindowTranslucency
 * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
 *
 * @since 1.7
 */
public void setShape(Shape shape) {
    synchronized (getTreeLock()) {
        if (shape != null) {
            GraphicsConfiguration gc = getGraphicsConfiguration();
            GraphicsDevice gd = gc.getDevice();
            if (gc.getDevice().getFullScreenWindow() == this) {
                throw new IllegalComponentStateException(
                    "Setting shape for full-screen window is not supported.");
            }
            if (!gd.isWindowTranslucencySupported(
                    GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
            {
                throw new UnsupportedOperationException(
                    "PERPIXEL_TRANSPARENT translucency is not supported.");
            }
        }
        this.shape = (shape == null) ? null : new Path2D.Float(shape);
        WindowPeer peer = (WindowPeer) this.peer;
        if (peer != null) {
            peer.applyShape(shape == null ? null : Region.getInstance(shape, null));
        }
    }
}
 
源代码9 项目: openjdk-jdk9   文件: Window.java
/**
 * Sets the shape of the window.
 * <p>
 * Setting a shape cuts off some parts of the window. Only the parts that
 * belong to the given {@link Shape} remain visible and clickable. If
 * the shape argument is {@code null}, this method restores the default
 * shape, making the window rectangular on most platforms.
 * <p>
 * The following conditions must be met to set a non-null shape:
 * <ul>
 * <li>The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 * PERPIXEL_TRANSPARENT} translucency must be supported by the
 * underlying system
 * <li>The window must be undecorated (see {@link Frame#setUndecorated}
 * and {@link Dialog#setUndecorated})
 * <li>The window must not be in full-screen mode (see {@link
 * GraphicsDevice#setFullScreenWindow(Window)})
 * </ul>
 * <p>
 * If the requested shape is not {@code null}, and any of the above
 * conditions are not met, the shape of this window will not change,
 * and either the {@code UnsupportedOperationException} or {@code
 * IllegalComponentStateException} will be thrown.
 * <p>
 * The translucency levels of individual pixels may also be effected by the
 * alpha component of their color (see {@link Window#setBackground(Color)}) and the
 * opacity value (see {@link #setOpacity(float)}). See {@link
 * GraphicsDevice.WindowTranslucency} for more details.
 *
 * @param shape the shape to set to the window
 *
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is decorated
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is in full-screen mode
 * @throws UnsupportedOperationException if the shape is not {@code
 *     null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 *     PERPIXEL_TRANSPARENT} translucency is not supported
 *
 * @see Window#getShape()
 * @see Window#setBackground(Color)
 * @see Window#setOpacity(float)
 * @see Frame#isUndecorated
 * @see Dialog#isUndecorated
 * @see GraphicsDevice.WindowTranslucency
 * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
 *
 * @since 1.7
 */
public void setShape(Shape shape) {
    synchronized (getTreeLock()) {
        if (shape != null) {
            GraphicsConfiguration gc = getGraphicsConfiguration();
            GraphicsDevice gd = gc.getDevice();
            if (gc.getDevice().getFullScreenWindow() == this) {
                throw new IllegalComponentStateException(
                    "Setting shape for full-screen window is not supported.");
            }
            if (!gd.isWindowTranslucencySupported(
                    GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
            {
                throw new UnsupportedOperationException(
                    "PERPIXEL_TRANSPARENT translucency is not supported.");
            }
        }
        this.shape = (shape == null) ? null : new Path2D.Float(shape);
        WindowPeer peer = (WindowPeer) this.peer;
        if (peer != null) {
            peer.applyShape(shape == null ? null : Region.getInstance(shape, null));
        }
    }
}
 
源代码10 项目: jdk8u-jdk   文件: Window.java
/**
 * Sets the shape of the window.
 * <p>
 * Setting a shape cuts off some parts of the window. Only the parts that
 * belong to the given {@link Shape} remain visible and clickable. If
 * the shape argument is {@code null}, this method restores the default
 * shape, making the window rectangular on most platforms.
 * <p>
 * The following conditions must be met to set a non-null shape:
 * <ul>
 * <li>The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 * PERPIXEL_TRANSPARENT} translucency must be supported by the
 * underlying system
 * <li>The window must be undecorated (see {@link Frame#setUndecorated}
 * and {@link Dialog#setUndecorated})
 * <li>The window must not be in full-screen mode (see {@link
 * GraphicsDevice#setFullScreenWindow(Window)})
 * </ul>
 * <p>
 * If the requested shape is not {@code null}, and any of the above
 * conditions are not met, the shape of this window will not change,
 * and either the {@code UnsupportedOperationException} or {@code
 * IllegalComponentStateException} will be thrown.
 * <p>
 * The translucency levels of individual pixels may also be effected by the
 * alpha component of their color (see {@link Window#setBackground(Color)}) and the
 * opacity value (see {@link #setOpacity(float)}). See {@link
 * GraphicsDevice.WindowTranslucency} for more details.
 *
 * @param shape the shape to set to the window
 *
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is decorated
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is in full-screen mode
 * @throws UnsupportedOperationException if the shape is not {@code
 *     null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 *     PERPIXEL_TRANSPARENT} translucency is not supported
 *
 * @see Window#getShape()
 * @see Window#setBackground(Color)
 * @see Window#setOpacity(float)
 * @see Frame#isUndecorated
 * @see Dialog#isUndecorated
 * @see GraphicsDevice.WindowTranslucency
 * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
 *
 * @since 1.7
 */
public void setShape(Shape shape) {
    synchronized (getTreeLock()) {
        if (shape != null) {
            GraphicsConfiguration gc = getGraphicsConfiguration();
            GraphicsDevice gd = gc.getDevice();
            if (gc.getDevice().getFullScreenWindow() == this) {
                throw new IllegalComponentStateException(
                    "Setting shape for full-screen window is not supported.");
            }
            if (!gd.isWindowTranslucencySupported(
                    GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
            {
                throw new UnsupportedOperationException(
                    "PERPIXEL_TRANSPARENT translucency is not supported.");
            }
        }
        this.shape = (shape == null) ? null : new Path2D.Float(shape);
        WindowPeer peer = (WindowPeer)getPeer();
        if (peer != null) {
            peer.applyShape(shape == null ? null : Region.getInstance(shape, null));
        }
    }
}
 
源代码11 项目: Java8CN   文件: Window.java
/**
 * Sets the shape of the window.
 * <p>
 * Setting a shape cuts off some parts of the window. Only the parts that
 * belong to the given {@link Shape} remain visible and clickable. If
 * the shape argument is {@code null}, this method restores the default
 * shape, making the window rectangular on most platforms.
 * <p>
 * The following conditions must be met to set a non-null shape:
 * <ul>
 * <li>The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 * PERPIXEL_TRANSPARENT} translucency must be supported by the
 * underlying system
 * <li>The window must be undecorated (see {@link Frame#setUndecorated}
 * and {@link Dialog#setUndecorated})
 * <li>The window must not be in full-screen mode (see {@link
 * GraphicsDevice#setFullScreenWindow(Window)})
 * </ul>
 * <p>
 * If the requested shape is not {@code null}, and any of the above
 * conditions are not met, the shape of this window will not change,
 * and either the {@code UnsupportedOperationException} or {@code
 * IllegalComponentStateException} will be thrown.
 * <p>
 * The translucency levels of individual pixels may also be effected by the
 * alpha component of their color (see {@link Window#setBackground(Color)}) and the
 * opacity value (see {@link #setOpacity(float)}). See {@link
 * GraphicsDevice.WindowTranslucency} for more details.
 *
 * @param shape the shape to set to the window
 *
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is decorated
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is in full-screen mode
 * @throws UnsupportedOperationException if the shape is not {@code
 *     null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 *     PERPIXEL_TRANSPARENT} translucency is not supported
 *
 * @see Window#getShape()
 * @see Window#setBackground(Color)
 * @see Window#setOpacity(float)
 * @see Frame#isUndecorated
 * @see Dialog#isUndecorated
 * @see GraphicsDevice.WindowTranslucency
 * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
 *
 * @since 1.7
 */
public void setShape(Shape shape) {
    synchronized (getTreeLock()) {
        if (shape != null) {
            GraphicsConfiguration gc = getGraphicsConfiguration();
            GraphicsDevice gd = gc.getDevice();
            if (gc.getDevice().getFullScreenWindow() == this) {
                throw new IllegalComponentStateException(
                    "Setting shape for full-screen window is not supported.");
            }
            if (!gd.isWindowTranslucencySupported(
                    GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
            {
                throw new UnsupportedOperationException(
                    "PERPIXEL_TRANSPARENT translucency is not supported.");
            }
        }
        this.shape = (shape == null) ? null : new Path2D.Float(shape);
        WindowPeer peer = (WindowPeer)getPeer();
        if (peer != null) {
            peer.applyShape(shape == null ? null : Region.getInstance(shape, null));
        }
    }
}
 
源代码12 项目: hottub   文件: Window.java
/**
 * Sets the shape of the window.
 * <p>
 * Setting a shape cuts off some parts of the window. Only the parts that
 * belong to the given {@link Shape} remain visible and clickable. If
 * the shape argument is {@code null}, this method restores the default
 * shape, making the window rectangular on most platforms.
 * <p>
 * The following conditions must be met to set a non-null shape:
 * <ul>
 * <li>The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 * PERPIXEL_TRANSPARENT} translucency must be supported by the
 * underlying system
 * <li>The window must be undecorated (see {@link Frame#setUndecorated}
 * and {@link Dialog#setUndecorated})
 * <li>The window must not be in full-screen mode (see {@link
 * GraphicsDevice#setFullScreenWindow(Window)})
 * </ul>
 * <p>
 * If the requested shape is not {@code null}, and any of the above
 * conditions are not met, the shape of this window will not change,
 * and either the {@code UnsupportedOperationException} or {@code
 * IllegalComponentStateException} will be thrown.
 * <p>
 * The translucency levels of individual pixels may also be effected by the
 * alpha component of their color (see {@link Window#setBackground(Color)}) and the
 * opacity value (see {@link #setOpacity(float)}). See {@link
 * GraphicsDevice.WindowTranslucency} for more details.
 *
 * @param shape the shape to set to the window
 *
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is decorated
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is in full-screen mode
 * @throws UnsupportedOperationException if the shape is not {@code
 *     null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 *     PERPIXEL_TRANSPARENT} translucency is not supported
 *
 * @see Window#getShape()
 * @see Window#setBackground(Color)
 * @see Window#setOpacity(float)
 * @see Frame#isUndecorated
 * @see Dialog#isUndecorated
 * @see GraphicsDevice.WindowTranslucency
 * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
 *
 * @since 1.7
 */
public void setShape(Shape shape) {
    synchronized (getTreeLock()) {
        if (shape != null) {
            GraphicsConfiguration gc = getGraphicsConfiguration();
            GraphicsDevice gd = gc.getDevice();
            if (gc.getDevice().getFullScreenWindow() == this) {
                throw new IllegalComponentStateException(
                    "Setting shape for full-screen window is not supported.");
            }
            if (!gd.isWindowTranslucencySupported(
                    GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
            {
                throw new UnsupportedOperationException(
                    "PERPIXEL_TRANSPARENT translucency is not supported.");
            }
        }
        this.shape = (shape == null) ? null : new Path2D.Float(shape);
        WindowPeer peer = (WindowPeer)getPeer();
        if (peer != null) {
            peer.applyShape(shape == null ? null : Region.getInstance(shape, null));
        }
    }
}
 
源代码13 项目: openjdk-8-source   文件: Window.java
/**
 * Sets the shape of the window.
 * <p>
 * Setting a shape cuts off some parts of the window. Only the parts that
 * belong to the given {@link Shape} remain visible and clickable. If
 * the shape argument is {@code null}, this method restores the default
 * shape, making the window rectangular on most platforms.
 * <p>
 * The following conditions must be met to set a non-null shape:
 * <ul>
 * <li>The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 * PERPIXEL_TRANSPARENT} translucency must be supported by the
 * underlying system
 * <li>The window must be undecorated (see {@link Frame#setUndecorated}
 * and {@link Dialog#setUndecorated})
 * <li>The window must not be in full-screen mode (see {@link
 * GraphicsDevice#setFullScreenWindow(Window)})
 * </ul>
 * <p>
 * If the requested shape is not {@code null}, and any of the above
 * conditions are not met, the shape of this window will not change,
 * and either the {@code UnsupportedOperationException} or {@code
 * IllegalComponentStateException} will be thrown.
 * <p>
 * The translucency levels of individual pixels may also be effected by the
 * alpha component of their color (see {@link Window#setBackground(Color)}) and the
 * opacity value (see {@link #setOpacity(float)}). See {@link
 * GraphicsDevice.WindowTranslucency} for more details.
 *
 * @param shape the shape to set to the window
 *
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is decorated
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is in full-screen mode
 * @throws UnsupportedOperationException if the shape is not {@code
 *     null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 *     PERPIXEL_TRANSPARENT} translucency is not supported
 *
 * @see Window#getShape()
 * @see Window#setBackground(Color)
 * @see Window#setOpacity(float)
 * @see Frame#isUndecorated
 * @see Dialog#isUndecorated
 * @see GraphicsDevice.WindowTranslucency
 * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
 *
 * @since 1.7
 */
public void setShape(Shape shape) {
    synchronized (getTreeLock()) {
        if (shape != null) {
            GraphicsConfiguration gc = getGraphicsConfiguration();
            GraphicsDevice gd = gc.getDevice();
            if (gc.getDevice().getFullScreenWindow() == this) {
                throw new IllegalComponentStateException(
                    "Setting shape for full-screen window is not supported.");
            }
            if (!gd.isWindowTranslucencySupported(
                    GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
            {
                throw new UnsupportedOperationException(
                    "PERPIXEL_TRANSPARENT translucency is not supported.");
            }
        }
        this.shape = (shape == null) ? null : new Path2D.Float(shape);
        WindowPeer peer = (WindowPeer)getPeer();
        if (peer != null) {
            peer.applyShape(shape == null ? null : Region.getInstance(shape, null));
        }
    }
}
 
源代码14 项目: openjdk-8   文件: Window.java
/**
 * Sets the shape of the window.
 * <p>
 * Setting a shape cuts off some parts of the window. Only the parts that
 * belong to the given {@link Shape} remain visible and clickable. If
 * the shape argument is {@code null}, this method restores the default
 * shape, making the window rectangular on most platforms.
 * <p>
 * The following conditions must be met to set a non-null shape:
 * <ul>
 * <li>The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 * PERPIXEL_TRANSPARENT} translucency must be supported by the
 * underlying system
 * <li>The window must be undecorated (see {@link Frame#setUndecorated}
 * and {@link Dialog#setUndecorated})
 * <li>The window must not be in full-screen mode (see {@link
 * GraphicsDevice#setFullScreenWindow(Window)})
 * </ul>
 * <p>
 * If the requested shape is not {@code null}, and any of the above
 * conditions are not met, the shape of this window will not change,
 * and either the {@code UnsupportedOperationException} or {@code
 * IllegalComponentStateException} will be thrown.
 * <p>
 * The translucency levels of individual pixels may also be effected by the
 * alpha component of their color (see {@link Window#setBackground(Color)}) and the
 * opacity value (see {@link #setOpacity(float)}). See {@link
 * GraphicsDevice.WindowTranslucency} for more details.
 *
 * @param shape the shape to set to the window
 *
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is decorated
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is in full-screen mode
 * @throws UnsupportedOperationException if the shape is not {@code
 *     null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 *     PERPIXEL_TRANSPARENT} translucency is not supported
 *
 * @see Window#getShape()
 * @see Window#setBackground(Color)
 * @see Window#setOpacity(float)
 * @see Frame#isUndecorated
 * @see Dialog#isUndecorated
 * @see GraphicsDevice.WindowTranslucency
 * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
 *
 * @since 1.7
 */
public void setShape(Shape shape) {
    synchronized (getTreeLock()) {
        if (shape != null) {
            GraphicsConfiguration gc = getGraphicsConfiguration();
            GraphicsDevice gd = gc.getDevice();
            if (gc.getDevice().getFullScreenWindow() == this) {
                throw new IllegalComponentStateException(
                    "Setting shape for full-screen window is not supported.");
            }
            if (!gd.isWindowTranslucencySupported(
                    GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
            {
                throw new UnsupportedOperationException(
                    "PERPIXEL_TRANSPARENT translucency is not supported.");
            }
        }
        this.shape = (shape == null) ? null : new Path2D.Float(shape);
        WindowPeer peer = (WindowPeer)getPeer();
        if (peer != null) {
            peer.applyShape(shape == null ? null : Region.getInstance(shape, null));
        }
    }
}
 
源代码15 项目: jdk8u_jdk   文件: Window.java
/**
 * Sets the shape of the window.
 * <p>
 * Setting a shape cuts off some parts of the window. Only the parts that
 * belong to the given {@link Shape} remain visible and clickable. If
 * the shape argument is {@code null}, this method restores the default
 * shape, making the window rectangular on most platforms.
 * <p>
 * The following conditions must be met to set a non-null shape:
 * <ul>
 * <li>The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 * PERPIXEL_TRANSPARENT} translucency must be supported by the
 * underlying system
 * <li>The window must be undecorated (see {@link Frame#setUndecorated}
 * and {@link Dialog#setUndecorated})
 * <li>The window must not be in full-screen mode (see {@link
 * GraphicsDevice#setFullScreenWindow(Window)})
 * </ul>
 * <p>
 * If the requested shape is not {@code null}, and any of the above
 * conditions are not met, the shape of this window will not change,
 * and either the {@code UnsupportedOperationException} or {@code
 * IllegalComponentStateException} will be thrown.
 * <p>
 * The translucency levels of individual pixels may also be effected by the
 * alpha component of their color (see {@link Window#setBackground(Color)}) and the
 * opacity value (see {@link #setOpacity(float)}). See {@link
 * GraphicsDevice.WindowTranslucency} for more details.
 *
 * @param shape the shape to set to the window
 *
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is decorated
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is in full-screen mode
 * @throws UnsupportedOperationException if the shape is not {@code
 *     null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 *     PERPIXEL_TRANSPARENT} translucency is not supported
 *
 * @see Window#getShape()
 * @see Window#setBackground(Color)
 * @see Window#setOpacity(float)
 * @see Frame#isUndecorated
 * @see Dialog#isUndecorated
 * @see GraphicsDevice.WindowTranslucency
 * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
 *
 * @since 1.7
 */
public void setShape(Shape shape) {
    synchronized (getTreeLock()) {
        if (shape != null) {
            GraphicsConfiguration gc = getGraphicsConfiguration();
            GraphicsDevice gd = gc.getDevice();
            if (gc.getDevice().getFullScreenWindow() == this) {
                throw new IllegalComponentStateException(
                    "Setting shape for full-screen window is not supported.");
            }
            if (!gd.isWindowTranslucencySupported(
                    GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
            {
                throw new UnsupportedOperationException(
                    "PERPIXEL_TRANSPARENT translucency is not supported.");
            }
        }
        this.shape = (shape == null) ? null : new Path2D.Float(shape);
        WindowPeer peer = (WindowPeer)getPeer();
        if (peer != null) {
            peer.applyShape(shape == null ? null : Region.getInstance(shape, null));
        }
    }
}
 
源代码16 项目: jdk8u-jdk   文件: Window.java
/**
 * Sets the shape of the window.
 * <p>
 * Setting a shape cuts off some parts of the window. Only the parts that
 * belong to the given {@link Shape} remain visible and clickable. If
 * the shape argument is {@code null}, this method restores the default
 * shape, making the window rectangular on most platforms.
 * <p>
 * The following conditions must be met to set a non-null shape:
 * <ul>
 * <li>The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 * PERPIXEL_TRANSPARENT} translucency must be supported by the
 * underlying system
 * <li>The window must be undecorated (see {@link Frame#setUndecorated}
 * and {@link Dialog#setUndecorated})
 * <li>The window must not be in full-screen mode (see {@link
 * GraphicsDevice#setFullScreenWindow(Window)})
 * </ul>
 * <p>
 * If the requested shape is not {@code null}, and any of the above
 * conditions are not met, the shape of this window will not change,
 * and either the {@code UnsupportedOperationException} or {@code
 * IllegalComponentStateException} will be thrown.
 * <p>
 * The translucency levels of individual pixels may also be effected by the
 * alpha component of their color (see {@link Window#setBackground(Color)}) and the
 * opacity value (see {@link #setOpacity(float)}). See {@link
 * GraphicsDevice.WindowTranslucency} for more details.
 *
 * @param shape the shape to set to the window
 *
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is decorated
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is in full-screen mode
 * @throws UnsupportedOperationException if the shape is not {@code
 *     null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 *     PERPIXEL_TRANSPARENT} translucency is not supported
 *
 * @see Window#getShape()
 * @see Window#setBackground(Color)
 * @see Window#setOpacity(float)
 * @see Frame#isUndecorated
 * @see Dialog#isUndecorated
 * @see GraphicsDevice.WindowTranslucency
 * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
 *
 * @since 1.7
 */
public void setShape(Shape shape) {
    synchronized (getTreeLock()) {
        if (shape != null) {
            GraphicsConfiguration gc = getGraphicsConfiguration();
            GraphicsDevice gd = gc.getDevice();
            if (gc.getDevice().getFullScreenWindow() == this) {
                throw new IllegalComponentStateException(
                    "Setting shape for full-screen window is not supported.");
            }
            if (!gd.isWindowTranslucencySupported(
                    GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
            {
                throw new UnsupportedOperationException(
                    "PERPIXEL_TRANSPARENT translucency is not supported.");
            }
        }
        this.shape = (shape == null) ? null : new Path2D.Float(shape);
        WindowPeer peer = (WindowPeer)getPeer();
        if (peer != null) {
            peer.applyShape(shape == null ? null : Region.getInstance(shape, null));
        }
    }
}
 
源代码17 项目: jdk-1.7-annotated   文件: Window.java
/**
 * Sets the shape of the window.
 * <p>
 * Setting a shape cuts off some parts of the window. Only the parts that
 * belong to the given {@link Shape} remain visible and clickable. If
 * the shape argument is {@code null}, this method restores the default
 * shape, making the window rectangular on most platforms.
 * <p>
 * The following conditions must be met to set a non-null shape:
 * <ul>
 * <li>The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 * PERPIXEL_TRANSPARENT} translucency must be supported by the
 * underlying system
 * <li>The window must be undecorated (see {@link Frame#setUndecorated}
 * and {@link Dialog#setUndecorated})
 * <li>The window must not be in full-screen mode (see {@link
 * GraphicsDevice#setFullScreenWindow(Window)})
 * </ul>
 * <p>
 * If the requested shape is not {@code null}, and any of the above
 * conditions are not met, the shape of this window will not change,
 * and either the {@code UnsupportedOperationException} or {@code
 * IllegalComponentStateException} will be thrown.
 * <p>
 * The tranlucency levels of individual pixels may also be effected by the
 * alpha component of their color (see {@link Window#setBackground(Color)}) and the
 * opacity value (see {@link #setOpacity(float)}). See {@link
 * GraphicsDevice.WindowTranslucency} for more details.
 *
 * @param shape the shape to set to the window
 *
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is decorated
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is in full-screen mode
 * @throws UnsupportedOperationException if the shape is not {@code
 *     null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 *     PERPIXEL_TRANSPARENT} translucency is not supported
 *
 * @see Window#getShape()
 * @see Window#setBackground(Color)
 * @see Window#setOpacity(float)
 * @see Frame#isUndecorated
 * @see Dialog#isUndecorated
 * @see GraphicsDevice.WindowTranslucency
 * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
 *
 * @since 1.7
 */
public void setShape(Shape shape) {
    synchronized (getTreeLock()) {
        if (shape != null) {
            GraphicsConfiguration gc = getGraphicsConfiguration();
            GraphicsDevice gd = gc.getDevice();
            if (gc.getDevice().getFullScreenWindow() == this) {
                throw new IllegalComponentStateException(
                    "Setting shape for full-screen window is not supported.");
            }
            if (!gd.isWindowTranslucencySupported(
                    GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
            {
                throw new UnsupportedOperationException(
                    "PERPIXEL_TRANSPARENT translucency is not supported.");
            }
        }
        this.shape = (shape == null) ? null : new Path2D.Float(shape);
        WindowPeer peer = (WindowPeer)getPeer();
        if (peer != null) {
            peer.applyShape(shape == null ? null : Region.getInstance(shape, null));
        }
    }
}
 
源代码18 项目: jdk8u-dev-jdk   文件: Window.java
/**
 * Sets the shape of the window.
 * <p>
 * Setting a shape cuts off some parts of the window. Only the parts that
 * belong to the given {@link Shape} remain visible and clickable. If
 * the shape argument is {@code null}, this method restores the default
 * shape, making the window rectangular on most platforms.
 * <p>
 * The following conditions must be met to set a non-null shape:
 * <ul>
 * <li>The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 * PERPIXEL_TRANSPARENT} translucency must be supported by the
 * underlying system
 * <li>The window must be undecorated (see {@link Frame#setUndecorated}
 * and {@link Dialog#setUndecorated})
 * <li>The window must not be in full-screen mode (see {@link
 * GraphicsDevice#setFullScreenWindow(Window)})
 * </ul>
 * <p>
 * If the requested shape is not {@code null}, and any of the above
 * conditions are not met, the shape of this window will not change,
 * and either the {@code UnsupportedOperationException} or {@code
 * IllegalComponentStateException} will be thrown.
 * <p>
 * The translucency levels of individual pixels may also be effected by the
 * alpha component of their color (see {@link Window#setBackground(Color)}) and the
 * opacity value (see {@link #setOpacity(float)}). See {@link
 * GraphicsDevice.WindowTranslucency} for more details.
 *
 * @param shape the shape to set to the window
 *
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is decorated
 * @throws IllegalComponentStateException if the shape is not {@code
 *     null} and the window is in full-screen mode
 * @throws UnsupportedOperationException if the shape is not {@code
 *     null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
 *     PERPIXEL_TRANSPARENT} translucency is not supported
 *
 * @see Window#getShape()
 * @see Window#setBackground(Color)
 * @see Window#setOpacity(float)
 * @see Frame#isUndecorated
 * @see Dialog#isUndecorated
 * @see GraphicsDevice.WindowTranslucency
 * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
 *
 * @since 1.7
 */
public void setShape(Shape shape) {
    synchronized (getTreeLock()) {
        if (shape != null) {
            GraphicsConfiguration gc = getGraphicsConfiguration();
            GraphicsDevice gd = gc.getDevice();
            if (gc.getDevice().getFullScreenWindow() == this) {
                throw new IllegalComponentStateException(
                    "Setting shape for full-screen window is not supported.");
            }
            if (!gd.isWindowTranslucencySupported(
                    GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
            {
                throw new UnsupportedOperationException(
                    "PERPIXEL_TRANSPARENT translucency is not supported.");
            }
        }
        this.shape = (shape == null) ? null : new Path2D.Float(shape);
        WindowPeer peer = (WindowPeer)getPeer();
        if (peer != null) {
            peer.applyShape(shape == null ? null : Region.getInstance(shape, null));
        }
    }
}