Package ej.mwt.render

## Class RenderPolicy

- java.lang.Object
- - ej.mwt.render.RenderPolicy

- Direct Known Subclasses:
    `DefaultRenderPolicy`

      public abstract class RenderPolicy
      extends Object

  A render policy is responsible of rendering the widgets of a desktop on the display.

  A render policy is associated to a single desktop.

  A render policy provides a method to render the desktop on the display. This method is used by the desktop in order to perform the initial rendering of the complete widget hierarchy.

  A render policy also provides a method to handle render requests targeting specific widgets of the desktop. The goal of this method is to render only a part of the widget hierarchy considering that an old representation of the desktop is already visible on the display. The most naive implementation would be to render the whole hierarchy of the desktop.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static interface` | `RenderPolicy.RenderListener` | Listener for render events (when it is requested and when it is actually executed).

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected static String` | `DEBUG_RENDER_ENABLED_CONSTANT` | `BON boolean constant` to enable/disable the render debug.
    `protected static String` | `DEBUG_RENDER_MONITOR_CONSTANT` | `BON Class constant` to set the render monitor.
    `protected static RenderPolicy.RenderListener` | `MONITOR` | `RenderPolicy.RenderListener` instance to be used by all `RenderPolicy` implementations.

  - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `RenderPolicy​(Desktop desktop)` | Creates a render policy.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Desktop` | `getDesktop()` | Returns the desktop managed by this render policy.
    `abstract void` | `renderDesktop()` | Renders the desktop on the display.
    `protected void` | `renderWidget​(GraphicsContext g, Widget widget)` | Performs the increment render of the widget.
    `abstract void` | `requestRender​(Widget widget, int x, int y, int width, int height)` | Requests a rendering of the given widget on the display.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEBUG_RENDER_ENABLED_CONSTANT

          protected static final String DEBUG_RENDER_ENABLED_CONSTANT

      `BON boolean constant` to enable/disable the render debug.

      If enabled, "ej.mwt.debug.render.monitor" must also be set.

      See Also:
        Constant Field Values

    - #### DEBUG_RENDER_MONITOR_CONSTANT

          protected static final String DEBUG_RENDER_MONITOR_CONSTANT

      `BON Class constant` to set the render monitor.

      Set it to the FQN of an implementation of `RenderPolicy.RenderListener` to monitor rendering.

      See Also:
        Constant Field Values

    - #### MONITOR

          @Nullable
          protected static final RenderPolicy.RenderListener MONITOR

      `RenderPolicy.RenderListener` instance to be used by all `RenderPolicy` implementations.

      It is `null` if "ej.mwt.debug.render.enabled" is `false`.

  - ### Constructor Detail

    - #### RenderPolicy

          protected RenderPolicy​(Desktop desktop)

      Creates a render policy.
      Parameters:
        `desktop` - the desktop to render.

  - ### Method Detail

    - #### getDesktop

          public Desktop getDesktop()

      Returns the desktop managed by this render policy.
      Returns:
        the desktop managed by this render policy.

    - #### renderDesktop

          public abstract void renderDesktop()

      Renders the desktop on the display. This method is used by the desktop in order to perform the initial rendering of the complete widget hierarchy.

      This method should be called in the MicroUI thread as the rendering of the widget is performed synchronously.

    - #### requestRender

          public abstract void requestRender​(Widget widget,
                                             int x,
                                             int y,
                                             int width,
                                             int height)

      Requests a rendering of the given widget on the display. The goal of this method is to render only a part of the widget hierarchy considering that an old representation of the desktop is already visible on the display.

      This method returns immediately and the rendering of the widget is performed asynchronously in the MicroUI thread.

      The given bounds are relative to the widget.

      Parameters:
        `widget` - the widget to render.
        `x` - the x coordinate of the area to render.
        `y` - the y coordinate of the area to render.
        `width` - the width of the area to render.
        `height` - the height of the area to render.

    - #### renderWidget

          protected void renderWidget​(GraphicsContext g,
                                      Widget widget)

      Performs the increment render of the widget.
      Parameters:
        `g` - the graphics context.
        `widget` - the widget to render.