Java 8 GraphicsConfiguration - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 GraphicsConfiguration class.

This code example shows how to use the following methods:createCompatibleVolatileImage
        g.dispose();
 
        // need to 'accelerate' the image 
        if (dstImage == null) {
            dstImage =
                gc.createCompatibleVolatileImage(TESTW, TESTH,
                                                 Transparency.OPAQUE);
        } 
        dstImage.validate(gc);
        g = dstImage.getGraphics();
        g.drawImage(image, 0, 0, null);
        g.drawImage(image, 0, 0, null);
        g.drawImage(image, 0, 0, null);
    } 
 
    static VolatileImage getVImage(GraphicsConfiguration gc,
                                   int w, int h)
    { 
        VolatileImage image =
            gc.createCompatibleVolatileImage(w, h, Transparency.OPAQUE);

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:createCompatibleVolatileImage
This code example shows how to use the following methods:createCompatibleVolatileImage
This code example shows how to use the following methods:createCompatibleVolatileImage
 
	@Override 
	public void render(Java2dGame game) {
		GraphicsConfiguration gc = canvas.getGraphicsConfiguration();
 
		int validated = backBufferImage.validate(gc);
		if (validated == VolatileImage.IMAGE_INCOMPATIBLE) {
			createBackBufferImage(gc);
		} 
 
		game.render((Graphics2D) backBufferImage.getGraphics());
 
		Graphics graphics = canvas.getGraphics();
		if (graphics!=null)
			graphics.drawImage(backBufferImage, 0, 0, null);
	} 
 
	private void createBackBufferImage(GraphicsConfiguration gc) {
		if (backBufferImage == null)
			backBufferImage = gc.createCompatibleVolatileImage(canvas.getWidth(), canvas.getHeight());

5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getColorModel
   * @return the passed Capabilities 
   */ 
  public static CapabilitiesImmutable setupCapabilitiesRGBABits(final CapabilitiesImmutable capabilitiesIn, final GraphicsConfiguration gc) {
    final Capabilities capabilities = (Capabilities) capabilitiesIn.cloneMutable();
 
    final ColorModel cm = gc.getColorModel();
    if(null==cm) {
        throw new NativeWindowException("Could not determine AWT ColorModel"); 
    } 
    final int cmBitsPerPixel = cm.getPixelSize();
    int bitsPerPixel = 0;
    final int[] bitesPerComponent = cm.getComponentSize();
    if(bitesPerComponent.length>=3) {
        capabilities.setRedBits(bitesPerComponent[0]);
        bitsPerPixel += bitesPerComponent[0];
        capabilities.setGreenBits(bitesPerComponent[1]);
        bitsPerPixel += bitesPerComponent[1];
        capabilities.setBlueBits(bitesPerComponent[2]);
        bitsPerPixel += bitesPerComponent[2];
    } 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:createCompatibleImage
     * but allows reusing released images. 
     */ 
    public static BufferedImage getGCCompatibleImage(int width, int height) {
        List<BufferedImage> imgList = recycledImages.get(new Dimension(width, height));
        if (imgList == null || imgList.isEmpty()) {
            return gc.createCompatibleImage(width, height, Transparency.TRANSLUCENT);
        } 
        numRecycledImages--;
        BufferedImage img = imgList.remove(imgList.size() - 1);
        // Clear the image 
        Graphics2D g2D = img.createGraphics();
        g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f));
        Rectangle2D.Double rect = new Rectangle2D.Double(0, 0, width, height);
        g2D.fill(rect);
        return img;
    } 
 
    /**  
     * Add an image to the recycled images list (or if img = null, does nothing). 
     * Note: the passed variable should be immediately set to null to avoid aliasing bugs. 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:createCompatibleImage
import java.awt.image.BufferedImage;
import org.allbinary.logic.communication.log.LogFactory; 
 
public class MirrorImageUtil 
{ 
 
   private MirrorImageUtil() 
   { 
   } 
 
   public static BufferedImage getImage(
      BufferedImage bufferedImage, boolean verticle, boolean horizontal)
   { 
      LogUtil.put(LogFactory.getInstance("Starting", "MirrorImageUtil", "getImage")); 
 
      BufferedImage newBufferedImage = 
         BufferedImageUtil.create( 
            bufferedImage.getWidth(null),
            bufferedImage.getHeight(null)
         ); 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:createCompatibleImage
          .getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
 
    private UiUtils() {} 
 
    public static BufferedImage newTransparentImage(int w, int h) {
        return graphicsConfiguration.createCompatibleImage(w, h, Transparency.TRANSLUCENT);
    } 
 
    public static boolean isBrightColor(Color c) {
        return c.getRed() > 192 && c.getGreen() > 192 && c.getBlue() < 64;
    } 
 
    public static void highlightComponent(final JComponent c) {
        if (c.getBackground() == HIGHLIGHT) return; //prevent two timers
        c.setBackground(HIGHLIGHT);
        Timer t = new Timer(800, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                c.setBackground(null);
            } 
        }); 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:createCompatibleImage
        // create the offscreen buffer 
        GraphicsEnvironment local = 
            GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice screen = local.getDefaultScreenDevice();
        GraphicsConfiguration conf = screen.getDefaultConfiguration();
        surface = conf.createCompatibleImage(width, height, Transparency.TRANSLUCENT );
 
        // create the graphics interface 
        graphics = (Graphics2D) surface.createGraphics();
 
        // clear it 
        clear(); 
    } 
     
    /** 
     * Erase the contents of the surface, returning it to a fully transparent state. 
     * 
     */ 
    public void clear() 
    { 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getBounds
Dimension size;
        Point location = new Point();
        GraphicsConfiguration gc;
        gc = component.getGraphicsConfiguration();
        Rectangle sBounds = gc.getBounds();
        Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
        // Take into account screen insets, decrease viewport 
        sBounds.x += screenInsets.left;
        sBounds.y += screenInsets.top;
        sBounds.width -= (screenInsets.left + screenInsets.right);
        sBounds.height -= (screenInsets.top + screenInsets.bottom);
 
        hideTooltip(); 
 
        JRichTooltipPanel tip = new JRichTooltipPanel(this);
        size = tip.getPreferredSize();
 
 
        // display directly below or above it 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Java 8 GraphicsConfiguration Methods: