Class Cropper

java.lang.Object
com.vaadin.flow.component.Component
de.f0rce.cropper.Cropper
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasSize, java.io.Serializable

@Tag("lit-cropper")
@JsModule("./@f0rce/lit-cropper/lit-cropper.js")
@NpmPackage(value="cropperjs",
            version="1.5.11")
public class Cropper
extends com.vaadin.flow.component.Component
implements com.vaadin.flow.component.HasSize
See Also:
Serialized Form
  • Constructor Summary

    Constructors 
    Constructor Description
    Cropper​(CropperSettings settings, java.lang.String imgSrc, java.lang.String mimeType)
    Initialize the cropper with settings.
    Cropper​(java.lang.String imgSrc, java.lang.String mimeType)
    Initialize the cropper with default settings.
  • Method Summary

    Modifier and Type Method Description
    void disable()
    When disabled the user can't move the crop box.
    void enable()
    When enabled the user can move the crop box.
    double getEncoderQuality()
    Returns the current set image encoder quality.
    byte[] getImageBase64()
    Returns the cropped image uri as Base64 encoded byte array.
    java.lang.String getImageUri()
    Returns the cropped image uri.
    com.vaadin.flow.shared.Registration onReady​(com.vaadin.flow.component.ComponentEventListener<CropperReadyEvent> listener)
    Add's a listener to the cropper as soon as the frontend is ready.
    void setEncoderQuality​(double encoderQuality)
    Sets the quality of the image encoder (defaults to 0.85).

    Methods inherited from class com.vaadin.flow.component.Component

    from, getChildren, getElement, getId, getParent, getTranslation, getTranslation, getUI, isVisible, onEnabledStateChanged, setId, setVisible

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.HasSize

    getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
  • Constructor Details

    • Cropper

      public Cropper​(CropperSettings settings, java.lang.String imgSrc, java.lang.String mimeType)
      Initialize the cropper with settings.
      Parameters:
      settings - CropperSettings
      imgSrc - String
      mimeType - String
    • Cropper

      public Cropper​(java.lang.String imgSrc, java.lang.String mimeType)
      Initialize the cropper with default settings.
      Parameters:
      imgSrc - String
      mimeType - String
  • Method Details

    • onReady

      public com.vaadin.flow.shared.Registration onReady​(com.vaadin.flow.component.ComponentEventListener<CropperReadyEvent> listener)
      Add's a listener to the cropper as soon as the frontend is ready.
      Parameters:
      listener - ComponentEventListener
      Returns:
      Registration
    • getImageUri

      public java.lang.String getImageUri()
      Returns the cropped image uri.
      Returns:
      String
    • getImageBase64

      public byte[] getImageBase64()
      Returns the cropped image uri as Base64 encoded byte array.
      Returns:
      byte[]
    • setEncoderQuality

      public void setEncoderQuality​(double encoderQuality)
      Sets the quality of the image encoder (defaults to 0.85).
      Parameters:
      encoderQuality - double
    • getEncoderQuality

      public double getEncoderQuality()
      Returns the current set image encoder quality.
      Returns:
      double
    • enable

      public void enable()
      When enabled the user can move the crop box.
    • disable

      public void disable()
      When disabled the user can't move the crop box.