List of usage examples for java.awt Graphics2D setComposite
public abstract void setComposite(Composite comp);
From source file:com.anrisoftware.prefdialog.miscswing.validatingfields.ValidatingComponent.java
private void paintInvalidOverlay(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setComposite(ALPHA); g2.setPaint(invalidBackground);/*from w w w . j a v a 2s. c o m*/ Rectangle bounds = g.getClipBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); }
From source file:photodb.cdi.ImageManager.java
private BufferedImage createResizedCopy(final Image originalImage, final int scaledWidth, final int scaledHeight, final boolean preserveAlpha) { final int imageType = preserveAlpha ? BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB; final BufferedImage scaledBI = new BufferedImage(scaledWidth, scaledHeight, imageType); final Graphics2D g = scaledBI.createGraphics(); if (preserveAlpha) { g.setComposite(AlphaComposite.Src); }/*www . java2s.c o m*/ g.drawImage(originalImage, 0, 0, scaledWidth, scaledHeight, null); g.dispose(); return scaledBI; }
From source file:net.sf.mzmine.modules.visualization.scatterplot.scatterplotchart.DiagonalLineRenderer.java
public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset dataset, PlotRenderingInfo info) {//w ww . java 2 s .c o m // Set transparency g2.setComposite(alpha); return super.initialise(g2, dataArea, plot, dataset, info); }
From source file:bachelorthesis.captchabuilder.builder.CaptchaBuilder.java
private BufferedImage flattenImage() { BufferedImage rImage;/*from w w w . j ava 2s. co m*/ if (bg == null) { rImage = new BackgroundProducerBuilder(BackgroundProducerType.TRANSPARENT).create() .getBackground(img.getWidth(), img.getHeight()); } else { rImage = bg; } // Paint the main image over the background Graphics2D g = rImage.createGraphics(); g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f)); g.drawImage(img, null, null); return rImage; }
From source file:net.sf.mzmine.modules.visualization.tic.TICPlotRenderer.java
protected void drawPrimaryLine(XYItemRendererState state, Graphics2D g2, XYPlot plot, XYDataset dataset, int pass, int series, int item, ValueAxis domainAxis, ValueAxis rangeAxis, Rectangle2D dataArea) { g2.setComposite(makeComposite(transparency)); super.drawPrimaryLine(state, g2, plot, dataset, pass, series, item, domainAxis, rangeAxis, dataArea); }
From source file:net.sf.mzmine.modules.visualization.tic.TICPlotRenderer.java
protected void drawPrimaryLineAsPath(XYItemRendererState state, Graphics2D g2, XYPlot plot, XYDataset dataset, int pass, int series, int item, ValueAxis domainAxis, ValueAxis rangeAxis, Rectangle2D dataArea) { g2.setComposite(makeComposite(transparency)); super.drawPrimaryLineAsPath(state, g2, plot, dataset, pass, series, item, domainAxis, rangeAxis, dataArea); }
From source file:com.skcraft.launcher.swing.InstanceTableModel.java
private ImageIcon buildDownloadIcon(BufferedImage instanceIcon) { try {// ww w . j a v a2 s . com BufferedImage iconBg = instanceIcon; BufferedImage iconFg = ImageIO.read(Launcher.class.getResource("download_icon_overlay.png")); BufferedImage iconCombined = new BufferedImage(iconBg.getWidth(), iconBg.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D canvas = iconCombined.createGraphics(); canvas.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f)); canvas.drawImage(iconBg, 0, 0, null); canvas.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f)); canvas.drawImage(iconFg, iconBg.getWidth() - iconFg.getWidth(), iconBg.getHeight() - iconFg.getHeight(), null); canvas.dispose(); return new ImageIcon(iconCombined); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:net.sf.maltcms.chromaui.project.spi.nodes.DescriptorNode.java
@Override public Image getIcon(int type) { Image descrImage = DescriptorFactory.getImage(getBean()); int w = descrImage.getWidth(null); int h = descrImage.getHeight(null); if (getBean() instanceof IColorizableDescriptor) { IColorizableDescriptor colorDescr = (IColorizableDescriptor) getBean(); Color c = colorDescr.getColor(); if (c != null) { BufferedImage bi = new BufferedImage(w / 10, h / 10, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = bi.createGraphics(); g2.setColor(colorDescr.getColor()); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.9f)); g2.fillRect(0, 0, bi.getWidth(), bi.getHeight()); descrImage = ImageUtilities.mergeImages(bi, descrImage, w - bi.getWidth(), h - bi.getHeight()); }// w w w. ja va 2 s. co m } return descrImage; }
From source file:com.anrisoftware.prefdialog.miscswing.lists.RubberBandingList.java
private void drawSelectionRubberBand(Graphics2D g) { g.setPaint(getSelectionBackground()); g.draw(rubberBand);/*from ww w .j a v a 2s.c o m*/ g.setComposite(ALPHA); g.setPaint(selectionColor); g.fill(rubberBand); }
From source file:uk.co.modularaudio.service.bufferedimageallocation.impl.debugwindow.imagebrowser.RawImageCanvas.java
@Override public void paint(final Graphics rawG) { final Graphics2D g = (Graphics2D) rawG; g.getClipBounds(clipBounds);//from ww w .ja v a 2 s.com if (curBufferedImage != null) { g.setComposite(opaqueComposite); g.setColor(Color.DARK_GRAY); g.fillRect(0, 0, width, height); g.drawImage(curBufferedImage, 0, 0, null); // Draw the free blocks over the top // We draw 50 transparent fill then outline with full yellow g.setColor(DARK_BLUE); g.setComposite(ninetyPercentAlphaComposite); // g.setComposite( fiftyPercentAlphaComposite ); // g.setComposite( tenPercentAlphaComposite ); for (final Rectangle freeBlockRectangle : freeBlockRectangles) { g.fillRect(freeBlockRectangle.x, freeBlockRectangle.y, freeBlockRectangle.width, freeBlockRectangle.height); } g.setColor(Color.yellow); g.setComposite(opaqueComposite); for (final Rectangle freeBlockRectangle : freeBlockRectangles) { g.drawRect(freeBlockRectangle.x, freeBlockRectangle.y, freeBlockRectangle.width, freeBlockRectangle.height); } g.setComposite(opaqueComposite); g.setColor(Color.RED); for (final Rectangle usedBlockRectangle : usedBlockRectangles) { g.drawRect(usedBlockRectangle.x, usedBlockRectangle.y, usedBlockRectangle.width, usedBlockRectangle.height); } } else { g.setColor(Color.gray); g.fillRect(0, 0, width, height); } }