public class Path extends java.lang.Object implements IGeometry
PrecisionUtils
) to compensate for rounding effects.Modifier and Type | Class and Description |
---|---|
static class |
Path.Segment
Representation for different types of
Path.Segment s. |
Modifier and Type | Field and Description |
---|---|
static int |
WIND_EVEN_ODD
Winding rule for determining the interior of the
Path . |
static int |
WIND_NON_ZERO
Winding rule for determining the interior of the
Path . |
Constructor and Description |
---|
Path()
Creates a new empty path with a default winding rule of
WIND_NON_ZERO . |
Path(int windingRule)
Creates a new empty path with given winding rule.
|
Path(int windingRule,
Path.Segment... segments)
Creates a path from the given segments, using the given winding rule.
|
Path(Path.Segment... segments)
Creates a path from the given segments, using the default winding rule
WIND_NON_ZERO . |
Modifier and Type | Method and Description |
---|---|
Path |
add(java.util.List<Path.Segment> segments)
|
Path |
add(Path.Segment... segments)
Adds the given
Path.Segment s to this Path . |
static Path |
add(Path pa,
Path pb)
Unions the two specified
Path s |
java.lang.Object |
clone()
Overridden with public visibility as recommended within
Cloneable
. |
Path |
close()
Closes the current sub-path by drawing a straight line (line-to) to the
location of the last move to.
|
boolean |
contains(Point p)
|
boolean |
contains(Rectangle r)
|
Path |
cubicTo(double control1X,
double control1Y,
double control2X,
double control2Y,
double x,
double y)
Adds a cubic Bezier curve segment from the current position to the
specified end position, using the two provided control points as Bezier
control points.
|
boolean |
equals(java.lang.Object obj) |
static Path |
exclusiveOr(Path pa,
Path pb)
Computes the area covered by the first or the second but not both given
areas.
|
Rectangle |
getBounds()
|
Path |
getCopy()
Returns a new identical copy of this
IGeometry . |
java.util.List<ICurve> |
getOutlines()
|
Path.Segment[] |
getSegments()
Returns the segments that make up this path.
|
Path |
getTransformed(AffineTransform t)
|
int |
getWindingRule()
Returns the winding rule used to determine the interior of this path.
|
int |
hashCode() |
static Path |
intersect(Path pa,
Path pb)
Intersects the given areas.
|
Path |
lineTo(double x,
double y)
Adds a straight line segment from the current position to the specified
end position.
|
Path |
moveTo(double x,
double y)
Changes the current position.
|
Path |
quadTo(double controlX,
double controlY,
double x,
double y)
Adds a quadratic curve segment from the current position to the specified
end position, using the provided control point as a parametric control
point.
|
Path |
reset()
Resets the path to be empty.
|
Path |
setWindingRule(int windingRule)
Sets the winding rule of this
Path to the passed-in integer
constant which is either of:
WIND_NON_ZERO (default)
WIND_EVEN_ODD
|
static Path |
subtract(Path pa,
Path pb)
Subtracts the second given area from the first given area.
|
Path |
toPath()
|
boolean |
touches(IGeometry g)
|
boolean |
touches(Rectangle r)
|
public static final int WIND_EVEN_ODD
Path
. Indicates
that a Point
is regarded to lie inside the Path
, if any
ray starting in that Point
and pointing to infinity crosses the
Path.Segment
s of the Path
an odd number of times.public static final int WIND_NON_ZERO
Path
. Indicates
that a Point
is regarded to lie inside the Path
, if any
ray starting from that Point
and pointing to infinity is crossed
by Path
Path.Segment
s a different number of times in the
counter-clockwise direction than in the clockwise direction.public Path()
WIND_NON_ZERO
.public Path(int windingRule)
windingRule
- the winding rule to use; one of WIND_EVEN_ODD
or
WIND_NON_ZERO
public Path(int windingRule, Path.Segment... segments)
windingRule
- the winding rule to use; one of WIND_EVEN_ODD
or
WIND_NON_ZERO
segments
- The segments to initialize the path withpublic Path(Path.Segment... segments)
WIND_NON_ZERO
.segments
- The segments to initialize the path withpublic static Path add(Path pa, Path pb)
Path
spa
- the first area to addpb
- the second area to addpublic static Path exclusiveOr(Path pa, Path pb)
pa
- the first area to compute the xor forpb
- the second area to compute the xor forpublic static Path intersect(Path pa, Path pb)
pa
- the first area to intersectpb
- the second area to intersectpublic static Path subtract(Path pa, Path pb)
pa
- the area to subtract frompb
- the area to subtractpublic final Path add(java.util.List<Path.Segment> segments)
segments
- The Path.Segment
s to add to this Path
.this
for convenience.public final Path add(Path.Segment... segments)
Path.Segment
s to this Path
.segments
- The Path.Segment
s to add to this Path
.this
for convenience.public final Path close()
this
for conveniencepublic boolean contains(Rectangle r)
public final Path cubicTo(double control1X, double control1Y, double control2X, double control2Y, double x, double y)
control1X
- The x-coordinate of the first Bezier control pointcontrol1Y
- The y-coordinate of the first Bezier control pointcontrol2X
- The x-coordinate of the second Bezier control pointcontrol2Y
- The y-coordinate of the second Bezier control pointx
- The x-coordinate of the desired target pointy
- The y-coordinate of the desired target pointthis
for conveniencepublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public Path getCopy()
IGeometry
IGeometry
.public java.util.List<ICurve> getOutlines()
List
of ICurve
s, representing the outline of
this
Path
. For every Path.Segment.LINE_TO
,
Path.Segment.QUAD_TO
, Path.Segment.CUBIC_TO
, and
Path.Segment.CLOSE
, one BezierCurve
is created that resembles
that segment.public Path.Segment[] getSegments()
Path.Segment
s representing the segments of this
pathpublic Path getTransformed(AffineTransform t)
Path
representation of this IGeometry
. Subclasses may override this
method to return a more specific representation.getTransformed
in interface IGeometry
t
- The AffineTransform
to be appliedPath
representation of this
IGeometry
public int getWindingRule()
WIND_EVEN_ODD
or
WIND_NON_ZERO
public final Path lineTo(double x, double y)
x
- The x-coordinate of the desired target pointy
- The y-coordinate of the desired target pointthis
for conveniencepublic final Path moveTo(double x, double y)
Path.Segment
of type
Path.Segment.MOVE_TO
is added to this Path.x
- The x-coordinate of the desired target pointy
- The y-coordinate of the desired target pointthis
for conveniencepublic final Path quadTo(double controlX, double controlY, double x, double y)
controlX
- The x-coordinate of the control pointcontrolY
- The y-coordinate of the control pointx
- The x-coordinate of the desired target pointy
- The y-coordinate of the desired target pointthis
for conveniencepublic final Path reset()
this
for conveniencepublic Path setWindingRule(int windingRule)
Path
to the passed-in integer
constant which is either of:
WIND_NON_ZERO
(default)WIND_EVEN_ODD
windingRule
- the new winding rule of this Path
this
for conveniencepublic Path toPath()
IGeometry
toPath
in interface IGeometry
Path
representation for this IGeometry
.IGeometry.toPath()
public boolean touches(Rectangle r)
public java.lang.Object clone()
Cloneable
.clone
in class java.lang.Object
public final int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
Copyright (c) 2014 itemis AG, and others. All rights reserved.