use of java.awt.GraphicsConfiguration in project jdk8u_jdk by JetBrains.
the class bug8016356 method main.
public static void main(String[] args) throws Exception {
// Windows only test
if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {
// Retrieving top edge of Desktop
GraphicsConfiguration grConf = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
Rectangle scrRect = grConf.getBounds();
Insets scrInsets = Toolkit.getDefaultToolkit().getScreenInsets(grConf);
scrTop = scrRect.y + scrInsets.top;
color = new Color(0, 255, 0);
SwingUtilities.invokeAndWait(() -> {
createAndShowUI();
});
try {
Robot robot = new Robot();
robot.setAutoDelay(500);
robot.setAutoWaitForIdle(true);
robot.delay(1000);
// Resizing a window to invoke Windows Snap feature
readFrameInfo();
robot.mouseMove(frLoc.x + frSize.width / 2, frLoc.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseMove(frLoc.x + frSize.width / 2, scrTop);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
// Retrieving the color of window expanded area
readFrameInfo();
Insets insets = frame.getInsets();
Color bgColor = robot.getPixelColor(frLoc.x + frSize.width / 2, frLoc.y + frSize.height - insets.bottom - 1);
frame.dispose();
if (!bgColor.equals(color)) {
throw new RuntimeException("TEST FAILED: got " + bgColor + " instead of " + color);
}
System.out.println("TEST PASSED!");
} catch (AWTException ex) {
throw new RuntimeException("TEST FAILED!");
}
}
}
use of java.awt.GraphicsConfiguration in project jdk8u_jdk by JetBrains.
the class DrawImageBilinear method main.
public static void main(String[] args) {
boolean show = false;
for (String arg : args) {
if ("-show".equals(arg)) {
show = true;
}
}
String arch = System.getProperty("os.arch");
boolean isOglEnabled = Boolean.getBoolean("sun.java2d.opengl");
skipOglTextureTest = isOglEnabled && ("sparc".equals(arch));
System.out.println("Skip OpenGL texture test: " + skipOglTextureTest);
DrawImageBilinear test = new DrawImageBilinear();
Frame frame = new Frame();
frame.add(test);
frame.pack();
frame.setVisible(true);
// Wait until the component's been painted
synchronized (test) {
while (!done) {
try {
test.wait();
} catch (InterruptedException e) {
throw new RuntimeException("Failed: Interrupted");
}
}
}
GraphicsConfiguration gc = frame.getGraphicsConfiguration();
if (gc.getColorModel() instanceof IndexColorModel) {
System.out.println("IndexColorModel detected: " + "test considered PASSED");
frame.dispose();
return;
}
if (!show) {
frame.dispose();
}
if (capture == null) {
throw new RuntimeException("Failed: capture is null");
}
// Test background color
int pixel = capture.getRGB(5, 5);
if (pixel != 0xffffffff) {
throw new RuntimeException("Failed: Incorrect color for " + "background");
}
// Test pixels
testRegion(capture, new Rectangle(10, 10, 40, 40));
testRegion(capture, new Rectangle(80, 10, 40, 40));
testRegion(capture, new Rectangle(150, 10, 40, 40));
}
use of java.awt.GraphicsConfiguration in project jdk8u_jdk by JetBrains.
the class SourceClippingBlitTest method runTests.
public void runTests() {
GraphicsConfiguration gc = getGraphicsConfiguration();
for (Image srcIm : new Image[] { getBufferedImage(gc, IMAGEW, IMAGEH, BufferedImage.TYPE_INT_RGB, true), getBufferedImage(gc, IMAGEW, IMAGEH, BufferedImage.TYPE_INT_RGB, false), // BufferedImage.TYPE_INT_ARGB, false),
getVImage(gc, IMAGEW, IMAGEH) }) {
System.out.println("Testing source: " + srcIm);
// wiggle the source and dest rectangles
try {
for (int locationVar = -10; locationVar < 20; locationVar += 10) {
for (int sizeVar = -10; sizeVar < 20; sizeVar += 10) {
Rectangle srcRect = (Rectangle) IMAGE_BOUNDS.clone();
srcRect.translate(locationVar, locationVar);
srcRect.grow(sizeVar, sizeVar);
Rectangle dstRect = new Rectangle(sizeVar, sizeVar, srcRect.width, srcRect.height);
System.out.println("testing blit rect src: " + srcRect);
System.out.println(" dst: " + dstRect);
render(getGraphics(), srcIm, srcRect, dstRect);
test(srcRect, dstRect);
}
}
System.out.println("Test passed.");
} finally {
synchronized (lock) {
done = true;
lock.notifyAll();
}
}
}
}
use of java.awt.GraphicsConfiguration in project jdk8u_jdk by JetBrains.
the class SourceClippingBlitTest method render.
public void render(Graphics g, Image image, Rectangle srcRect, Rectangle dstRect) {
int w = getWidth();
int h = getHeight();
g.setColor(Color.green);
g.fillRect(0, 0, w, h);
int bltWidth = srcRect.width;
int bltHeight = srcRect.height;
VolatileImage vi = null;
if (image instanceof VolatileImage) {
vi = (VolatileImage) image;
}
do {
if (vi != null) {
GraphicsConfiguration gc = getGraphicsConfiguration();
if (vi.validate(gc) != VolatileImage.IMAGE_OK) {
initImage(gc, vi);
}
}
g.drawImage(image, dstRect.x, dstRect.y, dstRect.x + bltWidth, dstRect.y + bltHeight, srcRect.x, srcRect.y, srcRect.x + bltWidth, srcRect.y + bltHeight, Color.red, null);
} while (vi != null && vi.contentsLost());
}
use of java.awt.GraphicsConfiguration in project jdk8u_jdk by JetBrains.
the class bug7181438 method createVolatileImage.
private static VolatileImage createVolatileImage() {
final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
final GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
return gc.createCompatibleVolatileImage(SIZE, SIZE, Transparency.TRANSLUCENT);
}
Aggregations