public abstract class FrontPanel extends Object
The implementation has the responsability to create the unique device according the front panel file
(*.fp
) written by the user.
The steps to create a device are:
*.fp
),Modifier and Type | Field and Description |
---|---|
static PrintStream |
out
This static field makes an abstraction on the standard output stream where print some traces.
|
Constructor and Description |
---|
FrontPanel() |
Modifier and Type | Method and Description |
---|---|
abstract void |
checkVersion(String compatibilityVersion,
String version)
Checks if given version is compatible with the compatibilityVersion.
|
void |
disposeIfNotNull(Image... images)
Disposes given images.
|
abstract Device |
getDevice()
Gets the unique device created from the front panel file (
*.fp ). |
static FrontPanel |
getFrontPanel()
Gets the unique instance of the front panel engine.
|
protected abstract PrintStream |
getPrintStream()
Gets the output streams where print the traces.
|
abstract Class<?> |
getUserClass(Class<?> caller,
Class<?> expectedType,
String classname)
Gets the class whose name is classname.
|
Image |
newImage(Image image)
Creates a copy of given image in a new platform-specific
Image . |
abstract Image |
newImage(InputStream stream)
Loads the image defined by the
stream in a platform-specific Image . |
abstract Image |
newImage(int width,
int height,
int color,
boolean isTransparent)
Creates a new platform-specific
Image with the specified size and initial color. |
abstract <T> T |
newUserInstance(Class<?> caller,
Class<T> expectedType,
String classname)
Instanciates the class whose name is classname.
|
abstract void |
repaintDevice()
Asks to repaint all device area.
|
abstract void |
repaintDevice(int x,
int y,
int width,
int height)
Asks to repaint a part of device area.
|
abstract void |
repaintWidget(Widget w)
Asks to repaint all widget area.
|
abstract void |
repaintWidget(Widget w,
int x,
int y,
int width,
int height)
Asks to repaint a part of widget area.
|
protected abstract void |
start()
Starts the simulation.
|
void |
verifyUserClass(Class<?> caller,
Class<?> expectedType,
String classname)
Checks if the class whose name is classname is a subclass of expected type and if this class is available in the
same class loader than caller.
|
public static final PrintStream out
System.out
.public abstract void checkVersion(String compatibilityVersion, String version) throws IllegalArgumentException
This method is used by front panel framework to ensure the engine in plugin (designer mode) or the engine in
MicroEJ platform (application mode) is compatible with the framework fetched by the front panel user project
(project which contains the front panel file (*.fp
)).
The versions are compatible when:
compatibilityVersion
- the reference version.version
- the version to check.IllegalArgumentException
- if the version is not compatible with the compatibilityVersion.public void disposeIfNotNull(Image... images)
images
- the images to dispose.public abstract Device getDevice() throws IllegalStateException
*.fp
).IllegalStateException
- thrown when the caller tries to get the device whereas the device is not fully created yet. This
method can not be called before the call to start()
performed by the clinit (that
means after the device and its widgets creation and finalization.public static FrontPanel getFrontPanel()
protected abstract PrintStream getPrintStream()
public abstract Class<?> getUserClass(Class<?> caller, Class<?> expectedType, String classname) throws IllegalArgumentException
caller
- the caller class, used to retrieve the caller class loader.expectedType
- the type the class to check has to extend or implement.classname
- the class name to check.IllegalArgumentException
- if at least one condition is not respected.public Image newImage(Image image)
Image
. The background color is black (0x0) and
the image is transparent.image
- the image to copy.Image
created.public abstract Image newImage(InputStream stream) throws IOException
stream
in a platform-specific Image
.stream
- the input stream of the image to load.Image
created.IOException
- if an error occur during the loading of the image.public abstract Image newImage(int width, int height, int color, boolean isTransparent)
Image
with the specified size and initial color.width
- the width of the wanted image.height
- the height of the wanted image.color
- the initial color of the wanted image.isTransparent
- specify if the image is transparent.Image
created.public abstract <T> T newUserInstance(Class<?> caller, Class<T> expectedType, String classname) throws IllegalArgumentException
caller
- the caller class, used to retrieve the caller class loader.expectedType
- the type the class to check has to extend or implement.classname
- the class name to check.IllegalArgumentException
- if at least one condition is not respected.public abstract void repaintDevice()
public abstract void repaintDevice(int x, int y, int width, int height)
x
- x coordinate of area to repaint.y
- y coordinate of area to repaint.width
- width of area to repaint.height
- height of area to repaint.public abstract void repaintWidget(Widget w)
w
- the widget to repaint.public abstract void repaintWidget(Widget w, int x, int y, int width, int height)
w
- the widget to repaint.x
- x coordinate of area to repaint.y
- y coordinate of area to repaint.width
- width of area to repaint.height
- height of area to repaint.protected abstract void start()
FrontPanel
clinit.public void verifyUserClass(Class<?> caller, Class<?> expectedType, String classname) throws IllegalArgumentException
caller
- the caller class, used to retrieve the caller class loader.expectedType
- the type the class to check has to extend or implement.classname
- the class name to check.IllegalArgumentException
- if at least one condition is not respected.