public final class ShapeBuilder extends Object
Constructor and Description |
---|
ShapeBuilder()
Constructor.
|
ShapeBuilder(boolean useTwips)
Constructor.
|
ShapeBuilder(Styles styles)
Constructor.
|
ShapeBuilder(Styles styles,
boolean useTwips)
Constructor.
|
ShapeBuilder(Styles styles,
Point origin)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
Shape |
build() |
void |
close()
Creates a straight-edge record (i.e a straight line) from the current
drawing position to the last move-to position.
|
void |
correctRoundingErrors()
If a shape is closed then the start and finish records must match exactly
to the nearest twip.
|
void |
curved(double cx,
double cy,
double ax,
double ay)
Creates a quadratic spline in SWF as a curved-edge record.
|
static void |
divideQuad(double[] src,
int srcoff,
double[] left,
int loff,
double[] right,
int roff)
From java.awt.geom.QuadCurve2D
|
int |
getCurrentFillStyle0()
Gets the current fill style index.
|
int |
getCurrentFillStyle1()
Gets the current fill style 1 index.
|
int |
getCurrentLineStyle()
Gets the current line style index.
|
static Point |
getPointOnSegment(Point P0,
Point P1,
double ratio)
Return a point on a segment [P0, P1] which distance from P0 is ratio of
the length [P0, P1]
|
boolean |
getUseFillStyle1()
Gets whether the current paint method should include fill style 1
information, which controls how intersecting shape fills are drawn.
|
void |
move(double x,
double y)
Moves the current pen position to a new location without drawing.
|
void |
processShape(IShapeIterator si)
Processes a
Shape by converting its general path to a series
of ShapeRecord s. |
void |
setCurrentFillStyle0(int index)
Sets the current fill style index.
|
void |
setCurrentFillStyle1(int index)
Sets the current fill style 1 index.
|
void |
setCurrentLineStyle(int index)
Sets the current line style index.
|
void |
setFont12or3(boolean b)
Set whether the shape is part of a DefineFont1, DefineFont2 or
DefineFont3 tag.
|
void |
setUseFillStyle0(boolean b)
Sets the paint method to include fill style 0 information, which is for
filling simple shapes.
|
void |
setUseFillStyle1(boolean b)
Sets the paint method to include fill style 1 information, which controls
how intersecting shape fills are drawn.
|
void |
straight(double x,
double y)
Calculates the change or 'delta' in position between the current pen
location and a given co-ordinate pair.
|
public ShapeBuilder()
Creates an empty Flash Shape with the pen starting at [0.0, 0.0].
public ShapeBuilder(boolean useTwips)
Creates an empty Flash Shape with the pen starting at [0.0,0.0].
useTwips
- true
to convert to twips.public ShapeBuilder(Styles styles)
Creates an empty Flash Shape with the pen starting at [0.0, 0.0].
public ShapeBuilder(Styles styles, boolean useTwips)
Use this constructor to specify whether co-ordinates will be converted to twips (1/20th of a pixel). The default is to use this conversion.
useTwips
- true
to convert to twips.public ShapeBuilder(Styles styles, Point origin)
Creates an empty Flash Shape. ShapeRecord
s can
be added manually using the process shape method.
origin
- the pen starting point, typically [0.0,0.0]processShape(IShapeIterator)
public Shape build()
public void processShape(IShapeIterator si)
Shape
by converting its general path to a series
of ShapeRecord
s. The records are not terminated with an
EndShapeRecord
so that subsequent calls can be made to this
method to concatenate more shape paths.
For closed shapes (including character glyphs) there exists a high
possibility of rounding errors caused by the conversion of
double-precision pixel co-ordinates to integer twips (1 twip = 1/20th
pixel at 72 dpi). As such, at each move command this error is checked and
corrected.
si
- A IShapeIterator who's path will be converted to records and
added to the collectionpublic void correctRoundingErrors()
StraightEdgeRecord
with a delta equal to the accumulated
rounding errors, if such errors exists.public void move(double x, double y)
x
- The new horizontal location.y
- The new vertical location.public void straight(double x, double y)
x
- The new horizontal location.y
- The new vertical location.public void curved(double cx, double cy, double ax, double ay)
cx
- - control point-xcy
- - control point-yax
- - anchor point-xay
- - anchor point-ypublic void close()
public static void divideQuad(double[] src, int srcoff, double[] left, int loff, double[] right, int roff)
public void setFont12or3(boolean b)
b
- true if shape part of a font tagpublic int getCurrentLineStyle()
LineStyleArray
public void setCurrentLineStyle(int index)
index
- index to a line style in the LineStyleArray
public int getCurrentFillStyle0()
FillStyleArray
public void setCurrentFillStyle0(int index)
index
- The index of a fill style.public int getCurrentFillStyle1()
FillStyleArray
public void setCurrentFillStyle1(int index)
index
- The index of a fill style.public boolean getUseFillStyle1()
public void setUseFillStyle1(boolean b)
b
- if set to true, fill style 1 information will be used for
intersecting shapespublic void setUseFillStyle0(boolean b)
b
- if set to true, fill style 0 information will be used for normal
shapesCopyright © 2016 The Apache Software Foundation. All rights reserved.