public class LLUIPainter extends Object
The equivalent of embedded structures and enumerations are LLUIPainter.MicroUIImage
, LLUIPainter.MicroUIGraphicsContext
and
LLUIPainter.MicroUIImageFormat
. They are used to identify the MicroUI graphical objects: GraphicsContext, Image, image
format. etc.
Implementation must use the framework object LLUIDisplay.Instance
as monitor to synchronize drawings.
All native methods has a byte array as first parameter. This identifies the destination target: the MicroUI
GraphicsContext. This target is retrieved in MicroEJ application calling the method gc.getSNIContext()
.
The returned byte array must be mapped on a LLUIPainter.MicroUIGraphicsContext
object in MicroUI native drawing method
implementation (see LLUIDisplay.mapMicroUIGraphicsContext(byte[])
).
For a MicroUI Image, MicroEJ application has to call image.getSNIContext()
to get the image byte array.
This byte array must be mapped it on a LLUIPainter.MicroUIImage
object in MicroUI native drawing method implementation
(see LLUIDisplay.mapMicroUIImage(byte[])
).
A graphics context holds a clip and the drawer is not allowed to perform a drawing outside this clip (otherwise the
behavior is unknown). Note the bottom-right coordinates might be smaller than top-left (in x and/or y) when the clip
width and/or height is null. The clip may be disabled (when the current drawing fits the clip); this allows to reduce
runtime. See LLUIPainter.MicroUIGraphicsContext.isClipEnabled()
. Note: several clip methods are available in
LLUIPainter.MicroUIGraphicsContext
to check if a drawing fits the clip.
The drawing method must:
LLUIPainter.MicroUIGraphicsContext.getRenderingColor()
(in order
to respect embedded display pixel representation constraints),Display.flush()
area (dirty area); if not performed, the next call to
Display.flush()
will not call
LLUIDisplayImpl#flush(MicroUIGraphicsContext, Image, int, int, int, int)
method.The native method implementation pattern is:
void drawXxx(byte[] target, ...) { LLUIDisplay graphicalEngine = LLUIDisplay.Instance; // all calls to GraphicalEngine.Instance APIs must be synchronized on GraphicalEngine.Instance itself synchronized (graphicalEngine) { // map a MicroUIGraphicsContext on given byte array which represents the destination target MicroUIGraphicsContext gc = graphicalEngine.mapMicroUIGraphicsContext(target); // ask to the graphical engine if a drawing can be performed on target if (gc.requestDrawing()) { // call current drawer's equivalent drawing method getDrawer().drawXxx(gc, x, y); // contrary to MicroUI native drawing methods implementation for embedded (LLUI_PAINTER_impl.h), there // is no status to set in MicroUI graphical engine } } }
Modifier and Type | Class and Description |
---|---|
static interface |
LLUIPainter.MicroUIGraphicsContext
Represents a MicroUI GraphicsContext.
|
static interface |
LLUIPainter.MicroUIImage
Represents a MicroUI Image.
|
static class |
LLUIPainter.MicroUIImageFormat
Enumerates all MicroUI Image RAW formats.
|
Modifier and Type | Method and Description |
---|---|
static void |
drawCircle(byte[] target,
int x,
int y,
int diameter)
MicroUI native "drawCircle".
|
static void |
drawCircleArc(byte[] target,
int x,
int y,
int diameter,
float startAngle,
float arcAngle)
MicroUI native "drawCircleArc".
|
static void |
drawEllipse(byte[] target,
int x,
int y,
int width,
int height)
MicroUI native "drawEllipse".
|
static void |
drawEllipseArc(byte[] target,
int x,
int y,
int width,
int height,
float startAngle,
float arcAngle)
MicroUI native "drawEllipseArc".
|
static void |
drawHorizontalLine(byte[] target,
int x,
int y,
int width)
MicroUI native "drawHorizontalLine".
|
static void |
drawImage(byte[] target,
byte[] source,
int regionX,
int regionY,
int width,
int height,
int x,
int y,
int alpha)
MicroUI native "drawImage".
|
static void |
drawLine(byte[] target,
int x1,
int y1,
int x2,
int y2)
MicroUI native "drawLine".
|
static void |
drawRectangle(byte[] target,
int x,
int y,
int width,
int height)
MicroUI native "drawRectangle".
|
static void |
drawRoundedRectangle(byte[] target,
int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
MicroUI native "drawRoundedRectangle".
|
static void |
drawVerticalLine(byte[] target,
int x,
int y,
int height)
MicroUI native "drawVerticalLine".
|
static void |
fillCircle(byte[] target,
int x,
int y,
int diameter)
MicroUI native "fillCircle".
|
static void |
fillCircleArc(byte[] target,
int x,
int y,
int diameter,
float startAngle,
float arcAngle)
MicroUI native "fillCircleArc".
|
static void |
fillEllipse(byte[] target,
int x,
int y,
int width,
int height)
MicroUI native "fillEllipse".
|
static void |
fillEllipseArc(byte[] target,
int x,
int y,
int width,
int height,
float startAngle,
float arcAngle)
MicroUI native "fillEllipseArc".
|
static void |
fillRectangle(byte[] target,
int x,
int y,
int width,
int height)
MicroUI native "fillRectangle".
|
static void |
fillRoundedRectangle(byte[] target,
int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
MicroUI native "fillRoundedRectangle".
|
static UIDrawing |
getDrawer()
Returns the current drawer used by all implementation of MicroUI drawings native methods.
|
static void |
setDrawer(UIDrawing drawer)
Sets the given drawer as current drawer.
|
static void |
writePixel(byte[] target,
int x,
int y)
MicroUI native "writePixel".
|
public static void drawCircle(byte[] target, int x, int y, int diameter)
If the given diameter is negative or zero, nothing is drawn.
target
- the MicroUI GraphicsContext target.x
- the top-left pixel X coordinate.y
- the top-left pixel Y coordinate.diameter
- the circle square size.public static void drawCircleArc(byte[] target, int x, int y, int diameter, float startAngle, float arcAngle)
The arc is drawn from 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.
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.
If either the given diameter is negative or zero, or if arcAngle is zero, nothing is drawn.
The angles are given relative to the square. For instance an angle of 45 degrees is always defined by the line from the center of the square to the upper right corner of the square.
target
- the MicroUI GraphicsContext target.x
- the top-left pixel X coordinate.y
- the top-left pixel Y coordinate.diameter
- the diameter of the arc to draw.startAngle
- the beginning angle of the arc to drawarcAngle
- the angular extent of the arc from startAnglepublic static void drawEllipse(byte[] target, int x, int y, int width, int height)
If either the given width or height is negative or zero, nothing is drawn.
target
- the MicroUI GraphicsContext target.x
- the top-left pixel X coordinate.y
- the top-left pixel Y coordinate.width
- the ellipse width.height
- the ellipse height.public static void drawEllipseArc(byte[] target, int x, int y, int width, int height, float startAngle, float arcAngle)
The arc is drawn from 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 width and height.
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.
If either the given width or height is negative or zero, or if arcAngle is zero, nothing is drawn.
The angles are given relative to the rectangle. For instance an angle of 45 degrees is always defined by the line from the center of the rectangle to the upper right corner of the rectangle. Thus for a non squared rectangle angles are skewed along either height or width.
target
- the MicroUI GraphicsContext target.x
- the top-left pixel X coordinate.y
- the top-left pixel Y coordinate.width
- the rectangle width.height
- the rectangle height.startAngle
- the beginning angle of the arc to drawarcAngle
- the angular extent of the arc from startAnglepublic static void drawHorizontalLine(byte[] target, int x, int y, int width)
See class comment to have more information about native method implementation.
target
- drawing destination target: a byte array to map on a LLUIPainter.MicroUIGraphicsContext
.x
- the first pixel line X coordinate.y
- the first pixel line Y coordinate.width
- the line size.public static void drawImage(byte[] target, byte[] source, int regionX, int regionY, int width, int height, int x, int y, int alpha)
If the specified source region exceeds the image bounds, the copied region is limited to the image boundary. If the copied region goes out of the bounds of the graphics context area, pixels out of the range will not be drawn.
A global opacity value is given. When this value is 0xff (255, opaque), that means the image is drawn on the graphics context without managing an extra opacity. Only the image transparent pixels must have been merged with destination. All image opaque pixels override destination.
When this value is a value between 0 and 0xff, that means each pixel of the image must be merged with destination in addition with the image transparent pixels. An image opaque pixel becomes transparent (its opacity is the given alpha) and the opacity of an image transparent pixel becomes (alpha * alpha(pixel)) / 255.
target
- the MicroUI GraphicsContext target.source
- the MicroUI Image to draw.regionX
- the x coordinate of the upper-left corner of the region to copy.regionY
- the x coordinate of the upper-left corner of the region to copy.width
- the width of the region to copy.height
- the height of the region to copy.x
- the x coordinate of the top-left point in the destination.y
- the y coordinate of the top-left point in the destination.alpha
- the opacity level to apply to the region.public static void drawLine(byte[] target, int x1, int y1, int x2, int y2)
See class comment to have more information about native method implementation.
target
- drawing destination target: a byte array to map on a LLUIPainter.MicroUIGraphicsContext
.x1
- the first pixel line X coordinate.y1
- the first pixel line Y coordinate.x2
- the last pixel line X coordinate.y2
- the last pixel line Y coordinate.public static void drawRectangle(byte[] target, int x, int y, int width, int height)
See class comment to have more information about native method implementation.
target
- drawing destination target: a byte array to map on a LLUIPainter.MicroUIGraphicsContext
.x
- the top-left pixel X coordinate.y
- the top-left pixel Y coordinate.width
- the rectangle width.height
- the rectangle height.public static void drawRoundedRectangle(byte[] target, int x, int y, int width, int height, int arcWidth, int arcHeight)
target
- the MicroUI GraphicsContext target.x
- the top-left pixel X coordinate.y
- the top-left pixel Y coordinate.width
- the rectangle width.height
- the rectangle height.arcWidth
- the horizontal diameter of the arc at the corners.arcHeight
- the vertical diameter of the arc at the corners.public static void drawVerticalLine(byte[] target, int x, int y, int height)
See class comment to have more information about native method implementation.
target
- drawing destination target: a byte array to map on a LLUIPainter.MicroUIGraphicsContext
.x
- the first pixel line X coordinate.y
- the first pixel line Y coordinate.height
- the line size.public static void fillCircle(byte[] target, int x, int y, int diameter)
If the given diameter is negative or zero, nothing is drawn.
target
- the MicroUI GraphicsContext target.x
- the top-left pixel X coordinate.y
- the top-left pixel Y coordinate.diameter
- the circle square size.public static void fillCircleArc(byte[] target, int x, int y, int diameter, float startAngle, float arcAngle)
target
- the MicroUI GraphicsContext target.x
- the top-left pixel X coordinate.y
- the top-left pixel Y coordinate.diameter
- the diameter of the arc to draw.startAngle
- the beginning angle of the arc to drawarcAngle
- the angular extent of the arc from startAnglepublic static void fillEllipse(byte[] target, int x, int y, int width, int height)
If either the given width or height is negative or zero, nothing is drawn.
target
- the MicroUI GraphicsContext target.x
- the top-left pixel X coordinate.y
- the top-left pixel Y coordinate.width
- the ellipse width.height
- the ellipse height.public static void fillEllipseArc(byte[] target, int x, int y, int width, int height, float startAngle, float arcAngle)
The arc is drawn from 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 width and height.
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.
If either the given width or height is negative or zero, or if arcAngle is zero, nothing is drawn.
The angles are given relative to the rectangle. For instance an angle of 45 degrees is always defined by the line from the center of the rectangle to the upper right corner of the rectangle. Thus for a non squared rectangle angles are skewed along either height or width.
target
- the MicroUI GraphicsContext target.x
- the top-left pixel X coordinate.y
- the top-left pixel Y coordinate.width
- the rectangle width.height
- the rectangle height.startAngle
- the beginning angle of the arc to drawarcAngle
- the angular extent of the arc from startAnglepublic static void fillRectangle(byte[] target, int x, int y, int width, int height)
See class comment to have more information about native method implementation.
target
- drawing destination target: a byte array to map on a LLUIPainter.MicroUIGraphicsContext
.x
- the top-left pixel X coordinate.y
- the top-left pixel Y coordinate.width
- the rectangle width.height
- the rectangle height.public static void fillRoundedRectangle(byte[] target, int x, int y, int width, int height, int arcWidth, int arcHeight)
target
- the MicroUI GraphicsContext target.x
- the top-left pixel X coordinate.y
- the top-left pixel Y coordinate.width
- the rectangle width.height
- the rectangle height.arcWidth
- the horizontal diameter of the arc at the corners.arcHeight
- the vertical diameter of the arc at the corners.public static UIDrawing getDrawer()
public static void setDrawer(UIDrawing drawer)
The drawer has the responsibility to check the clip (draw outside current clip is forbidden) and has to update
the new Display.flush()
area (dirty area) as mentioned in LLUIPainter
class comment.
Default drawer is the MicroUI graphical engine's internal software drawer.
drawer
- the new drawer to use or null to use the MicroUI graphical engine's internal software drawer.public static void writePixel(byte[] target, int x, int y)
See class comment to have more information about native method implementation.
target
- drawing destination target: a byte array to map on a LLUIPainter.MicroUIGraphicsContext
.x
- the pixel X coordinate.y
- the pixel Y coordinate.