Package ej.mwt.render

## Class DefaultRenderPolicy

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

- Direct Known Subclasses:
    `OverlapRenderPolicy`

      public class DefaultRenderPolicy
      extends RenderPolicy

  This render policy renders the requested widget or its parent if transparent.

  When a widget is asked to be rendered:

  - if the widget is transparent, its parent is asked to be rendered (and recursively),
  - otherwise, the widget is rendered asynchronously.

  When one widget is asked to be rendered, a flush is requested to the display. When several widgets are asked to be rendered in a row, only one flush is done at the end.

  See Also:
    `Widget.isTransparent()`, `Display.requestFlush()`

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class ej.mwt.render.RenderPolicy

      `RenderPolicy.RenderListener`

  - ### Field Summary

    - ### Fields inherited from class ej.mwt.render.RenderPolicy

      `DEBUG_RENDER_ENABLED_CONSTANT, DEBUG_RENDER_MONITOR_CONSTANT, MONITOR`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DefaultRenderPolicy​(Desktop desktop)` | Creates a default render policy.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `renderDesktop()` | Renders the desktop on the display.
    `protected void` | `renderWidget​(Widget widget, int x, int y, int width, int height)` | This method performs the increment render of the widget.
    `void` | `requestRender​(Widget widget, int x, int y, int width, int height)` | Requests a rendering of the given widget on the display.
    `protected void` | `setParentClip​(Widget widget, GraphicsContext g)` | Clips and translates a graphics context to the absolute bounds of the parent of a widget.

    - ### Methods inherited from class ej.mwt.render.RenderPolicy

      `getDesktop, renderWidget`

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

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

- - ### Constructor Detail

    - #### DefaultRenderPolicy

          public DefaultRenderPolicy​(Desktop desktop)

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

  - ### Method Detail

    - #### renderDesktop

          public 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.

      The graphics context is translated to the position of the parent of the widget. The clipping area is set to the intersection of the parent's bounds and the given bounds.

      Specified by:
        `renderDesktop` in class `RenderPolicy`

    - #### requestRender

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

      Description copied from class: `RenderPolicy`
      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.

      Specified by:
        `requestRender` in class `RenderPolicy`
      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​(Widget widget,
                                      int x,
                                      int y,
                                      int width,
                                      int height)

      This method performs the increment render of the widget. Its implementation only renders the widget and not its siblings, but this behavior may be changed by overriding this method.

      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.

    - #### setParentClip

          protected void setParentClip​(Widget widget,
                                       GraphicsContext g)

      Clips and translates a graphics context to the absolute bounds of the parent of a widget.

      It applies recursively a translation to each parent's coordinates, and a clip to its content size.

      Parameters:
        `widget` - the widget to clip from.
        `g` - the graphics context to clip on.