use of java.awt.Graphics in project jdk8u_jdk by JetBrains.
the class TestEnvironment method erase.
public void erase() {
Graphics g = getGraphics();
if (g != null) {
g.setColor(Color.white);
g.fillRect(0, 0, getWidth(), getHeight());
g.dispose();
}
}
use of java.awt.Graphics in project jdk8u_jdk by JetBrains.
the class TestEnvironment method flushToScreen.
public void flushToScreen() {
if (testImage != null && comp != null) {
Graphics g = comp.getGraphics();
if (GraphicsTests.hasGraphics2D) {
((Graphics2D) g).setComposite(AlphaComposite.Src);
}
g.drawImage(testImage, 0, 0, null);
g.dispose();
}
}
use of java.awt.Graphics in project jdk8u_jdk by JetBrains.
the class GraphicsTests method cleanupTest.
public void cleanupTest(TestEnvironment env, Object ctx) {
Graphics graphics = ((Context) ctx).graphics;
graphics.dispose();
((Context) ctx).graphics = null;
}
use of java.awt.Graphics in project jdk8u_jdk by JetBrains.
the class XFramePeer method print.
/*
* Print the native component by rendering the Motif look ourselves.
* We also explicitly print the MenuBar since a MenuBar isn't a subclass
* of Component (and thus it has no "print" method which gets called by
* default).
*/
public void print(Graphics g) {
super.print(g);
Frame f = (Frame) target;
Insets finsets = f.getInsets();
Dimension fsize = f.getSize();
Color bg = f.getBackground();
Color fg = f.getForeground();
Color highlight = bg.brighter();
Color shadow = bg.darker();
if (hasDecorations(XWindowAttributesData.AWT_DECOR_BORDER)) {
// pure white
if (highlight.equals(Color.white)) {
g.setColor(new Color(230, 230, 230));
} else {
g.setColor(highlight);
}
g.drawLine(0, 0, fsize.width, 0);
g.drawLine(0, 1, fsize.width - 1, 1);
// left outer
// if (highlight.equals(Color.white)) {
// g.setColor(new Color(230, 230, 230));
// }
// else {
// g.setColor(highlight);
// }
g.drawLine(0, 0, 0, fsize.height);
g.drawLine(1, 0, 1, fsize.height - 1);
// bottom cross-hair
g.setColor(highlight);
g.drawLine(CROSSHAIR_INSET + 1, fsize.height - CROSSHAIR_INSET, fsize.width - CROSSHAIR_INSET, fsize.height - CROSSHAIR_INSET);
// right cross-hair
// g.setColor(highlight);
g.drawLine(fsize.width - CROSSHAIR_INSET, CROSSHAIR_INSET + 1, fsize.width - CROSSHAIR_INSET, fsize.height - CROSSHAIR_INSET);
// bottom outer
g.setColor(shadow);
g.drawLine(1, fsize.height, fsize.width, fsize.height);
g.drawLine(2, fsize.height - 1, fsize.width, fsize.height - 1);
// right outer
// g.setColor(shadow);
g.drawLine(fsize.width, 1, fsize.width, fsize.height);
g.drawLine(fsize.width - 1, 2, fsize.width - 1, fsize.height);
// top cross-hair
// g.setColor(shadow);
g.drawLine(CROSSHAIR_INSET, CROSSHAIR_INSET, fsize.width - CROSSHAIR_INSET, CROSSHAIR_INSET);
// left cross-hair
// g.setColor(shadow);
g.drawLine(CROSSHAIR_INSET, CROSSHAIR_INSET, CROSSHAIR_INSET, fsize.height - CROSSHAIR_INSET);
}
if (hasDecorations(XWindowAttributesData.AWT_DECOR_TITLE)) {
if (hasDecorations(XWindowAttributesData.AWT_DECOR_MENU)) {
// system menu
g.setColor(bg);
g.fill3DRect(SYS_MENU_X, BUTTON_Y, BUTTON_W, BUTTON_H, true);
g.fill3DRect(SYS_MENU_CONTAINED_X, SYS_MENU_CONTAINED_Y, SYS_MENU_CONTAINED_W, SYS_MENU_CONTAINED_H, true);
}
// title bar
// g.setColor(bg);
g.fill3DRect(TITLE_X, BUTTON_Y, fsize.width - TITLE_W_DIFF, BUTTON_H, true);
if (hasDecorations(XWindowAttributesData.AWT_DECOR_MINIMIZE)) {
// minimize button
// g.setColor(bg);
g.fill3DRect(fsize.width - MINIMIZE_X_DIFF, BUTTON_Y, BUTTON_W, BUTTON_H, true);
g.fill3DRect(fsize.width - MINIMIZE_CONTAINED_X_DIFF, MINIMIZE_CONTAINED_Y, MINIMIZE_CONTAINED_W, MINIMIZE_CONTAINED_H, true);
}
if (hasDecorations(XWindowAttributesData.AWT_DECOR_MAXIMIZE)) {
// maximize button
// g.setColor(bg);
g.fill3DRect(fsize.width - MAXIMIZE_X_DIFF, BUTTON_Y, BUTTON_W, BUTTON_H, true);
g.fill3DRect(fsize.width - MAXIMIZE_CONTAINED_X_DIFF, MAXIMIZE_CONTAINED_Y, MAXIMIZE_CONTAINED_W, MAXIMIZE_CONTAINED_H, true);
}
// title bar text
g.setColor(fg);
Font sysfont = new Font(Font.SANS_SERIF, Font.PLAIN, 10);
g.setFont(sysfont);
FontMetrics sysfm = g.getFontMetrics();
String ftitle = f.getTitle();
g.drawString(ftitle, ((TITLE_X + TITLE_X + fsize.width - TITLE_W_DIFF) / 2) - (sysfm.stringWidth(ftitle) / 2), TITLE_MID_Y + sysfm.getMaxDescent());
}
if (f.isResizable() && hasDecorations(XWindowAttributesData.AWT_DECOR_RESIZEH)) {
// add resize cross hairs
// upper-left horiz (shadow)
g.setColor(shadow);
g.drawLine(1, HORIZ_RESIZE_INSET, CROSSHAIR_INSET, HORIZ_RESIZE_INSET);
// upper-left vert (shadow)
// g.setColor(shadow);
g.drawLine(VERT_RESIZE_INSET, 1, VERT_RESIZE_INSET, CROSSHAIR_INSET);
// upper-right horiz (shadow)
// g.setColor(shadow);
g.drawLine(fsize.width - CROSSHAIR_INSET + 1, HORIZ_RESIZE_INSET, fsize.width, HORIZ_RESIZE_INSET);
// upper-right vert (shadow)
// g.setColor(shadow);
g.drawLine(fsize.width - VERT_RESIZE_INSET - 1, 2, fsize.width - VERT_RESIZE_INSET - 1, CROSSHAIR_INSET + 1);
// lower-left horiz (shadow)
// g.setColor(shadow);
g.drawLine(1, fsize.height - HORIZ_RESIZE_INSET - 1, CROSSHAIR_INSET, fsize.height - HORIZ_RESIZE_INSET - 1);
// lower-left vert (shadow)
// g.setColor(shadow);
g.drawLine(VERT_RESIZE_INSET, fsize.height - CROSSHAIR_INSET + 1, VERT_RESIZE_INSET, fsize.height);
// lower-right horiz (shadow)
// g.setColor(shadow);
g.drawLine(fsize.width - CROSSHAIR_INSET + 1, fsize.height - HORIZ_RESIZE_INSET - 1, fsize.width, fsize.height - HORIZ_RESIZE_INSET - 1);
// lower-right vert (shadow)
// g.setColor(shadow);
g.drawLine(fsize.width - VERT_RESIZE_INSET - 1, fsize.height - CROSSHAIR_INSET + 1, fsize.width - VERT_RESIZE_INSET - 1, fsize.height);
// upper-left horiz (highlight)
g.setColor(highlight);
g.drawLine(2, HORIZ_RESIZE_INSET + 1, CROSSHAIR_INSET, HORIZ_RESIZE_INSET + 1);
// upper-left vert (highlight)
// g.setColor(highlight);
g.drawLine(VERT_RESIZE_INSET + 1, 2, VERT_RESIZE_INSET + 1, CROSSHAIR_INSET);
// upper-right horiz (highlight)
// g.setColor(highlight);
g.drawLine(fsize.width - CROSSHAIR_INSET + 1, HORIZ_RESIZE_INSET + 1, fsize.width - 1, HORIZ_RESIZE_INSET + 1);
// upper-right vert (highlight)
// g.setColor(highlight);
g.drawLine(fsize.width - VERT_RESIZE_INSET, 2, fsize.width - VERT_RESIZE_INSET, CROSSHAIR_INSET);
// lower-left horiz (highlight)
// g.setColor(highlight);
g.drawLine(2, fsize.height - HORIZ_RESIZE_INSET, CROSSHAIR_INSET, fsize.height - HORIZ_RESIZE_INSET);
// lower-left vert (highlight)
// g.setColor(highlight);
g.drawLine(VERT_RESIZE_INSET + 1, fsize.height - CROSSHAIR_INSET + 1, VERT_RESIZE_INSET + 1, fsize.height - 1);
// lower-right horiz (highlight)
// g.setColor(highlight);
g.drawLine(fsize.width - CROSSHAIR_INSET + 1, fsize.height - HORIZ_RESIZE_INSET, fsize.width - 1, fsize.height - HORIZ_RESIZE_INSET);
// lower-right vert (highlight)
// g.setColor(highlight);
g.drawLine(fsize.width - VERT_RESIZE_INSET, fsize.height - CROSSHAIR_INSET + 1, fsize.width - VERT_RESIZE_INSET, fsize.height - 1);
}
XMenuBarPeer peer = menubarPeer;
if (peer != null) {
Insets insets = getInsets();
Graphics ng = g.create();
int menubarX = 0;
int menubarY = 0;
if (hasDecorations(XWindowAttributesData.AWT_DECOR_BORDER)) {
menubarX += CROSSHAIR_INSET + 1;
menubarY += CROSSHAIR_INSET + 1;
}
if (hasDecorations(XWindowAttributesData.AWT_DECOR_TITLE)) {
menubarY += BUTTON_H;
}
try {
ng.translate(menubarX, menubarY);
peer.print(ng);
} finally {
ng.dispose();
}
}
}
use of java.awt.Graphics in project jdk8u_jdk by JetBrains.
the class WGLGraphicsConfig method flip.
/**
* Performs the native WGL flip operation for the given target Component.
*/
@Override
public void flip(WComponentPeer peer, Component target, VolatileImage backBuffer, int x1, int y1, int x2, int y2, BufferCapabilities.FlipContents flipAction) {
if (flipAction == BufferCapabilities.FlipContents.COPIED) {
SurfaceManager vsm = SurfaceManager.getManager(backBuffer);
SurfaceData sd = vsm.getPrimarySurfaceData();
if (sd instanceof WGLVSyncOffScreenSurfaceData) {
WGLVSyncOffScreenSurfaceData vsd = (WGLVSyncOffScreenSurfaceData) sd;
SurfaceData bbsd = vsd.getFlipSurface();
Graphics2D bbg = new SunGraphics2D(bbsd, Color.black, Color.white, null);
try {
bbg.drawImage(backBuffer, 0, 0, null);
} finally {
bbg.dispose();
}
} else {
Graphics g = peer.getGraphics();
try {
g.drawImage(backBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
} finally {
g.dispose();
}
return;
}
} else if (flipAction == BufferCapabilities.FlipContents.PRIOR) {
// not supported by WGL...
return;
}
OGLSurfaceData.swapBuffers(peer.getData());
if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
Graphics g = backBuffer.getGraphics();
try {
g.setColor(target.getBackground());
g.fillRect(0, 0, backBuffer.getWidth(), backBuffer.getHeight());
} finally {
g.dispose();
}
}
}
Aggregations