use of java.awt.GraphicsDevice in project jdk8u_jdk by JetBrains.
the class bug8071705 method main.
public static void main(String[] args) throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
final boolean[] result = new boolean[1];
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JFrame frame = createGUI();
GraphicsDevice[] devices = checkScreens();
// check if we have more than one and if they are stacked
// vertically
GraphicsDevice device = checkConfigs(devices);
if (device == null) {
// just pass the test
frame.dispose();
result[0] = true;
latch.countDown();
} else {
FrameListener listener = new FrameListener(device, latch, result);
frame.addComponentListener(listener);
frame.setVisible(true);
}
}
});
latch.await();
if (result[0] == false) {
throw new RuntimeException("popup menu rendered in wrong position");
}
System.out.println("OK");
}
use of java.awt.GraphicsDevice in project jdk8u_jdk by JetBrains.
the class OpaqueImageToSurfaceBlitTest method main.
public static void main(String[] args) {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gd.getDefaultConfiguration();
VolatileImage vi = gc.createCompatibleVolatileImage(16, 16);
vi.validate(gc);
BufferedImage bi = new BufferedImage(2, 2, BufferedImage.TYPE_INT_RGB);
int[] data = ((DataBufferInt) bi.getRaster().getDataBuffer()).getData();
data[0] = 0x0000007f;
data[1] = 0x0000007f;
data[2] = 0xff00007f;
data[3] = 0xff00007f;
Graphics2D g = vi.createGraphics();
g.setComposite(AlphaComposite.SrcOver.derive(0.999f));
g.drawImage(bi, 0, 0, null);
bi = vi.getSnapshot();
if (bi.getRGB(0, 0) != bi.getRGB(1, 1)) {
throw new RuntimeException("Test FAILED: color at 0x0 =" + Integer.toHexString(bi.getRGB(0, 0)) + " differs from 1x1 =" + Integer.toHexString(bi.getRGB(1, 1)));
}
System.out.println("Test PASSED.");
}
use of java.awt.GraphicsDevice in project jdk8u_jdk by JetBrains.
the class TSFrame method createGui.
public static Frame createGui(final boolean useSwing, final boolean useShape, final boolean useTransl, final boolean useNonOpaque, final float factor) {
Frame frame;
done = false;
if (useNonOpaque) {
if (useSwing) {
frame = new NonOpaqueJFrame();
// frame = new NonOpaqueJAppletFrame(gc);
} else {
frame = new NonOpaqueFrame();
}
animateComponent(frame);
} else if (useSwing) {
frame = new JFrame("Swing Frame");
JComponent p = new JButton("Swing!");
p.setPreferredSize(new Dimension(200, 100));
frame.add("North", p);
p = new MyJPanel();
animateComponent(p);
frame.add("Center", p);
} else {
frame = new Frame("AWT Frame") {
public void paint(Graphics g) {
g.setColor(Color.red);
g.fillRect(0, 0, 100, 100);
}
};
frame.setLayout(new BorderLayout());
Canvas c = new MyCanvas();
frame.add("North", c);
animateComponent(c);
c = new MyCanvas();
frame.add("Center", c);
animateComponent(c);
c = new MyCanvas();
frame.add("South", c);
animateComponent(c);
}
final Frame finalFrame = frame;
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
finalFrame.dispose();
done = true;
}
});
frame.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
finalFrame.dispose();
done = true;
}
});
frame.setPreferredSize(new Dimension(800, 600));
if (useShape) {
frame.setUndecorated(true);
}
frame.setLocation(450, 10);
frame.pack();
GraphicsDevice gd = frame.getGraphicsConfiguration().getDevice();
if (useShape) {
if (gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) {
System.out.println("applying PERPIXEL_TRANSPARENT");
frame.setShape(new Ellipse2D.Double(0, 0, frame.getWidth(), frame.getHeight() / 3));
frame.setTitle("PERPIXEL_TRANSPARENT");
} else {
System.out.println("Passed: PERPIXEL_TRANSPARENT unsupported");
}
}
if (useTransl) {
if (gd.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) {
System.out.println("applying TRANSLUCENT");
frame.setOpacity(factor);
frame.setTitle("TRANSLUCENT");
} else {
System.out.println("Passed: TRANSLUCENT unsupported");
}
}
if (useNonOpaque) {
if (gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
System.out.println("applying PERPIXEL_TRANSLUCENT");
frame.setBackground(new Color(0, 0, 0, 0));
frame.setTitle("PERPIXEL_TRANSLUCENT");
} else {
System.out.println("Passed: PERPIXEL_TRANSLUCENT unsupported");
}
}
frame.setVisible(true);
return frame;
}
use of java.awt.GraphicsDevice in project knime-core by knime.
the class TableView method getPreferredSize.
// TableView(TableContentView)
/**
* {@inheritDoc}
*/
@Override
public Dimension getPreferredSize() {
// get pref size from all view content and limit it by 2/3 physical screen size
Dimension superPrefSize = super.getPreferredSize();
if (super.isPreferredSizeSet() || !isPreferredSizeDataDependent()) {
return superPrefSize;
}
Dimension contentPrefSize = getContentTable().getPreferredSize();
Dimension rowHeadPrefSize = rowHeader != null ? rowHeader.getPreferredSize() : new Dimension(0, 0);
Dimension colHeadPrefSize = columnHeader != null ? columnHeader.getPreferredSize() : new Dimension(0, 0);
int prefContentWidth = contentPrefSize.width + rowHeadPrefSize.width + colHeadPrefSize.width;
int prefContentHeight = contentPrefSize.height + rowHeadPrefSize.height + rowHeadPrefSize.height;
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
int screenWidth = 2 * gd.getDisplayMode().getWidth() / 3;
int screenHeight = 1 * gd.getDisplayMode().getHeight() / 3;
int calcWidth = Math.max(superPrefSize.width, Math.min(screenWidth, prefContentWidth));
int calcHeight = Math.max(superPrefSize.height, Math.min(screenHeight, prefContentHeight));
return new Dimension(calcWidth, calcHeight);
}
use of java.awt.GraphicsDevice in project vcell by virtualcell.
the class DialogUtils method getScreenSize.
/**
* get screensize including multi monitor environment
* @return
*/
public static Dimension getScreenSize() {
// http://stackoverflow.com/questions/3680221/how-can-i-get-the-monitor-size-in-java
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
int width = gd.getDisplayMode().getWidth();
int height = gd.getDisplayMode().getHeight();
return new Dimension(width, height);
}
Aggregations