|
JHotDraw 7.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<BezierPath.Node>
org.jhotdraw.geom.BezierPath
public class BezierPath
BezierPath allows the construction of paths consisting of straight lines, quadratic curves and cubic curves.
A BezierPath represents a geometric path constructed by vertices. Each Node has three control points: C0, C1, C2. A mask defines which control points are in use. The path passes through C0. C1 controls the curve going towards C0. C2 controls the curve going away from C0.
Nested Class Summary | |
---|---|
static class |
BezierPath.Node
Defines a vertex (node) of the bezier path. |
Field Summary | |
---|---|
static int |
C0_MASK
Constant for having only control point C0 in effect. |
static int |
C1_MASK
Constant for having control point C1 in effect (in addition to C0). |
static int |
C1C2_MASK
Constant for having control points C1 and C2 in effect (in addition to C0). |
static int |
C2_MASK
Constant for having control point C2 in effect (in addition to C0). |
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
BezierPath()
Creates a new instance. |
Method Summary | |
---|---|
void |
add(int mask,
java.awt.geom.Point2D.Double c0,
java.awt.geom.Point2D.Double c1,
java.awt.geom.Point2D.Double c2)
Convenience method for adding a control point with three coordinates C0, C1 and C2 with a mask. |
void |
add(java.awt.geom.Point2D.Double c0)
Convenience method for adding a control point with a single coordinate C0. |
void |
addPoint(double x,
double y)
|
void |
arcTo(double rx,
double ry,
double xAxisRotation,
boolean largeArcFlag,
boolean sweepFlag,
double x,
double 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. |
java.awt.geom.Point2D.Double |
chop(java.awt.geom.Point2D.Double p)
Returns a point on the edge of the bezier path which crosses the line from the center of the bezier path to the specified point. |
BezierPath |
clone()
Creates a deep copy of the BezierPath. |
boolean |
contains(double x,
double y)
|
boolean |
contains(double x,
double y,
double w,
double h)
|
boolean |
contains(java.awt.geom.Point2D p)
|
boolean |
contains(java.awt.geom.Rectangle2D r)
|
void |
curveTo(double x1,
double y1,
double x2,
double y2,
double x3,
double y3)
|
int |
findSegment(java.awt.geom.Point2D.Double find,
float tolerance)
Gets the segment of the polyline that is hit by the given Point2D.Double. |
java.awt.geom.Point2D.Double |
get(int index,
int coord)
Convenience method for getting a single coordinate of a control point. |
java.awt.Rectangle |
getBounds()
|
java.awt.geom.Rectangle2D.Double |
getBounds2D()
|
java.awt.geom.Point2D.Double |
getCenter()
Returns the point at the center of the bezier path. |
double |
getLengthOfPath(double flatness)
Returns the length of the path. |
java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.AffineTransform at)
|
java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.AffineTransform at,
double flatness)
|
java.awt.geom.Point2D.Double |
getPointOnPath(double relative,
double flatness)
Returns a relative point on the path. |
double |
getRelativePositionOnPath(java.awt.geom.Point2D.Double find,
double flatness)
Returns the relative position of the specified point on the path. |
int |
getWindingRule()
Gets winding rule for filling the bezier path. |
int |
indexOfOutermostNode()
Return the index of the control point that is furthest from the center |
boolean |
intersects(double x,
double y,
double w,
double h)
|
boolean |
intersects(java.awt.geom.Rectangle2D r)
|
void |
invalidatePath()
This must be called after the BezierPath has been changed. |
boolean |
isClosed()
|
int |
joinSegments(java.awt.geom.Point2D.Double join,
float tolerance)
Joins two segments into one if the given Point2D.Double hits a node of the bezier path. |
void |
lineTo(double x1,
double y1)
|
void |
moveTo(double x1,
double y1)
|
boolean |
outlineContains(java.awt.geom.Point2D.Double p,
double tolerance)
Returns true, if the outline of this bezier path contains the specified point. |
void |
quadTo(double x1,
double y1,
double x2,
double y2)
|
void |
set(int index,
int coord,
java.awt.geom.Point2D.Double p)
Convenience method for changing a single coordinate of a control point. |
void |
setClosed(boolean newValue)
|
void |
setTo(BezierPath that)
|
void |
setWindingRule(int newValue)
Sets winding rule for filling the bezier path. |
int |
splitSegment(java.awt.geom.Point2D.Double split,
float tolerance)
Splits the segment at the given Point2D.Double if a segment was hit. |
java.awt.geom.GeneralPath |
toGeneralPath()
Converts the BezierPath into a GeneralPath. |
java.awt.geom.Point2D.Double[] |
toPolygonArray()
|
void |
transform(java.awt.geom.AffineTransform tx)
Transforms the BezierPath. |
void |
validatePath()
Recomputes the BezierPath, if it is invalid. |
Methods inherited from class java.util.ArrayList |
---|
add, add, addAll, addAll, clear, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize |
Methods inherited from class java.util.AbstractList |
---|
equals, hashCode, iterator, listIterator, listIterator, subList |
Methods inherited from class java.util.AbstractCollection |
---|
containsAll, removeAll, retainAll, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList |
Field Detail |
---|
public static final int C0_MASK
public static final int C1_MASK
public static final int C2_MASK
public static final int C1C2_MASK
Constructor Detail |
---|
public BezierPath()
Method Detail |
---|
public void add(java.awt.geom.Point2D.Double c0)
public void addPoint(double x, double y)
public void add(int mask, java.awt.geom.Point2D.Double c0, java.awt.geom.Point2D.Double c1, java.awt.geom.Point2D.Double c2)
public void set(int index, int coord, java.awt.geom.Point2D.Double p)
public java.awt.geom.Point2D.Double get(int index, int coord)
public void invalidatePath()
public void validatePath()
public java.awt.geom.GeneralPath toGeneralPath()
public boolean contains(java.awt.geom.Point2D p)
contains
in interface java.awt.Shape
public boolean outlineContains(java.awt.geom.Point2D.Double p, double tolerance)
p
- The point to be tested.tolerance
- The tolerance for the test.public boolean intersects(java.awt.geom.Rectangle2D r)
intersects
in interface java.awt.Shape
public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at)
getPathIterator
in interface java.awt.Shape
public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at, double flatness)
getPathIterator
in interface java.awt.Shape
public boolean contains(java.awt.geom.Rectangle2D r)
contains
in interface java.awt.Shape
public boolean intersects(double x, double y, double w, double h)
intersects
in interface java.awt.Shape
public java.awt.geom.Rectangle2D.Double getBounds2D()
getBounds2D
in interface java.awt.Shape
public java.awt.Rectangle getBounds()
getBounds
in interface java.awt.Shape
public boolean contains(double x, double y, double w, double h)
contains
in interface java.awt.Shape
public boolean contains(double x, double y)
contains
in interface java.awt.Shape
public void setClosed(boolean newValue)
public boolean isClosed()
public BezierPath clone()
clone
in class java.util.ArrayList<BezierPath.Node>
public void transform(java.awt.geom.AffineTransform tx)
tx
- the transformation.public void setTo(BezierPath that)
public java.awt.geom.Point2D.Double getCenter()
public java.awt.geom.Point2D.Double chop(java.awt.geom.Point2D.Double p)
public int indexOfOutermostNode()
public java.awt.geom.Point2D.Double getPointOnPath(double relative, double flatness)
relative
- a value between 0 and 1.public double getLengthOfPath(double flatness)
flatness
- the flatness used to approximate the length.public double getRelativePositionOnPath(java.awt.geom.Point2D.Double find, double flatness)
flatness
- the flatness used to approximate the length.
public int findSegment(java.awt.geom.Point2D.Double find, float tolerance)
public int joinSegments(java.awt.geom.Point2D.Double join, float tolerance)
public int splitSegment(java.awt.geom.Point2D.Double split, float tolerance)
public void moveTo(double x1, double y1)
public void lineTo(double x1, double y1)
public void quadTo(double x1, double y1, double x2, double y2)
public void curveTo(double x1, double y1, double x2, double y2, double x3, double y3)
public void arcTo(double rx, double ry, double xAxisRotation, boolean largeArcFlag, boolean sweepFlag, double x, double y)
As specified in http://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands
The implementation of this method has been derived from Apache Batik class org.apache.batik.ext.awt.geom.ExtendedGeneralPath#computArc
rx
- the x radius of the ellipsery
- the y radius of the ellipsexAxisRotation
- 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.public java.awt.geom.Point2D.Double[] toPolygonArray()
public void setWindingRule(int newValue)
newValue
- Must be GeneralPath.WIND_EVEN_ODD or GeneralPath.WIND_NON_ZERO.public int getWindingRule()
|
Copyright 1996-2007 (c) JHotDraw.org. Some rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |