use of java.awt.GraphicsConfiguration in project jdk8u_jdk by JetBrains.
the class TransformSetGet method main.
public static void main(final String[] args) {
final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
final GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
final VolatileImage vi = gc.createCompatibleVolatileImage(200, 200);
final SunGraphics2D sg2d = (SunGraphics2D) vi.createGraphics();
sg2d.constrain(0, 61, 100, 100);
final AffineTransform expected = sg2d.cloneTransform();
sg2d.setTransform(sg2d.getTransform());
final AffineTransform actual = sg2d.cloneTransform();
sg2d.dispose();
vi.flush();
if (!expected.equals(actual)) {
System.out.println("Expected = " + expected);
System.out.println("Actual = " + actual);
throw new RuntimeException("Wrong transform");
}
}
use of java.awt.GraphicsConfiguration in project jdk8u_jdk by JetBrains.
the class CloneConfigsTest method main.
public static void main(String[] args) {
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] devices = env.getScreenDevices();
GraphicsConfiguration c = new TestConfig();
for (GraphicsDevice gd : devices) {
System.out.println("Device: " + gd);
GraphicsConfiguration[] configs = gd.getConfigurations();
for (int i = 0; i < configs.length; i++) {
GraphicsConfiguration gc = configs[i];
System.out.println("\tConfig: " + gc);
configs[i] = c;
}
// verify whether array of configs was modified
configs = gd.getConfigurations();
for (GraphicsConfiguration gc : configs) {
if (gc == c) {
throw new RuntimeException("Test failed.");
}
}
System.out.println("Test passed.");
}
}
use of java.awt.GraphicsConfiguration in project jdk8u_jdk by JetBrains.
the class IncorrectAlphaConversionBicubic method main.
public static void main(final String[] args) {
final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
final GraphicsDevice gd = ge.getDefaultScreenDevice();
final GraphicsConfiguration gc = gd.getDefaultConfiguration();
final VolatileImage vi = gc.createCompatibleVolatileImage(SIZE, SIZE, TRANSLUCENT);
final BufferedImage bi = makeUnmanagedBI(gc, TRANSLUCENT);
final int expected = bi.getRGB(2, 2);
int attempt = 0;
BufferedImage snapshot;
while (true) {
if (++attempt > 10) {
throw new RuntimeException("Too many attempts: " + attempt);
}
vi.validate(gc);
final Graphics2D g2d = vi.createGraphics();
g2d.setComposite(AlphaComposite.Src);
g2d.scale(2, 2);
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g2d.drawImage(bi, 0, 0, null);
g2d.dispose();
snapshot = vi.getSnapshot();
if (vi.contentsLost()) {
continue;
}
break;
}
final int actual = snapshot.getRGB(2, 2);
if (actual != expected) {
System.err.println("Actual: " + Integer.toHexString(actual));
System.err.println("Expected: " + Integer.toHexString(expected));
throw new RuntimeException("Test failed");
}
}
use of java.awt.GraphicsConfiguration in project jdk8u_jdk by JetBrains.
the class IncorrectBounds method main.
public static void main(final String[] args) {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
VolatileImage vi = gc.createCompatibleVolatileImage(width / 4, height / 4);
final BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
while (true) {
vi.validate(gc);
Graphics2D g2d = vi.createGraphics();
g2d.setColor(Color.green);
g2d.fillRect(0, 0, width / 4, height / 4);
g2d.dispose();
if (vi.validate(gc) != VolatileImage.IMAGE_OK) {
try {
Thread.sleep(100);
} catch (InterruptedException ignored) {
}
continue;
}
Graphics2D g = bi.createGraphics();
g.setComposite(AlphaComposite.Src);
g.setColor(Color.red);
g.fillRect(0, 0, width, height);
// Use sx and sy outside of VI bounds.
g.drawImage(vi, 0, 0, width / 2, height / 2, 0, 0, width * 2, height * 2, null);
g.dispose();
if (vi.contentsLost()) {
try {
Thread.sleep(100);
} catch (InterruptedException ignored) {
}
continue;
}
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
if (x < width / 16 && y < height / 16) {
if (bi.getRGB(x, y) != Color.green.getRGB()) {
throw new RuntimeException("Test failed.");
}
} else {
if (bi.getRGB(x, y) != Color.red.getRGB()) {
throw new RuntimeException("Test failed.");
}
}
}
}
break;
}
}
use of java.awt.GraphicsConfiguration in project jdk8u_jdk by JetBrains.
the class VolatileImageBug method main.
public static void main(String[] args) {
boolean iaeThrown = false;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
try {
VolatileImage volatileImage = gc.createCompatibleVolatileImage(0, 0);
} catch (IllegalArgumentException iae) {
iaeThrown = true;
}
if (!iaeThrown) {
throw new RuntimeException("IllegalArgumentException not thrown " + "for createCompatibleVolatileImage(0,0)");
}
}
Aggregations