use of java.awt.GraphicsDevice in project jdk8u_jdk by JetBrains.
the class bug8071705 method checkConfigs.
private static GraphicsDevice checkConfigs(GraphicsDevice[] devices) {
GraphicsDevice correctDevice = null;
if (devices.length < 2) {
return correctDevice;
}
Toolkit toolkit = Toolkit.getDefaultToolkit();
Rectangle screenBounds = new Rectangle(toolkit.getScreenSize());
int halfScreen = screenBounds.height / 2;
for (int i = 0; i < devices.length; i++) {
if (devices[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
GraphicsConfiguration conf = devices[i].getDefaultConfiguration();
Rectangle bounds = conf.getBounds();
if (bounds.y >= halfScreen) {
// found
correctDevice = devices[i];
break;
}
}
}
return correctDevice;
}
use of java.awt.GraphicsDevice in project jdk8u_jdk by JetBrains.
the class StrikeDisposalCrashTest method main.
public static void main(String[] args) {
System.setProperty("sun.java2d.font.reftype", "weak");
GraphicsDevice[] gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
Frame[] frames = new Frame[gd.length];
for (int i = 0; i < frames.length; i++) {
GraphicsConfiguration gc = gd[i].getDefaultConfiguration();
Frame f = new Frame("Frame on " + gc, gc);
f.setSize(100, 100);
f.setLocation(gc.getBounds().x, gc.getBounds().y);
f.pack();
frames[i] = f;
}
Font f1 = new Font("Dialog", Font.PLAIN, 10);
Font f2 = new Font("Dialog", Font.ITALIC, 12);
for (int i = 0; i < frames.length / 2; i++) {
// making sure the glyphs are cached in the accel. cache on
// one frame, then the other
renderText(frames[i], f1);
renderText(frames[frames.length - 1 - i], f1);
// and now the other way around, with different glyphs
renderText(frames[frames.length - 1 - i], f2);
renderText(frames[i], f2);
}
// try to force strike disposal (note that we have to use
// -Dsun.java2d.font.reftype=weak to facilitate the disposal)
System.gc();
System.runFinalization();
System.gc();
System.runFinalization();
for (Frame f : frames) {
f.dispose();
}
System.err.println("Exiting. If the test crashed after this it FAILED");
}
use of java.awt.GraphicsDevice in project JMRI by JMRI.
the class ReportContext method addScreenSize.
/**
* Provide screen - size information. This is based on the
* jmri.util.JmriJFrame calculation, but isn't refactored to there because
* we also want diagnostic info
*/
public void addScreenSize() {
try {
// Find screen size. This throws null-pointer exceptions on
// some Java installs, however, for unknown reasons, so be
// prepared to fall back.
JFrame dummy = new JFrame();
try {
Insets insets = dummy.getToolkit().getScreenInsets(dummy.getGraphicsConfiguration());
Dimension screen = dummy.getToolkit().getScreenSize();
addString("Screen size h:" + screen.height + ", w:" + screen.width + " Inset t:" + insets.top + ", b:" + insets.bottom + "; l:" + insets.left + ", r:" + insets.right);
} catch (NoSuchMethodError ex) {
Dimension screen = dummy.getToolkit().getScreenSize();
addString("Screen size h:" + screen.height + ", w:" + screen.width + " (No Inset method available)");
}
} catch (HeadlessException ex) {
// failed, fall back to standard method
addString("(Cannot sense screen size due to " + ex.toString() + ")");
}
try {
// Find screen resolution. Not expected to fail, but just in case....
int dpi = Toolkit.getDefaultToolkit().getScreenResolution();
addString("Screen resolution: " + dpi);
} catch (HeadlessException ex) {
addString("Screen resolution not available");
}
//Rectangle virtualBounds = new Rectangle();
try {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
addString("Environment max bounds: " + ge.getMaximumWindowBounds());
try {
GraphicsDevice[] gs = ge.getScreenDevices();
for (GraphicsDevice gd : gs) {
GraphicsConfiguration[] gc = gd.getConfigurations();
for (int i = 0; i < gc.length; i++) {
addString("bounds[" + i + "] = " + gc[i].getBounds());
// virtualBounds = virtualBounds.union(gc[i].getBounds());
}
addString("Device: " + gd.getIDstring() + " bounds = " + gd.getDefaultConfiguration().getBounds() + " " + gd.getDefaultConfiguration().toString());
}
} catch (HeadlessException ex) {
addString("Exception getting device bounds " + ex.getMessage());
}
} catch (HeadlessException ex) {
addString("Exception getting max window bounds " + ex.getMessage());
}
// various Linux window managers
try {
Insets jmriInsets = JmriInsets.getInsets();
addString("JmriInsets t:" + jmriInsets.top + ", b:" + jmriInsets.bottom + "; l:" + jmriInsets.left + ", r:" + jmriInsets.right);
} catch (Exception ex) {
addString("Exception getting JmriInsets" + ex.getMessage());
}
}
use of java.awt.GraphicsDevice in project jabref by JabRef.
the class WindowLocation method getVirtualBounds.
private Rectangle getVirtualBounds() {
Rectangle bounds = new Rectangle(0, 0, 0, 0);
GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
for (GraphicsDevice device : devices) {
bounds.add(device.getDefaultConfiguration().getBounds());
}
return bounds;
}
use of java.awt.GraphicsDevice in project karaf by apache.
the class ScreenshotDumpProvider method createDump.
/**
* {@inheritDoc}
*/
public void createDump(DumpDestination destination) throws Exception {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
// get all graphic devices attached to computer
GraphicsDevice[] gs = ge.getScreenDevices();
// create dump entry for each device
for (int i = 0; i < gs.length; i++) {
DisplayMode mode = gs[i].getDisplayMode();
Rectangle bounds = new Rectangle(0, 0, mode.getWidth(), mode.getHeight());
BufferedImage screenshot = new Robot(gs[i]).createScreenCapture(bounds);
// to attach your entry to destination you have to execute this line
OutputStream outputStream = destination.add("screenshot/display_" + i + ".png");
ImageIO.write(screenshot, "PNG", outputStream);
outputStream.close();
}
}
Aggregations