Area class in java

java.awt.geom.Area is a class in java programming language. Inside of this class exists 23 public methods. Declaration of this class as follows.

public class java.awt.geom.Area 
implements java.awt.Shape,java.lang.Cloneable 

Area public method

There are following useful methods which is define the inside of java.awt.geom.Area class.

MethodDescription
Modifier and Type It method and Description
void add(Area rhs) It adds the shape of the specified to the shape of this Area.
Object clone() It returns an exact copy of this object.
boolean contains(double x, double y) It tests if the specified coordinates are inside the boundary of the , as described by the definition of insideness.
boolean contains(double x, double y, double w, double h) It tests if the interior of the entirely contains the specified rectangular area.
boolean contains(Point2D p) It tests if a specified is inside the boundary of the Shape, as described by the definition of insideness.
boolean contains(Rectangle2D r) It tests if the interior of the entirely contains the specified Rectangle2D.
Area createTransformedArea(AffineTransform t) It creates a new object that contains the same geometry as this Area transformed by the specified AffineTransform.
boolean equals(Area other) It tests whether the geometries of the two objects are equal.
void exclusiveOr(Area rhs) It sets the shape of this to be the combined area of its current shape and the shape of the specified Area, minus their intersection.
Rectangle getBounds() It returns a bounding that completely encloses this Area.
Rectangle2D getBounds2D() It returns a high precision bounding that completely encloses this Area.
PathIterator getPathIterator(AffineTransform at) It creates a for the outline of this Area object.
PathIterator getPathIterator(AffineTransform at, double flatness) It creates a for the flattened outline of this Area object.
void intersect(Area rhs) It sets the shape of this to the intersection of its current shape and the shape of the specified Area.
boolean intersects(double x, double y, double w, double h) It tests if the interior of the intersects the interior of a specified rectangular area.
boolean intersects(Rectangle2D r) It tests if the interior of the intersects the interior of a specified Rectangle2D.
boolean isEmpty() It tests whether this object encloses any area.
boolean isPolygonal() It tests whether this consists entirely of straight edged polygonal geometry.
boolean isRectangular() It tests whether this is rectangular in shape.
boolean isSingular() It tests whether this is comprised of a single closed subpath.
void reset() It removes all of the geometry from this and restores it to an empty area.
void subtract(Area rhs) It subtracts the shape of the specified from the shape of this Area.
void transform(AffineTransform t) It transforms the geometry of this using the specified .

This reference is belong to javadoc

Public Constructors

There is 2 types of public constructor is defined inside the class, Whose syntax as follows.

public java.awt.geom.Area()
public java.awt.geom.Area(java.awt.Shape)

Example of those constructors.

import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;
import java.awt.Shape;
public class Example 
{
    public static void main(String[] args) {
        
        Shape s = new Rectangle2D.Float(10.0f, 10.0f, 10.0f, 10.0f);
        // Create Instance
        Area a1 = new Area();
        Area a2 = new Area(s);
    }
}
Instance of java.awt.geom.Area class in java


Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment







© 2021, kalkicode.com, All rights reserved