Package ej.microui

Class MicroUI


  • public abstract class MicroUI
    extends Object
    The MicroUI class offers basic services in the MicroUI implementation.
    MicroUI is started explicitly by calling start(). MicroUI may also be stopped with stop().

    MicroUI is using a dedicated thread to read the input events and to manage the display serialized event mechanism. This thread is started when method start() is called.

    This internal thread can call application methods (such as event callback). All exceptions thrown during this peace of code are caught and redirected to the thread uncaught exception handler (Thread.getUncaughtExceptionHandler()) or to the Thread.getDefaultUncaughtExceptionHandler() when no specific handler is configured. If no handler is configured, a call to Throwable.printStackTrace() is performed.

    • Constructor Summary

      Constructors 
      Constructor Description
      MicroUI()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void callSerially​(Runnable run)
      Serializes a call event in the system event stream.
      static boolean isStarted()
      Checks if MicroUI has been started.
      static boolean isUIThread()
      Gets whether the current thread is the MicroUI thread.
      static boolean isUIThread​(Thread thread)
      Gets whether the given thread is the MicroUI thread.
      static void start()
      Starts MicroUI.
      It implies starting event serialization as well as rendering mechanisms.
      This method does nothing if MicroUI is already started.
      static void stop()
      Stops MicroUI.
      It implies stopping any potential event serialization as well as rendering mechanisms.
      This method does nothing if MicroUI is already stopped.
    • Constructor Detail

      • MicroUI

        public MicroUI()
    • Method Detail

      • start

        public static void start()
        Starts MicroUI.
        It implies starting event serialization as well as rendering mechanisms.
        This method does nothing if MicroUI is already started.
        Throws:
        SecurityException - if a security manager exists and does not allow the caller to start MicroUI.
      • stop

        public static void stop()
        Stops MicroUI.
        It implies stopping any potential event serialization as well as rendering mechanisms.
        This method does nothing if MicroUI is already stopped.
        Throws:
        SecurityException - if a security manager exists and does not allow the caller to stop MicroUI.
      • isStarted

        public static boolean isStarted()
        Checks if MicroUI has been started.
        Returns:
        true when MicroUI is running.
      • isUIThread

        public static boolean isUIThread​(Thread thread)
        Gets whether the given thread is the MicroUI thread.
        Parameters:
        thread - the thread to check
        Returns:
        true if the given thread is the MicroUI thread, false otherwise.
        Throws:
        MicroUIException - if MicroUI is not started
      • isUIThread

        public static boolean isUIThread()
        Gets whether the current thread is the MicroUI thread.
        Returns:
        true if the current thread is the MicroUi thread, false otherwise.
        Throws:
        MicroUIException - if MicroUI is not started
      • callSerially

        public static void callSerially​(Runnable run)
        Serializes a call event in the system event stream. When the event is processed, the run() method of the Runnable object is called.
        Multiple call events may be requested with callSerially(): they will occur in the order in which they were requested (first in first out policy).
        The call to the run() method of the Runnable object is performed asynchronously Therefore callSerially() will never block waiting for the run() method to finish.
        The run() method should return quickly, as with other callback methods.
        The callSerially() mechanism may be used by applications as a synchronization tool in the event stream.
        Parameters:
        run - a Runnable object to call
        Throws:
        MicroUIException - if MicroUI is not started