public class PathMaker extends Object
Modifier and Type | Field and Description |
---|---|
double |
arcControlValue
For each elliptical arc segment drawn the Bezier control points are at a
tangent to the start and end points.
|
float |
arcSegmentAngle
When an elliptical arc is being drawn it is split up into smaller
segments so as to fit as close as possible using a Bezier curve.
|
protected boolean |
closed |
protected double |
lastX |
protected double |
lastY |
protected IPath |
path
The IPath being drawn to.
|
static int |
START_ALREADY_STARTED
A possible startOptions value.
|
static int |
START_LINE_TO
A possible startOptions value.
|
static int |
START_NEW_PATH
A possible startOptions value.
|
protected boolean |
started |
Constructor and Description |
---|
PathMaker(IPath path)
Create a new PathMaker for the IPath.
|
Modifier and Type | Method and Description |
---|---|
void |
addQuadToPath(double x1,
double y1,
double x2,
double y2)
Add a Cubic Bezier curve segment (or segments) that approximates a Quadratic
segment.
|
void |
addToPath(double x,
double y)
Add a straight line segment to the path.
|
void |
addToPath(double x1,
double y1,
double x2,
double y2,
double x3,
double y3)
Add a Cubic Bezier curve segment from the current point to (x3,y3) using
(x1, y1) and (x2, y2) as the control points.
|
void |
arc(int startOptions,
double x,
double y,
double width,
double height,
float startAngle,
float angle)
Draw an arc of an ellipse that fits within the specified bounding
box.
|
void |
closedArc(double x,
double y,
double width,
double height,
float startAngle,
float angle)
Draw a closed arc section of an ellipse as a new closed path.
|
void |
closePath()
Close the destination path.
|
void |
ellipse(double x,
double y,
double width,
double height)
Create a closed ellipse as a new path.
|
boolean |
hasClosed() |
boolean |
hasStarted() |
void |
pie(double x,
double y,
double width,
double height,
float startAngle,
float angle)
Draw a closed pie section of an ellipse as a new closed path.
|
void |
roundRect(double x,
double y,
double width,
double height,
double radius)
Create a rounded rectangle as a new path.
|
void |
startPath(double x,
double y) |
protected IPath path
protected boolean started
protected boolean closed
protected double lastX
protected double lastY
public float arcSegmentAngle
public double arcControlValue
public static final int START_NEW_PATH
public static final int START_LINE_TO
public static final int START_ALREADY_STARTED
public PathMaker(IPath path)
path
- the IPath object.public boolean hasStarted()
public boolean hasClosed()
public void arc(int startOptions, double x, double y, double width, double height, float startAngle, float angle)
startOptions
- one of the START_XXX values.x
- the x co-ordinate of the ellipse bounding box.y
- the y co-ordinate of the ellipse bounding box.width
- the width of the ellipse bounding box.height
- the height of the ellipse bounding box.startAngle
- the starting point of the arc given in degrees
where 0 is the 3 O'clock position and a positive value indicates
an anti-clockwise direction. Therefore 90 is the 12 O'clock and
-90 (or 270) is the 6 O'clock.angle
- the size of the arc in degrees. A positive value indicates
an anti-clockwise direction.public void ellipse(double x, double y, double width, double height)
startOptions
- one of the START_XXX values.x
- the x co-ordinate of the ellipse bounding box.y
- the y co-ordinate of the ellipse bounding box.width
- the width of the ellipse bounding box.height
- the height of the ellipse bounding box.public void roundRect(double x, double y, double width, double height, double radius)
startOptions
- one of the START_XXX values.x
- the x co-ordinate of the ellipse bounding box.y
- the y co-ordinate of the ellipse bounding box.width
- the width of the ellipse bounding box.height
- the height of the ellipse bounding box.radius
- the radius of the circles drawn on the corners.public void pie(double x, double y, double width, double height, float startAngle, float angle)
x
- the x co-ordinate of the ellipse bounding box.y
- the y co-ordinate of the ellipse bounding box.width
- the width of the ellipse bounding box.height
- the height of the ellipse bounding box.startAngle
- the starting point of the arc given in degrees
where 0 is the 3 O'clock position and a positive value indicates
an anti-clockwise direction. Therefore 90 is the 12 O'clock and
-90 (or 270) is the 6 O'clock.angle
- the size of the arc in degrees. A positive value indicates
an anti-clockwise direction.public void closedArc(double x, double y, double width, double height, float startAngle, float angle)
x
- the x co-ordinate of the ellipse bounding box.y
- the y co-ordinate of the ellipse bounding box.width
- the width of the ellipse bounding box.height
- the height of the ellipse bounding box.startAngle
- the starting point of the arc given in degrees
where 0 is the 3 O'clock position and a positive value indicates
an anti-clockwise direction. Therefore 90 is the 12 O'clock and
-90 (or 270) is the 6 O'clock.angle
- the size of the arc in degrees. A positive value indicates
an anti-clockwise direction.public void closePath()
public void startPath(double x, double y)
public void addToPath(double x, double y)
public void addToPath(double x1, double y1, double x2, double y2, double x3, double y3)
public void addQuadToPath(double x1, double y1, double x2, double y2)
x1
- the quadratic control point x co-ordinate.y1
- the quadratic control point y co-ordinate.x2
- the end point x co-ordinate.y2
- the end point y co-ordinate.