Package org.zkoss.stateless.sul

## Interface ICropper

- All Superinterfaces:
    `IAnyGroup<ICropper>`, `IComponent<ICropper>`, `IHtmlBasedComponent<ICropper>`

      public interface ICropper
      extends IHtmlBasedComponent<ICropper>, IAnyGroup<ICropper>

  Immutable `Cropper` component

  An image cropper that can select a range to get the cropped result.

  ### Support @Action

  Name | Action Type
  --- | ---
  onChange | Denotes user has resized the selected range.
  onChanging | Denotes user is resizing the selected range.
  onCrop | ActionData: `FileData` Denotes user has cropped the image.

  Author:
    katherine
  See Also:
    `Cropper`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface | Description
    --- | --- | ---
    `static class` | `ICropper.Builder` | Builds instances of type `ICropper`.
    `static class` | `ICropper.Crossorigin` | Specifies the crossorigin setting with `withCrossorigin(Crossorigin)`
    `static class` | `ICropper.Updater` | Builds an updater of type `ICropper` for `UiAgent.smartUpdate(Locator, SmartUpdater)`.

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static ICropper` | `DEFAULT` | Constant for default attributes of this immutable component.

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `default double` | `getAspectRatio()` | Returns the aspect ratio of the cropped area.
    `Image` | `getContent()` | Returns the content set by `withContent(org.zkoss.image.Image)`.
    `default java.lang.String` | `getCroppedFormat()` | Returns the cropped image format, e.g., `"image/png"`, `"image/jpeg"`.
    `java.lang.String` | `getCrossorigin()` | Returns the crossorigin of the img of this cropper, could be `"anonymous"`, `"use-credentials"` or `null`.
    `default int` | `getH()` | Returns the height of the crop area in pixel.
    `default int` | `getMaxHeight()` | Returns the maximum height of the selected crop area.
    `default int` | `getMaxWidth()` | Returns the maximum width of the selected crop area.
    `default int` | `getMinHeight()` | Returns the minimum height of the selected crop area.
    `default int` | `getMinWidth()` | Returns the minimum width of the selected crop area.
    `java.lang.String` | `getSrc()` | Returns the source URI of the image.
    `default int` | `getW()` | Returns the width of the crop area in pixel.
    `default java.lang.String` | `getWidgetClass()` | Returns the client widget class.
    `default int` | `getX()` | Returns the left position of the crop area relates to the left edge of the child image in pixel.
    `default int` | `getY()` | Returns the top position of the crop area relates to the top edge of the child image in pixel.
    `default boolean` | `isInstant()` | Returns whether to send back onChange action immediately while the user is resizing the selected area.
    `default boolean` | `isToolbarVisible()` | Returns whether the toolbar is visible.
    `static ICropper` | `of​(java.lang.String src)` | Returns the instance with the given `src`.
    `static ICropper` | `of​(java.lang.String src, int x, int y, int w, int h)` | Returns the instance with the given src, x, y, w, and h.
    `static ICropper` | `ofId​(java.lang.String id)` | Returns the instance with the given id.
    `static ICropper` | `ofSize​(int x, int y, int w, int h)` | Returns the instance with the given size, x, y, w, and h.
    `ICropper` | `withAspectRatio​(double aspectRatio)` | Returns a copy of `this` immutable component with the specified `aspectRatio`.
    `default ICropper` | `withContent​(java.awt.image.RenderedImage image)` | Returns a copy of `this` immutable component with the specified `image`.
    `ICropper` | `withContent​(Image image)` | Returns a copy of `this` immutable component with the specified `image`.
    `ICropper` | `withCroppedFormat​(java.lang.String croppedFormat)` | Returns a copy of `this` immutable component with the specified `croppedFormat`.
    `ICropper` | `withCrossorigin​(java.lang.String crossorigin)` | Returns a copy of `this` immutable component with the specified `crossorigin`.
    `default ICropper` | `withCrossorigin​(ICropper.Crossorigin crossorigin)` | Returns a copy of `this` immutable component with the specified `crossorigin`.
    `ICropper` | `withH​(int h)` | Returns a copy of `this` immutable component with the specified `h`.
    `ICropper` | `withInstant​(boolean instant)` | Returns a copy of `this` immutable component with the specified `instant`.
    `ICropper` | `withMaxHeight​(int maxHeight)` | Returns a copy of `this` immutable component with the specified `maxHeight`.
    `ICropper` | `withMaxWidth​(int maxWidth)` | Returns a copy of `this` immutable component with the specified `maxWidth`.
    `ICropper` | `withMinHeight​(int minHeight)` | Returns a copy of `this` immutable component with the specified `minHeight`.
    `ICropper` | `withMinWidth​(int minWidth)` | Returns a copy of `this` immutable component with the specified `minWidth`.
    `ICropper` | `withSrc​(java.lang.String src)` | Returns a copy of `this` immutable component with the specified `src`.
    `ICropper` | `withToolbarVisible​(boolean toolbarVisible)` | Returns a copy of `this` immutable component with the specified `toolbarVisible`.
    `ICropper` | `withW​(int w)` | Returns a copy of `this` immutable component with the specified `w`.
    `ICropper` | `withX​(int x)` | Returns a copy of `this` immutable component with the specified `x`.
    `ICropper` | `withY​(int y)` | Returns a copy of `this` immutable component with the specified `y`.

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

      `getAction, getActions, getClientAttributes, getId, getMold, 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`

- - ### Field Detail

    - #### DEFAULT

          static final ICropper DEFAULT

      Constant for default attributes of this immutable component.

  - ### Method Detail

    - #### getWidgetClass

          default java.lang.String getWidgetClass()

      Returns the client widget class.

      Default: `"zkmax.cropper.Cropper"`

      Specified by:
        `getWidgetClass` in interface `IComponent<ICropper>`

    - #### getCrossorigin

          @Nullable
          java.lang.String getCrossorigin()

      Returns the crossorigin of the img of this cropper, could be `"anonymous"`, `"use-credentials"` or `null`.

      Default: `null`.

    - #### withCrossorigin

          ICropper withCrossorigin​(@Nullable
                                   java.lang.String crossorigin)

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

      Sets the crossorigin of the img of this cropper, could be `"anonymous"`, `"use-credentials"` or `null`.

      Parameters:
        `crossorigin` - The crossorigin of the img of this cropper, could be `"anonymous"`, `"use-credentials"` or `null`.

        Default: `null`.

      Returns:
        A modified copy of the `this` object

    - #### withCrossorigin

          default ICropper withCrossorigin​(@Nullable
                                           ICropper.Crossorigin crossorigin)

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

      Sets the crossorigin of the img of this cropper, could be `"anonymous"`, `"use-credentials"` or `null`.

      Parameters:
        `crossorigin` - The crossorigin of the img of this cropper, could be `"anonymous"`, `"use-credentials"` or `null`.

        Default: `null`.

      Returns:
        A modified copy of the `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

          ICropper withContent​(@Nullable
                               Image image)

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

      Sets the content directly.

      Default: `null`.

      Calling this method implies `withSrc(null)`. In other words, the invocation of `withContent(org.zkoss.image.Image)` overrides the `withSrc(String)`, if any.

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

    - #### withContent

          default ICropper 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

    - #### getAspectRatio

          default double getAspectRatio()

      Returns the aspect ratio of the cropped area.

      Default: `0` Means the ratio has no restrict

    - #### withAspectRatio

          ICropper withAspectRatio​(double aspectRatio)

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

      Sets the aspect ratio of the selected area.

      Parameters:
        `aspectRatio` - The aspect ratio of the selected area.

        Default: `0`

      Returns:
        A modified copy of `this` object

    - #### getMinWidth

          default int getMinWidth()

      Returns the minimum width of the selected crop area.

      Default: `0`

    - #### withMinWidth

          ICropper withMinWidth​(int minWidth)

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

      Sets the minimum width of the selected crop area.

      Parameters:
        `minWidth` - The minimum width of the selected crop area.

        Default: `0`

      Returns:
        A modified copy of `this` object

    - #### getMinHeight

          default int getMinHeight()

      Returns the minimum height of the selected crop area.

      Default: `0`

    - #### withMinHeight

          ICropper withMinHeight​(int minHeight)

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

      Sets the minimum height of the selected crop area.

      Parameters:
        `minHeight` - The minimum height of the selected crop area.

        Default: `0`

      Returns:
        A modified copy of `this` object

    - #### getMaxWidth

          default int getMaxWidth()

      Returns the maximum width of the selected crop area.

      Default: `0`

    - #### withMaxWidth

          ICropper withMaxWidth​(int maxWidth)

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

      Sets the maximum width of the selected crop area.

      Parameters:
        `maxWidth` - The maximum width of the selected crop area.

        Default: `0`

      Returns:
        A modified copy of `this` object

    - #### getMaxHeight

          default int getMaxHeight()

      Returns the maximum height of the selected crop area.

      Default: `0`

    - #### withMaxHeight

          ICropper withMaxHeight​(int maxHeight)

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

      Sets the maximum height of the selected crop area.

      Parameters:
        `maxHeight` - The maximum height of the selected crop area.

        Default: `0`

      Returns:
        A modified copy of `this` object

    - #### getX

          default int getX()

      Returns the left position of the crop area relates to the left edge of the child image in pixel.

      Default: `0`

    - #### withX

          ICropper withX​(int x)

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

      Sets the left position of the crop area relates to the left edge of the child image in pixel.

      Parameters:
        `x` - The left position of the crop area

        Default: `0`

      Returns:
        A modified copy of `this` object

    - #### getY

          default int getY()

      Returns the top position of the crop area relates to the top edge of the child image in pixel.

      Default: `0`

    - #### withY

          ICropper withY​(int y)

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

      Sets the top position of the crop area relates to the top edge of the child image in pixel.

      Parameters:
        `y` - The top position of the crop area

        Default: `0`

      Returns:
        A modified copy of `this` object

    - #### getW

          default int getW()

      Returns the width of the crop area in pixel.

      Default: `0`

    - #### withW

          ICropper withW​(int w)

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

      Sets the width of the crop area in pixel.

      Parameters:
        `w` - The width of the crop area in pixel.

        Default: `0`

      Returns:
        A modified copy of `this` object

    - #### getH

          default int getH()

      Returns the height of the crop area in pixel.

      Default: `0`

    - #### withH

          ICropper withH​(int h)

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

      Sets the height of the crop area in pixel.

      Parameters:
        `h` - The height of the crop area in pixel.

        Default: `0`

      Returns:
        A modified copy of `this` object

    - #### isToolbarVisible

          default boolean isToolbarVisible()

      Returns whether the toolbar is visible.

      Default: `true`

    - #### withToolbarVisible

          ICropper withToolbarVisible​(boolean toolbarVisible)

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

      Sets whether the toolbar is visible.

      Parameters:
        `toolbarVisible` - Whether the toolbar is visible.

        Default: `true`

      Returns:
        A modified copy of `this` object

    - #### getCroppedFormat

          default java.lang.String getCroppedFormat()

      Returns the cropped image format, e.g., `"image/png"`, `"image/jpeg"`. If the requested type is invalid or unspecified, it will use `"image/png"`.

      Default: `"image/png"`.

    - #### withCroppedFormat

          ICropper withCroppedFormat​(java.lang.String croppedFormat)

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

      Sets the cropped image format, e.g., `"image/png"`, `"image/jpeg"`. If the requested type is invalid or unspecified, it will use `"image/png"`.

      Parameters:
        `croppedFormat` - The cropped image format.

        Default: `"image/png"`

      Returns:
        A modified copy of `this` object

    - #### isInstant

          default boolean isInstant()

      Returns whether to send back onChange action immediately while the user is resizing the selected area.

      Default: `false`

    - #### withInstant

          ICropper withInstant​(boolean instant)

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

      Sets whether to send back onChange action immediately while the user is resizing the selected area.

      Parameters:
        `instant` - Whether to send back onChange action immediately while the user is resizing the selected area.

        Default: `"image/png"`

      Returns:
        A modified copy of `this` object

    - #### getSrc

          @Nullable
          java.lang.String getSrc()

      Returns the source URI of the image.

      Default: `null`.

    - #### withSrc

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

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

      Sets the source URI of the image.

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

    - #### of

          static ICropper of​(java.lang.String src)

      Returns the instance with the given `src`.
      Parameters:
        `src` - The URI of the image source.

    - #### of

          static ICropper of​(java.lang.String src,
                             int x,
                             int y,
                             int w,
                             int h)

      Returns the instance with the given src, x, y, w, and h.
      Parameters:
        `src` - The URI of the image source
        `x` - The left position of the crop area
        `y` - The top position of the crop area
        `w` - The width of the crop area
        `h` - The height of the crop area

    - #### ofSize

          static ICropper ofSize​(int x,
                                 int y,
                                 int w,
                                 int h)

      Returns the instance with the given size, x, y, w, and h.
      Parameters:
        `x` - The left position of the crop area
        `y` - The top position of the crop area
        `w` - The width of the crop area
        `h` - The height of the crop area

    - #### ofId

          static ICropper ofId​(java.lang.String id)

      Returns the instance with the given id.
      Parameters:
        `id` - The id to identify this component