Package de.f0rce.signaturepad
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 -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.RegistrationaddValueChangeListener(com.vaadin.flow.component.ComponentEventListener<ValueChangedEvent> listener) Add a listener to the editor, which listens to when the value changed.voidclear()Clears the widget.Returns the current set background color.doubleReturns the current set radius of a single dot.doubleReturns the current set encoder quality.byte[]Returns the current shown image as Base64 decoded byte array.Returns the current shown image in URI format.doubleReturns the current set maximum width of a line.doubleReturns the current set minimum width of a line.intReturns the current set min distance.Returns the current set pen color.intReturns the current set throttle.getType()Returns the current set MIME-Type.doubleReturns the current set velocityFilterWeight.booleanReturns if the clear button is visible.booleanisEmpty()Returns if the widget is empty.booleanReturns if the widget is set to read only.voidsetBackgroundColor(int red, int green, int blue) Sets the background color in RGB format.voidsetBackgroundColor(int red, int green, int blue, int alpha) Sets the background color in RGBA format.voidsetBackgroundColor(String hex) Sets the background color in hex format.voidsetClearButtonVisible(boolean clearButtonVisible) Set the clear button's (top right) visibility.voidsetDotSize(double dotSize) Sets the radius of a single dot.voidsetDotSize(int dotSize) Sets the radius of a single dot.voidsetEncoderQuality(double encoderQuality) Sets the encoder quality.voidSets the image of the widget in URI Format.voidsetLineMaxWidth(double lineMaxWidth) Sets the maximum width of a line.voidsetLineMaxWidth(int lineMaxWidth) Sets the maximum width of a line.voidsetLineMinWidth(double lineMinWidth) Sets the minimum width of a line.voidsetLineMinWidth(int lineMinWidth) Sets the minimum width of a line.voidsetMinDistance(int minDistance) Sets the minDistance, which adds the next point only if the previous one is farther than x pixels.voidsetPenColor(int red, int green, int blue) Sets the pen color in RGB format.voidsetPenColor(String hex) Sets the pen color in hex format.voidsetReadOnly(boolean readOnly) Sets the widget read only.voidsetThrottle(int throttle) Sets the throttle, which will draw the next point at most once per every x milliseconds.voidSets the background color transparent.voidSets the MIME-Type for the image encoder.voidsetVelocityFilterWeight(double velocityFilterWeight) Sets the velocityFilterWeight, which is used to modify new velocity based on the previous velocity.voidsetVelocityFilterWeight(int velocityFilterWeight) Sets the velocityFilterWeight, which is used to modify new velocity based on the previous velocity.voidundo()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, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods 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, setWidthFullMethods 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- intgreen- intblue- int
-
setBackgroundColor
public void setBackgroundColor(int red, int green, int blue, int alpha) Sets the background color in RGBA format.- Parameters:
red- intgreen- intblue- intalpha- int
-
setBackgroundColor
Sets the background color in hex format.- Parameters:
hex-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- intgreen- intblue- int
-
setPenColor
Sets the pen color in hex format.- Parameters:
hex-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
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
Sets the MIME-Type for the image encoder. Has to start with "image/"!- Parameters:
type-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
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
ValueChangedEventfor all available returned values.- Parameters:
listener-ComponentEventListener- Returns:
Registration
-