public class ShapePainter extends Object
ShapePainter
class offers a set of static methods to render thick shapes (with or without
anti-aliasing) and polygons.Modifier and Type | Class and Description |
---|---|
static class |
ShapePainter.Cap
Defines the cap representation when drawing a line or a circle arc.
|
Modifier and Type | Method and Description |
---|---|
static void |
drawPolygon(GraphicsContext gc,
int[] xys)
Draws the closed polygon which is defined by the array of integer coordinates, using the current color.
|
static void |
drawPolygon(GraphicsContext gc,
int[] xys,
int offset,
int length)
Draws the closed polygon which is defined by the array of integer coordinates, using the current color.
|
static void |
drawThickCircle(GraphicsContext gc,
int x,
int y,
int diameter,
int thickness)
Draws the outline of a circle covering the square specified by its diameter, using the
GraphicsContext 's
current color.The center of the circle is defined as the center of the square whose origin is at (x,y) (upper-left
corner) and whose dimension is given by diameter .If diameter is negative, nothing is drawn. |
static void |
drawThickCircleArc(GraphicsContext gc,
int x,
int y,
int diameter,
float startAngle,
float arcAngle,
int thickness)
Draws the outline of a circular arc covering the specified square, using the
GraphicsContext 's current
color.The arc is drawn from startAngle up to arcAngle degrees. |
static void |
drawThickEllipse(GraphicsContext gc,
int x,
int y,
int width,
int height,
int thickness)
Draws the outline of a ellipse covering the specified rectangle, using the
GraphicsContext 's current
color.The center of the ellipse is defined as the center of the rectangle whose origin is at (x,y)
(upper-left corner) and whose dimension is given by width and height .If either width or height is negative or zero, nothing is drawn. |
static void |
drawThickFadedCircle(GraphicsContext gc,
int x,
int y,
int diameter,
int thickness,
int fade)
Draws the faded outline of a circle covering the square specified by its diameter, using the
GraphicsContext 's current color.The center of the circle is defined as the center of the square whose origin is at (x,y) (upper-left
corner) and whose dimension is given by diameter .If diameter is negative or zero, nothing is drawn. |
static void |
drawThickFadedCircleArc(GraphicsContext gc,
int x,
int y,
int diameter,
float startAngle,
float arcAngle,
int thickness,
int fade,
ShapePainter.Cap startCap,
ShapePainter.Cap endCap)
Draws the faded outline of a circular arc covering the specified square, using the current color and caps.
|
static void |
drawThickFadedEllipse(GraphicsContext gc,
int x,
int y,
int width,
int height,
int thickness,
int fade)
Draws the outline of a ellipse covering the specified rectangle, using the
GraphicsContext 's current
color.The center of the ellipse is defined as the center of the rectangle whose origin is at (x,y)
(upper-left corner) and whose dimension is given by width and height .If either width or height is negative or zero, nothing is drawn. |
static void |
drawThickFadedLine(GraphicsContext gc,
int startX,
int startY,
int endX,
int endY,
int thickness,
int fade,
ShapePainter.Cap startCap,
ShapePainter.Cap endCap)
|
static void |
drawThickFadedPoint(GraphicsContext gc,
int x,
int y,
int thickness,
int fade)
Draws a faded point at
(x,y) using the GraphicsContext 's current color. |
static void |
drawThickLine(GraphicsContext gc,
int startX,
int startY,
int endX,
int endY,
int thickness)
|
static void |
fillPolygon(GraphicsContext gc,
int[] xys)
Fills the closed polygon which is defined by the array of integer coordinates, using the current color.
|
static void |
fillPolygon(GraphicsContext gc,
int[] xys,
int offset,
int length)
Fills the closed polygon which is defined by the array of integer coordinates, using the current color.
|
public static void drawPolygon(GraphicsContext gc, int[] xys)
draw(xys,0,xys.length);
gc
- the graphics context where render the drawing.xys
- the array of coordinates : x1,y1,......xn,yn.IllegalArgumentException
- if the given array length is odd.public static void drawPolygon(GraphicsContext gc, int[] xys, int offset, int length)
gc
- the graphics context where render the drawing.xys
- the array of coordinates : x1,y1,......xn,yn.offset
- the x1
index in xys
.length
- the number of coordinates, must be even.IllegalArgumentException
- if the given array length is odd.ArrayIndexOutOfBoundsException
- the wanted data is outside the array bounds.public static void drawThickCircle(GraphicsContext gc, int x, int y, int diameter, int thickness)
GraphicsContext
's
current color.(x,y)
(upper-left
corner) and whose dimension is given by diameter
.diameter
is negative, nothing is drawn.
The rendering is aliased but the rendering time is often faster than
drawThickFadedCircle(GraphicsContext, int, int, int, int, int)
.
Equivalent to calling drawThickFadedCircle(GraphicsContext, int, int, int, int, int)
with a fade equals
to 0.
gc
- the graphics context where render the drawing.x
- the x coordinate of the upper-left corner of the square where the circle is drawn.y
- the y coordinate of the upper-left corner of the square where the circle is drawn.diameter
- the diameter of the circle to draw.thickness
- the thickness to apply.IllegalArgumentException
- when given thickness is negativepublic static void drawThickCircleArc(GraphicsContext gc, int x, int y, int diameter, float startAngle, float arcAngle, int thickness)
GraphicsContext
's current
color.startAngle
up to arcAngle
degrees. The center of the arc is
defined as the center of the square whose origin is at (x,y)
(upper-left corner) and whose dimension
is given by diameter
.diameter
is negative, nothing is drawn.
The rendering is aliased but the rendering time is often faster than
drawThickFadedCircleArc(GraphicsContext, int, int, int, float, float, int, int, Cap, Cap)
.
Equivalent to calling
drawThickFadedCircleArc(GraphicsContext, int, int, int, float, float, int, int, Cap, Cap)
with a fade
equals to 0 and ShapePainter.Cap.NONE
for caps.
gc
- the graphics context where render the drawing.x
- the x coordinate of the upper-left corner of the square where the arc is drawn.y
- the y coordinate of the upper-left corner of the square where the arc is drawn.diameter
- the diameter of the arc to draw.startAngle
- the beginning angle of the arc to draw.arcAngle
- the angular extent of the arc from startAngle
.thickness
- the thickness to apply.IllegalArgumentException
- when given thickness is negativepublic static void drawThickEllipse(GraphicsContext gc, int x, int y, int width, int height, int thickness)
GraphicsContext
's current
color.(x,y)
(upper-left corner) and whose dimension is given by width
and height
.width
or height
is negative or zero, nothing is drawn.
The rendering is aliased but the rendering time is often faster than
drawThickFadedEllipse(GraphicsContext, int, int, int, int, int, int)
.
Equivalent to calling drawThickFadedEllipse(GraphicsContext, int, int, int, int, int, int)
with a fade
equals to 0.
gc
- the graphics context where render the drawing.x
- the x coordinate of the upper-left corner of the rectangle where the ellipse is drawny
- the y coordinate of the upper-left corner of the rectangle where the ellipse is drawnwidth
- the width of the ellipse to drawheight
- the height of the ellipse to drawthickness
- the thickness to apply.IllegalArgumentException
- when given thickness is negativepublic static void drawThickFadedCircle(GraphicsContext gc, int x, int y, int diameter, int thickness, int fade)
GraphicsContext
's current color.(x,y)
(upper-left
corner) and whose dimension is given by diameter
.diameter
is negative or zero, nothing is drawn.gc
- the graphics context where render the drawing.x
- the x coordinate of the upper-left corner of the square where the circle is drawny
- the y coordinate of the upper-left corner of the square where the circle is drawndiameter
- the diameter of the circle to drawthickness
- the thickness to apply.fade
- the fade to apply.IllegalArgumentException
- when given thickness or fade is negativepublic static void drawThickFadedCircleArc(GraphicsContext gc, int x, int y, int diameter, float startAngle, float arcAngle, int thickness, int fade, ShapePainter.Cap startCap, ShapePainter.Cap endCap)
startAngle
up to arcAngle
degrees. The center of the arc is
defined as the center of the square whose origin is at (x,y)
(upper-left corner) and whose dimension
is given by diameter
.diameter
is negative or zero, nothing is drawn.gc
- the graphics context where render the drawing.x
- the x coordinate of the upper-left corner of the square where the arc is drawny
- the y coordinate of the upper-left corner of the square where the arc is drawndiameter
- the diameter of the arc to drawstartAngle
- the beginning angle of the arc to drawarcAngle
- the angular extent of the arc from startAngle
thickness
- the thickness to apply.fade
- the fade to apply.startCap
- the cap to draw at startAngle.endCap
- the cap to draw at startAngle + arcAngle.IllegalArgumentException
- when given thickness or fade is negativepublic static void drawThickFadedEllipse(GraphicsContext gc, int x, int y, int width, int height, int thickness, int fade)
GraphicsContext
's current
color.(x,y)
(upper-left corner) and whose dimension is given by width
and height
.width
or height
is negative or zero, nothing is drawn.gc
- the graphics context where render the drawing.x
- the x coordinate of the upper-left corner of the rectangle where the ellipse is drawny
- the y coordinate of the upper-left corner of the rectangle where the ellipse is drawnwidth
- the width of the ellipse to drawheight
- the height of the ellipse to drawthickness
- the thickness to apply.fade
- the fade to apply.IllegalArgumentException
- when given thickness or fade is negativepublic static void drawThickFadedLine(GraphicsContext gc, int startX, int startY, int endX, int endY, int thickness, int fade, ShapePainter.Cap startCap, ShapePainter.Cap endCap)
gc
- the graphics context where render the drawing.startX
- the x coordinate of the start of the linestartY
- the y coordinate of the start of the lineendX
- the x coordinate of the end of the lineendY
- the y coordinate of the end of the linethickness
- the thickness to apply.fade
- the fade to apply.startCap
- the cap to draw on (x1,y1).endCap
- the cap to draw on (x2,y2).IllegalArgumentException
- when given thickness or fade is negativepublic static void drawThickFadedPoint(GraphicsContext gc, int x, int y, int thickness, int fade)
(x,y)
using the GraphicsContext
's current color.gc
- the graphics context where render the drawing.x
- the x coordinate of the pointy
- the y coordinate of the pointthickness
- the thickness to apply.fade
- the fade to apply.IllegalArgumentException
- when given thickness is negativepublic static void drawThickLine(GraphicsContext gc, int startX, int startY, int endX, int endY, int thickness)
(x1,y1)
to (x2,y2)
using the GraphicsContext
's current color.
The rendering is aliased but the rendering time is often faster than
drawThickFadedLine(GraphicsContext, int, int, int, int, int, int, Cap, Cap)
.
Equivalent to calling drawThickFadedLine(GraphicsContext, int, int, int, int, int, int, Cap, Cap)
with a
fade equals to 0 and ShapePainter.Cap.NONE
for caps.
gc
- the graphics context where render the drawing.startX
- the x coordinate of the start of the line.startY
- the y coordinate of the start of the line.endX
- the x coordinate of the end of the line.endY
- the y coordinate of the end of the line.thickness
- the thickness to apply.IllegalArgumentException
- when given thickness is negativepublic static void fillPolygon(GraphicsContext gc, int[] xys)
fill(xys,0,xys.length);
gc
- the graphics context where render the drawing.xys
- the array of coordinates : x1,y1,......xn,yn.IllegalArgumentException
- if the given array length is odd.public static void fillPolygon(GraphicsContext gc, int[] xys, int offset, int length)
gc
- the graphics context where render the drawing.xys
- the array of coordinates : x1,y1,......xn,yn.offset
- the x1
index in xys
.length
- the number of coordinates, must be even.ArrayIndexOutOfBoundsException
- if offset
and length
do not specify a valid range within xys
.IllegalArgumentException
- if the xys
length is odd.