Package org.apache.batik.ext.awt.geom
Class ExtendedGeneralPath
- java.lang.Object
-
- org.apache.batik.ext.awt.geom.ExtendedGeneralPath
-
- All Implemented Interfaces:
java.awt.Shape,java.lang.Cloneable,ExtendedShape
public class ExtendedGeneralPath extends java.lang.Object implements ExtendedShape, java.lang.Cloneable
TheExtendedGeneralPathclass represents a geometric path constructed from straight lines, quadratic and cubic (Bezier) curves and elliptical arc. This class delegates lines and curves to an enclosedGeneralPath. Elliptical arc is implemented using anArc2Din float precision.Warning : An elliptical arc may be composed of several path segments. For futher details, see the SVG Appendix F.6
- Version:
- $Id: ExtendedGeneralPath.java 1733416 2016-03-03 07:07:13Z gadams $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classExtendedGeneralPath.EPI
-
Field Summary
Fields Modifier and Type Field Description (package private) floatcx(package private) floatcy(package private) floatmx(package private) floatmy(package private) intnumSeg(package private) intnumValsprotected java.awt.geom.GeneralPathpathThe enclosed general path.(package private) int[]types(package private) float[]values
-
Constructor Summary
Constructors Constructor Description ExtendedGeneralPath()Constructs a newExtendedGeneralPath.ExtendedGeneralPath(int rule)Constructs a newExtendedGeneralPathwith the specified winding rule to control operations that require the interior of the path to be defined.ExtendedGeneralPath(int rule, int initialCapacity)Constructs a newExtendedGeneralPathobject with the specified winding rule and the specified initial capacity to store path coordinates.ExtendedGeneralPath(java.awt.Shape s)Constructs a newExtendedGeneralPathobject from an arbitraryShapeobject.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappend(java.awt.geom.PathIterator pi, boolean connect)Delegates to the enclosedGeneralPath.voidappend(java.awt.Shape s, boolean connect)Delegates to the enclosedGeneralPath.voidappend(ExtendedPathIterator epi, boolean connect)Delegates to the enclosedGeneralPath.voidarcTo(float rx, float ry, float angle, boolean largeArcFlag, boolean sweepFlag, float x, float y)Adds an elliptical arc, defined by two radii, an angle from the x-axis, a flag to choose the large arc or not, a flag to indicate if we increase or decrease the angles and the final point of the arc.protected voidcheckMoveTo()Checks if previous command was a moveto command, skipping a close command (if present).java.lang.Objectclone()Delegates to the enclosedGeneralPath.voidclosePath()Delegates to the enclosedGeneralPath.static java.awt.geom.Arc2DcomputeArc(double x0, double y0, double rx, double ry, double angle, boolean largeArcFlag, boolean sweepFlag, double x, double y)This constructs an unrotated Arc2D from the SVG specification of an Elliptical arc.booleancontains(double x, double y)Delegates to the enclosedGeneralPath.booleancontains(double x, double y, double w, double h)Delegates to the enclosedGeneralPath.booleancontains(java.awt.geom.Point2D p)Delegates to the enclosedGeneralPath.booleancontains(java.awt.geom.Rectangle2D r)Delegates to the enclosedGeneralPath.java.awt.ShapecreateTransformedShape(java.awt.geom.AffineTransform at)Delegates to the enclosedGeneralPath.voidcurveTo(float x1, float y1, float x2, float y2, float x3, float y3)Delegates to the enclosedGeneralPath.java.awt.RectanglegetBounds()Delegates to the enclosedGeneralPath.java.awt.geom.Rectangle2DgetBounds2D()Delegates to the enclosedGeneralPath.java.awt.geom.Point2DgetCurrentPoint()get the current position ornull.ExtendedPathIteratorgetExtendedPathIterator()Delegates to the enclosedGeneralPath.java.awt.geom.PathIteratorgetPathIterator(java.awt.geom.AffineTransform at)Delegates to the enclosedGeneralPath.java.awt.geom.PathIteratorgetPathIterator(java.awt.geom.AffineTransform at, double flatness)Delegates to the enclosedGeneralPath.intgetWindingRule()Delegates to the enclosedGeneralPath.booleanintersects(double x, double y, double w, double h)Delegates to the enclosedGeneralPath.booleanintersects(java.awt.geom.Rectangle2D r)Delegates to the enclosedGeneralPath.voidlineTo(float x, float y)Delegates to the enclosedGeneralPath.private voidmakeRoom(int numValues)Make sure, that the requested number of slots in vales[] are available.voidmoveTo(float x, float y)Delegates to the enclosedGeneralPath.voidquadTo(float x1, float y1, float x2, float y2)Delegates to the enclosedGeneralPath.voidreset()Delegates to the enclosedGeneralPath.voidsetWindingRule(int rule)Delegates to the enclosedGeneralPath.voidtransform(java.awt.geom.AffineTransform at)Delegates to the enclosedGeneralPath.
-
-
-
Constructor Detail
-
ExtendedGeneralPath
public ExtendedGeneralPath()
Constructs a newExtendedGeneralPath.
-
ExtendedGeneralPath
public ExtendedGeneralPath(int rule)
Constructs a newExtendedGeneralPathwith the specified winding rule to control operations that require the interior of the path to be defined.
-
ExtendedGeneralPath
public ExtendedGeneralPath(int rule, int initialCapacity)Constructs a newExtendedGeneralPathobject with the specified winding rule and the specified initial capacity to store path coordinates.
-
ExtendedGeneralPath
public ExtendedGeneralPath(java.awt.Shape s)
Constructs a newExtendedGeneralPathobject from an arbitraryShapeobject.
-
-
Method Detail
-
arcTo
public void arcTo(float rx, float ry, float angle, boolean largeArcFlag, boolean sweepFlag, float x, float y)Adds an elliptical arc, defined by two radii, an angle from the x-axis, a flag to choose the large arc or not, a flag to indicate if we increase or decrease the angles and the final point of the arc.- Parameters:
rx- the x radius of the ellipsery- the y radius of the ellipseangle- the angle from the x-axis of the current coordinate system to the x-axis of the ellipse in degrees.largeArcFlag- the large arc flag. If true the arc spanning less than or equal to 180 degrees is chosen, otherwise the arc spanning greater than 180 degrees is chosensweepFlag- the sweep flag. If true the line joining center to arc sweeps through decreasing angles otherwise it sweeps through increasing anglesx- the absolute x coordinate of the final point of the arc.y- the absolute y coordinate of the final point of the arc.
-
computeArc
public static java.awt.geom.Arc2D computeArc(double x0, double y0, double rx, double ry, double angle, boolean largeArcFlag, boolean sweepFlag, double x, double y)This constructs an unrotated Arc2D from the SVG specification of an Elliptical arc. To get the final arc you need to apply a rotation transform such as: AffineTransform.getRotateInstance (angle, arc.getX()+arc.getWidth()/2, arc.getY()+arc.getHeight()/2);
-
moveTo
public void moveTo(float x, float y)Delegates to the enclosedGeneralPath.
-
lineTo
public void lineTo(float x, float y)Delegates to the enclosedGeneralPath.
-
quadTo
public void quadTo(float x1, float y1, float x2, float y2)Delegates to the enclosedGeneralPath.
-
curveTo
public void curveTo(float x1, float y1, float x2, float y2, float x3, float y3)Delegates to the enclosedGeneralPath.
-
closePath
public void closePath()
Delegates to the enclosedGeneralPath.
-
checkMoveTo
protected void checkMoveTo()
Checks if previous command was a moveto command, skipping a close command (if present).
-
append
public void append(java.awt.Shape s, boolean connect)Delegates to the enclosedGeneralPath.
-
append
public void append(java.awt.geom.PathIterator pi, boolean connect)Delegates to the enclosedGeneralPath.
-
append
public void append(ExtendedPathIterator epi, boolean connect)
Delegates to the enclosedGeneralPath.
-
getWindingRule
public int getWindingRule()
Delegates to the enclosedGeneralPath.
-
setWindingRule
public void setWindingRule(int rule)
Delegates to the enclosedGeneralPath.
-
getCurrentPoint
public java.awt.geom.Point2D getCurrentPoint()
get the current position ornull.
-
reset
public void reset()
Delegates to the enclosedGeneralPath.
-
transform
public void transform(java.awt.geom.AffineTransform at)
Delegates to the enclosedGeneralPath.
-
createTransformedShape
public java.awt.Shape createTransformedShape(java.awt.geom.AffineTransform at)
Delegates to the enclosedGeneralPath.
-
getBounds
public java.awt.Rectangle getBounds()
Delegates to the enclosedGeneralPath.- Specified by:
getBoundsin interfacejava.awt.Shape
-
getBounds2D
public java.awt.geom.Rectangle2D getBounds2D()
Delegates to the enclosedGeneralPath.- Specified by:
getBounds2Din interfacejava.awt.Shape
-
contains
public boolean contains(double x, double y)Delegates to the enclosedGeneralPath.- Specified by:
containsin interfacejava.awt.Shape
-
contains
public boolean contains(java.awt.geom.Point2D p)
Delegates to the enclosedGeneralPath.- Specified by:
containsin interfacejava.awt.Shape
-
contains
public boolean contains(double x, double y, double w, double h)Delegates to the enclosedGeneralPath.- Specified by:
containsin interfacejava.awt.Shape
-
contains
public boolean contains(java.awt.geom.Rectangle2D r)
Delegates to the enclosedGeneralPath.- Specified by:
containsin interfacejava.awt.Shape
-
intersects
public boolean intersects(double x, double y, double w, double h)Delegates to the enclosedGeneralPath.- Specified by:
intersectsin interfacejava.awt.Shape
-
intersects
public boolean intersects(java.awt.geom.Rectangle2D r)
Delegates to the enclosedGeneralPath.- Specified by:
intersectsin interfacejava.awt.Shape
-
getPathIterator
public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at)
Delegates to the enclosedGeneralPath.- Specified by:
getPathIteratorin interfacejava.awt.Shape
-
getPathIterator
public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at, double flatness)Delegates to the enclosedGeneralPath.- Specified by:
getPathIteratorin interfacejava.awt.Shape
-
getExtendedPathIterator
public ExtendedPathIterator getExtendedPathIterator()
Delegates to the enclosedGeneralPath.- Specified by:
getExtendedPathIteratorin interfaceExtendedShape
-
clone
public java.lang.Object clone()
Delegates to the enclosedGeneralPath.- Overrides:
clonein classjava.lang.Object
-
makeRoom
private void makeRoom(int numValues)
Make sure, that the requested number of slots in vales[] are available. Must be called even for numValues = 0, because it is also used for initialization of those arrays.- Parameters:
numValues- number of requested coordinates
-
-