Example usage for java.awt.geom Area getBounds2D

List of usage examples for java.awt.geom Area getBounds2D

Introduction

In this page you can find the example usage for java.awt.geom Area getBounds2D.

Prototype

public Rectangle2D getBounds2D() 

Source Link

Document

Returns a high precision bounding Rectangle2D that completely encloses this Area .

Usage

From source file:Main.java

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

    Ellipse2D e1 = new Ellipse2D.Double(20.0, 20.0, 80.0, 70.0);
    Ellipse2D e2 = new Ellipse2D.Double(20.0, 70.0, 40.0, 40.0);

    Area a1 = new Area(e1);
    Area a2 = new Area(e2);

    a1.subtract(a2);/* w ww . java  2  s  .  c  o  m*/

    g2.setColor(Color.orange);
    g2.fill(a1);

    g2.setColor(Color.black);
    g2.drawString("subtract", 20, 140);

    System.out.println(a1.getBounds2D());
}