8173409: make setMixingCutoutShape public and remove jdk.desktop

Reviewed-by: serb, mchung, alexsch
This commit is contained in:
Phil Race 2017-02-03 09:28:34 -08:00
parent 2679fdea07
commit e9dd1485e6
11 changed files with 18 additions and 227 deletions

View File

@ -456,8 +456,7 @@ public final class AWTUtilities {
"The component argument should not be null.");
}
AWTAccessor.getComponentAccessor().setMixingCutoutShape(component,
shape);
component.setMixingCutoutShape(shape);
}
}

View File

@ -10380,7 +10380,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
}
/**
* Sets a 'mixing-cutout' shape for the given component.
* Sets a 'mixing-cutout' shape for this lightweight component.
*
* This method is used exclusively for the purposes of the
* Heavyweight/Lightweight Components Mixing feature and will
* have no effect if applied to a heavyweight component.
*
* By default a lightweight component is treated as an opaque rectangle for
* the purposes of the Heavyweight/Lightweight Components Mixing feature.
@ -10393,7 +10397,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
* <li>{@code null} - reverts the default cutout shape (the rectangle equal
* to the component's {@code getBounds()})
* <li><i>empty-shape</i> - does not cut out anything from heavyweight
* components. This makes the given lightweight component effectively
* components. This makes this lightweight component effectively
* transparent. Note that descendants of the lightweight component still
* affect the shapes of heavyweight components. An example of an
* <i>empty-shape</i> is {@code new Rectangle()}.
@ -10407,16 +10411,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
* for the given glass pane component. If a developer needs some other
* 'mixing-cutout' shape for the glass pane (which is rare), this must be
* changed manually after installing the glass pane to the root pane.
* <p>
* Note that the 'mixing-cutout' shape neither affects painting, nor the
* mouse events handling for the given component. It is used exclusively
* for the purposes of the Heavyweight/Lightweight Components Mixing
* feature.
*
* @param shape the new 'mixing-cutout' shape
* @since 9
*/
void setMixingCutoutShape(Shape shape) {
public void setMixingCutoutShape(Shape shape) {
Region region = shape == null ? null : Region.getInstance(shape, null);
synchronized (getTreeLock()) {

View File

@ -286,8 +286,7 @@ public final class JLayer<V extends Component>
super.remove(oldGlassPane);
}
if (glassPane != null) {
AWTAccessor.getComponentAccessor().setMixingCutoutShape(glassPane,
new Rectangle());
glassPane.setMixingCutoutShape(new Rectangle());
glassPane.setVisible(isGlassPaneVisible);
super.addImpl(glassPane, null, 0);
}

View File

@ -663,8 +663,7 @@ public class JRootPane extends JComponent implements Accessible {
throw new NullPointerException("glassPane cannot be set to null.");
}
AWTAccessor.getComponentAccessor().setMixingCutoutShape(glass,
new Rectangle());
glass.setMixingCutoutShape(new Rectangle());
boolean visible = false;
if (glassPane != null && glassPane.getParent() == this) {

View File

@ -88,9 +88,6 @@ module java.desktop {
exports sun.awt to
jdk.accessibility;
exports com.sun.awt to
jdk.desktop;
opens javax.swing.plaf.basic to
jdk.jconsole;
opens com.sun.java.swing.plaf.windows to

View File

@ -93,12 +93,6 @@ public final class AWTAccessor {
* its parent.
*/
Rectangle getBounds(Component comp);
/*
* Sets the shape of a lw component to cut out from hw components.
*
* See 6797587, 6776743, 6768307, and 6768332 for details
*/
void setMixingCutoutShape(Component comp, Shape shape);
/**
* Sets GraphicsConfiguration value for the component.

View File

@ -1,95 +0,0 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.awt;
import java.awt.Component;
import java.awt.Shape;
import com.sun.awt.AWTUtilities;
/**
* A class to allow access to JDK-specific utility methods.
* Methods in this class are always deprecated since a caller
* should be aware they may be removed and replaced in the future.
* Access using reflection is highly recommended.
* @since 9
*/
public final class AWTUtils {
/**
* No-one should be creating instances of this class.
*/
private AWTUtils() {
}
/**
* Sets a 'mixing-cutout' shape for the given component.
*
* By default a lightweight component is treated as an opaque rectangle for
* the purposes of the Heavyweight/Lightweight Components Mixing feature.
* This method enables developers to set an arbitrary shape to be cut out
* from heavyweight components positioned underneath the lightweight
* component in the z-order.
* <p>
* The {@code shape} argument may have the following values:
* <ul>
* <li>{@code null} - reverts the default cutout shape (the rectangle equal
* to the component's {@code getBounds()})
* <li><i>empty-shape</i> - does not cut out anything from heavyweight
* components. This makes the given lightweight component effectively
* transparent. Note that descendants of the lightweight component still
* affect the shapes of heavyweight components. An example of an
* <i>empty-shape</i> is {@code new Rectangle()}.
* <li><i>non-empty-shape</i> - the given shape will be cut out from
* heavyweight components.
* </ul>
* <p>
* The most common example when the 'mixing-cutout' shape is needed is a
* glass pane component. The {@link JRootPane#setGlassPane()} method
* automatically sets the <i>empty-shape</i> as the 'mixing-cutout' shape
* for the given glass pane component. If a developer needs some other
* 'mixing-cutout' shape for the glass pane (which is rare), this must be
* changed manually after installing the glass pane to the root pane.
* <p>
* Note that the 'mixing-cutout' shape neither affects painting, nor the
* mouse events handling for the given component. It is used exclusively
* for the purposes of the Heavyweight/Lightweight Components Mixing
* feature.
*
* @param component the component that needs non-default
* 'mixing-cutout' shape
* @param shape the new 'mixing-cutout' shape
* @throws NullPointerException if the component argument is {@code null}
* @deprecated This API may be removed or replaced.
*/
@Deprecated
@SuppressWarnings("deprecation")
public static void setComponentMixingCutoutShape(Component component,
Shape shape) {
AWTUtilities.setComponentMixingCutoutShape(component, shape);
}
}

View File

@ -1,34 +0,0 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Provides non-SE desktop APIs.
*/
module jdk.desktop {
requires transitive java.desktop;
exports jdk.awt;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -22,7 +22,6 @@
*/
import com.sun.awt.AWTUtilities;
import java.awt.Frame;
import java.awt.Panel;
import java.awt.Point;
@ -44,11 +43,10 @@ import test.java.awt.regtesthelpers.Util;
/*
* @test
* @key headful
* @bug 6776743
* @bug 6776743 8173409
* @summary Opaque overlapping test for each AWT component
* @library /java/awt/patchlib ../../regtesthelpers
* @modules java.desktop/com.sun.awt
* java.desktop/java.awt.peer
* @modules java.desktop/java.awt.peer
* java.desktop/sun.awt
* @build java.desktop/java.awt.Helper
* @build Util
@ -134,12 +132,10 @@ public class OpaqueOverlapping extends OverlappingTestBase {
// flag value.
for (int i = 0; i < 9; ++i) {
if (i == 3) {
AWTUtilities.setComponentMixingCutoutShape(light,
new Rectangle());
light.setMixingCutoutShape(new Rectangle());
}
if (i == 6) {
AWTUtilities.setComponentMixingCutoutShape(light,
null);
light.setMixingCutoutShape(null);
}
robot.mousePress(InputEvent.BUTTON1_MASK);

View File

@ -24,11 +24,10 @@
/*
@test
@key headful
@bug 4811096
@bug 4811096 8173409
@summary Tests whether opaque and non-opaque components mix correctly
@author anthony.petrov@...: area=awt.mixing
@library ../regtesthelpers
@modules java.desktop/com.sun.awt
@build Util
@run main OpaqueTest
*/
@ -44,7 +43,6 @@ import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import test.java.awt.regtesthelpers.Util;
import com.sun.awt.AWTUtilities;
@ -125,12 +123,10 @@ public class OpaqueTest
// flag value.
for (int i = 0; i < 9; ++i) {
if (i == 3) {
AWTUtilities.setComponentMixingCutoutShape(light,
new Rectangle());
light.setMixingCutoutShape(new Rectangle());
}
if (i == 6) {
AWTUtilities.setComponentMixingCutoutShape(light,
null);
light.setMixingCutoutShape(null);
}
robot.mousePress(InputEvent.BUTTON1_MASK);

View File

@ -1,59 +0,0 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8167126
*/
import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.Rectangle;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
public class TestJDKAWTUtils {
static JFrame f;
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(() -> {
f = new JFrame("test");
JPanel p = new JPanel();
JButton b = new JButton("Hello");
b.setFont(new Font(Font.DIALOG, Font.PLAIN, 80));
p.setLayout(new BorderLayout());
p.add("Center", b);
f.getContentPane().add(p);
f.pack();
f.setVisible(true);
Rectangle r = new Rectangle(0, 0, 50, 50);
jdk.awt.AWTUtils.setComponentMixingCutoutShape(b, r);
});
Thread.sleep(2000);
SwingUtilities.invokeAndWait(() -> f.dispose());
}
}