public class Display
extends java.lang.Object
Display
object represents a pixelated screen in the platform, and there is a display for each such
pixelated screen. Available displays can be retrieved with the method getAllDisplays()
. A default display is
defined in every MicroUI implementation and can be fetched with the method getDefaultDisplay()
.Displayable
on its implementation screen. Only one
Displayable
can be set on a display at a time; it is said to be visible or to be shown. The visible
Displayable
can be retrieved with the method getDisplayable()
.Displayable.show()
allows the Displayable to be selected for rendering on its display. It can be called at
any time by the application, for instance in response to user inputs.Display
uses a GraphicsContext
to draw on its corresponding screen. All draw actions are
serialized. The application should not use a display's graphics context outside the events mechanism
repaint()
and paint()
. Nevertheless, for exceptional cases a new
GraphicsContext
may be created using getNewGraphicsContext()
. This new
GraphicsContext
bypasses the standard serialized drawing mechanism and allows drawings to be rendered on the
display at any time.
FIFOPump
to manage its serialized event mechanism.Constructor and Description |
---|
Display() |
Modifier and Type | Method and Description |
---|---|
void |
callSerially(java.lang.Runnable run)
Serializes a call event in the system event stream.
|
static Display[] |
getAllDisplays()
Returns all available displays.
|
int |
getBacklight()
Returns the current backlight setting
|
int |
getBacklightColor()
Returns the current backlight color.
|
int |
getBPP()
Returns the number of bits per pixel of the display.
|
int |
getContrast()
Returns the contrast of the display.
|
static Display |
getDefaultDisplay()
Returns the default display of the system.
|
Displayable |
getDisplayable()
Returns the current
Displayable object in the Display .The value returned by getDisplayable() may be null if no Displayable is
visible. |
int |
getDisplayColor(int color)
Gets the color that will be displayed if the specified color is requested.
For example, with a monochrome display, this method will return either 0xFFFFFF (white) or 0x000000 (black) depending on the brightness of the specified color. |
EventHandler |
getEventSerializer()
Returns the display's event serializer or
null . |
int |
getHeight()
Returns the height in pixels of the display screen area available to the application.
|
ExplicitFlush |
getNewExplicitFlush()
Returns a new
ExplicitFlush which works on the same system screen as this display. |
GraphicsContext |
getNewGraphicsContext()
Returns a new
GraphicsContext which works on the same system screen as this display. |
int |
getNumberOfAlphaLevels()
Gets the number of alpha transparency levels supported by the implementation.
The minimum possible is 2, which represents full transparency and full opacity with no blending. |
int |
getNumberOfColors()
Gets the number of colors that can be represented on the device.
Note that the number of colors for a black and white display is 2. |
Image |
getScreenshot()
Creates an image with the full content of the display.
|
Image |
getScreenshot(int x,
int y,
int width,
int height)
Creates an image with the content of the display region specified thanks the given rectangle.
|
int |
getWidth()
Returns the width in pixels of the display screen area available to the application.
|
void |
handleEvent(int event)
Injects a MicroUI event to be handled by the event generator associated with this Display.
|
boolean |
hasBacklight()
Tells whether the display has backlight.
|
boolean |
isColor()
Tells whether the display offers color.
|
boolean |
isDisplayThread()
Gets whether the current thread is the display events thread.
|
boolean |
isDisplayThread(java.lang.Thread thread)
Gets whether the given thread is the display events thread.
|
boolean |
isDoubleBuffered()
Returns if the display uses an underlying double buffer (either hardware or software).
|
void |
setBacklight(int backlight)
Sets the backlight of the display.
|
void |
setBacklightColor(int rgbColor)
Sets the current backlight color, if it is allowed by implementation.
|
void |
setContrast(int contrast)
Sets the contrast of the display.
|
void |
setPriority(int priority)
Sets the priority of the display events processing.
|
void |
switchBacklight(boolean on)
Switches on or off the backlight of the display.
|
void |
waitForEvent()
Blocks the current thread (with all its locks) until all events outstanding at the time of the call have been
processed.
|
void |
waitForEvent(int event)
Sends
event in the event stream and blocks the current thread (with all its locks) until the
event processing is finished. |
public EventHandler getEventSerializer()
null
.null
.public int getHeight()
public int getWidth()
public int getBPP()
public boolean isColor()
public int getNumberOfColors()
public int getNumberOfAlphaLevels()
public boolean isDoubleBuffered()
public final int getDisplayColor(int color)
color
- the desired color in 0x00RRGGBB format.public boolean hasBacklight()
public void setContrast(int contrast)
contrast
value range is 0-100contrast
- the new value of the contrastpublic int getContrast()
public void switchBacklight(boolean on)
on
- Switch on the backlight if true
; switch off the backlight if false
public void setBacklight(int backlight)
backlight
value range is 0-100backlight
- the new value of the backlightpublic int getBacklight()
public void setBacklightColor(int rgbColor)
rgbColor
- the color to setpublic int getBacklightColor()
public static Display[] getAllDisplays() throws java.lang.IllegalStateException
null
but the array may be empty.java.lang.IllegalStateException
- if MicroUI is not started.public static Display getDefaultDisplay() throws java.lang.IllegalStateException
null
.java.lang.IllegalStateException
- if MicroUI is not started.public Displayable getDisplayable()
Displayable
object in the Display
.getDisplayable()
may be null
if no Displayable
is
visible.Displayable
object in the Display
public GraphicsContext getNewGraphicsContext()
GraphicsContext
which works on the same system screen as this display. With this
GraphicsContext
, it is possible to draw on the system screen at any time without modifying the
normal system execution. The new graphics context has its own clip, color, font etc. After each draw action (a
drawLine for example), the system screen will show the drawn pixels. java.lang.OutOfMemoryError
- if there is not enough room to add a new graphics context.public ExplicitFlush getNewExplicitFlush()
ExplicitFlush
which works on the same system screen as this display. With this
ExplicitFlush
, it is possible to draw on the system screen at any time without modifying the normal
system execution. The new graphics context has its own clip, color, font etc. Each draw action will not be
automatically flushed. The user has to flush it via the ExplicitFlush.flush()
method.java.lang.OutOfMemoryError
- if there is not enough room to add a new graphics context.public Image getScreenshot()
This call is identical to: getScreenshot(0, 0, display.getWidth(), display.getHeight())
.
ImageCreationException
- if MicroUI implementation cannot create the image.java.lang.OutOfMemoryError
- if there is not enough room to add a new image.GraphicsContext.drawRegion(Display, int, int, int, int, int, int, int, int)
public Image getScreenshot(int x, int y, int width, int height)
x
- the x coordinate of the upper-left corner of the region to copy.y
- the y 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.java.lang.IllegalArgumentException
- if the zone to copy is out of the bounds of the source image or if either width
or
height
is zero or negative.ImageCreationException
- if MicroUI implementation cannot create the image.java.lang.OutOfMemoryError
- if there is not enough room to add a new image.GraphicsContext.drawRegion(Display, int, int, int, int, int, int, int, int)
public void callSerially(java.lang.Runnable run)
run()
method of
the Runnable
object is called.callSerially()
: they will occur in the order in which
they were requested (first in first out policy).run()
method of the Runnable
object is performed asynchronously
Therefore callSerially()
will never block waiting for the run()
method to finish.run()
method should return quickly, as with other callback methods.callSerially()
mechanism may be used by applications as a synchronization tool in the event
stream.run
- a Runnable
object to calljava.lang.SecurityException
- if a security manager exists and does not allow the caller to get the display.public void waitForEvent(int event)
event
in the event stream and blocks the current thread (with all its locks) until the
event
processing is finished.event
- the event to send and to wait for.java.lang.RuntimeException
- if the current thread is the Display
's events thread.public void waitForEvent()
java.lang.RuntimeException
- if the current thread is the Display
's events thread.public boolean isDisplayThread(java.lang.Thread thread)
thread
- the thread to checktrue
if the given thread is the display events thread, false
otherwise.public boolean isDisplayThread()
true
if the current thread is the display events thread, false
otherwise.public void setPriority(int priority)
priority
- the new priority of display events processingjava.lang.IllegalArgumentException
- If the priority is not in the range Thread.MIN_PRIORITY
to Thread.MAX_PRIORITY
.public void handleEvent(int event)
event
- an event in the MicroUI format