public class AntiAliasedShapes
extends java.lang.Object
AntiAliasedShapes
class offers advanced drawing facilities, to render anti aliased lines, circles etc.
AntiAliasedShapes
instance holds a global state (thickness and fade) for all drawings. Several
AntiAliasedShapes
instances can be created at same time. However a default instance is created on MicroUI
framework startup and it always available.Modifier and Type | Class and Description |
---|---|
static class |
AntiAliasedShapes.Cap
Define the cap representation when drawing a circle arc
|
Modifier and Type | Field and Description |
---|---|
static AntiAliasedShapes |
Singleton
Default
AntiAliasedShapes instance created on MicroUI framework startup. |
Constructor and Description |
---|
AntiAliasedShapes()
Creates a new
AntiAliasedShapes instance. |
Modifier and Type | Method and Description |
---|---|
void |
drawCircle(GraphicsContext gc,
int x,
int y,
int diameter)
Draws the outline of a circle covering the rectangle specified by its diameter, using the
GraphicsContext
's current color.The center of the circle is defined as the center of the rectangle whose origin is at (x,y)
(upper-left corner) and whose dimension is given by diameter .If diameter is negative, nothing is drawn. |
void |
drawCircleArc(GraphicsContext gc,
int x,
int y,
int diameter,
int startAngle,
int arcAngle)
Draws the outline of a circular arc covering the specified square, using the current color, stroke style and caps
The arc is drawn from startAngle up to arcAngle degrees. |
void |
drawEllipse(GraphicsContext gc,
int x,
int y,
int width,
int height)
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, nothing is drawn. |
void |
drawLine(GraphicsContext gc,
int x1,
int y1,
int x2,
int y2)
|
void |
drawPoint(GraphicsContext gc,
int x,
int y)
Draws a point at
(x,y) using the GraphicsContext 's current color. |
AntiAliasedShapes.Cap |
getEndCap()
Returns the current shape end cap.
|
int |
getFade()
Returns the current
fade . |
AntiAliasedShapes.Cap |
getStartCap()
Returns the current shape start cap.
|
int |
getThickness()
Returns the current
thickness . |
void |
reset()
Resets the
AntiAliasedShapes global state to its initial values. |
void |
setCaps(AntiAliasedShapes.Cap start,
AntiAliasedShapes.Cap end)
Configures the caps representation.
|
void |
setEndCap(AntiAliasedShapes.Cap cap)
Configures the cap representation of end of shape.
|
void |
setFade(int fade)
Apply a new
fade . |
void |
setStartCap(AntiAliasedShapes.Cap cap)
Configures the cap representation of start of shape.
|
void |
setThickness(int thickness)
Apply a new
thickness . |
public static AntiAliasedShapes Singleton
AntiAliasedShapes
instance created on MicroUI framework startup.public AntiAliasedShapes()
AntiAliasedShapes
instance. The global state is set to its initial value.reset()
public void reset()
AntiAliasedShapes
global state to its initial values. Default fade
is 1 and
default thickness
is 0.public int getFade()
fade
.fade
.public void setFade(int fade)
fade
.fade
- the new fade to apply.java.lang.IllegalArgumentException
- when given fade is negativepublic int getThickness()
thickness
.thickness
.public void setThickness(int thickness)
thickness
.thickness
- the new thickness to apply.java.lang.IllegalArgumentException
- when given thickness is negativepublic AntiAliasedShapes.Cap getStartCap()
public void setStartCap(AntiAliasedShapes.Cap cap)
drawCircleArc(GraphicsContext, int, int, int, int, int)
.cap
- the shape cap configurationpublic AntiAliasedShapes.Cap getEndCap()
public void setEndCap(AntiAliasedShapes.Cap cap)
drawCircleArc(GraphicsContext, int, int, int, int, int)
.cap
- the shape cap configurationpublic void setCaps(AntiAliasedShapes.Cap start, AntiAliasedShapes.Cap end)
drawCircleArc(GraphicsContext, int, int, int, int, int)
. It is equivalent to the following code
sequence:setStartCap(start);
setEndCap(end);
start
- the shape cap configurationend
- the shape cap configurationpublic void drawPoint(GraphicsContext gc, int x, int y)
(x,y)
using the GraphicsContext
's current color.gc
- the GraphicsContext
where render the drawing.x
- the x coordinate of the pointy
- the y coordinate of the pointpublic void drawLine(GraphicsContext gc, int x1, int y1, int x2, int y2)
gc
- the GraphicsContext
where render the drawing.x1
- the x coordinate of the start of the liney1
- the y coordinate of the start of the linex2
- the x coordinate of the end of the liney2
- the y coordinate of the end of the linepublic final void drawCircleArc(GraphicsContext gc, int x, int y, int diameter, int startAngle, int arcAngle)
startAngle
up to arcAngle
degrees. The center of the arc is
defined as the center of the rectangle whose origin is at (x,y)
(upper-left corner) and whose
dimension is given by diameter
.diameter
is negative, nothing is drawn.gc
- the GraphicsContext
where render the drawing.x
- the x coordinate of the upper-left corner of the rectangle where the arc is drawny
- the y coordinate of the upper-left corner of the rectangle 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
setStartCap(Cap)
,
setEndCap(Cap)
,
setCaps(Cap, Cap)
public void drawCircle(GraphicsContext gc, int x, int y, int diameter)
GraphicsContext
's current color.(x,y)
(upper-left corner) and whose dimension is given by diameter
.diameter
is negative, nothing is drawn.gc
- the GraphicsContext
where render the drawing.x
- the x coordinate of the upper-left corner of the rectangle where the circle is drawny
- the y coordinate of the upper-left corner of the rectangle where the circle is drawndiameter
- the diameter of the circle to drawpublic void drawEllipse(GraphicsContext gc, int x, int y, int width, int height)
GraphicsContext
's current
color.(x,y)
(upper-left corner) and whose dimension is given by width
and height
.width
or height
is negative, nothing is drawn.gc
- the GraphicsContext
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 draw