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:XORRectangles.java

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

    // using white as the XOR color.
    g2.setXORMode(Color.white);//  w  w  w.j  a v  a2 s.c  o m
    // Paint a red rectangle.
    Rectangle2D r = new Rectangle2D.Double(50, 50, 150, 100);
    g2.setPaint(Color.red);
    g2.fill(r);
    g2.transform(AffineTransform.getTranslateInstance(25, 25));
    // Draw a blue rectangle.
    g2.setPaint(Color.blue);
    g2.fill(r);
}

From source file:Hypnosis1.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    Shape s = createShape();/* www  .  j ava 2s  . c  o  m*/
    g2.setPaint(paint);
    g2.fill(s);
    g2.setPaint(Color.white);
    g2.draw(s);
}

From source file:FilledArc.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    int x = 5;/*from w ww . j  a  v a  2  s . c o  m*/
    int y = 7;

    // fill Arc2D
    g2.setPaint(Color.red);
    g2.fill(new Arc2D.Double(x, y, 200, 200, 90, 135, Arc2D.OPEN));
    g2.setPaint(Color.black);
    g2.drawString("Filled Arc2D", x, 250);

}

From source file:FilledRectangleDemo2D.java

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

    g2.setPaint(Color.gray);//from w ww.j a  v  a2s  .  c o m
    int x = 5;
    int y = 7;

    g2.setPaint(Color.red);
    g2.fill(new Rectangle2D.Double(x, y, 200, 200));
    g2.setPaint(Color.black);
    g2.drawString("Filled Rectangle2D", x, 250);
}

From source file:CompositeTest.java

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

    BufferedImage image = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
    Graphics2D gImage = image.createGraphics();
    gImage.setPaint(Color.red);//  w ww.  ja  v  a  2s. c o m
    gImage.fill(shape1);
    AlphaComposite composite = AlphaComposite.getInstance(rule, alpha);
    gImage.setComposite(composite);
    gImage.setPaint(Color.blue);
    gImage.fill(shape2);
    g2.drawImage(image, null, 0, 0);
}

From source file:Bounce.java

public void paintComponent(Graphics g) {
    super.paintComponent(g); // erase background
    Graphics2D g2 = (Graphics2D) g;
    for (Ball b : balls) {
        g2.fill(b.getShape());
    }//from w w w .  j av a  2s.  c o  m
}

From source file:Main.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    int w = getSize().width;
    int h = getSize().height;

    Arc2D arc = new Arc2D.Double(0.0, 0.5, w, h, 0.0, 60.0, Arc2D.CHORD);

    g2.draw(arc);/*from   www.  j ava 2 s .  c o  m*/

    arc.setArcByCenter(2, 3, w, h, 110.0f, Arc2D.PIE);
    g2.fill(arc);

    arc = new Arc2D.Float(0.0f, 0.0f, w, h, 210.0f, 130.0f, Arc2D.OPEN);

    g2.draw(arc);
}

From source file:SVGJUnitTest.java

public void paint(Graphics2D g2d) {

    g2d.setPaint(Color.red);
    g2d.fill(new Rectangle(10, 10, 100, 100));
}

From source file:Main.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    int w = getSize().width;
    int h = getSize().height;

    Arc2D arc = new Arc2D.Double(0.0, 0.5, w, h, 0.0, 60.0, Arc2D.CHORD);

    g2.draw(arc);/*from w  ww.ja  v a2 s . c o m*/

    arc.setArc(0.0f, 0.0f, w, h, 80.0f, 110.0f, Arc2D.PIE);
    g2.fill(arc);

    arc = new Arc2D.Float(0.0f, 0.0f, w, h, 210.0f, 130.0f, Arc2D.OPEN);

    g2.draw(arc);
}

From source file:SVGJUnitTest.java

public void paint2(Graphics2D g2d) {

    g2d.setPaint(Color.green);
    g2d.fill(new Rectangle(90, 90, 100, 100));
}