Package org.zkoss.stateless.sul

## Interface IImageBase<I extends IImageBase>

- All Superinterfaces:
    `IComponent<I>`, `IHtmlBasedComponent<I>`, `IXulElement<I>`
  All Known Subinterfaces:
    `IImage`, `IImagemap`

      public interface IImageBase<I extends IImageBase>
      extends IXulElement<I>

  Immutable `Image` base component.

  To turn on the preload image facility for this component, you have to specify `withPreloadImage(boolean)` to true.

  Or configure it from zk.xml by setting library properties. For example,

        <library-property/>
           <name>org.zkoss.zul.image.preload</name/>
           <value>true</value/>
       </library-property/>

  Note: with zk.xml setting, it will affect to all subcomponents, which are extended from `IImageBase`
  Author:
    katherine

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Image` | `getContent()` | Returns the content set by `withContent(org.zkoss.image.Image)`.
    `java.lang.String` | `getHover()` | Returns the URI of the hover image.
    `java.lang.String` | `getSrc()` | Returns the source URI of the image.
    `default boolean` | `isPreloadImage()` | Returns whether to preload the image.
    `default I` | `withContent​(java.awt.image.RenderedImage image)` | Returns a copy of `this` immutable component with the specified `image`.
    `I` | `withContent​(Image image)` | Returns a copy of `this` immutable component with the specified `image`.
    `I` | `withHover​(java.lang.String hover)` | Returns a copy of `this` immutable component with the specified `hover`.
    `I` | `withPreloadImage​(boolean preloadImage)` | Returns a copy of `this` immutable component with the specified `preloadImage` URI.
    `I` | `withSrc​(java.lang.String src)` | Returns a copy of `this` immutable component with the specified `src`.

    - ### Methods inherited from interface org.zkoss.stateless.sul.IComponent

      `getAction, getActions, getClientAttributes, getId, getMold, getWidgetClass, getWidgetListeners, getWidgetOverrides, isVisible, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withActions, withActions, withClientAttribute, withClientAttributes, withId, withMold, withVisible, withWidgetClass, withWidgetListener, withWidgetListeners, withWidgetOverride, withWidgetOverrides`

    - ### Methods inherited from interface org.zkoss.stateless.sul.IHtmlBasedComponent

      `getClientAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getStyle, getTabindex, getTooltiptext, getTop, getVflex, getWidth, getZclass, getZIndex, isFocus, withClientAction, withDraggable, withDroppable, withFocus, withHeight, withHflex, withLeft, withRenderdefer, withSclass, withStyle, withTabindex, withTabindex, withTooltiptext, withTop, withVflex, withWidth, withZclass, withZIndex`

    - ### Methods inherited from interface org.zkoss.stateless.sul.IXulElement

      `getContext, getCtrlKeys, getPopup, getTooltip, withContext, withCtrlKeys, withPopup, withTooltip`

- - ### Method Detail

    - #### getHover

          @Nullable
          java.lang.String getHover()

      Returns the URI of the hover image. The hover image is used when the mouse is moving over this component.

      Default: `null`.

    - #### withHover

          I withHover​(@Nullable
                      java.lang.String hover)

      Returns a copy of `this` immutable component with the specified `hover`.

      Sets the image URI. The hover image is used when the mouse is moving over this component.

      Parameters:
        `hover` - The hover image URI.
      Returns:
        A modified copy of `this` object

    - #### getContent

          @Nullable
          Image getContent()

      Returns the content set by `withContent(org.zkoss.image.Image)`.

      Note: it won't fetch what is set through by `withSrc(String)`. It simply returns what is passed to `withContent(org.zkoss.image.Image)`.

    - #### withContent

          I withContent​(@Nullable
                        Image image)

      Returns a copy of `this` immutable component with the specified `image`.

      Sets the content directly.

      Default: `null`.

      Note: If calling this with `withSrc(String)`, the `withContent(org.zkoss.image.Image)` has higher priority

      Parameters:
        `image` - The image to display.
      Returns:
        A modified copy of `this` object
      See Also:
        `withSrc(String)`

    - #### withContent

          default I withContent​(@Nullable
                                java.awt.image.RenderedImage image)

      Returns a copy of `this` immutable component with the specified `image`.

      Sets the content directly with the rendered image. It actually encodes the rendered image to an PNG image (`Image`) with `Images.encode(java.lang.String, java.awt.image.RenderedImage, float, boolean)`, and then invoke `withContent(org.zkoss.image.Image)`}.

      If you want more control such as different format, quality, and naming, you can use `Images` directly.

      Parameters:
        `image` - The image to display.
      Returns:
        A modified copy of `this` object

    - #### getSrc

          @Nullable
          java.lang.String getSrc()

      Returns the source URI of the image.

      Default: `null`.

    - #### withSrc

          I withSrc​(@Nullable
                    java.lang.String src)

      Returns a copy of `this` immutable component with the specified `src`.

      Sets the source URI of the image.

      Notice that once the `withContent(org.zkoss.image.Image)` is specified, this attribute will be ignored.

      ##### Locale Dependent Image

      Like using any other properties that accept an URI, you can specify "*" for identifying a Locale dependent image. For example, if you have different images for different Locales, you could use the following code.

           @RichletMapping("/locale")
           public IComponent locale() {
               return IImage.of("/stateless/ZK-Logo*.gif");
           }

      Assuming one of your users is visiting your page with de_DE as the preferred Locale. ZK will try to locate the image file called /stateless/ZK-Logo_de_DE.gif. If it is not found, it will try /stateless/ZK-Logo_de.gif and finally /stateless/ZK-Logo.gif.

      Note: If calling this with `withContent(org.zkoss.image.Image)`, the `withContent(org.zkoss.image.Image)` has higher priority

      Parameters:
        `src` - The URI of the image source
      Returns:
        A modified copy of `this` object
      See Also:
        `withContent(org.zkoss.image.Image)`, `withContent(RenderedImage)`

    - #### isPreloadImage

          default boolean isPreloadImage()

      Returns whether to preload the image.

      Default: `false`, if the `"org.zkoss.zul.image.preload"` library property is not set in zk.xml.

    - #### withPreloadImage

          I withPreloadImage​(boolean preloadImage)

      Returns a copy of `this` immutable component with the specified `preloadImage` URI.

      Sets to `true` to enable to preload the image. Note: the priority of this attribute is higher than zk.xml if both preload image are specified.

      Returns:
        A modified copy of the `this` object