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, java.io.Serializable

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

    Constructors 
    Constructor Description
    SignaturePad()
    Default constructor.
  • Method Summary

    Modifier and Type Method Description
    void clear()
    Clears the widget.
    java.lang.String getBackgroundColor()
    Returns the current set background color.
    double getDotSize()
    Returns the current set radius of a single dot.
    double getEncoderQuality()
    Returns the current set encoder quality.
    byte[] getImageBase64()
    Returns the current shown image as Base64 decoded byte array.
    java.lang.String getImageURI()
    Returns the current shown image in URI format.
    double getLineMaxWidth()
    Returns the current set maximum width of a line.
    double getLineMinWidth()
    Returns the current set minimum width of a line.
    int getMinDistance()
    Returns the current set min distance.
    java.lang.String getPenColor()
    Returns the current set pen color.
    int getThrottle()
    Returns the current set throttle.
    java.lang.String getType()
    Returns the current set MIME-Type.
    double getVelocityFilterWeight()
    Returns the current set velocityFilterWeight.
    boolean isEmpty()
    Returns if the widget is empty.
    boolean isReadOnly()
    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 setBackgroundColor​(java.lang.String hex)
    Sets the background color in hex format.
    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 setImage​(java.lang.String uri)
    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 setPenColor​(java.lang.String hex)
    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 setTransparentBackground()
    Sets the background color transparent.
    void setType​(java.lang.String type)
    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 undo()
    Reverts the last change you did to the canvas itself.

    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

    • 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​(java.lang.String hex)
      Sets the background color in hex format.
      Parameters:
      hex - String
    • getBackgroundColor

      public java.lang.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​(java.lang.String hex)
      Sets the pen color in hex format.
      Parameters:
      hex - String
    • getPenColor

      public java.lang.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 java.lang.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​(java.lang.String type)
      Sets the MIME-Type for the image encoder. Has to start with "image/"!
      Parameters:
      type - String
    • getType

      public java.lang.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​(java.lang.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.