Example usage for java.awt Graphics2D fill

List of usage examples for java.awt Graphics2D fill

Introduction

In this page you can find the example usage for java.awt Graphics2D fill.

Prototype

public abstract void fill(Shape s);

Source Link

Document

Fills the interior of a Shape using the settings of the Graphics2D context.

Usage

From source file:Main.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    Rectangle r = new Rectangle(10, 10, 50, 40);

    System.out.println(r.createIntersection(new Rectangle(20, 20, 40, 40)));

    g2.fill(r);
}

From source file:BasicShapes.java

public void paint(Graphics g) {
    BufferedImage bimage = new BufferedImage(200, 200, BufferedImage.TYPE_BYTE_INDEXED);
    Graphics2D g2d = bimage.createGraphics();

    Color transparent = new Color(0, 0, 0, 0);
    g2d.setColor(transparent);// w ww.j  a  va2  s  . co  m
    g2d.setComposite(AlphaComposite.Src);
    g2d.fill(new Rectangle2D.Float(20, 20, 100, 20));
    g2d.dispose();

}

From source file:GradientPaintDemo.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setPaint(new GradientPaint(0, 0, Color.lightGray, 200, 200, Color.blue, false));

    Rectangle r = new Rectangle(5, 5, 200, 200);

    g2.fill(r);
}

From source file:ec.util.chart.swing.JTimeSeriesRendererSupport.java

static void drawToolTip(Graphics2D g2, double x, double y, double anchorOffset, String label, Font font,
        Paint paint, Paint fillPaint, Paint outlinePaint, Stroke outlineStroke) {
    LabelBlock block = new LabelBlock(label/*.replace("\n", "")*/, font, paint);
    block.setMargin(3, 3, 3, 3);// ww  w .j a v  a 2s .c  o m

    Rectangle2D hotspot = createHotspot(g2, x, y, anchorOffset + 10, block.arrange(g2));
    Shape shape = createShape(x, y, hotspot);

    if (fillPaint != null) {
        g2.setPaint(fillPaint);
        g2.fill(shape);
    }

    if (outlinePaint != null && outlineStroke != null) {
        g2.setStroke(outlineStroke);
        g2.setPaint(outlinePaint);
        g2.draw(shape);
    }

    block.draw(g2, hotspot);
}

From source file:MainClass.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    Ellipse2D e = new Ellipse2D.Float(40, 40, 120, 120);
    GradientPaint gp = new GradientPaint(75, 75, Color.white, 95, 95, Color.gray, true);
    g2.setPaint(gp);//from w  ww  . j  a v a2 s.com
    g2.fill(e);
}

From source file:D20140128.ApacheXMLGraphicsTest.TilingPatternExample.java

private void paintShapes(Graphics2D g2d) {
    g2d.setPaint(paint);/*from  w  w  w .  ja  v  a  2 s  . c  o  m*/
    Rectangle rect = new Rectangle(10, 50, 30, 30);
    g2d.fill(rect);
    rect = new Rectangle(10, 90, 40, 20);
    g2d.fill(rect);
    Polygon poly = new Polygon(new int[] { 50, 100, 150 }, new int[] { 100, 20, 100 }, 3);
    g2d.fill(poly);
}

From source file:Main.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    Shape ball = new Ellipse2D.Float(i++, i++, 5, 5);
    g2.setColor(Color.RED);/*from www . j  a  v a2s  . co  m*/
    g2.fill(ball);
}

From source file:BallRoom.java

public void paint(Graphics g) {

    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    Shape ball = new Ellipse2D.Float(i++, i++, 5, 5);
    g2.setColor(Color.RED);/*  w  ww .  j  av a 2s.co m*/
    g2.fill(ball);
}

From source file:AlphaCompositeSRCOUT.java

public void paint(Graphics g) {
    Graphics2D g2D = (Graphics2D) g;

    int w = getSize().width;
    int h = getSize().height;

    BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
    Graphics2D big = bi.createGraphics();

    ac = AlphaComposite.getInstance(compositeRule, alphaValue);

    big.setColor(Color.red);/*  w w  w .jav a2s.  co  m*/
    big.drawString("Destination", w / 4, h / 4);
    big.fill(new Ellipse2D.Double(0, h / 3, 2 * w / 3, h / 3));

    big.setColor(Color.blue);
    big.drawString("Source", 3 * w / 4, h / 4);

    big.setComposite(ac);
    big.fill(new Ellipse2D.Double(w / 3, h / 3, 2 * w / 3, h / 3));

    g2D.drawImage(bi, null, 0, 0);
}

From source file:MainClass.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    Rectangle2D r = new Rectangle2D.Double(50, 50, 150, 100);
    g2.setPaint(Color.red);/*from   w  w  w.ja  va  2 s.c  o m*/
    g2.fill(r);

    Composite c = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .4f);
    g2.setComposite(c);

    g2.setPaint(Color.blue);
    g2.setFont(new Font("Times New Roman", Font.PLAIN, 72));
    g2.drawString("www.java2s.com", 25, 130);
}