Package ej.mwt.stylesheet

## Class CachedStylesheet

- java.lang.Object
- - ej.mwt.stylesheet.CachedStylesheet

- All Implemented Interfaces:
    `Stylesheet`

      public class CachedStylesheet
      extends Object
      implements Stylesheet

  Wraps a stylesheet and provides a cache to avoid having several instances of the same style.

  When a style is requested for a given widget, its style is retrieved from the wrapped stylesheet. If an equal style is available in the cache, it is returned. Otherwise, the style is added to the cache.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `CachedStylesheet​(Stylesheet stylesheet)` | Creates a cached stylesheet with the given stylesheet to wrap and the default cache size.
    `CachedStylesheet​(Stylesheet stylesheet, int size)` | Creates a cached stylesheet with the given stylesheet to wrap and the given cache size.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Style` | `getStyle​(Widget widget)` | Gets the style for a widget.

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

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

- - ### Constructor Detail

    - #### CachedStylesheet

          public CachedStylesheet​(Stylesheet stylesheet)

      Creates a cached stylesheet with the given stylesheet to wrap and the default cache size.
      Parameters:
        `stylesheet` - the stylesheet to wrap.

    - #### CachedStylesheet

          public CachedStylesheet​(Stylesheet stylesheet,
                                  int size)

      Creates a cached stylesheet with the given stylesheet to wrap and the given cache size.
      Parameters:
        `stylesheet` - the stylesheet to wrap.
        `size` - the size of the cache.

  - ### Method Detail

    - #### getStyle

          public Style getStyle​(Widget widget)

      Description copied from interface: `Stylesheet`
      Gets the style for a widget.
      Specified by:
        `getStyle` in interface `Stylesheet`
      Parameters:
        `widget` - the widget to get the style for.
      Returns:
        the style applied to the widget.