Java Code Examples for org.jdesktop.swingx.graphics.GraphicsUtilities#createCompatibleTranslucentImage()
The following examples show how to use
org.jdesktop.swingx.graphics.GraphicsUtilities#createCompatibleTranslucentImage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JXPanel.java From littleluck with Apache License 2.0 | 6 votes |
/** * Overriden paint method to take into account the alpha setting * @param g */ @Override public void paint(Graphics g) { float a = getAlpha(); if (a == 1) { super.paint(g); } else { //the component is translucent, so we need to render to //an intermediate image before painting BufferedImage img = GraphicsUtilities.createCompatibleTranslucentImage(getWidth(), getHeight()); Graphics2D gfx = img.createGraphics(); super.paint(gfx); gfx.dispose(); Graphics2D g2d = (Graphics2D)g; Composite oldComp = g2d.getComposite(); Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, a); g2d.setComposite(alphaComp); g2d.drawImage(img, null, 0, 0); g2d.setComposite(oldComp); } }
Example 2
Source File: JXPanel.java From beautyeye with Apache License 2.0 | 6 votes |
/** * Overriden paint method to take into account the alpha setting * @param g */ @Override public void paint(Graphics g) { float a = getAlpha(); if (a == 1) { super.paint(g); } else { //the component is translucent, so we need to render to //an intermediate image before painting BufferedImage img = GraphicsUtilities.createCompatibleTranslucentImage(getWidth(), getHeight()); Graphics2D gfx = img.createGraphics(); super.paint(gfx); gfx.dispose(); Graphics2D g2d = (Graphics2D)g; Composite oldComp = g2d.getComposite(); Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, a); g2d.setComposite(alphaComp); g2d.drawImage(img, null, 0, 0); g2d.setComposite(oldComp); } }
Example 3
Source File: JXPanel.java From Darcula with Apache License 2.0 | 6 votes |
/** * Overriden paint method to take into account the alpha setting * @param g */ @Override public void paint(Graphics g) { float a = getAlpha(); if (a == 1) { super.paint(g); } else { //the component is translucent, so we need to render to //an intermediate image before painting BufferedImage img = GraphicsUtilities.createCompatibleTranslucentImage(getWidth(), getHeight()); Graphics2D gfx = img.createGraphics(); super.paint(gfx); gfx.dispose(); Graphics2D g2d = (Graphics2D)g; Composite oldComp = g2d.getComposite(); Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, a); g2d.setComposite(alphaComp); g2d.drawImage(img, null, 0, 0); g2d.setComposite(oldComp); } }
Example 4
Source File: SnippetNavigator.java From littleluck with Apache License 2.0 | 5 votes |
private void matchLabelBorderToButtons() { Insets insets = new Insets(4, 6, 4, 6); Dimension buttonSize = prevButton.getPreferredSize(); prevButton.setSize(buttonSize); BufferedImage image = GraphicsUtilities. createCompatibleTranslucentImage( buttonSize.width, buttonSize.height); prevButton.paint(image.getGraphics()); BufferedImage labelTopImage = GraphicsUtilities. createCompatibleTranslucentImage( buttonSize.width - insets.left - insets.right, insets.top); labelTopImage.getGraphics().drawImage(image, 0, 0, buttonSize.width - insets.left - insets.right, insets.top, insets.left, 0, buttonSize.width - insets.right, insets.top, null, null); BufferedImage labelBottomImage = GraphicsUtilities.createCompatibleTranslucentImage(buttonSize.width - insets.left - insets.right, insets.bottom); labelBottomImage.getGraphics().drawImage(image, 0, 0, buttonSize.width - insets.left - insets.right, insets.top, insets.left, buttonSize.height - insets.bottom, buttonSize.width - insets.right, buttonSize.height, null, null); statusLabel.setBorder(new CenterLabelBorder(labelTopImage, labelBottomImage)); needLabelBorder = false; }
Example 5
Source File: SnippetNavigator.java From beautyeye with Apache License 2.0 | 5 votes |
private void matchLabelBorderToButtons() { Insets insets = new Insets(4, 6, 4, 6); Dimension buttonSize = prevButton.getPreferredSize(); prevButton.setSize(buttonSize); BufferedImage image = GraphicsUtilities. createCompatibleTranslucentImage( buttonSize.width, buttonSize.height); prevButton.paint(image.getGraphics()); BufferedImage labelTopImage = GraphicsUtilities. createCompatibleTranslucentImage( buttonSize.width - insets.left - insets.right, insets.top); labelTopImage.getGraphics().drawImage(image, 0, 0, buttonSize.width - insets.left - insets.right, insets.top, insets.left, 0, buttonSize.width - insets.right, insets.top, null, null); BufferedImage labelBottomImage = GraphicsUtilities.createCompatibleTranslucentImage(buttonSize.width - insets.left - insets.right, insets.bottom); labelBottomImage.getGraphics().drawImage(image, 0, 0, buttonSize.width - insets.left - insets.right, insets.top, insets.left, buttonSize.height - insets.bottom, buttonSize.width - insets.right, buttonSize.height, null, null); statusLabel.setBorder(new CenterLabelBorder(labelTopImage, labelBottomImage)); needLabelBorder = false; }
Example 6
Source File: SnippetNavigator.java From Darcula with Apache License 2.0 | 5 votes |
private void matchLabelBorderToButtons() { Insets insets = new Insets(4, 6, 4, 6); Dimension buttonSize = prevButton.getPreferredSize(); prevButton.setSize(buttonSize); BufferedImage image = GraphicsUtilities. createCompatibleTranslucentImage( buttonSize.width, buttonSize.height); prevButton.paint(image.getGraphics()); BufferedImage labelTopImage = GraphicsUtilities. createCompatibleTranslucentImage( buttonSize.width - insets.left - insets.right, insets.top); labelTopImage.getGraphics().drawImage(image, 0, 0, buttonSize.width - insets.left - insets.right, insets.top, insets.left, 0, buttonSize.width - insets.right, insets.top, null, null); BufferedImage labelBottomImage = GraphicsUtilities.createCompatibleTranslucentImage(buttonSize.width - insets.left - insets.right, insets.bottom); labelBottomImage.getGraphics().drawImage(image, 0, 0, buttonSize.width - insets.left - insets.right, insets.top, insets.left, buttonSize.height - insets.bottom, buttonSize.width - insets.right, buttonSize.height, null, null); statusLabel.setBorder(new CenterLabelBorder(labelTopImage, labelBottomImage)); needLabelBorder = false; }