Class SignaturePad

java.lang.Object
com.vaadin.flow.component.Component
de.f0rce.signaturepad.SignaturePad
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, Serializable

@Tag("lit-signature-pad") @JsModule("./@f0rce/signature-widget.js") @NpmPackage(value="signature_pad", version="4.1.5") public class SignaturePad extends com.vaadin.flow.component.Component implements com.vaadin.flow.component.HasSize
Author:
David "F0rce" Dodlek
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.vaadin.flow.shared.Registration
    addValueChangeListener(com.vaadin.flow.component.ComponentEventListener<ValueChangedEvent> listener)
    Add a listener to the editor, which listens to when the value changed.
    void
    Clears the widget.
    Returns the current set background color.
    double
    Returns the current set radius of a single dot.
    double
    Returns the current set encoder quality.
    byte[]
    Returns the current shown image as Base64 decoded byte array.
    Returns the current shown image in URI format.
    double
    Returns the current set maximum width of a line.
    double
    Returns the current set minimum width of a line.
    int
    Returns the current set min distance.
    Returns the current set pen color.
    int
    Returns the current set throttle.
    Returns the current set MIME-Type.
    double
    Returns the current set velocityFilterWeight.
    boolean
    Returns if the clear button is visible.
    boolean
    Returns if the widget is empty.
    boolean
    Returns if the widget is set to read only.
    void
    setBackgroundColor(int red, int green, int blue)
    Sets the background color in RGB format.
    void
    setBackgroundColor(int red, int green, int blue, int alpha)
    Sets the background color in RGBA format.
    void
    Sets the background color in hex format.
    void
    setClearButtonVisible(boolean clearButtonVisible)
    Set the clear button's (top right) visibility.
    void
    setDotSize(double dotSize)
    Sets the radius of a single dot.
    void
    setDotSize(int dotSize)
    Sets the radius of a single dot.
    void
    setEncoderQuality(double encoderQuality)
    Sets the encoder quality.
    void
    Sets the image of the widget in URI Format.
    void
    setLineMaxWidth(double lineMaxWidth)
    Sets the maximum width of a line.
    void
    setLineMaxWidth(int lineMaxWidth)
    Sets the maximum width of a line.
    void
    setLineMinWidth(double lineMinWidth)
    Sets the minimum width of a line.
    void
    setLineMinWidth(int lineMinWidth)
    Sets the minimum width of a line.
    void
    setMinDistance(int minDistance)
    Sets the minDistance, which adds the next point only if the previous one is farther than x pixels.
    void
    setPenColor(int red, int green, int blue)
    Sets the pen color in RGB format.
    void
    Sets the pen color in hex format.
    void
    setReadOnly(boolean readOnly)
    Sets the widget read only.
    void
    setThrottle(int throttle)
    Sets the throttle, which will draw the next point at most once per every x milliseconds.
    void
    Sets the background color transparent.
    void
    Sets the MIME-Type for the image encoder.
    void
    setVelocityFilterWeight(double velocityFilterWeight)
    Sets the velocityFilterWeight, which is used to modify new velocity based on the previous velocity.
    void
    setVelocityFilterWeight(int velocityFilterWeight)
    Sets the velocityFilterWeight, which is used to modify new velocity based on the previous velocity.
    void
    Reverts the last change you did to the canvas itself.

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

    addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible

    Methods inherited from class java.lang.Object

    clone, equals, finalize, 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

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

    addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
  • Constructor Details

    • SignaturePad

      public SignaturePad()
      Default constructor. By default height is set to 100px and width to 300px.
  • Method Details

    • clear

      public void clear()
      Clears the widget.
    • setDotSize

      public void setDotSize(int dotSize)
      Sets the radius of a single dot.
      Parameters:
      dotSize - int
    • setDotSize

      public void setDotSize(double dotSize)
      Sets the radius of a single dot.
      Parameters:
      dotSize - double
    • getDotSize

      public double getDotSize()
      Returns the current set radius of a single dot.
      Returns:
      double
    • setLineMinWidth

      public void setLineMinWidth(int lineMinWidth)
      Sets the minimum width of a line. Defaults to 0.5.
      Parameters:
      lineMinWidth - int
    • setLineMinWidth

      public void setLineMinWidth(double lineMinWidth)
      Sets the minimum width of a line. Defaults to 0.5.
      Parameters:
      lineMinWidth - double
    • getLineMinWidth

      public double getLineMinWidth()
      Returns the current set minimum width of a line.
      Returns:
      double
    • setLineMaxWidth

      public void setLineMaxWidth(int lineMaxWidth)
      Sets the maximum width of a line. Defaults to 2.5.
      Parameters:
      lineMaxWidth - int
    • setLineMaxWidth

      public void setLineMaxWidth(double lineMaxWidth)
      Sets the maximum width of a line. Defaults to 2.5.
      Parameters:
      lineMaxWidth - double
    • getLineMaxWidth

      public double getLineMaxWidth()
      Returns the current set maximum width of a line.
      Returns:
      double
    • setThrottle

      public void setThrottle(int throttle)
      Sets the throttle, which will draw the next point at most once per every x milliseconds. Set it to 0 to turn off throttling. Defaults to 16.
      Parameters:
      throttle - int
    • getThrottle

      public int getThrottle()
      Returns the current set throttle.
      Returns:
      int
    • setMinDistance

      public void setMinDistance(int minDistance)
      Sets the minDistance, which adds the next point only if the previous one is farther than x pixels. Defaults to 5.
      Parameters:
      minDistance - int
    • getMinDistance

      public int getMinDistance()
      Returns the current set min distance.
      Returns:
      int
    • setBackgroundColor

      public void setBackgroundColor(int red, int green, int blue)
      Sets the background color in RGB format.
      Parameters:
      red - int
      green - int
      blue - int
    • setBackgroundColor

      public void setBackgroundColor(int red, int green, int blue, int alpha)
      Sets the background color in RGBA format.
      Parameters:
      red - int
      green - int
      blue - int
      alpha - int
    • setBackgroundColor

      public void setBackgroundColor(String hex)
      Sets the background color in hex format.
      Parameters:
      hex - String
    • getBackgroundColor

      public String getBackgroundColor()
      Returns the current set background color.
      Returns:
      String
    • setPenColor

      public void setPenColor(int red, int green, int blue)
      Sets the pen color in RGB format.
      Parameters:
      red - int
      green - int
      blue - int
    • setPenColor

      public void setPenColor(String hex)
      Sets the pen color in hex format.
      Parameters:
      hex - String
    • getPenColor

      public String getPenColor()
      Returns the current set pen color.
      Returns:
      String
    • setVelocityFilterWeight

      public void setVelocityFilterWeight(int velocityFilterWeight)
      Sets the velocityFilterWeight, which is used to modify new velocity based on the previous velocity. Defaults to 0.7
      Parameters:
      velocityFilterWeight - int
    • setVelocityFilterWeight

      public void setVelocityFilterWeight(double velocityFilterWeight)
      Sets the velocityFilterWeight, which is used to modify new velocity based on the previous velocity. Defaults to 0.7
      Parameters:
      velocityFilterWeight - double
    • getVelocityFilterWeight

      public double getVelocityFilterWeight()
      Returns the current set velocityFilterWeight.
      Returns:
      double
    • getImageURI

      public String getImageURI()
      Returns the current shown image in URI format.
      Returns:
      String
    • getImageBase64

      public byte[] getImageBase64()
      Returns the current shown image as Base64 decoded byte array.
      Returns:
      byte[]
    • setType

      public void setType(String type)
      Sets the MIME-Type for the image encoder. Has to start with "image/"!
      Parameters:
      type - String
    • getType

      public String getType()
      Returns the current set MIME-Type. Defaults to image/png.
      Returns:
      String
    • setReadOnly

      public void setReadOnly(boolean readOnly)
      Sets the widget read only.
      Parameters:
      readOnly - boolean
    • isReadOnly

      public boolean isReadOnly()
      Returns if the widget is set to read only.
      Returns:
      boolean
    • setImage

      public void setImage(String uri)
      Sets the image of the widget in URI Format.
      Parameters:
      uri - String
    • setEncoderQuality

      public void setEncoderQuality(double encoderQuality)
      Sets the encoder quality. All values between 0-1 are accepted. Defaults to 0.85.
      Parameters:
      encoderQuality - double
    • getEncoderQuality

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

      public void undo()
      Reverts the last change you did to the canvas itself.
    • isEmpty

      public boolean isEmpty()
      Returns if the widget is empty.
      Returns:
      boolean
    • setTransparentBackground

      public void setTransparentBackground()
      Sets the background color transparent.
    • setClearButtonVisible

      public void setClearButtonVisible(boolean clearButtonVisible)
      Set the clear button's (top right) visibility.
      Parameters:
      clearButtonVisible - boolean
    • isClearButtonVisible

      public boolean isClearButtonVisible()
      Returns if the clear button is visible.
      Returns:
      boolean
    • addValueChangeListener

      public com.vaadin.flow.shared.Registration addValueChangeListener(com.vaadin.flow.component.ComponentEventListener<ValueChangedEvent> listener)
      Add a listener to the editor, which listens to when the value changed.

      Check ValueChangedEvent for all available returned values.

      Parameters:
      listener - ComponentEventListener
      Returns:
      Registration