List of usage examples for java.awt Graphics2D fill
public abstract void fill(Shape s);
From source file:com.github.lucapino.sheetmaker.PreviewJFrame.java
public static BufferedImage makeRoundedCorner(BufferedImage image, int cornerRadius) { int w = image.getWidth(); int h = image.getHeight(); BufferedImage output = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = output.createGraphics(); // This is what we want, but it only does hard-clipping, i.e. aliasing // g2.setClip(new RoundRectangle2D ...) // so instead fake soft-clipping by first drawing the desired clip shape // in fully opaque white with antialiasing enabled... g2.setComposite(AlphaComposite.Src); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setColor(Color.WHITE);//from ww w. j a v a 2 s.co m g2.fill(new RoundRectangle2D.Float(0, 0, w, h, cornerRadius, cornerRadius)); // ... then compositing the image on top, // using the white shape from above as alpha source g2.setComposite(AlphaComposite.SrcIn); g2.drawImage(image, 0, 0, null); g2.dispose(); return output; }
From source file:com.zacwolf.commons.email.Email.java
public static BufferedImage makeRoundedBanner(BufferedImage image, int cornerRadius) { int w = image.getWidth(); int h = image.getHeight() + 10; BufferedImage output = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = output.createGraphics(); g2.setComposite(AlphaComposite.Src); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setColor(Color.WHITE);/*from w ww . j a v a 2 s . co m*/ g2.fill(new RoundRectangle2D.Float(0, 0, w, h, cornerRadius, cornerRadius)); g2.setComposite(AlphaComposite.SrcAtop); g2.drawImage(image, 0, 0, null); g2.setComposite(AlphaComposite.SrcOver); // g2.setColor(new Color(153,153,153));//slight grey border // g2.drawRoundRect(0, 0, w-1, h, cornerRadius, cornerRadius); g2.dispose(); return output.getSubimage(0, 0, image.getWidth(), image.getHeight()); }
From source file:com.jaeksoft.searchlib.util.ImageUtils.java
public static final void yellowHighlight(Image image, Collection<Rectangle> boxes, float outsetFactor) { if (CollectionUtils.isEmpty(boxes)) return;/*w ww .j ava 2s. co m*/ Graphics2D g2d = (Graphics2D) image.getGraphics(); g2d.setPaint(Color.YELLOW); Composite originalComposite = g2d.getComposite(); AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f); g2d.setComposite(ac); for (Rectangle box : boxes) { if (outsetFactor != 1.0F) { box = new Rectangle(box); box.grow((int) (box.getHeight() * outsetFactor), (int) (box.getWidth() * outsetFactor)); } g2d.fill(box); } g2d.setComposite(originalComposite); }
From source file:Hexagon.java
public static File write(String fileName, Shape shape) throws IOException { Rectangle bounds = shape.getBounds(); BufferedImage img = createImage(bounds.width, bounds.height); Graphics2D g2 = (Graphics2D) img.createGraphics(); //g2.setColor(WebColor.CornSilk.getColor()); g2.fill(shape); g2.setColor(Color.black);/*from w w w . j a v a 2 s . c om*/ g2.draw(shape); return write(fileName, img); }
From source file:org.gumtree.vis.mask.ChartMaskingUtilities.java
public static void drawMaskBoarder(Graphics2D g2, Rectangle2D frame) { g2.setPaint(Color.orange);//from w ww . j ava 2 s .c o m g2.setStroke(new BasicStroke(1)); g2.draw(frame); Rectangle2D dragPoint = new Rectangle2D.Double(frame.getMinX() - maskDragPointHalfWidth, frame.getMinY() - maskDragPointHalfWidth, maskDragPointWidth, maskDragPointWidth); g2.fill(dragPoint); dragPoint.setRect(frame.getCenterX() - maskDragPointHalfWidth, frame.getMinY() - maskDragPointHalfWidth, maskDragPointWidth, maskDragPointWidth); g2.fill(dragPoint); dragPoint.setRect(frame.getMaxX() - maskDragPointHalfWidth, frame.getMinY() - maskDragPointHalfWidth, maskDragPointWidth, maskDragPointWidth); g2.fill(dragPoint); dragPoint.setRect(frame.getMaxX() - maskDragPointHalfWidth, frame.getCenterY() - maskDragPointHalfWidth, maskDragPointWidth, maskDragPointWidth); g2.fill(dragPoint); dragPoint.setRect(frame.getMinX() - maskDragPointHalfWidth, frame.getCenterY() - maskDragPointHalfWidth, maskDragPointWidth, maskDragPointWidth); g2.fill(dragPoint); dragPoint.setRect(frame.getMinX() - maskDragPointHalfWidth, frame.getMaxY() - maskDragPointHalfWidth, maskDragPointWidth, maskDragPointWidth); g2.fill(dragPoint); dragPoint.setRect(frame.getCenterX() - maskDragPointHalfWidth, frame.getMaxY() - maskDragPointHalfWidth, maskDragPointWidth, maskDragPointWidth); g2.fill(dragPoint); dragPoint.setRect(frame.getMaxX() - maskDragPointHalfWidth, frame.getMaxY() - maskDragPointHalfWidth, maskDragPointWidth, maskDragPointWidth); g2.fill(dragPoint); Color fillColor = new Color(250, 250, 50, 30); g2.setPaint(fillColor); g2.fill(frame); }
From source file:org.gumtree.vis.mask.ChartMaskingUtilities.java
private static void drawMaskBoarder(Graphics2D g2, Abstract2DMask mask) { g2.setPaint(Color.orange);/*ww w .j a v a2 s .com*/ g2.setStroke(new BasicStroke(1)); Rectangle2D frame = mask.getRectangleFrame(); g2.draw(frame); Rectangle2D dragPoint = new Rectangle2D.Double(frame.getMinX() - maskDragPointHalfWidth, frame.getMinY() - maskDragPointHalfWidth, maskDragPointWidth, maskDragPointWidth); g2.fill(dragPoint); dragPoint.setRect(frame.getCenterX() - maskDragPointHalfWidth, frame.getMinY() - maskDragPointHalfWidth, maskDragPointWidth, maskDragPointWidth); g2.fill(dragPoint); dragPoint.setRect(frame.getMaxX() - maskDragPointHalfWidth, frame.getMinY() - maskDragPointHalfWidth, maskDragPointWidth, maskDragPointWidth); g2.fill(dragPoint); dragPoint.setRect(frame.getMaxX() - maskDragPointHalfWidth, frame.getCenterY() - maskDragPointHalfWidth, maskDragPointWidth, maskDragPointWidth); g2.fill(dragPoint); dragPoint.setRect(frame.getMinX() - maskDragPointHalfWidth, frame.getCenterY() - maskDragPointHalfWidth, maskDragPointWidth, maskDragPointWidth); g2.fill(dragPoint); dragPoint.setRect(frame.getMinX() - maskDragPointHalfWidth, frame.getMaxY() - maskDragPointHalfWidth, maskDragPointWidth, maskDragPointWidth); g2.fill(dragPoint); dragPoint.setRect(frame.getCenterX() - maskDragPointHalfWidth, frame.getMaxY() - maskDragPointHalfWidth, maskDragPointWidth, maskDragPointWidth); g2.fill(dragPoint); dragPoint.setRect(frame.getMaxX() - maskDragPointHalfWidth, frame.getMaxY() - maskDragPointHalfWidth, maskDragPointWidth, maskDragPointWidth); g2.fill(dragPoint); Color fillColor = new Color(250, 250, 50, 10); g2.setPaint(fillColor); g2.fill(mask.getShape()); }
From source file:juicebox.tools.utils.juicer.apa.APAPlotter.java
/** * @param g2 graphics2D object/*from w w w . jav a 2 s .c o m*/ */ private static void plotColorScaleBar(Graphics2D g2) { // calculate color scale bar dimensions & location Point csBarTL = new Point(heatmapWidth + colorScaleHorizontalMargin, colorScaleVerticalMargin); Point csBarBL = new Point(heatmapWidth + colorScaleHorizontalMargin, fullHeight - colorScaleVerticalMargin); Rectangle csBar = new Rectangle(csBarTL.x, csBarTL.y, colorScaleWidth - 2 * colorScaleHorizontalMargin, fullHeight - 2 * colorScaleVerticalMargin); // plot the color scale linear gradient LinearGradientPaint gradient = new LinearGradientPaint(csBarTL, csBarBL, gradientFractions, gradientColors); g2.setPaint(gradient); g2.fill(csBar); // plot a border around color scale g2.setColor(Color.black); g2.drawRect(csBar.x, csBar.y, csBar.width, csBar.height); }
From source file:MainClass.java
public void paint(Graphics g) { Shape shape = new Rectangle2D.Float(100, 50, 80, 80); Graphics2D g2 = (Graphics2D) g; g2.fill(shape); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Rectangle r = new Rectangle(10, 10); g2.fill(r); System.out.println(r.isEmpty()); }
From source file:BasicDraw.java
public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setColor(Color.red);//from w w w.ja v a 2 s .c o m g2d.fill(new Rectangle(20, 20, 200, 200)); int red = 230; int green = 45; int blue = 67; g2d.setColor(new Color(red, green, blue)); g2d.fill(new Rectangle(40, 40, 200, 200)); }