-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
6u13
-
x86
-
windows_xp
J2SE Version (please include all output from java -version flag):
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)
Does this problem occur on J2SE 5.0.x or 6.0? Yes / No (pick one)
Yes
Operating System Configuration Information (be specific):
Client: Microsoft Windows XP [Version 5.1.2600]
Bug Description:
Method to find out the most transparent color that accepts mouse events
When using PERPIXEL_TRANSLUCENT we need to be able to make the background show
through as much as possible while still accepting mouse events (for annotating
the users screen).
On most computers the color new Color(0, 0, 0, 1) works for this, however on
some computers we have seen that new Color(0, 0, 0, 4) is required for this to work.
We need to be able to determine at runtime which color will work.
On two different computers each with Microsoft Windows XP [Version 5.1.2600] and
running the same version of java (1.6.0_13):
The one with
sun.awt.Win32GraphicsConfig@3c0007[dev=Win32GraphicsDevice[screen=0],pixfmt=7]
sun.awt.Win32GraphicsConfig@125fefa[dev=Win32GraphicsDevice[screen=0],pixfmt=8]
sun.awt.Win32GraphicsConfig@186df0f[dev=Win32GraphicsDevice[screen=0],pixfmt=11]
sun.awt.Win32GraphicsConfig@19e8f17[dev=Win32GraphicsDevice[screen=0],pixfmt=12]
sun.awt.Win32GraphicsConfig@c44b88[dev=Win32GraphicsDevice[screen=0],pixfmt=15]
sun.awt.Win32GraphicsConfig@13ad33d[dev=Win32GraphicsDevice[screen=0],pixfmt=16]
requires new Color(0, 0, 0, 1) to work
and the one with
sun.awt.Win32GraphicsConfig@1050169[dev=Win32GraphicsDevice[screen=0],pixfmt=1]
sun.awt.Win32GraphicsConfig@19fcc69[dev=Win32GraphicsDevice[screen=0],pixfmt=2]
sun.awt.Win32GraphicsConfig@253498[dev=Win32GraphicsDevice[screen=0],pixfmt=5]
sun.awt.Win32GraphicsConfig@9fef6f[dev=Win32GraphicsDevice[screen=0],pixfmt=6]
sun.awt.Win32GraphicsConfig@209f4e[dev=Win32GraphicsDevice[screen=0],pixfmt=9]
sun.awt.Win32GraphicsConfig@1bac748[dev=Win32GraphicsDevice[screen=0],pixfmt=10]
requires new Color(0, 0, 0, 4) to work
The Test below can be used to test this.
1) Click on Test PERPIXEL_TRANSLUCENT button.
2) Move the mouse to the center of each of the cells.
3) If the cell number turns red then this color will work, we need a way of finding out the minimum one that will work.
import static com.sun.awt.AWTUtilities.*;
import static com.sun.awt.AWTUtilities.Translucency.*;
import static com.sun.awt.AWTUtilities.Translucency.TRANSLUCENT;
import static java.awt.Color.*;
import static java.awt.Cursor.*;
import static java.awt.Cursor.CROSSHAIR_CURSOR;
import static java.awt.RenderingHints.*;
import static java.lang.System.*;
import static javax.swing.JFrame.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.util.*;
import javax.swing.*;
public class Test {
public static void main(String[] args) {
JFrame frame = new JFrame("Transparency Tester");
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.setBounds(10, 10, 300, 300);
frame.setLayout(new FlowLayout());
frame.add(new JButton(new AbstractAction("Output Graphics Configurations") {
public void actionPerformed(ActionEvent e) {
for (GraphicsDevice graphicsDevice : GraphicsEnvironment.getLocalGraphicsEnvironment().
getScreenDevices()) {
for (GraphicsConfiguration graphicsConfiguration : graphicsDevice.getConfigurations()) {
out.println(graphicsConfiguration + " is Translucency Capable: " +
isTranslucencyCapable(graphicsConfiguration));
}
}
}
}));
frame.add(new JButton(new AbstractAction("Test PERPIXEL_TRANSLUCENT") {
{
setEnabled(isTranslucencySupported(PERPIXEL_TRANSLUCENT));
}
private GraphicsConfiguration getTranslucencyCapableGraphicsConfiguration() {
GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice defaultGraphicsDevice = graphicsEnvironment.getDefaultScreenDevice();
GraphicsConfiguration defaultGraphicsConfiguration = defaultGraphicsDevice.
getDefaultConfiguration();
if (isTranslucencyCapable(defaultGraphicsConfiguration)) {
return defaultGraphicsConfiguration;
}
for (GraphicsConfiguration graphicsConfiguration : defaultGraphicsDevice.getConfigurations()
) {
if (graphicsConfiguration != defaultGraphicsConfiguration && isTranslucencyCapable(
graphicsConfiguration)) {
return graphicsConfiguration;
}
}
for (GraphicsDevice graphicsDevice : graphicsEnvironment.getScreenDevices()) {
if (graphicsDevice != defaultGraphicsDevice) {
for (GraphicsConfiguration graphicsConfiguration : graphicsDevice.getConfigurations()) {
if (isTranslucencyCapable(graphicsConfiguration)) {
return graphicsConfiguration;
}
}
}
}
return defaultGraphicsConfiguration;
}
@Override
public void actionPerformed(ActionEvent e) {
final Set<Integer> movedAlphas = new HashSet<Integer>();
final JFrame frame = new JFrame("PERPIXEL_TRANSLUCENT Test",
getTranslucencyCapableGraphicsConfiguration()) {
@Override
public void paint(Graphics aGraphics) {
Graphics2D graphics = (Graphics2D)aGraphics.create();
graphics.setRenderingHint(KEY_STROKE_CONTROL, VALUE_STROKE_PURE);
graphics.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON);
int alpha = 0;
for (int j = 0; j < 16; j++) {
for (int i = 0; i < 16; i++) {
graphics.setColor(new Color(0, 0, 0, alpha));
graphics.fillRect(i * 30, j * 30, 30, 30);
graphics.setColor(WHITE);
graphics.fillRect(i * 30, j * 30, 30, 10);
graphics.setColor(BLACK);
graphics.drawRect(i * 30, j * 30, 30, 30);
if (movedAlphas.contains(alpha)) {
graphics.setColor(RED);
}
graphics.drawString(Integer.toString(alpha), i * 30 + 5, j * 30 + 10);
alpha++;
}
}
}
};
frame.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
int x = e.getX();
int y = e.getY();
int alpha = 0;
for (int j = 0; j < 16; j++) {
for (int i = 0; i < 16; i++) {
if (x > i * 30 + 2 && x < i * 30 + 28 && y > j * 30 + 12 && y < j * 30 + 28) {
if (movedAlphas.add(alpha)) {
frame.repaint();
}
return;
}
alpha++;
}
}
frame.repaint();
}
});
frame.setUndecorated(true);
setWindowOpaque(frame, false);
frame.setCursor(getPredefinedCursor(CROSSHAIR_CURSOR));
frame.setBounds(10, 10, 480, 480);
frame.setVisible(true);
}
}));
frame.add(new JButton(new AbstractAction("Test PERPIXEL_TRANSPARENT") {
{
setEnabled(isTranslucencySupported(PERPIXEL_TRANSPARENT));
}
@Override
public void actionPerformed(ActionEvent e) {
JFrame frame = new JFrame("PERPIXEL_TRANSPARENT Test");
frame.setUndecorated(true);
setWindowShape(frame, new Ellipse2D.Float(0, 0, 300, 300));
frame.setCursor(getPredefinedCursor(CROSSHAIR_CURSOR));
frame.setBounds(320, 320, 300, 300);
frame.setVisible(true);
}
}));
frame.add(new JButton(new AbstractAction("Test TRANSLUCENT") {
{
setEnabled(isTranslucencySupported(TRANSLUCENT));
}
@Override
public void actionPerformed(ActionEvent e) {
JFrame frame = new JFrame("TRANSLUCENT Test");
setWindowOpacity(frame, 0.5F);
frame.setCursor(getPredefinedCursor(CROSSHAIR_CURSOR));
frame.setBounds(630, 320, 300, 300);
frame.setVisible(true);
}
}));
frame.setVisible(true);
}
}
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)
Does this problem occur on J2SE 5.0.x or 6.0? Yes / No (pick one)
Yes
Operating System Configuration Information (be specific):
Client: Microsoft Windows XP [Version 5.1.2600]
Bug Description:
Method to find out the most transparent color that accepts mouse events
When using PERPIXEL_TRANSLUCENT we need to be able to make the background show
through as much as possible while still accepting mouse events (for annotating
the users screen).
On most computers the color new Color(0, 0, 0, 1) works for this, however on
some computers we have seen that new Color(0, 0, 0, 4) is required for this to work.
We need to be able to determine at runtime which color will work.
On two different computers each with Microsoft Windows XP [Version 5.1.2600] and
running the same version of java (1.6.0_13):
The one with
sun.awt.Win32GraphicsConfig@3c0007[dev=Win32GraphicsDevice[screen=0],pixfmt=7]
sun.awt.Win32GraphicsConfig@125fefa[dev=Win32GraphicsDevice[screen=0],pixfmt=8]
sun.awt.Win32GraphicsConfig@186df0f[dev=Win32GraphicsDevice[screen=0],pixfmt=11]
sun.awt.Win32GraphicsConfig@19e8f17[dev=Win32GraphicsDevice[screen=0],pixfmt=12]
sun.awt.Win32GraphicsConfig@c44b88[dev=Win32GraphicsDevice[screen=0],pixfmt=15]
sun.awt.Win32GraphicsConfig@13ad33d[dev=Win32GraphicsDevice[screen=0],pixfmt=16]
requires new Color(0, 0, 0, 1) to work
and the one with
sun.awt.Win32GraphicsConfig@1050169[dev=Win32GraphicsDevice[screen=0],pixfmt=1]
sun.awt.Win32GraphicsConfig@19fcc69[dev=Win32GraphicsDevice[screen=0],pixfmt=2]
sun.awt.Win32GraphicsConfig@253498[dev=Win32GraphicsDevice[screen=0],pixfmt=5]
sun.awt.Win32GraphicsConfig@9fef6f[dev=Win32GraphicsDevice[screen=0],pixfmt=6]
sun.awt.Win32GraphicsConfig@209f4e[dev=Win32GraphicsDevice[screen=0],pixfmt=9]
sun.awt.Win32GraphicsConfig@1bac748[dev=Win32GraphicsDevice[screen=0],pixfmt=10]
requires new Color(0, 0, 0, 4) to work
The Test below can be used to test this.
1) Click on Test PERPIXEL_TRANSLUCENT button.
2) Move the mouse to the center of each of the cells.
3) If the cell number turns red then this color will work, we need a way of finding out the minimum one that will work.
import static com.sun.awt.AWTUtilities.*;
import static com.sun.awt.AWTUtilities.Translucency.*;
import static com.sun.awt.AWTUtilities.Translucency.TRANSLUCENT;
import static java.awt.Color.*;
import static java.awt.Cursor.*;
import static java.awt.Cursor.CROSSHAIR_CURSOR;
import static java.awt.RenderingHints.*;
import static java.lang.System.*;
import static javax.swing.JFrame.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.util.*;
import javax.swing.*;
public class Test {
public static void main(String[] args) {
JFrame frame = new JFrame("Transparency Tester");
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.setBounds(10, 10, 300, 300);
frame.setLayout(new FlowLayout());
frame.add(new JButton(new AbstractAction("Output Graphics Configurations") {
public void actionPerformed(ActionEvent e) {
for (GraphicsDevice graphicsDevice : GraphicsEnvironment.getLocalGraphicsEnvironment().
getScreenDevices()) {
for (GraphicsConfiguration graphicsConfiguration : graphicsDevice.getConfigurations()) {
out.println(graphicsConfiguration + " is Translucency Capable: " +
isTranslucencyCapable(graphicsConfiguration));
}
}
}
}));
frame.add(new JButton(new AbstractAction("Test PERPIXEL_TRANSLUCENT") {
{
setEnabled(isTranslucencySupported(PERPIXEL_TRANSLUCENT));
}
private GraphicsConfiguration getTranslucencyCapableGraphicsConfiguration() {
GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice defaultGraphicsDevice = graphicsEnvironment.getDefaultScreenDevice();
GraphicsConfiguration defaultGraphicsConfiguration = defaultGraphicsDevice.
getDefaultConfiguration();
if (isTranslucencyCapable(defaultGraphicsConfiguration)) {
return defaultGraphicsConfiguration;
}
for (GraphicsConfiguration graphicsConfiguration : defaultGraphicsDevice.getConfigurations()
) {
if (graphicsConfiguration != defaultGraphicsConfiguration && isTranslucencyCapable(
graphicsConfiguration)) {
return graphicsConfiguration;
}
}
for (GraphicsDevice graphicsDevice : graphicsEnvironment.getScreenDevices()) {
if (graphicsDevice != defaultGraphicsDevice) {
for (GraphicsConfiguration graphicsConfiguration : graphicsDevice.getConfigurations()) {
if (isTranslucencyCapable(graphicsConfiguration)) {
return graphicsConfiguration;
}
}
}
}
return defaultGraphicsConfiguration;
}
@Override
public void actionPerformed(ActionEvent e) {
final Set<Integer> movedAlphas = new HashSet<Integer>();
final JFrame frame = new JFrame("PERPIXEL_TRANSLUCENT Test",
getTranslucencyCapableGraphicsConfiguration()) {
@Override
public void paint(Graphics aGraphics) {
Graphics2D graphics = (Graphics2D)aGraphics.create();
graphics.setRenderingHint(KEY_STROKE_CONTROL, VALUE_STROKE_PURE);
graphics.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON);
int alpha = 0;
for (int j = 0; j < 16; j++) {
for (int i = 0; i < 16; i++) {
graphics.setColor(new Color(0, 0, 0, alpha));
graphics.fillRect(i * 30, j * 30, 30, 30);
graphics.setColor(WHITE);
graphics.fillRect(i * 30, j * 30, 30, 10);
graphics.setColor(BLACK);
graphics.drawRect(i * 30, j * 30, 30, 30);
if (movedAlphas.contains(alpha)) {
graphics.setColor(RED);
}
graphics.drawString(Integer.toString(alpha), i * 30 + 5, j * 30 + 10);
alpha++;
}
}
}
};
frame.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
int x = e.getX();
int y = e.getY();
int alpha = 0;
for (int j = 0; j < 16; j++) {
for (int i = 0; i < 16; i++) {
if (x > i * 30 + 2 && x < i * 30 + 28 && y > j * 30 + 12 && y < j * 30 + 28) {
if (movedAlphas.add(alpha)) {
frame.repaint();
}
return;
}
alpha++;
}
}
frame.repaint();
}
});
frame.setUndecorated(true);
setWindowOpaque(frame, false);
frame.setCursor(getPredefinedCursor(CROSSHAIR_CURSOR));
frame.setBounds(10, 10, 480, 480);
frame.setVisible(true);
}
}));
frame.add(new JButton(new AbstractAction("Test PERPIXEL_TRANSPARENT") {
{
setEnabled(isTranslucencySupported(PERPIXEL_TRANSPARENT));
}
@Override
public void actionPerformed(ActionEvent e) {
JFrame frame = new JFrame("PERPIXEL_TRANSPARENT Test");
frame.setUndecorated(true);
setWindowShape(frame, new Ellipse2D.Float(0, 0, 300, 300));
frame.setCursor(getPredefinedCursor(CROSSHAIR_CURSOR));
frame.setBounds(320, 320, 300, 300);
frame.setVisible(true);
}
}));
frame.add(new JButton(new AbstractAction("Test TRANSLUCENT") {
{
setEnabled(isTranslucencySupported(TRANSLUCENT));
}
@Override
public void actionPerformed(ActionEvent e) {
JFrame frame = new JFrame("TRANSLUCENT Test");
setWindowOpacity(frame, 0.5F);
frame.setCursor(getPredefinedCursor(CROSSHAIR_CURSOR));
frame.setBounds(630, 320, 300, 300);
frame.setVisible(true);
}
}));
frame.setVisible(true);
}
}