public class Curve extends Object
A Curve object is stateless but the methods are not static so that a better implementation can be created and substituted for the static variable "curve" if necessary.
Modifier and Type | Field and Description |
---|---|
static Curve |
curve |
static int |
MAX_POINTS |
Constructor and Description |
---|
Curve() |
Modifier and Type | Method and Description |
---|---|
int |
calculateCubes(float[] xpoints,
float[] ypoints,
int pointsOffset,
Object destX,
Object destY,
int offset,
int options)
Calculate the curve points for the curve.
|
protected int |
calculateCubes(float startx,
float starty,
float control1x,
float control1y,
float control2x,
float control2y,
float endx,
float endy,
Object destx,
Object desty,
int offset,
int options) |
int |
calculateLines(float[] xpoints,
float[] ypoints,
int pointsOffset,
Object destX,
Object destY,
int offset,
int options)
Calculate the line points for the line.
|
protected int |
calculateLines(float startx,
float starty,
float endx,
float endy,
Object destx,
Object desty,
int offset,
int options)
This calculates the points on a quad curve, for either the x or y co-ordinate.
|
int |
calculateQuads(float[] xpoints,
float[] ypoints,
int pointsOffset,
Object destX,
Object destY,
int offset,
int options)
Calculate the curve points for the curve.
|
protected int |
calculateQuads(float startx,
float starty,
float controlx,
float controly,
float endx,
float endy,
Object destx,
Object desty,
int offset,
int options)
This calculates the points on a quad curve, for either the x or y co-ordinate.
|
void |
copyTransformedQuadrant(int[] srcXYPoints,
int srcOffset,
int numPoints,
int[] destXYPoints,
int destOffset,
int quadrant,
int x,
int y,
int width,
int height,
int xradius,
int yradius) |
void |
drawArc(Graphics g,
int x,
int y,
int width,
int height,
float startAngle,
float angle)
Draw an arc of an ellipse on the Graphics context using the current pen.
|
void |
drawRoundRectOutline(Graphics g,
int style,
int x,
int y,
int width,
int height,
int radius,
int labelWidth) |
IntArray |
getArcLines(int x,
int y,
int width,
int height,
float start,
float angle,
IntArray dest)
Given a bounding box for an ellipse, this method finds the line segments
along the specified arc such that there are no gaps in the arc.
|
IntArray |
getArcPoints(int x,
int y,
int width,
int height,
float start,
float angle,
IntArray dest)
Given a bounding box for an ellipse, this method finds the points
along the specified arc such that there are no gaps in the arc.
|
QuadrantPoints |
getCachedQuadrantPoints(int rx,
int ry)
This returns a reused version of a QuadrantPoints for the specified
x and y radii.
|
protected int |
getQuadrantPoints(int rx,
int ry,
int[] destX,
int[] destY,
int xOffset,
int yOffset) |
QuadrantPoints |
getQuadrantPoints(int rx,
int ry,
QuadrantPoints dest) |
void |
paintClosedArc(Graphics g,
int x,
int y,
int width,
int height,
float startAngle,
float angle,
boolean useBrush,
boolean usePen)
Draw and/or fill a closed arc of an ellipse on the Graphics context.
|
void |
paintPie(Graphics g,
int x,
int y,
int width,
int height,
float startAngle,
float angle,
boolean useBrush,
boolean usePen)
Draw and/or fill a pie section of an ellipse on the Graphics context.
|
void |
paintRoundRect(Graphics g,
int x,
int y,
int width,
int height,
int radius,
boolean useBrush,
boolean usePen) |
int |
pointsToLines(int[] x,
int[] y,
int xoffset,
int yoffset,
int numPoints)
Convert points to straight line segments as best as possible.
|
void |
rightTransform(int[] xpoints,
int[] ypoints,
int xoffset,
int yoffset,
int count,
int m00,
int m10,
int m01,
int m11,
int m02,
int m12)
Transform a set of x and y co-ordinates but only with integer precision.
|
void |
rightTransform(int[] xyPoints,
int offset,
int count,
int m00,
int m10,
int m01,
int m11,
int m02,
int m12) |
public static Curve curve
public static final int MAX_POINTS
protected int calculateLines(float startx, float starty, float endx, float endy, Object destx, Object desty, int offset, int options)
This method does NOT include the last point on the curve, but DOES include the first one.
protected int calculateQuads(float startx, float starty, float controlx, float controly, float endx, float endy, Object destx, Object desty, int offset, int options)
This method does NOT include the last point on the curve, but DOES include the first one.
protected int calculateCubes(float startx, float starty, float control1x, float control1y, float control2x, float control2y, float endx, float endy, Object destx, Object desty, int offset, int options)
public int calculateLines(float[] xpoints, float[] ypoints, int pointsOffset, Object destX, Object destY, int offset, int options)
xpoints
- The X coordinates for the curve.
The first one should be the start point, the second should be the end point.ypoints
- The Y coordinates for the curve.
The first one should be the start point, the second should be the end point.
one should be the end point.pointsOffset
- The offset of the points in the xpoints and ypoints array.destX
- Either an int[] or float[] object to hold the destination X points. Can be
null if you only are interested in the number of points that will be calculated.destY
- Either an int[] or float[] object to hold the destination Y points. Can be
null if you only are interested in the number of points that will be calculated.offset
- The offset into the destX and destY arrays for the points to go.options
- No options are currently defined.public int calculateQuads(float[] xpoints, float[] ypoints, int pointsOffset, Object destX, Object destY, int offset, int options)
xpoints
- The X coordinates for the curve.
The first one should be the start point, the second should be the control point and the third
one should be the end point.ypoints
- The Y coordinates for the curve.
The first one should be the start point, the second should be the control point and the third
one should be the end point.pointsOffset
- The offset of the points in the xpoints and ypoints array.destX
- Either an int[] or float[] object to hold the destination X points. Can be
null if you only are interested in the number of points that will be calculated.destY
- Either an int[] or float[] object to hold the destination Y points. Can be
null if you only are interested in the number of points that will be calculated.offset
- The offset into the destX and destY arrays for the points to go.options
- No options are currently defined.public int calculateCubes(float[] xpoints, float[] ypoints, int pointsOffset, Object destX, Object destY, int offset, int options)
xpoints
- The X coordinates for the curve.
The first one should be the start point, the second should be the control point and the third
one should be the end point.ypoints
- The Y coordinates for the curve.
The first one should be the start point, the second should be the control point and the third
one should be the end point.pointsOffset
- The offset of the points in the xpoints and ypoints array.destX
- Either an int[] or float[] object to hold the destination X points. Can be
null if you only are interested in the number of points that will be calculated.destY
- Either an int[] or float[] object to hold the destination Y points. Can be
null if you only are interested in the number of points that will be calculated.offset
- The offset into the destX and destY arrays for the points to go.options
- No options are currently defined.public void rightTransform(int[] xpoints, int[] ypoints, int xoffset, int yoffset, int count, int m00, int m10, int m01, int m11, int m02, int m12)
The transform is done as follows:
x = x*m00+y*m01+m02 y = x*m10+y*m11+m12
x
- They
- xoffset
- yoffset
- count
- m00
- m10
- m01
- m11
- m02
- m12
- public final void rightTransform(int[] xyPoints, int offset, int count, int m00, int m10, int m01, int m11, int m02, int m12)
protected int getQuadrantPoints(int rx, int ry, int[] destX, int[] destY, int xOffset, int yOffset)
public QuadrantPoints getQuadrantPoints(int rx, int ry, QuadrantPoints dest)
public QuadrantPoints getCachedQuadrantPoints(int rx, int ry)
rx
- the x-radius.ry
- the y-radius.public int pointsToLines(int[] x, int[] y, int xoffset, int yoffset, int numPoints)
x
- the x co-ordinates.y
- the y co-ordinates. If it is null it is assumed equal to x.xoffset
- the x offset for the start of the x co-ordinates.yoffset
- the y offset for the start of the y co-ordinates.
If y is equal to x (or null) AND the y offset is equal to the x offset
or the x offset+1 then it assumed that the x and y co-ordinates
are interleaved within the array (first x, then y).numPoints
- the number of points in the original data.public IntArray getArcPoints(int x, int y, int width, int height, float start, float angle, IntArray dest)
The points are placed in the destination IntArray with the x and y co-ordinates interleaved - i.e. X1, Y1, X2, Y2, ...
The number of co-ordinate points will be equal to the returned IntArray length field divided by 2.
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.start
- the start angle in degrees, where 0 is at the 3 O' clock
position (due East), 90 is at the 12 O' clock position (due North), etc..angle
- the number of degrees of the arc anti-clockwise.dest
- - a destination IntArray which will be cleared
before having the x,y co-ordinates added.public IntArray getArcLines(int x, int y, int width, int height, float start, float angle, IntArray dest)
The points are placed in the destination IntArray with the x and y co-ordinates interleaved - i.e. X1, Y1, X2, Y2, ...
The number of co-ordinate points will be equal to the returned IntArray length field divided by 2.
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.start
- the start angle in degrees, where 0 is at the 3 O' clock
position (due East), 90 is at the 12 O' clock position (due North), etc..angle
- the number of degrees of the arc anti-clockwise.dest
- - a destination IntArray which will be cleared
before having the x,y co-ordinates added.public void drawArc(Graphics g, int x, int y, int width, int height, float startAngle, float angle)
g
- The destination graphics.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.start
- the start angle in degrees, where 0 is at the 3 O' clock
position (due East), 90 is at the 12 O' clock position (due North), etc..angle
- the number of degrees of the arc anti-clockwise.public void paintClosedArc(Graphics g, int x, int y, int width, int height, float startAngle, float angle, boolean useBrush, boolean usePen)
A start angle of 0 and an arc angle of 360 will give a full ellipse.
g
- The destination graphics.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.start
- the start angle in degrees, where 0 is at the 3 O' clock
position (due East), 90 is at the 12 O' clock position (due North), etc..angle
- the number of degrees of the arc anti-clockwise.useBrush
- true to fill the closed arc with the current brush.usePen
- true to outline the closed arc with the current pen.public void paintPie(Graphics g, int x, int y, int width, int height, float startAngle, float angle, boolean useBrush, boolean usePen)
g
- The destination graphics.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.start
- the start angle in degrees, where 0 is at the 3 O' clock
position (due East), 90 is at the 12 O' clock position (due North), etc..angle
- the number of degrees of the arc anti-clockwise.useBrush
- true to fill the pie section with the current brush.usePen
- true to outline the pie section with the current pen.public void copyTransformedQuadrant(int[] srcXYPoints, int srcOffset, int numPoints, int[] destXYPoints, int destOffset, int quadrant, int x, int y, int width, int height, int xradius, int yradius)
public void drawRoundRectOutline(Graphics g, int style, int x, int y, int width, int height, int radius, int labelWidth)
public void paintRoundRect(Graphics g, int x, int y, int width, int height, int radius, boolean useBrush, boolean usePen)