Class Displayable

  • All Implemented Interfaces:
    EventHandler
    Direct Known Subclasses:
    Desktop

    public abstract class Displayable
    extends Object
    implements EventHandler
    Displayable is an abstract class which defines the very objects that can be shown on the Display.
    A Displayable may be shown or hidden, but at most one Displayable is shown on the Display.

    Subclasses should define the Displayable contents and their possible interactions with the user.

    By default, a new Displayable object is not visible on the display.
    See Also:
    Display
    • Constructor Detail

      • Displayable

        public Displayable()
    • Method Detail

      • requestRender

        public void requestRender()
        Requests a rendering for the entire displayable. Calling this method may result in subsequent call to render(GraphicsContext) on the displayable.

        The call to render(GraphicsContext) occurs asynchronously to this call. That is, this method will not block waiting for render(GraphicsContext) to finish. After render action (after call to render(GraphicsContext)), a call to Display.flush() is synchronously performed.

        This call may have no effect under certain conditions:

        • if the displayable is not visible on the display (see Display.isShown(Displayable)): the request is refused.
        • if the displayable is not visible on the display when the event is executed (a call to Display.requestShow(Displayable) has been performed with another displayable): the request is abandoned (this displayable is no longer the current displayable).
        • if a request is already available in the events queue and if the request is called from the MicroUI pump: the request is useless because this request has been already added and cannot be executed until the end of current caller method. The request is not added into the queue.
      • onShown

        protected void onShown()
        This method is called by system as soon as the displayable becomes visible. Application should override this method to control its own displayables. Default behavior does nothing.
        See Also:
        Display.requestShow(Displayable)
      • onHidden

        protected void onHidden()
        This method is called by system as soon as the displayable becomes hidden. Application should override this method to control its own displayables. Default behavior does nothing.
        See Also:
        Display.requestHide(Displayable)
      • render

        protected abstract void render​(GraphicsContext gc)
        Renders the displayable. This method is called by system as soon as the displayable has be rendered. Caller ensures the graphics context's clip and translate are reseted.
        Parameters:
        gc - the graphics context of display.