public class ShapeHelper extends Object implements ISWFConstants
FIXED_POINT_MULTIPLE, FIXED_POINT_MULTIPLE_8, GRADIENT_SQUARE, MORPH_MAX_RATIO, TWIPS_PER_PIXEL, WIDE_OFFSET_THRESHOLD
Constructor and Description |
---|
ShapeHelper() |
Modifier and Type | Method and Description |
---|---|
static Rect |
addJoint2Bounds(List<ShapeRecord> records,
LineStyle ls,
AbstractStrokeNode stroke,
double halfWeight,
Rect pathBBox) |
static Rect |
addMiterLimitStrokeToBounds(ShapeRecord segment1,
ShapeRecord segment2,
double miterLimit,
double halfWeight,
Rect pathBBox,
int xPrev,
int yPrev,
int x,
int y) |
static List<ShapeRecord> |
cubicToQuadratic(double startX,
double startY,
double control1X,
double control1Y,
double control2X,
double control2Y,
double anchorX,
double anchorY)
Approximates a cubic Bezier as a series of 4 quadratic CurvedEdgeRecord
with the method outlined by Timothee Groleau in ActionScript (which was
based on Helen Triolo's approach of using Casteljau's approximation).
|
static CurvedEdgeRecord |
curvedEdge(double startX,
double startY,
double controlX,
double controlY,
double anchorX,
double anchorY)
Creates a CurvedEdgeRecord to represent a quadratic curve by calculating
the deltas between the start coordinates and the control point
coordinates, and between the control point coordinates and the anchor
coordinates.
|
static Rect |
getBounds(List<ShapeRecord> records,
LineStyle ls,
AbstractStrokeNode strokeNode)
Utility method that calculates the minimum bounding rectangle that
encloses a list of ShapeRecords, taking into account the possible maximum
stroke width of any of the supplied linestyles.
|
static double |
getPointLength(org.apache.flex.compiler.internal.fxg.swf.ShapeHelper.Point p)
Get length of a point.
|
static List<ShapeRecord> |
implicitClosepath(double startX,
double startY,
double endX,
double endY)
Creates a List of ShapeRecord to draw a line that represents an implicit closepath
origin (startX, startY) to the specified coordinates (in pixels).
|
static List<ShapeRecord> |
line(double startX,
double startY,
double endX,
double endY)
Creates a List of ShapeRecord to draw a line from the given
origin (startX, startY) to the specified coordinates (in pixels).
|
static StyleChangeRecord |
move(double x,
double y)
Creates a StyleChangeRecord to represent a move command without changing
style information.
|
static org.apache.flex.compiler.internal.fxg.swf.ShapeHelper.Point |
normalize(org.apache.flex.compiler.internal.fxg.swf.ShapeHelper.Point p,
double length)
Normalize a point.
|
static List<ShapeRecord> |
path(PathNode node,
boolean fill,
Collection<ICompilerProblem> problems)
Note this utility was ported to Java from the ActionScript class
'flex.graphics.Path' - specifically its 'data' property setter function.
|
static List<ShapeRecord> |
rectangle(double width,
double height)
Creates a List of ShapeRecord to draw a rectangle from the
origin (0.0, 0.0) for the specified width and height (in pixels).
|
static List<ShapeRecord> |
rectangle(double startX,
double startY,
double width,
double height)
Creates a List of ShapeRecord to draw a rectangle from the given
origin (startX, startY) for the specified width and height (in pixels).
|
static List<ShapeRecord> |
rectangle(double startx,
double starty,
double width,
double height,
double radiusX,
double radiusY,
double topLeftRadiusX,
double topLeftRadiusY,
double topRightRadiusX,
double topRightRadiusY,
double bottomLeftRadiusX,
double bottomLeftRadiusY,
double bottomRightRadiusX,
double bottomRightRadiusY)
Creates a List of ShapeRecord to draw a rectangle from the given
origin (startX, startY) for the specified width and height (in pixels)
and radiusX and radiusY for rounded corners.
|
static void |
replaceStyles(List<ShapeRecord> shapeRecords,
int lineStyleIndex,
int fillStyle0Index,
int fillStyle1Index,
Styles styleContext)
Replaces the style information for the all the StyleChangeRecords in a list
of ShapeRecords.
|
static void |
setPathStyles(List<ShapeRecord> shapeRecords,
int lineStyleIndex,
int fillStyle0Index,
int fillStyle1Index,
Styles styles)
Sets the style information for the all the StyleChangeRecords in a list
of ShapeRecords.
|
static void |
setStyles(List<ShapeRecord> shapeRecords,
int lineStyleIndex,
int fillStyle0Index,
int fillStyle1Index,
Styles styles)
Sets the style information for the first StyleChangeRecord in a list
of ShapeRecords.
|
static List<ShapeRecord> |
straightEdge(double xFrom,
double yFrom,
double xTo,
double yTo)
Creates a StraightEdgeRecord to represent a line as the delta between
the pair of coordinates (xFrom,yFrom) and (xTo,yTo).
|
public static List<ShapeRecord> line(double startX, double startY, double endX, double endY)
startX
- The origin x coordinate in pixels.startY
- The origin y coordinate in pixels.endX
- The end x coordinate in pixels.endY
- The end y coordinate in pixels.public static List<ShapeRecord> implicitClosepath(double startX, double startY, double endX, double endY)
startX
- The origin x coordinate in pixels.startY
- The origin y coordinate in pixels.endX
- The end x coordinate in pixels.endY
- The end y coordinate in pixels.public static List<ShapeRecord> rectangle(double startX, double startY, double width, double height)
startX
- The origin x coordinate in pixels.startY
- The origin y coordinate in pixels.width
- The rectangle width in pixels.height
- The rectangle width in pixels.public static List<ShapeRecord> rectangle(double startx, double starty, double width, double height, double radiusX, double radiusY, double topLeftRadiusX, double topLeftRadiusY, double topRightRadiusX, double topRightRadiusY, double bottomLeftRadiusX, double bottomLeftRadiusY, double bottomRightRadiusX, double bottomRightRadiusY)
startx
- The origin x coordinate in pixels.starty
- The origin y coordinate in pixels.width
- The rectangle width in pixels.height
- The rectangle width in pixels.radiusX
- The radiusX for rounded corner in pixelsradiusY
- The radius for rounded corner in pixelspublic static List<ShapeRecord> rectangle(double width, double height)
width
- The rectangle width in pixels.height
- The rectangle width in pixels.public static void setStyles(List<ShapeRecord> shapeRecords, int lineStyleIndex, int fillStyle0Index, int fillStyle1Index, Styles styles)
shapeRecords
- A list of shape records.lineStyleIndex
- The ShapeWithStyle LineStyle index (starting at 1)
or 0 if none.fillStyle0Index
- The ShapeWithStyle FillStyle index (starting at 1)
or 0 if none.fillStyle1Index
- The ShapeWithStyle FillStyle index (starting at 1)
or 0 if none.public static void setPathStyles(List<ShapeRecord> shapeRecords, int lineStyleIndex, int fillStyle0Index, int fillStyle1Index, Styles styles)
shapeRecords
- A list of shape records.lineStyleIndex
- The ShapeWithStyle LineStyle index (starting at 1)
or 0 if none.fillStyle0Index
- The ShapeWithStyle FillStyle index (starting at 1)
or 0 if none.fillStyle1Index
- The ShapeWithStyle FillStyle index (starting at 1)
or 0 if none.public static void replaceStyles(List<ShapeRecord> shapeRecords, int lineStyleIndex, int fillStyle0Index, int fillStyle1Index, Styles styleContext)
shapeRecords
- A list of shape records.lineStyleIndex
- The ShapeWithStyle LineStyle index (starting at 1)
or 0 if none.fillStyle0Index
- The ShapeWithStyle FillStyle index (starting at 1)
or 0 if none.fillStyle1Index
- The ShapeWithStyle FillStyle index (starting at 1)
or 0 if none.public static StyleChangeRecord move(double x, double y)
x
- The x coordinate in pixels.y
- The y coordinate in pixels.public static List<ShapeRecord> straightEdge(double xFrom, double yFrom, double xTo, double yTo)
xFrom
- The start x coordinate in pixels.yFrom
- The start y coordinate in pixels.xTo
- The end x coordinate in pixels.yTo
- The end y coordinate in pixels.public static CurvedEdgeRecord curvedEdge(double startX, double startY, double controlX, double controlY, double anchorX, double anchorY)
startX
- The start x coordinate in pixels.startY
- The start y coordinate in pixels.controlX
- The control point x coordinate in pixels.controlY
- The control point y coordinate in pixels.anchorX
- The anchor x coordinate in pixels.anchorY
- The anchor y coordinate in pixels.public static List<ShapeRecord> cubicToQuadratic(double startX, double startY, double control1X, double control1Y, double control2X, double control2Y, double anchorX, double anchorY)
startX
- The start x coordinate in pixels.startY
- The start y coordinate in pixels.control1X
- The first control point x coordinate in pixels.control1Y
- The first control point y coordinate in pixels.control2X
- The second control point x coordinate in pixels.control2Y
- The second control point y coordinate in pixels.anchorX
- The anchor x coordinate in pixels.anchorY
- The anchor y coordinate in pixels.public static List<ShapeRecord> path(PathNode node, boolean fill, Collection<ICompilerProblem> problems)
public static Rect getBounds(List<ShapeRecord> records, LineStyle ls, AbstractStrokeNode strokeNode)
public static Rect addJoint2Bounds(List<ShapeRecord> records, LineStyle ls, AbstractStrokeNode stroke, double halfWeight, Rect pathBBox)
public static Rect addMiterLimitStrokeToBounds(ShapeRecord segment1, ShapeRecord segment2, double miterLimit, double halfWeight, Rect pathBBox, int xPrev, int yPrev, int x, int y)
public static org.apache.flex.compiler.internal.fxg.swf.ShapeHelper.Point normalize(org.apache.flex.compiler.internal.fxg.swf.ShapeHelper.Point p, double length)
public static double getPointLength(org.apache.flex.compiler.internal.fxg.swf.ShapeHelper.Point p)
Copyright © 2016 The Apache Software Foundation. All rights reserved.