|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.flagstone.transform.util.shape.Canvas
public final class Canvas
The Canvas class is used to create shape definitions. Arbitrary paths can be created using a series of move, line or curve segments. Drawing operations using both absolute coordinates and coordinates relative to the current point (updated after every operation) are supported.
For curves both cubic and quadratic curves are supported. Flash only supports quadratic curves so cubic curves are approximated by a series of line segments using (converting cubic to quadratic curves is mathematically difficult). The smoothness of cubic curves is controlled by the flatness attribute which can be used to limit the number of line segments that are drawn.
As a path is drawn the maximum and minimum x and y coordinates are recorded so that the bounding rectangle that completely encloses the shape can be defined. This is used when creating shape definitions using the DefineShape, DefineShape2 or DefineShape3 classes.
When drawing paths whether coordinates are specified in twips or pixels is set when the Canvas object is created. When specifying coordinates in pixels all coordinates are converted internally to twips to perform the actual drawing.
Constructor Summary | |
---|---|
Canvas()
Creates a new Canvas object with no path defined. |
Method Summary | |
---|---|
void |
clear()
Creates a new path, discarding any path elements drawn. |
void |
close()
Closes the current path by drawing a line from the current point to the starting point of the path. |
void |
curve(int acontrolX,
int acontrolY,
int aanchorX,
int aanchorY)
Draw a quadratic bezier curve from the current point to the point (x,y) with the control point (x1, y1). |
void |
curve(int cax,
int cay,
int cbx,
int cby,
int anx,
int any)
Draw a cubic bezier curve from the current point to the point (x,y) with the off-curve control points (x1, y1) and (x2, y2). |
DefineShape2 |
defineShape(int identifier)
Generates a shape containing the current path and styles. |
DefineShape3 |
defineTransparentShape(int identifier)
Generates a transparent shape containing the current path and styles. |
Bounds |
getBounds()
Generates the bounding box that encloses the current path. |
List<FillStyle> |
getFillStyles()
Get a copy of the list of fill styles. |
List<LineStyle> |
getLineStyles()
Get a copy of the list of line styles. |
Shape |
getShape()
Returns the Shape object containing the objects used to draw the current path. |
boolean |
isPixels()
Are the coordinates used when drawing a path are expressed in pixels (true) or twips (false). |
void |
line(int xCoord,
int yCoord)
draw a line from the current point to the point (x,y). |
void |
move(int xCoord,
int yCoord)
Move to the point (x,y). |
void |
moveForFont(int xCoord,
int yCoord)
Move to the point (x,y). |
void |
polygon(int[] points)
Draws a closed shape with vertices defines by pairs of coordinates from the array argument. |
void |
rcurve(int rcontrolX,
int rcontrolY,
int ranchorX,
int ranchorY)
Draw a quadratic bezier curve relative to the current point to the point. |
void |
rcurve(int controlAX,
int controlAY,
int controlBX,
int controlBY,
int anchorX,
int anchorY)
Draw a cubic bezier curve relative to the current point. |
void |
reflect(int xCoord,
int yCoord)
Draw a quadratic bezier curve from the current point to the point (x,y) using the control point for the previously drawn curve. |
void |
reflect(int ctrlX,
int ctrlY,
int anchorX,
int anchorY)
Draw a cubic bezier curve from the current point to the point (x,y). |
void |
rline(int xCoord,
int yCoord)
Draw a line relative to the current point. |
void |
rmove(int xCoord,
int yCoord)
Move relative to the current point. |
void |
rpolygon(int[] points)
Draws a closed shape with vertices defines by pairs of coordinates from the array argument. |
void |
rreflect(int xCoord,
int yCoord)
Draw a quadratic bezier curve relative to the current point to the point using the control point for the previously drawn curve. |
void |
rreflect(int ctrlX,
int ctrlY,
int anchorX,
int anchorY)
Draw a cubic bezier curve relative to the current point. |
void |
setAltStyle(FillStyle style)
Set the style used to fill overlapping enclosed areas. |
void |
setFillStyle(FillStyle style)
Set the style used to fill enclosed areas. |
void |
setLineStyle(LineStyle1 style)
Set the style used to draw lines. |
void |
setPixels(boolean arePixels)
Sets whether the coordinates used when drawing a path are expressed in pixels (true) or twips (false). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Canvas()
Method Detail |
---|
public boolean isPixels()
public void setPixels(boolean arePixels)
arePixels
- true if coordinates are expressed in pixels, false if
they are twips.public Bounds getBounds()
public List<LineStyle> getLineStyles()
public List<FillStyle> getFillStyles()
public Shape getShape()
public void setLineStyle(LineStyle1 style)
style
- a line style.public void setFillStyle(FillStyle style)
style
- a fill style.public void setAltStyle(FillStyle style)
style
- a fill style.public DefineShape2 defineShape(int identifier)
identifier
- an unique identifier for the shape.
public DefineShape3 defineTransparentShape(int identifier)
identifier
- an unique identifier for the shape.
public void clear()
public void close()
public void move(int xCoord, int yCoord)
xCoord
- the x-coordinate of the point to move to.yCoord
- the y-coordinate of the point to move to.public void moveForFont(int xCoord, int yCoord)
xCoord
- the x-coordinate of the point to move to.yCoord
- the y-coordinate of the point to move to.public void rmove(int xCoord, int yCoord)
xCoord
- the distance along the x-axis.yCoord
- the distance along the y-axis.public void line(int xCoord, int yCoord)
xCoord
- the x-coordinate of the end of the line.yCoord
- the y-coordinate of the end of the line.public void rline(int xCoord, int yCoord)
xCoord
- the distance along the x-axis to the end of the line.yCoord
- the distance along the y-axis to the end of the line.public void curve(int acontrolX, int acontrolY, int aanchorX, int aanchorY)
acontrolX
- the x-coordinate of the control point.acontrolY
- the y-coordinate of the control point.aanchorX
- the x-coordinate of the end of the curve.aanchorY
- the y-coordinate of the end of the curve.public void rcurve(int rcontrolX, int rcontrolY, int ranchorX, int ranchorY)
rcontrolX
- the distance along the x-axis from the current point to the
control point.rcontrolY
- the distance along the y-axis from the current point to the
control point.ranchorX
- the distance along the x-axis from the current point to the
end of the curve.ranchorY
- the distance along the y-axis from the current point to the
end of the curve.public void curve(int cax, int cay, int cbx, int cby, int anx, int any)
cax
- the x-coordinate of the first control point.cay
- the y-coordinate of the first control point.cbx
- the x-coordinate of the second control point.cby
- the y-coordinate of the second control point.anx
- the x-coordinate of the end of the curve.any
- the y-coordinate of the end of the curve.public void rcurve(int controlAX, int controlAY, int controlBX, int controlBY, int anchorX, int anchorY)
controlAX
- the distance along the x-axis from the current point to the
first control point.controlAY
- the distance along the y-axis from the current point to the
first control point.controlBX
- the distance along the x-axis from the current point to the
second control point.controlBY
- the distance along the y-axis from the current point to the
second control point.anchorX
- the distance along the x-axis from the current point to the
end of the curve.anchorY
- the distance along the y-axis from the current point to the
end of the curve.public void reflect(int xCoord, int yCoord)
xCoord
- the x-coordinate of the end of the curve.yCoord
- the y-coordinate of the end of the curve.public void rreflect(int xCoord, int yCoord)
xCoord
- the distance along the x-axis from the current point to the
end of the curve.yCoord
- the distance along the y-axis from the current point to the
end of the curve.public void reflect(int ctrlX, int ctrlY, int anchorX, int anchorY)
ctrlX
- the x-coordinate of the control point.ctrlY
- the y-coordinate of the control point.anchorX
- the x-coordinate of the end of the curve.anchorY
- the y-coordinate of the end of the curve.public void rreflect(int ctrlX, int ctrlY, int anchorX, int anchorY)
ctrlX
- the distance along the x-axis from the current point to the
second control point.ctrlY
- the distance along the y-axis from the current point to the
second control point.anchorX
- the distance along the x-axis from the current point to the
end of the curve.anchorY
- the distance along the y-axis from the current point to the
end of the curve.public void rpolygon(int[] points)
points
- and array of coordinate pairs. The first pair of points
defines the coordinates of a move operation, successive pairs
define the coordinates for relative lines.public void polygon(int[] points)
points
- and array of coordinate pairs. The first pair of points
defines the coordinates of a move operation, successive pairs
define the coordinates of the lines.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |