Path2D class in java

java.awt.geom.Path2D is a class in java programming language. Inside of this class exists 28 public methods and 2 public variable which is access outside the package. Declaration of this class as follows.

public abstract class java.awt.geom.Path2D 
implements java.awt.Shape,java.lang.Cloneable 

Public Variable

There is following variables which is defined as public in (java.awt.geom.Path2D) java class.

WIND_EVEN_ODD;
WIND_NON_ZERO;

Lets see an example how to used of those variable.

// Instance variables java.awt.geom.Path2D
import java.awt.geom.Path2D;
class Example
{
    public static void main(String[] args)
    {
        System.out.println(Path2D.WIND_EVEN_ODD);
        System.out.println(Path2D.WIND_NON_ZERO);
    }
}
0
1

Path2D public method

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

MethodDescription
abstract void append(PathIterator pi, boolean connect) It appends the geometry of the specified object to the path, possibly connecting the new geometry to the existing path segments with a line segment.
void append(Shape s, boolean connect) It appends the geometry of the specified object to the path, possibly connecting the new geometry to the existing path segments with a line segment.
abstract Object clone() It creates a new object of the same class as this object.
void closePath() It closes the current subpath by drawing a straight line back to the coordinates of the last definition of insideness.
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.
static boolean contains(PathIterator pi, double x, double y) It tests if the specified coordinates are inside the closed boundary of the specified .
static boolean contains(PathIterator pi, double x, double y, double w, double h) It tests if the specified rectangular area is entirely inside the closed boundary of the specified .
static boolean contains(PathIterator pi, Point2D p) It tests if the specified is inside the closed boundary of the specified .
static boolean contains(PathIterator pi, Rectangle2D r) It tests if the specified is entirely inside the closed boundary of the specified .
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.
Shape createTransformedShape(AffineTransform at) It returns a new representing a transformed version of this Path2D.
abstract void curveTo(double x1, double y1, double x2, double y2, double x3, double y3) It adds a curved segment, defined by three new points, to the path by drawing a Bézier curve that intersects both the current coordinates and the specified coordinates , using the specified points (x1,y1) and (x2,y2) as Bézier control points.
Rectangle getBounds() It returns an integer that completely encloses the Shape.
Point2D getCurrentPoint() It returns the coordinates most recently added to the end of the path as a object.
PathIterator getPathIterator(AffineTransform at, double flatness) It returns an iterator object that iterates along the boundary and provides access to a flattened view of the Shape outline geometry.
int getWindingRule() It returns the fill style winding rule.
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.
static boolean intersects(PathIterator pi, double x, double y, double w, double h) It tests if the interior of the specified intersects the interior of a specified set of rectangular coordinates.
static boolean intersects(PathIterator pi, Rectangle2D r) It tests if the interior of the specified intersects the interior of a specified .
boolean intersects(Rectangle2D r) It tests if the interior of the intersects the interior of a specified Rectangle2D.
abstract void lineTo(double x, double y) It adds a point to the path by drawing a straight line from the current coordinates to the new specified coordinates specified in double precision.
abstract void moveTo(double x, double y) It adds a point to the path by moving to the specified coordinates specified in double precision.
abstract void quadTo(double x1, double y1, double x2, double y2) It adds a curved segment, defined by two new points, to the path by drawing a Quadratic curve that intersects both the current coordinates and the specified coordinates , using the specified point (x1,y1) as a quadratic parametric control point.
void reset() It resets the path to empty.
void setWindingRule(int rule) It sets the winding rule for this path to the specified value.
abstract void transform(AffineTransform at) It transforms the geometry of this path using the specified .

This reference is belong to javadoc

Path2D is abstract class, Variable of this class capable to hold the reference of subclass (Path2D.Double, Path2D.Float). For example.

java.awt.geom.Path2D.Double

import java.awt.geom.Path2D;
class Example
{
    public static void main(String[] args)
    {
        // Create Instance
        Path2D.Double p = new Path2D.Double();
        // Display result 
        System.out.println(p.getWindingRule());
    }
}
Path2D.Double instance
1

java.awt.geom.Path2D.Float

import java.awt.geom.Path2D;
class Example
{
    public static void main(String[] args)
    {
        // Create Instance
        Path2D.Double p = new Path2D.Float();
        // Display result 
        System.out.println(p.getWindingRule());
    }
}
Path2D.Float instance
1


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