Package org.gvsig.fmap.geom.jts.gputils
Class DefaultGeneralPathX
java.lang.Object
org.gvsig.fmap.geom.primitive.GeneralPathX
org.gvsig.fmap.geom.jts.gputils.DefaultGeneralPathX
- All Implemented Interfaces:
Shape,Serializable,Cloneable,org.gvsig.fmap.geom.primitive.IGeneralPathX
public class DefaultGeneralPathX
extends org.gvsig.fmap.geom.primitive.GeneralPathX
implements Shape, Cloneable, Serializable
The
GeneralPathX class represents a geometric path
constructed from straight lines, and quadratic and cubic
(Bézier) curves. It can contain multiple subpaths.
The winding rule specifies how the interior of a path is determined. There are two types of winding rules: EVEN_ODD and NON_ZERO.
An EVEN_ODD winding rule means that enclosed regions of the path alternate between interior and exterior areas as traversed from the outside of the path towards a point inside the region.
A NON_ZERO winding rule means that if a ray is drawn in any direction from a given point to infinity and the places where the path intersects the ray are examined, the point is inside of the path if and only if the number of times that the path crosses the ray from left to right does not equal the number of times that the path crosses the ray from right to left.
- Version:
- 1.58, 01/23/03
- Author:
- Jim Graham
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static org.gvsig.fmap.geom.GeometryManagerFields inherited from class org.gvsig.fmap.geom.primitive.GeneralPathX
INIT_SIZEFields inherited from interface org.gvsig.fmap.geom.primitive.IGeneralPathX
curvesize, SEG_CLOSE, SEG_CUBICTO, SEG_LINETO, SEG_MOVETO, SEG_QUADTO, WIND_EVEN_ODD, WIND_NON_ZERO -
Constructor Summary
ConstructorsConstructorDescriptionDefaultGeneralPathX(int rule) Constructs a newGeneralPathXobject with the specified winding rule to control operations that require the interior of the path to be defined.DefaultGeneralPathX(PathIterator piter, boolean is2Dz, double zValue) DefaultGeneralPathX(PathIterator piter, boolean is2Dz, double zValue, int capacity) Constructs a newGeneralPathXobject from an arbitraryShapeobject. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSegment(org.gvsig.fmap.geom.primitive.Point[] segment) voidappend(PathIterator pi, boolean connect) Appends the geometry of the specifiedPathIteratorobject to the path, possibly connecting the new geometry to the existing path segments with a line segment.voidappend(org.gvsig.fmap.geom.primitive.GeneralPathX gp) clone()Creates a new object of the same class as this object.voidCloses the current subpath by drawing a straight line back to the coordinates of the lastmoveTo.booleancontains(double x, double y) Tests if the specified coordinates are inside the boundary of thisShape.booleancontains(double x, double y, double w, double h) Tests if the specified rectangular area is inside the boundary of thisShape.booleanTests if the specifiedPoint2Dis inside the boundary of thisShape.booleanTests if the specifiedRectangle2Dis inside the boundary of thisShape.Returns a new transformedShape.voidcurveTo(double x1, double y1, double x2, double y2, double x3, double y3) 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 coordinates (x3, y3), using the specified points (x1, y1) and (x2, y2) as Bézier control points.voidcurveTo(org.gvsig.fmap.geom.primitive.Point point1, org.gvsig.fmap.geom.primitive.Point point2, org.gvsig.fmap.geom.primitive.Point point3) voidensureCapacity(int capacity) voidflip()Convertimos el path a puntos y luego le damos la vuelta.double[]get3DCoordinatesAt(int index) Return the bounding box of the path.Returns the bounding box of the path.double[]getCoordinatesAt(int index) Returns the coordinates most recently added to the end of the path as aPoint2Dobject.intintReturns aPathIteratorobject that iterates along the boundary of thisShapeand provides access to the geometry of the outline of thisShape.getPathIterator(AffineTransform at, double flatness) Returns aPathIteratorobject that iterates along the boundary of the flattenedShapeand provides access to the geometry of the outline of theShape.org.gvsig.fmap.geom.primitive.PointgetPointAt(int index) double[]byte[]bytegetTypeAt(int index) intReturns the fill style winding rule.booleanintersects(double x, double y, double w, double h) Tests if the interior of thisShapeintersects the interior of a specified set of rectangular coordinates.booleanTests if the interior of thisShapeintersects the interior of a specifiedRectangle2D.booleanisCCW()Check if the first part is CCW.booleanisClosed()Check if the first part is closed.booleanisSimple()voidlineTo(double x, double y) Adds a point to the path by drawing a straight line from the current coordinates to the new specified coordinates.voidlineTo(org.gvsig.fmap.geom.primitive.Point point) voidmoveTo(double x, double y) Adds a point to the path by moving to the specified coordinates.voidmoveTo(org.gvsig.fmap.geom.primitive.Point point) voidquadTo(double x1, double y1, double x2, double y2) 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 coordinates (x2, y2), using the specified point (x1, y1) as a quadratic parametric control point.voidquadTo(org.gvsig.fmap.geom.primitive.Point point1, org.gvsig.fmap.geom.primitive.Point point2) voidreProject(org.gvsig.crs.projection.lib.CoordinateTransformation ct) voidreset()Resets the path to empty.intsetNumCoords(int numCoords) voidsetNumTypes(int numTypes) voidsetPointCoords(double[] pointCoords) voidsetPointTypes(byte[] pointTypes) voidsetWindingRule(int rule) Sets the winding rule for this path to the specified value.voidTransforms the geometry of this path using the specifiedAffineTransform.
-
Field Details
-
geomManager
protected static org.gvsig.fmap.geom.GeometryManager geomManager
-
-
Constructor Details
-
DefaultGeneralPathX
public DefaultGeneralPathX(int rule) Constructs a newGeneralPathXobject with the specified winding rule to control operations that require the interior of the path to be defined.- Parameters:
rule- the winding rule- See Also:
-
DefaultGeneralPathX
-
DefaultGeneralPathX
Constructs a newGeneralPathXobject from an arbitraryShapeobject. All of the initial geometry and the winding rule for this path are taken from the specifiedShapeobject.- Parameters:
piter-is2Dz-zValue-capacity-
-
-
Method Details
-
moveTo
public void moveTo(double x, double y) Adds a point to the path by moving to the specified coordinates.- Specified by:
moveToin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
moveToin classorg.gvsig.fmap.geom.primitive.GeneralPathX- Parameters:
x- , y the specified coordinates
-
moveTo
public void moveTo(org.gvsig.fmap.geom.primitive.Point point) - Specified by:
moveToin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
moveToin classorg.gvsig.fmap.geom.primitive.GeneralPathX
-
lineTo
public void lineTo(double x, double y) Adds a point to the path by drawing a straight line from the current coordinates to the new specified coordinates.- Specified by:
lineToin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
lineToin classorg.gvsig.fmap.geom.primitive.GeneralPathX- Parameters:
x- , y the specified coordinates
-
lineTo
public void lineTo(org.gvsig.fmap.geom.primitive.Point point) - Specified by:
lineToin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
lineToin classorg.gvsig.fmap.geom.primitive.GeneralPathX
-
addSegment
public void addSegment(org.gvsig.fmap.geom.primitive.Point[] segment) - Specified by:
addSegmentin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
addSegmentin classorg.gvsig.fmap.geom.primitive.GeneralPathX
-
quadTo
public void quadTo(double x1, double y1, double x2, double y2) 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 coordinates (x2, y2), using the specified point (x1, y1) as a quadratic parametric control point.- Specified by:
quadToin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
quadToin classorg.gvsig.fmap.geom.primitive.GeneralPathX- Parameters:
x1- , y1 the coordinates of the first quadratic control pointy1-x2- , y2 the coordinates of the final endpointy2-
-
quadTo
public void quadTo(org.gvsig.fmap.geom.primitive.Point point1, org.gvsig.fmap.geom.primitive.Point point2) - Specified by:
quadToin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
quadToin classorg.gvsig.fmap.geom.primitive.GeneralPathX
-
curveTo
public void curveTo(double x1, double y1, double x2, double y2, double x3, double y3) 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 coordinates (x3, y3), using the specified points (x1, y1) and (x2, y2) as Bézier control points.- Specified by:
curveToin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
curveToin classorg.gvsig.fmap.geom.primitive.GeneralPathX- Parameters:
x1- , y1 the coordinates of the first Béezier control pointy1-x2- , y2 the coordinates of the second Bézier control pointy2-x3- , y3 the coordinates of the final endpointy3-
-
curveTo
public void curveTo(org.gvsig.fmap.geom.primitive.Point point1, org.gvsig.fmap.geom.primitive.Point point2, org.gvsig.fmap.geom.primitive.Point point3) - Specified by:
curveToin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
curveToin classorg.gvsig.fmap.geom.primitive.GeneralPathX
-
closePath
public void closePath()Closes the current subpath by drawing a straight line back to the coordinates of the lastmoveTo. If the path is already closed then this method has no effect.- Specified by:
closePathin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
closePathin classorg.gvsig.fmap.geom.primitive.GeneralPathX
-
isClosed
public boolean isClosed()Check if the first part is closed.- Specified by:
isClosedin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
isClosedin classorg.gvsig.fmap.geom.primitive.GeneralPathX- Returns:
-
append
Appends the geometry of the specifiedPathIteratorobject to the path, possibly connecting the new geometry to the existing path segments with a line segment. If theconnectparameter istrueand the path is not empty then any initialmoveToin the geometry of the appendedShapeis turned into alineTosegment. If the destination coordinates of such a connectinglineTosegment match the ending coordinates of a currently open subpath then the segment is omitted as superfluous. The winding rule of the specifiedShapeis ignored and the appended geometry is governed by the winding rule specified for this path.- Specified by:
appendin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
appendin classorg.gvsig.fmap.geom.primitive.GeneralPathX- Parameters:
pi- thePathIteratorwhose geometry is appended to this pathconnect- a boolean to control whether or not to turn an initialmoveTosegment into alineTosegment to connect the new geometry to the existing path
-
append
public void append(org.gvsig.fmap.geom.primitive.GeneralPathX gp) - Specified by:
appendin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
appendin classorg.gvsig.fmap.geom.primitive.GeneralPathX
-
getWindingRule
public int getWindingRule()Returns the fill style winding rule.- Specified by:
getWindingRulein interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
getWindingRulein classorg.gvsig.fmap.geom.primitive.GeneralPathX- Returns:
- an integer representing the current winding rule.
- See Also:
-
setWindingRule
public void setWindingRule(int rule) Sets the winding rule for this path to the specified value.- Specified by:
setWindingRulein interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
setWindingRulein classorg.gvsig.fmap.geom.primitive.GeneralPathX- Parameters:
rule- an integer representing the specified winding rule- See Also:
-
getCurrentPoint
Returns the coordinates most recently added to the end of the path as aPoint2Dobject.- Specified by:
getCurrentPointin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
getCurrentPointin classorg.gvsig.fmap.geom.primitive.GeneralPathX- Returns:
- a
Point2Dobject containing the ending coordinates of the path ornullif there are no points in the path.
-
reset
public void reset()Resets the path to empty. The append position is set back to the beginning of the path and all coordinates and point types are forgotten.- Specified by:
resetin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
resetin classorg.gvsig.fmap.geom.primitive.GeneralPathX
-
transform
Transforms the geometry of this path using the specifiedAffineTransform. The geometry is transformed in place, which permanently changes the boundary defined by this object.- Specified by:
transformin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
transformin classorg.gvsig.fmap.geom.primitive.GeneralPathX- Parameters:
at- theAffineTransformused to transform the area
-
reProject
public void reProject(org.gvsig.crs.projection.lib.CoordinateTransformation ct) - Specified by:
reProjectin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
reProjectin classorg.gvsig.fmap.geom.primitive.GeneralPathX
-
createTransformedShape
Returns a new transformedShape.- Specified by:
createTransformedShapein interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
createTransformedShapein classorg.gvsig.fmap.geom.primitive.GeneralPathX- Parameters:
at- theAffineTransformused to transform a newShape.- Returns:
- a new
Shape, transformed with the specifiedAffineTransform.
-
getBounds
Return the bounding box of the path. -
getBounds2D
Returns the bounding box of the path.- Specified by:
getBounds2Din interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Specified by:
getBounds2Din interfaceShape- Overrides:
getBounds2Din classorg.gvsig.fmap.geom.primitive.GeneralPathX- Returns:
- a
Rectangle2Dobject that bounds the current path.
-
contains
public boolean contains(double x, double y) Tests if the specified coordinates are inside the boundary of thisShape.- Specified by:
containsin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Specified by:
containsin interfaceShape- Overrides:
containsin classorg.gvsig.fmap.geom.primitive.GeneralPathX- Parameters:
x- , y the specified coordinates- Returns:
trueif the specified coordinates are inside thisShape;falseotherwise
-
contains
Tests if the specifiedPoint2Dis inside the boundary of thisShape.- Specified by:
containsin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Specified by:
containsin interfaceShape- Overrides:
containsin classorg.gvsig.fmap.geom.primitive.GeneralPathX- Parameters:
p- the specifiedPoint2D- Returns:
trueif thisShapecontains the specifiedPoint2D,falseotherwise.
-
contains
public boolean contains(double x, double y, double w, double h) Tests if the specified rectangular area is inside the boundary of thisShape.- Specified by:
containsin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Specified by:
containsin interfaceShape- Overrides:
containsin classorg.gvsig.fmap.geom.primitive.GeneralPathX- Parameters:
x- , y the specified coordinatesy-w- the width of the specified rectangular areah- the height of the specified rectangular area- Returns:
trueif thisShapecontains the specified rectangluar area;falseotherwise.
-
contains
Tests if the specifiedRectangle2Dis inside the boundary of thisShape.- Specified by:
containsin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Specified by:
containsin interfaceShape- Overrides:
containsin classorg.gvsig.fmap.geom.primitive.GeneralPathX- Parameters:
r- a specifiedRectangle2D- Returns:
trueif thisShapebounds the specifiedRectangle2D;falseotherwise.
-
intersects
public boolean intersects(double x, double y, double w, double h) Tests if the interior of thisShapeintersects the interior of a specified set of rectangular coordinates.- Specified by:
intersectsin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Specified by:
intersectsin interfaceShape- Overrides:
intersectsin classorg.gvsig.fmap.geom.primitive.GeneralPathX- Parameters:
x- , y the specified coordinatesy-w- the width of the specified rectangular coordinatesh- the height of the specified rectangular coordinates- Returns:
trueif thisShapeand the interior of the specified set of rectangular coordinates intersect each other;falseotherwise.
-
intersects
Tests if the interior of thisShapeintersects the interior of a specifiedRectangle2D.- Specified by:
intersectsin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Specified by:
intersectsin interfaceShape- Overrides:
intersectsin classorg.gvsig.fmap.geom.primitive.GeneralPathX- Parameters:
r- the specifiedRectangle2D- Returns:
trueif thisShapeand the interior of the specifiedRectangle2Dintersect each other;falseotherwise.
-
getPathIterator
Returns aPathIteratorobject that iterates along the boundary of thisShapeand provides access to the geometry of the outline of thisShape. The iterator for this class is not multi-threaded safe, which means that thisGeneralPathXclass does not guarantee that modifications to the geometry of thisGeneralPathXobject do not affect any iterations of that geometry that are already in process.- Specified by:
getPathIteratorin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Specified by:
getPathIteratorin interfaceShape- Overrides:
getPathIteratorin classorg.gvsig.fmap.geom.primitive.GeneralPathX- Parameters:
at- anAffineTransform- Returns:
- a new
PathIteratorthat iterates along the boundary of thisShapeand provides access to the geometry of thisShape's outline
-
getPathIterator
Returns aPathIteratorobject that iterates along the boundary of the flattenedShapeand provides access to the geometry of the outline of theShape. The iterator for this class is not multi-threaded safe, which means that thisGeneralPathXclass does not guarantee that modifications to the geometry of thisGeneralPathXobject do not affect any iterations of that geometry that are already in process.- Specified by:
getPathIteratorin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Specified by:
getPathIteratorin interfaceShape- Overrides:
getPathIteratorin classorg.gvsig.fmap.geom.primitive.GeneralPathX- Parameters:
at- anAffineTransformflatness- the maximum distance that the line segments used to approximate the curved segments are allowed to deviate from any point on the original curve- Returns:
- a new
PathIteratorthat iterates along the flattenedShapeboundary.
-
clone
Creates a new object of the same class as this object.- Specified by:
clonein interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
clonein classorg.gvsig.fmap.geom.primitive.GeneralPathX- Returns:
- a clone of this instance.
- Throws:
OutOfMemoryError- if there is not enough memory.- Since:
- 1.2
- See Also:
-
setNumTypes
public void setNumTypes(int numTypes) - Specified by:
setNumTypesin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
setNumTypesin classorg.gvsig.fmap.geom.primitive.GeneralPathX
-
getNumTypes
public int getNumTypes()- Specified by:
getNumTypesin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
getNumTypesin classorg.gvsig.fmap.geom.primitive.GeneralPathX
-
setNumCoords
public int setNumCoords(int numCoords) - Specified by:
setNumCoordsin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
setNumCoordsin classorg.gvsig.fmap.geom.primitive.GeneralPathX
-
getNumCoords
public int getNumCoords()- Specified by:
getNumCoordsin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
getNumCoordsin classorg.gvsig.fmap.geom.primitive.GeneralPathX
-
getTypeAt
public byte getTypeAt(int index) - Specified by:
getTypeAtin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
getTypeAtin classorg.gvsig.fmap.geom.primitive.GeneralPathX
-
setPointTypes
public void setPointTypes(byte[] pointTypes) - Specified by:
setPointTypesin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
setPointTypesin classorg.gvsig.fmap.geom.primitive.GeneralPathX
-
getPointTypes
public byte[] getPointTypes()- Specified by:
getPointTypesin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
getPointTypesin classorg.gvsig.fmap.geom.primitive.GeneralPathX
-
setPointCoords
public void setPointCoords(double[] pointCoords) - Specified by:
setPointCoordsin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
setPointCoordsin classorg.gvsig.fmap.geom.primitive.GeneralPathX- Parameters:
pointCoords-
-
getPointCoords
public double[] getPointCoords()- Specified by:
getPointCoordsin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
getPointCoordsin classorg.gvsig.fmap.geom.primitive.GeneralPathX- Returns:
-
getPointAt
public org.gvsig.fmap.geom.primitive.Point getPointAt(int index) - Specified by:
getPointAtin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
getPointAtin classorg.gvsig.fmap.geom.primitive.GeneralPathX
-
getCoordinatesAt
public double[] getCoordinatesAt(int index) - Specified by:
getCoordinatesAtin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
getCoordinatesAtin classorg.gvsig.fmap.geom.primitive.GeneralPathX
-
get3DCoordinatesAt
public double[] get3DCoordinatesAt(int index) - Specified by:
get3DCoordinatesAtin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
get3DCoordinatesAtin classorg.gvsig.fmap.geom.primitive.GeneralPathX
-
flip
public void flip()Convertimos el path a puntos y luego le damos la vuelta.- Specified by:
flipin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
flipin classorg.gvsig.fmap.geom.primitive.GeneralPathX
-
isCCW
public boolean isCCW()Check if the first part is CCW.- Specified by:
isCCWin interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
isCCWin classorg.gvsig.fmap.geom.primitive.GeneralPathX- Returns:
-
isSimple
public boolean isSimple()- Specified by:
isSimplein interfaceorg.gvsig.fmap.geom.primitive.IGeneralPathX- Overrides:
isSimplein classorg.gvsig.fmap.geom.primitive.GeneralPathX- Returns:
- the isSimple
-
ensureCapacity
public void ensureCapacity(int capacity)
-