public abstract class MicroUIDisplay extends Widget
A subclass of this widget 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.
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. It has to be used
to store the drawings (see getDrawingBuffer()
. If not set by the front panel parser using
setDisplayWidth(int)
and setDisplayHeight(int)
, the display size is equals to the widget size (see
finalizeConfiguration()
).
Modifier and Type | Class and Description |
---|---|
static class |
MicroUIDisplay.AbstractDisplayExtension
The abstract base class for display extensions.
|
Widget.WidgetAttribute, Widget.WidgetDescription
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.
|
DEFAULT_LABEL
Constructor and Description |
---|
MicroUIDisplay()
Creates a widget display compatible with MicroUI implementation.
|
Modifier and Type | Method and Description |
---|---|
int |
convertARGBColorToDisplayColor(int argbColor)
Converts an ARGB color (0xAARRGGBB) to the equivalent LCD color.
|
int |
convertDisplayColorToARGBColor(int displayColor)
Converts a LCD color to the equivalent color in ARGB format (0xAARRGGBB).
|
void |
finalizeConfiguration()
Checks whether the widget configuration is valid or not and finalizes the widget configuration according all
attributes previously set.
|
void |
flush()
Flushes the entire display.
|
abstract void |
flush(int x,
int y,
int width,
int height)
Flushes a part of the display limited by specified bounds.
|
int |
getBacklight()
Returns the backlight of the display.
|
int |
getContrast()
Returns the contrast of the display.
|
int |
getDisplayHeight()
Gets the display height.
|
int |
getDisplayWidth()
Gets the display width.
|
abstract Image |
getDrawingBuffer()
Gets the buffer where performing the drawings.
|
int |
getNbBitsPerPixel()
Gets the number of bits per pixel the display use.
|
int |
getNumberOfColors()
Gets the number of colors that can be represented on the device.
|
boolean |
hasBacklight()
Returns true if the display holds a backlight.
|
boolean |
isColor()
Tells whether the display offers color.
|
boolean |
isDoubleBuffered()
Returns if the display uses an underlying double buffer (either hardware or software).
|
boolean |
prepareBlendingOfIndexedColors(java.util.concurrent.atomic.AtomicInteger foreground,
java.util.concurrent.atomic.AtomicInteger background)
Prepare the blending of two ARGB colors.
|
void |
setBacklight(int backlight)
Sets the backlight of the display.
|
void |
setContrast(int contrast)
Sets the contrast of the display.
|
void |
setDisplayHeight(int height)
Sets the height of the display in pixels (see class comment).
|
void |
setDisplayWidth(int width)
Sets the width of the display in pixels (see class comment).
|
void |
setExtensionClass(java.lang.String extensionClassName)
Defines the class name of the user display extension when the graphical engine set in platform is a CUSTOM.
|
void |
start()
Starts the widget.
|
void |
switchBacklight(boolean on)
Sets the backlight of the screen.
|
dispose, getAbsoluteX, getAbsoluteY, getCurrentSkin, getFilter, getHeight, getLabel, getParent, getSkin, getWidth, getX, getY, isOver, repaint, repaint, setCurrentSkin, setFilter, setHeight, setLabel, setOverlay, setSkin, setWidth, setX, setY, showYourself
public static final int BACKLIGHT_MIN
public static final int BACKLIGHT_MAX
public static final int CONTRAST_MIN
public static final int CONTRAST_MAX
public MicroUIDisplay()
public void setDisplayWidth(int width)
This method should only be called by front panel parser.
width
- the width to set.public void setDisplayHeight(int height)
This method should only be called by front panel parser.
height
- the height to set.public void setExtensionClass(java.lang.String extensionClassName)
For all others graphical engine, this extension class is useless. However, when set, a check is performed in
finalizeConfiguration()
to verify whether this class is valid, even if it is not used.
This method should only be called by front panel parser.
extensionClassName
- the user display extension class name.public void finalizeConfiguration()
Widget
The widget attributes are set by the front panel parser but the order is not defined. This method allows to perform some checks between several attributes (this method is called by the front panel parser after setting all attributes defined in front panel file).
The configuration validation depends on widget itself. Each subclass must verify its configuration after checking its parent configuration.
When framework calling this method, all device widgets are not created and finalized yet, and by extension the
device itself is not fully created too. So the implementation must not have to call some methods on other widgets
and the methods Device.getDevice()
or FrontPanel.getDevice()
. As soon as all widgets are created
and finalized, the simulation starts calling the method Widget.start()
on each widget. As this moment only, the
widget is able to use the other widgets and the device itself.
On configuration error, a RuntimeException
(or a subclass of RuntimeException
) must be thrown.
This method should only be called by front panel parser.
finalizeConfiguration
in class Widget
public void start()
Widget
Widget.finalizeConfiguration()
).
Main implementation does nothing.
This method should only be called by front panel engine.
public boolean hasBacklight()
public void switchBacklight(boolean on)
on
- the new state of the backlight.public int getBacklight()
backlight
value range is
BACKLIGHT_MIN
-BACKLIGHT_MAX
. If the display do not manage backlight (
hasBacklight() == false
), returns BACKLIGHT_MIN
.public void setBacklight(int backlight)
backlight
- the new value of the backlight.public int getContrast()
CONTRAST_MIN
-CONTRAST_MAX
).public void setContrast(int contrast)
contrast
value range is CONTRAST_MIN
-CONTRAST_MAX
.contrast
- the new value of the contrast.public int getNbBitsPerPixel()
public int getNumberOfColors()
Note that the number of colors for a black and white display is 2. The extension has to return a valid number of
colors or a null or negative value. In second case, the returned number of colors is calculated with the
available number of bits per pixels set during the MicroEJ platform build: 1 << BPP
.
public boolean isColor()
public boolean isDoubleBuffered()
public int getDisplayWidth()
public int getDisplayHeight()
public int convertARGBColorToDisplayColor(int argbColor)
argbColor
- the color to convert.microUIColor
.public int convertDisplayColorToARGBColor(int displayColor)
displayColor
- the color to convert.displayColor
.public boolean prepareBlendingOfIndexedColors(java.util.concurrent.atomic.AtomicInteger foreground, java.util.concurrent.atomic.AtomicInteger background)
foreground
- the foreground ARGB color to convert.background
- the background ARGB color to convert.true
when the indexes have been found.public abstract Image getDrawingBuffer()
public void flush()
backBuffer
(not double buffered), nothing
is done.public abstract void flush(int x, int y, int width, int height)
backBuffer
(not double buffered), nothing is done.x
- the x coordinate of the zone to flush.y
- the x coordinate of the zone to flush.width
- the width of the zone to flush.height
- the height of the zone to flush.