Package org.eclipse.gef.geometry.planar
Class Path
java.lang.Object
org.eclipse.gef.geometry.planar.Path
- All Implemented Interfaces:
Serializable
,Cloneable
,IGeometry
Represents the geometric shape of a path, which may consist of independent
subgraphs.
Note that while all manipulations (e.g. within shrink, expand) within this
class are based on double precision, all comparisons (e.g. within contains,
intersects, equals, etc.) are based on a limited precision (with an accuracy
defined within
PrecisionUtils
) to compensate for rounding effects.- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Representation for different types ofPath.Segment
s. -
Field Summary
-
Constructor Summary
ConstructorDescriptionPath()
Creates a new empty path with a default winding rule ofWIND_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 ruleWIND_NON_ZERO
. -
Method Summary
Modifier and TypeMethodDescriptionfinal Path
add
(List<Path.Segment> segments) final Path
add
(Path.Segment... segments) Adds the givenPath.Segment
s to thisPath
.static Path
Unions the two specifiedPath
sclone()
Overridden with public visibility as recommended withinCloneable
.final Path
close()
Closes the current sub-path by drawing a straight line (line-to) to the location of the last move to.boolean
boolean
final 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
static Path
exclusiveOr
(Path pa, Path pb) Computes the area covered by the first or the second but not both given areas.getCopy()
Returns a new identical copy of thisIGeometry
.Returns the segments that make up this path.int
Returns the winding rule used to determine the interior of this path.final int
hashCode()
static Path
Intersects the given areas.final Path
lineTo
(double x, double y) Adds a straight line segment from the current position to the specified end position.final Path
moveTo
(double x, double y) Changes the current position.final 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.final Path
reset()
Resets the path to be empty.setWindingRule
(int windingRule) Sets the winding rule of thisPath
to the passed-in integer constant which is either of:WIND_NON_ZERO
(default)WIND_EVEN_ODD
static Path
Subtracts the second given area from the first given area.toPath()
boolean
boolean
-
Field Details
-
WIND_EVEN_ODD
public static final int WIND_EVEN_ODDWinding rule for determining the interior of thePath
. Indicates that aPoint
is regarded to lie inside thePath
, if any ray starting in thatPoint
and pointing to infinity crosses thePath.Segment
s of thePath
an odd number of times.- See Also:
-
WIND_NON_ZERO
public static final int WIND_NON_ZEROWinding rule for determining the interior of thePath
. Indicates that aPoint
is regarded to lie inside thePath
, if any ray starting from thatPoint
and pointing to infinity is crossed byPath
Path.Segment
s a different number of times in the counter-clockwise direction than in the clockwise direction.- See Also:
-
-
Constructor Details
-
Path
public Path()Creates a new empty path with a default winding rule ofWIND_NON_ZERO
. -
Path
public Path(int windingRule) Creates a new empty path with given winding rule.- Parameters:
windingRule
- the winding rule to use; one ofWIND_EVEN_ODD
orWIND_NON_ZERO
-
Path
Creates a path from the given segments, using the given winding rule.- Parameters:
windingRule
- the winding rule to use; one ofWIND_EVEN_ODD
orWIND_NON_ZERO
segments
- The segments to initialize the path with
-
Path
Creates a path from the given segments, using the default winding ruleWIND_NON_ZERO
.- Parameters:
segments
- The segments to initialize the path with
-
-
Method Details
-
add
Unions the two specifiedPath
s- Parameters:
pa
- the first area to addpb
- the second area to add- Returns:
- the sum of the areas
-
exclusiveOr
Computes the area covered by the first or the second but not both given areas.- Parameters:
pa
- the first area to compute the xor forpb
- the second area to compute the xor for- Returns:
- the exclusive-or of the areas
-
intersect
Intersects the given areas.- Parameters:
pa
- the first area to intersectpb
- the second area to intersect- Returns:
- the intersection of the areas, i.e. the area covered by both areas
-
subtract
Subtracts the second given area from the first given area.- Parameters:
pa
- the area to subtract frompb
- the area to subtract- Returns:
- the area covered by the first but not the second given area
-
add
- Parameters:
segments
- ThePath.Segment
s to add to thisPath
.- Returns:
this
for convenience.
-
add
Adds the givenPath.Segment
s to thisPath
.- Parameters:
segments
- ThePath.Segment
s to add to thisPath
.- Returns:
this
for convenience.
-
close
Closes the current sub-path by drawing a straight line (line-to) to the location of the last move to.- Returns:
this
for convenience
-
contains
Description copied from interface:IGeometry
-
contains
-
cubicTo
public final 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.- Parameters:
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 point- Returns:
this
for convenience
-
equals
-
getBounds
Description copied from interface:IGeometry
-
getCopy
Description copied from interface:IGeometry
Returns a new identical copy of thisIGeometry
. -
getOutlines
Returns aList
ofICurve
s, representing the outline ofthis
Path
. For everyPath.Segment.LINE_TO
,Path.Segment.QUAD_TO
,Path.Segment.CUBIC_TO
, andPath.Segment.CLOSE
, oneBezierCurve
is created that resembles that segment. -
getSegments
Returns the segments that make up this path.- Returns:
- an array of
Path.Segment
s representing the segments of this path
-
getTransformed
Default implementation returning a transformedPath
representation of thisIGeometry
. Subclasses may override this method to return a more specific representation.- Specified by:
getTransformed
in interfaceIGeometry
- Parameters:
t
- TheAffineTransform
to be applied- Returns:
- a transformed
Path
representation of thisIGeometry
-
getWindingRule
public int getWindingRule()Returns the winding rule used to determine the interior of this path.- Returns:
- the winding rule, i.e. one of
WIND_EVEN_ODD
orWIND_NON_ZERO
-
lineTo
Adds a straight line segment from the current position to the specified end position.- Parameters:
x
- The x-coordinate of the desired target pointy
- The y-coordinate of the desired target point- Returns:
this
for convenience
-
moveTo
Changes the current position. A newPath.Segment
of typePath.Segment.MOVE_TO
is added to this Path.- Parameters:
x
- The x-coordinate of the desired target pointy
- The y-coordinate of the desired target point- Returns:
this
for convenience
-
quadTo
Adds a quadratic curve segment from the current position to the specified end position, using the provided control point as a parametric control point.- Parameters:
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 point- Returns:
this
for convenience
-
reset
Resets the path to be empty.- Returns:
this
for convenience
-
setWindingRule
Sets the winding rule of thisPath
to the passed-in integer constant which is either of:WIND_NON_ZERO
(default)WIND_EVEN_ODD
- Parameters:
windingRule
- the new winding rule of thisPath
- Returns:
this
for convenience
-
toPath
Description copied from interface:IGeometry
-
touches
-
clone
Overridden with public visibility as recommended withinCloneable
. -
hashCode
public final int hashCode() -
touches
Description copied from interface:IGeometry
-