| Package | flare.util |
| Class | public class Shapes |
Graphics context
to draw with and a size parameter determining the radius of the shape
(i.e., the height and width of the shape are twice the size parameter).
All shapes are indicated by a name. This class registers these names
with drawing functions, allowing the lookup of shape rendering routines
by the shapes name. For example, these shape names may be assigned using
a flare.vis.operator.encoder.ShapeEncoder and then later
rendered by looking up the shape with this class, as done by the
flare.vis.data.render.ShapeRenderer class. The set of
available shapes can be extended by using the static
setShape method to register a new shape name and
drawing function.
| Method | Defined by | ||
|---|---|---|---|
|
consolidate(x1:Number, y1:Number, controlPoints:Array, x2:Number, y2:Number, p:Array = null):Array
[static]
A helper function for consolidating end points and control points
for a spline into a single array.
| Shapes | ||
|
drawArc(g:Graphics, x:Number, y:Number, radius:Number, a0:Number, a1:Number):void
[static]
Draws an arc (a segment of a circle's circumference)
| Shapes | ||
|
drawBSpline(g:Graphics, p:Array, npts:int = -1, move:Boolean = true):void
[static]
Draws a cubic open uniform B-spline.
| Shapes | ||
|
drawCardinal(g:Graphics, p:Array, npts:int = -1, s:Number = 0.15, closed:Boolean = false):void
[static]
Draws a cardinal spline composed of piecewise connected cubic
Bezier curves.
| Shapes | ||
|
drawCircle(g:Graphics, size:Number):void
[static]
Draws a circle shape.
| Shapes | ||
|
drawCross(g:Graphics, size:Number):void
[static]
Draws a cross shape.
| Shapes | ||
|
drawCubic(g:Graphics, ax:Number, ay:Number, bx:Number, by:Number, cx:Number, cy:Number, dx:Number, dy:Number, move:Boolean = true):void
[static]
Draws a cubic Bezier curve.
| Shapes | ||
|
drawDiamond(g:Graphics, size:Number):void
[static]
Draws a diamond shape.
| Shapes | ||
|
drawPolygon(g:Graphics, a:Array):void
[static]
Draws a polygon shape.
| Shapes | ||
|
drawSquare(g:Graphics, size:Number):void
[static]
Draws a square shape.
| Shapes | ||
|
drawTriangleDown(g:Graphics, size:Number):void
[static]
Draws a downward-pointing triangle shape.
| Shapes | ||
|
drawTriangleLeft(g:Graphics, size:Number):void
[static]
Draws a left-pointing triangle shape.
| Shapes | ||
|
drawTriangleRight(g:Graphics, size:Number):void
[static]
Draws a right-pointing triangle shape.
| Shapes | ||
|
drawTriangleUp(g:Graphics, size:Number):void
[static]
Draws an upward-pointing triangle shape.
| Shapes | ||
|
drawWedge(g:Graphics, x:Number, y:Number, outer:Number, inner:Number, a0:Number, a1:Number):void
[static]
Draws a wedge defined by an angular range and inner and outer radii.
| Shapes | ||
|
drawX(g:Graphics, size:Number):void
[static]
Draws an "x" shape.
| Shapes | ||
|
getShape(name:String):Function
[static]
Gets the shape drawing function with the given name.
| Shapes | ||
|
resetShapes():void
[static]
Resets all shape drawing functions to the default settings.
| Shapes | ||
|
setShape(name:String, draw:Function):void
[static]
Sets the shape drawing function for a given shape name.
| Shapes | ||
| Constant | Defined by | ||
|---|---|---|---|
| BEZIER : String = "bezier" [static] Constant indicating a Bezier curve.
| Shapes | ||
| BLOCK : String = "block" [static] Constant indicating a rectangular block shape.
| Shapes | ||
| BSPLINE : String = "bspline" [static] Constant indicating a B-spline.
| Shapes | ||
| CARDINAL : String = "cardinal" [static] Constant indicating a cardinal spline.
| Shapes | ||
| CIRCLE : String = "circle" [static] Constant indicating a circle shape.
| Shapes | ||
| CROSS : String = "cross" [static] Constant indicating a cross shape.
| Shapes | ||
| DIAMOND : String = "diamond" [static] Constant indicating a diamond shape.
| Shapes | ||
| HORIZONTAL_BAR : String = "horizontalBar" [static] Constant indicating a horizontal bar shape.
| Shapes | ||
| LINE : String = "line" [static] Constant indicating a straight line shape.
| Shapes | ||
| POLYBLOB : String = "polyblob" [static] Constant indicating a "polyblob" shape, a polygon whose
edges are interpolated with a cardinal spline.
| Shapes | ||
| POLYGON : String = "polygon" [static] Constant indicating a polygon shape.
| Shapes | ||
| SQUARE : String = "square" [static] Constant indicating a square shape.
| Shapes | ||
| TRIANGLE_DOWN : String = "triangleDown" [static] Constant indicating a downward-pointing triangle shape.
| Shapes | ||
| TRIANGLE_LEFT : String = "triangleLeft" [static] Constant indicating a leftward-pointing triangle shape.
| Shapes | ||
| TRIANGLE_RIGHT : String = "triangleRight" [static] Constant indicating a rightward-pointing triangle shape.
| Shapes | ||
| TRIANGLE_UP : String = "triangleUp" [static] Constant indicating a upward-pointing triangle shape.
| Shapes | ||
| VERTICAL_BAR : String = "verticalBar" [static] Constant indicating a vertical bar shape.
| Shapes | ||
| WEDGE : String = "wedge" [static] Constant indicating a wedge shape.
| Shapes | ||
| X : String = "x" [static] Constant indicating an 'X' shape.
| Shapes | ||
| consolidate | () | method |
public static function consolidate(x1:Number, y1:Number, controlPoints:Array, x2:Number, y2:Number, p:Array = null):ArrayA helper function for consolidating end points and control points for a spline into a single array.
Parametersx1:Number — the x-coordinate for the first end point
|
|
y1:Number — the y-coordinate for the first end point
|
|
controlPoints:Array — an array of control points
|
|
x2:Number — the x-coordinate for the second end point
|
|
y2:Number — the y-coordinate for the second end point
|
|
p:Array (default = null) — the array in which to store the consolidated points.
If null, a new array will be created and returned.
|
Array — the consolidated array of all points
|
| drawArc | () | method |
public static function drawArc(g:Graphics, x:Number, y:Number, radius:Number, a0:Number, a1:Number):voidDraws an arc (a segment of a circle's circumference)
Parametersg:Graphics — the graphics context to draw with
|
|
x:Number — the center x-coordinate of the arc
|
|
y:Number — the center y-coorindate of the arc
|
|
radius:Number — the radius of the arc
|
|
a0:Number — the starting angle of the arc (in radians)
|
|
a1:Number — the ending angle of the arc (in radians)
|
| drawBSpline | () | method |
public static function drawBSpline(g:Graphics, p:Array, npts:int = -1, move:Boolean = true):voidDraws a cubic open uniform B-spline. The spline passes through the first and last control points, but not necessarily any others.
Parametersg:Graphics — the graphics context to draw with
|
|
p:Array — an array of points defining the spline control points
|
|
npts:int (default = -1) — a slack parameter determining the "tightness" of the
spline. At value 1 (the default) a normal b-spline will be drawn,
at value 0 a straight line between the first and last points will
be drawn. Intermediate values interpolate smoothly between these
two extremes.
|
|
move:Boolean (default = true) — if true (the default), the graphics context will be
moved to the starting point before drawing starts. If false,
no move command will be issued; this is useful when connecting
multiple curves to define a filled region.
|
| drawCardinal | () | method |
public static function drawCardinal(g:Graphics, p:Array, npts:int = -1, s:Number = 0.15, closed:Boolean = false):voidDraws a cardinal spline composed of piecewise connected cubic Bezier curves. Curve control points are inferred so as to ensure C1 continuity (continuous derivative).
Parametersg:Graphics — the graphics context to draw with
|
|
p:Array — an array defining a polygon or polyline to render with a
cardinal spline
|
|
npts:int (default = -1) — a tension parameter determining the spline's "tightness"
|
|
s:Number (default = 0.15) — indicates if the cardinal spline should be a closed
shape. False by default.
|
|
closed:Boolean (default = false) |
| drawCircle | () | method |
public static function drawCircle(g:Graphics, size:Number):voidDraws a circle shape.
Parametersg:Graphics — the graphics context to draw with
|
|
size:Number — the radius of the circle
|
| drawCross | () | method |
public static function drawCross(g:Graphics, size:Number):voidDraws a cross shape.
Parametersg:Graphics — the graphics context to draw with
|
|
size:Number — the (half-)size of the cross. The height and width of
the shape will both be exactly twice the size parameter.
|
| drawCubic | () | method |
public static function drawCubic(g:Graphics, ax:Number, ay:Number, bx:Number, by:Number, cx:Number, cy:Number, dx:Number, dy:Number, move:Boolean = true):voidDraws a cubic Bezier curve.
Parametersg:Graphics — the graphics context to draw with
|
|
ax:Number — x-coordinate of the starting point
|
|
ay:Number — y-coordinate of the starting point
|
|
bx:Number — x-coordinate of the first control point
|
|
by:Number — y-coordinate of the first control point
|
|
cx:Number — x-coordinate of the second control point
|
|
cy:Number — y-coordinate of the second control point
|
|
dx:Number — x-coordinate of the ending point
|
|
dy:Number — y-coordinate of the ending point
|
|
move:Boolean (default = true) — if true (the default), the graphics context will be
moved to the starting point before drawing starts. If false,
no move command will be issued; this is useful when connecting
multiple curves to define a filled region.
|
| drawDiamond | () | method |
public static function drawDiamond(g:Graphics, size:Number):voidDraws a diamond shape.
Parametersg:Graphics — the graphics context to draw with
|
|
size:Number — the (half-)size of the diamond. The height and width of
the shape will both be exactly twice the size parameter.
|
| drawPolygon | () | method |
public static function drawPolygon(g:Graphics, a:Array):voidDraws a polygon shape.
Parametersg:Graphics — the graphics context to draw with
|
|
a:Array — a flat array of x, y values defining the polygon
|
| drawSquare | () | method |
public static function drawSquare(g:Graphics, size:Number):voidDraws a square shape.
Parametersg:Graphics — the graphics context to draw with
|
|
size:Number — the (half-)size of the square. The height and width of
the shape will both be exactly twice the size parameter.
|
| drawTriangleDown | () | method |
public static function drawTriangleDown(g:Graphics, size:Number):voidDraws a downward-pointing triangle shape.
Parametersg:Graphics — the graphics context to draw with
|
|
size:Number — the (half-)size of the triangle. The height and width of
the shape will both be exactly twice the size parameter.
|
| drawTriangleLeft | () | method |
public static function drawTriangleLeft(g:Graphics, size:Number):voidDraws a left-pointing triangle shape.
Parametersg:Graphics — the graphics context to draw with
|
|
size:Number — the (half-)size of the triangle. The height and width of
the shape will both be exactly twice the size parameter.
|
| drawTriangleRight | () | method |
public static function drawTriangleRight(g:Graphics, size:Number):voidDraws a right-pointing triangle shape.
Parametersg:Graphics — the graphics context to draw with
|
|
size:Number — the (half-)size of the triangle. The height and width of
the shape will both be exactly twice the size parameter.
|
| drawTriangleUp | () | method |
public static function drawTriangleUp(g:Graphics, size:Number):voidDraws an upward-pointing triangle shape.
Parametersg:Graphics — the graphics context to draw with
|
|
size:Number — the (half-)size of the triangle. The height and width of
the shape will both be exactly twice the size parameter.
|
| drawWedge | () | method |
public static function drawWedge(g:Graphics, x:Number, y:Number, outer:Number, inner:Number, a0:Number, a1:Number):voidDraws a wedge defined by an angular range and inner and outer radii. An inner radius of zero results in a pie-slice shape.
Parametersg:Graphics — the graphics context to draw with
|
|
x:Number — the center x-coordinate of the wedge
|
|
y:Number — the center y-coorindate of the wedge
|
|
outer:Number — the outer radius of the wedge
|
|
inner:Number — the inner radius of the wedge
|
|
a0:Number — the starting angle of the wedge (in radians)
|
|
a1:Number — the ending angle of the wedge (in radians)
|
| drawX | () | method |
public static function drawX(g:Graphics, size:Number):voidDraws an "x" shape.
Parametersg:Graphics — the graphics context to draw with
|
|
size:Number — the (half-)size of the "x". The height and width of
the shape will both be exactly twice the size parameter.
|
| getShape | () | method |
public static function getShape(name:String):FunctionGets the shape drawing function with the given name.
Parametersname:String — the name of the shape to draw
|
Function — a function for drawing the shape or null if the shape name
is not found. The returned function takes two parameters:
a graphics object and a numerical size value. The size value
indicates the radius of the shape.
|
| resetShapes | () | method |
public static function resetShapes():voidResets all shape drawing functions to the default settings.
| setShape | () | method |
public static function setShape(name:String, draw:Function):voidSets the shape drawing function for a given shape name.
Parametersname:String — the name of the shape to draw
|
|
draw:Function — a function for drawing the shape. This function must
take two parameters: a graphics object and a numerical size value.
The size value indicates the radius of the shape.
|
| BEZIER | constant |
public static const BEZIER:String = "bezier"Constant indicating a Bezier curve.
| BLOCK | constant |
public static const BLOCK:String = "block"Constant indicating a rectangular block shape.
| BSPLINE | constant |
public static const BSPLINE:String = "bspline"Constant indicating a B-spline.
| CARDINAL | constant |
public static const CARDINAL:String = "cardinal"Constant indicating a cardinal spline.
| CIRCLE | constant |
public static const CIRCLE:String = "circle"Constant indicating a circle shape.
| CROSS | constant |
public static const CROSS:String = "cross"Constant indicating a cross shape.
| DIAMOND | constant |
public static const DIAMOND:String = "diamond"Constant indicating a diamond shape.
| HORIZONTAL_BAR | constant |
public static const HORIZONTAL_BAR:String = "horizontalBar"Constant indicating a horizontal bar shape.
| LINE | constant |
public static const LINE:String = "line"Constant indicating a straight line shape.
| POLYBLOB | constant |
public static const POLYBLOB:String = "polyblob"Constant indicating a "polyblob" shape, a polygon whose edges are interpolated with a cardinal spline.
| POLYGON | constant |
public static const POLYGON:String = "polygon"Constant indicating a polygon shape.
| SQUARE | constant |
public static const SQUARE:String = "square"Constant indicating a square shape.
| TRIANGLE_DOWN | constant |
public static const TRIANGLE_DOWN:String = "triangleDown"Constant indicating a downward-pointing triangle shape.
| TRIANGLE_LEFT | constant |
public static const TRIANGLE_LEFT:String = "triangleLeft"Constant indicating a leftward-pointing triangle shape.
| TRIANGLE_RIGHT | constant |
public static const TRIANGLE_RIGHT:String = "triangleRight"Constant indicating a rightward-pointing triangle shape.
| TRIANGLE_UP | constant |
public static const TRIANGLE_UP:String = "triangleUp"Constant indicating a upward-pointing triangle shape.
| VERTICAL_BAR | constant |
public static const VERTICAL_BAR:String = "verticalBar"Constant indicating a vertical bar shape.
| WEDGE | constant |
public static const WEDGE:String = "wedge"Constant indicating a wedge shape.
| X | constant |
public static const X:String = "x"Constant indicating an 'X' shape.