public interface GraphicContext
drawX
- means that getColor()
will be used as the border of
the figure XfillX
- means that getColor()
will be used as the area of the
figure XModifier and Type | Method and Description |
---|---|
Area |
calculateTextSize(String text)
Calculates the size of the text.
|
void |
clip(Area rect)
Restricts which area of the context can be used to drawn on.
|
default void |
drawLine(double x1,
double y1,
double x2,
double y2)
Draws a simple line between two points.
|
void |
drawPolyline(double[] x,
double[] y)
Paints the outline of a polyline.
|
default void |
drawRectangle(Area rect)
Paints a outline of a rectangle.
|
default void |
drawRectangle(double x,
double y,
double width,
double height)
Paints a outline of a rectangle.
|
void |
drawText(double x,
double y,
String text)
Paints the text on a position.
|
void |
fillArc(double x,
double y,
double width,
double height,
double startAngle,
double arcAngle)
Draws the outline of a circular or elliptical arc covering the specified rectangle.
|
void |
fillOval(double x,
double y,
double width,
double height)
Paints a filled oval.
|
void |
fillPolygon(double[] x,
double[] y)
Paints a filled polygon.
|
default void |
fillRectangle(Area rect)
Paints a filled rectangle.
|
default void |
fillRectangle(double x,
double y,
double width,
double height)
Paints a filled rectangle.
|
int |
getColor()
Returns the color as ARGB int, e.g.
|
Font |
getFont()
Returns the font as an enum with the font properties as hints for the actual font
used by the GUI.
|
default void |
scale(double factor)
Scales the drawing canvas with the factor.
|
void |
scale(double x,
double y)
Scales the drawing canvas with the factor.
|
void |
setColor(int color)
Sets the color as ARGB int, e.g.
|
void |
setFont(Font font)
Sets the font as an enum with the font properties as hints for the actual font used
by the GUI.
|
void |
translate(double x,
double y)
Moves the drawing canvas's origin to the new coordinates.
|
void setColor(int color)
0xFFFF0000
and blue is
0xFF0000FF
.color
- the colorint getColor()
0xFFFF0000
and blue is
0xFF0000FF
.void setFont(Font font)
font
- the fontFont getFont()
Area calculateTextSize(String text)
text
- void translate(double x, double y)
x
- translate xy
- translate ydefault void scale(double factor)
factor
- factor for both x and yvoid scale(double x, double y)
x
- factor xy
- factor yvoid clip(Area rect)
null
to remove the restriction again.rect
- the clipping areadefault void drawLine(double x1, double y1, double x2, double y2)
x1
- - start point xy1
- - start point yx2
- - end point xy2
- - end point ydefault void fillRectangle(Area rect)
rect
- the rectangle's coordinatesdefault void fillRectangle(double x, double y, double width, double height)
x
- the rectangle's xy
- the rectangle's ywidth
- the rectangle's widthheight
- the rectangle's heightdefault void drawRectangle(Area rect)
rect
- the rectangle's coordinatesdefault void drawRectangle(double x, double y, double width, double height)
x
- the rectangle's xy
- the rectangle's ywidth
- the rectangle's widthheight
- the rectangle's heightvoid drawPolyline(double[] x, double[] y)
x
- the polygon's x coordinatesy
- the polygon's y coordinatesfillPolygon(double[], double[])
void fillPolygon(double[] x, double[] y)
x
- the polygon's x coordinatesy
- the polygon's y coordinatesdrawPolyline(double[], double[])
void drawText(double x, double y, String text)
x
- the text's xy
- the text's yvoid fillOval(double x, double y, double width, double height)
x
- the oval's xy
- the oval's ywidth
- the oval's widthheight
- the oval's heightvoid fillArc(double x, double y, double width, double height, double startAngle, double arcAngle)
The resulting arc begins at startAngle
and extends for
arcAngle
degrees, using the current color. Angles are interpreted such
that 0 degrees is at the 3 o'clock position. A positive value indicates a
counter-clockwise rotation while a negative value indicates a clockwise rotation.
The center of the arc is the center of the rectangle whose origin is
(x, y) and whose size is specified by the width
and
height
arguments.
The resulting arc covers an area width + 1
pixels wide by
height + 1
pixels tall.
x
- the x coordinate of the upper-left corner of the arc to be drawn.y
- the y coordinate of the upper-left corner of the arc to be drawn.width
- the width of the arc to be drawn.height
- the height of the arc to be drawn.startAngle
- the beginning angle.arcAngle
- the angular extent of the arc, relative to the start angle.Copyright © 2020. All rights reserved.