use of sun.awt.X11GraphicsConfig in project jdk8u_jdk by JetBrains.
the class XScrollRepeater method paint.
/**
* paint the scrollbar
* @param g the graphics context to paint into
* @param colors the colors to use when painting the scrollbar
* @param width the width of the scrollbar
* @param height the height of the scrollbar
* @param paintAll paint the whole scrollbar if true, just the thumb is false
*/
void paint(Graphics g, Color[] colors, boolean paintAll) {
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("Painting scrollbar " + this);
}
boolean useBufferedImage = false;
Graphics2D g2 = null;
BufferedImage buffer = null;
if (!(g instanceof Graphics2D)) {
// Fix for 5045936, 5055171. While printing, g is an instance
// of sun.print.ProxyPrintGraphics which extends Graphics.
// So we use a separate buffered image and its graphics is
// always Graphics2D instance
X11GraphicsConfig graphicsConfig = (X11GraphicsConfig) (sb.getEventSource().getGraphicsConfiguration());
buffer = graphicsConfig.createCompatibleImage(width, height);
g2 = buffer.createGraphics();
useBufferedImage = true;
} else {
g2 = (Graphics2D) g;
}
try {
Rectangle thumbRect = calculateThumbRect();
// if (prevH == thumbH && prevY == thumbPosY) {
// return;
// }
prevThumb = thumbRect;
// TODO: Share Motif colors
Color back = colors[XComponentPeer.BACKGROUND_COLOR];
Color selectColor = new Color(MotifColorUtilities.calculateSelectFromBackground(back.getRed(), back.getGreen(), back.getBlue()));
Color darkShadow = new Color(MotifColorUtilities.calculateBottomShadowFromBackground(back.getRed(), back.getGreen(), back.getBlue()));
Color lightShadow = new Color(MotifColorUtilities.calculateTopShadowFromBackground(back.getRed(), back.getGreen(), back.getBlue()));
XToolkit.awtLock();
try {
XlibWrapper.XFlush(XToolkit.getDisplay());
} finally {
XToolkit.awtUnlock();
}
/* paint the background slightly darker */
if (paintAll) {
// fill the entire background
g2.setColor(selectColor);
if (alignment == ALIGNMENT_HORIZONTAL) {
g2.fillRect(0, 0, thumbRect.x, height);
g2.fillRect(thumbRect.x + thumbRect.width, 0, width - (thumbRect.x + thumbRect.width), height);
} else {
g2.fillRect(0, 0, width, thumbRect.y);
g2.fillRect(0, thumbRect.y + thumbRect.height, width, height - (thumbRect.y + thumbRect.height));
}
// Paint edges
// TODO: Share Motif 3d rect drawing
g2.setColor(darkShadow);
// top
g2.drawLine(0, 0, width - 1, 0);
// left
g2.drawLine(0, 0, 0, height - 1);
g2.setColor(lightShadow);
// bottom
g2.drawLine(1, height - 1, width - 1, height - 1);
// right
g2.drawLine(width - 1, 1, width - 1, height - 1);
} else {
// Clear all thumb area
g2.setColor(selectColor);
Rectangle thumbArea = getThumbArea();
g2.fill(thumbArea);
}
if (paintAll) {
// ************ paint the arrows
paintArrows(g2, colors[XComponentPeer.BACKGROUND_COLOR], darkShadow, lightShadow);
}
// Thumb
g2.setColor(colors[XComponentPeer.BACKGROUND_COLOR]);
g2.fillRect(thumbRect.x, thumbRect.y, thumbRect.width, thumbRect.height);
g2.setColor(lightShadow);
g2.drawLine(thumbRect.x, thumbRect.y, thumbRect.x + thumbRect.width, // top
thumbRect.y);
g2.drawLine(thumbRect.x, thumbRect.y, thumbRect.x, // left
thumbRect.y + thumbRect.height);
g2.setColor(darkShadow);
g2.drawLine(thumbRect.x + 1, thumbRect.y + thumbRect.height, thumbRect.x + thumbRect.width, // bottom
thumbRect.y + thumbRect.height);
g2.drawLine(thumbRect.x + thumbRect.width, thumbRect.y + 1, thumbRect.x + thumbRect.width, // right
thumbRect.y + thumbRect.height);
} finally {
if (useBufferedImage) {
g2.dispose();
}
}
if (useBufferedImage) {
g.drawImage(buffer, 0, 0, null);
}
XToolkit.awtLock();
try {
XlibWrapper.XFlush(XToolkit.getDisplay());
} finally {
XToolkit.awtUnlock();
}
}
use of sun.awt.X11GraphicsConfig in project jdk8u_jdk by JetBrains.
the class X11VolatileSurfaceManager method initAcceleratedSurface.
/**
* Create a pixmap-based SurfaceData object
*/
protected SurfaceData initAcceleratedSurface() {
SurfaceData sData;
try {
X11GraphicsConfig gc = (X11GraphicsConfig) vImg.getGraphicsConfig();
ColorModel cm = gc.getColorModel();
long drawable = 0;
if (context instanceof Long) {
drawable = ((Long) context).longValue();
}
sData = X11SurfaceData.createData(gc, vImg.getWidth(), vImg.getHeight(), cm, vImg, drawable, Transparency.OPAQUE);
} catch (NullPointerException ex) {
sData = null;
} catch (OutOfMemoryError er) {
sData = null;
}
return sData;
}
use of sun.awt.X11GraphicsConfig in project jdk8u_jdk by JetBrains.
the class XEmbedClientHelper method handleReparentNotify.
public void handleReparentNotify(XEvent xev) {
XReparentEvent re = xev.get_xreparent();
long newParent = re.get_parent();
if (active) {
// unregister accelerators, etc. for old parent
embedded.notifyStopped();
// check if newParent is a root window
X11GraphicsConfig gc = (X11GraphicsConfig) embedded.getGraphicsConfiguration();
X11GraphicsDevice gd = (X11GraphicsDevice) gc.getDevice();
if ((newParent == XlibUtil.getRootWindow(gd.getScreen())) || (newParent == XToolkit.getDefaultRootWindow())) {
// reparenting to root means XEmbed termination
active = false;
} else {
// continue XEmbed with a new parent
server = newParent;
embedded.notifyStarted();
}
}
}
use of sun.awt.X11GraphicsConfig in project jdk8u_jdk by JetBrains.
the class X11SurfaceData method getGC.
public static X11GraphicsConfig getGC(X11ComponentPeer peer) {
if (peer != null) {
return (X11GraphicsConfig) peer.getGraphicsConfiguration();
} else {
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = env.getDefaultScreenDevice();
return (X11GraphicsConfig) gd.getDefaultConfiguration();
}
}
use of sun.awt.X11GraphicsConfig in project jdk8u_jdk by JetBrains.
the class XCanvasPeer method getAppropriateGraphicsConfiguration.
/* Get a GraphicsConfig with the same visual on the new
* screen, which should be easy in Xinerama mode.
*/
public GraphicsConfiguration getAppropriateGraphicsConfiguration(GraphicsConfiguration gc) {
if (graphicsConfig == null || gc == null) {
return gc;
}
// Opt: Only need to do if we're not using the default GC
int screenNum = ((X11GraphicsDevice) gc.getDevice()).getScreen();
X11GraphicsConfig parentgc;
// save vis id of current gc
int visual = graphicsConfig.getVisual();
X11GraphicsDevice newDev = (X11GraphicsDevice) GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[screenNum];
for (int i = 0; i < newDev.getNumConfigs(screenNum); i++) {
if (visual == newDev.getConfigVisualId(i, screenNum)) {
// use that
graphicsConfig = (X11GraphicsConfig) newDev.getConfigurations()[i];
break;
}
}
// just in case...
if (graphicsConfig == null) {
graphicsConfig = (X11GraphicsConfig) GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[screenNum].getDefaultConfiguration();
}
return graphicsConfig;
}
Aggregations