public interface LLUIDisplayImpl
An implementation of this interface is required to run a MicroUI application which uses the class MicroUI Display;
otherwise some errors will be thrown at runtime and the application will not able to run correctly. This
implementation should be a widget which allows to draw in an Image
. This image is used as "back buffer" (see
isDoubleBuffered()
). At the end of MicroEJ application drawings (via MicroUI painter classes), a call to
#flush(MicroUIGraphicsContext, Image, int, int, int, int)
is performed to render the image on the visible
part of front panel.
The display size may be different than the widget size. This allows to show on computer a bigger or smaller display
in pixels than the embedded display. The display size is the size given to the MicroEJ application. To retrieve the
display size, the methods Image.getWidth()
and Image.getHeight()
(on the image returned by
initialize()
) are called (instead of Widget.getWidth()
and Widget.getHeight()
which return
the widget size). The both values can be automatically set by the front panel parser if the display widget
(implementation of this interface) declares the following Widget.WidgetAttribute
:
@WidgetAttribute(name = "displayWidth", isOptional = true) @WidgetAttribute(name = "displayHeight", isOptional = true)This size may be optional, in this case the display size is equal to the widget size. This size (if applicable the widget size) must be used to create the
Image
returned by initialize()
.
This interface stubs a lot of methods. Only initialize()
and
#flush(MicroUIGraphicsContext, Image, int, int, int, int)
are mandatory. All others methods are optional and
perform same defaut behavior like embedded side.
Modifier and Type | Field and Description |
---|---|
static int |
BACKLIGHT_MAX
Maximal value of backlight according MicroUI specification.
|
static int |
BACKLIGHT_MIN
Minimal value of backlight according MicroUI specification.
|
static int |
CONTRAST_MAX
Maximal value of contrast according MicroUI specification.
|
static int |
CONTRAST_MIN
Minimal value of contrast according MicroUI specification.
|
Modifier and Type | Method and Description |
---|---|
default int |
convertARGBColorToDisplayColor(int argbColor)
Converts the 32-bit ARGB color format (A-R-G-B) into the display color format.
|
default int |
convertDisplayColorToARGBColor(int displayColor)
Converts the display color format into a 32-bit ARGB color format (A-R-G-B).
|
void |
flush(LLUIPainter.MicroUIGraphicsContext gc,
Image backBuffer,
int x,
int y,
int width,
int height)
Flushes a part of the display limited by specified bounds.
|
default int |
getBacklight()
Returns the backlight of the display.
|
default int |
getContrast()
Returns the contrast of the display.
|
default int |
getNumberOfColors()
Gets the number of colors that can be represented on the device.
|
default boolean |
hasBacklight()
Returns true if the display holds a backlight.
|
Image |
initialize()
Initializes the display widget to be compatible with MicroUI graphical engine.
|
default boolean |
isColor()
Asks if the display is a colored display or not.
|
default boolean |
isDoubleBuffered()
Returns if the display uses an underlying double buffer.
|
default boolean |
prepareBlendingOfIndexedColors(java.util.concurrent.atomic.AtomicInteger foreground,
java.util.concurrent.atomic.AtomicInteger background)
Prepares the blending of two ARGB colors.
|
default void |
setBacklight(int backlight)
Sets the backlight of the display.
|
default void |
setContrast(int contrast)
Sets the contrast of the display.
|
static final int BACKLIGHT_MAX
static final int BACKLIGHT_MIN
static final int CONTRAST_MAX
static final int CONTRAST_MIN
default int convertARGBColorToDisplayColor(int argbColor)
This function is called only when the display is not a standard display: when the pixel data does not match with
one of these formats: LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_ARGB8888
,
LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_RGB888
, LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_RGB565
,
LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_ARGB1555
,
LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_ARGB4444
, LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_C4
,
LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_C2
or LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_C1
.
In case of this function is not implemented whereas it is required, the result of pixel drawing is unknown.
Note: the opacity level (alpha) may be ignored if the display pixel representation does not hold the opacity level information.
The implementation should not directly call this function when performing a drawing. It must call
LLUIDisplay.convertARGBColorToColorToDraw(int)
instead in case of this conversion is graphical engine
built-in (standard display).
argbColor
- the color to convert.microUIColor
.default int convertDisplayColorToARGBColor(int displayColor)
This function is called only when the display is not a standard display: when the pixel data does not match with
one of these formats: LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_ARGB8888
,
LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_RGB888
, LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_RGB565
,
LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_ARGB1555
,
LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_ARGB4444
, LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_C4
,
LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_C2
or LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_C1
.
In case of this function is not implemented whereas it is required, the result of pixel drawing is unknown.
Note: the opacity level (alpha) may be ignored if the display pixel representation does not hold the opacity level information.
displayColor
- the color to convert.displayColor
.void flush(LLUIPainter.MicroUIGraphicsContext gc, Image backBuffer, int x, int y, int width, int height)
backBuffer
(not double buffered), nothing is done.gc
- the graphics context to flushbackBuffer
- the image returned by initialize()
x
- the x coordinate of the area to flush.y
- the x coordinate of the area to flush.width
- the width of the area to flush.height
- the height of the area to flush.default int getBacklight()
BACKLIGHT_MIN
.BACKLIGHT_MIN
-BACKLIGHT_MAX
).default int getContrast()
CONTRAST_MIN
.CONTRAST_MIN
-CONTRAST_MAX
).default int getNumberOfColors()
Note that the number of colors for a black and white display is 2. Usually the number of colors is 1 << BPP (BPP without transparency bits).
By default this method returns a value which follows this default rule.
default boolean hasBacklight()
Image initialize()
MicroUI.start()
.
This method has to return an image where MicroUI will performing its drawings. As mentionned in class comment, the widget size can be higher or smaller than the simulated display (embedded display). The returned buffer must have the embedded display size (and not the widget size).
This buffer is given as parameter in #flush(MicroUIGraphicsContext, Image, int, int, int, int)
method.
default boolean isColor()
By default this method returns false when the display pixel depth is lower than or equals to 4 and true otherwise.
default boolean isDoubleBuffered()
By default this method returns true and considers the interface implementation returns a "back" buffer in
initialize()
. This buffer is used to render the MicroUI drawings in background. When MicroUI
Display.flush() method is called, a call to #flush(MicroUIGraphicsContext, Image, int, int, int, int)
is
performed. The implementation has to copy the image content to another image (visible on front panel).
Implementation can override this method to return false. In this case the image returned by initialize()
is used as rendering buffer for MicroUI drawings and as visible buffer on front panel at same time.
default boolean prepareBlendingOfIndexedColors(java.util.concurrent.atomic.AtomicInteger foreground, java.util.concurrent.atomic.AtomicInteger background)
This function is called only when the display is not a standard display: when the pixel data does not match with
one of these formats: LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_ARGB8888
,
LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_RGB888
, LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_RGB565
,
LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_ARGB1555
,
LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_ARGB4444
, LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_C4
,
LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_C2
or LLUIPainter.MicroUIImageFormat.MICROUI_IMAGE_FORMAT_C1
.
This is useful only when the LCD is a palletized LCD. This method is called by framework when the MicroEJ application draws something which requires a blending between the current foreground color and a specific background color (draw a string, draw an anti-aliased line etc.).
The implementation has to replace the ARGB colors by the indexes of these colors in the LCD CLUT. The framework will use the intermediate values between these two indexes instead of blending in software the ARGB colors. No post conversion will be performed later.
When the ARGB colors are not available in the CLUT or when the range specified by the two ARGB colors is not
expected by the CLUT, the implementation should return false (feature not supported). In this way the blending
will be done in software and the result color will be converted later thanks a call to
convertARGBColorToDisplayColor(int)
.
By default the method returns false (feature not supported / useless).
foreground
- the foreground ARGB color to convert.background
- the background ARGB color to convert.default void setBacklight(int backlight)
backlight
- the new value of the backlight (range BACKLIGHT_MIN
-BACKLIGHT_MAX
).default void setContrast(int contrast)
contrast
- the new value of the contrast (range CONTRAST_MIN
-CONTRAST_MAX
).