Class TextStyle
java.lang.Object
com.vaadin.flow.component.map.configuration.AbstractConfigurationObject
com.vaadin.flow.component.map.configuration.style.TextStyle
- All Implemented Interfaces:
Serializable
Text style that defines how to render texts on the map.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
static enum
static class
-
Field Summary
Fields inherited from class com.vaadin.flow.component.map.configuration.AbstractConfigurationObject
propertyChangeSupport
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionThe fill color to use for the background of the text.The stroke with which to render the texts background border.getFill()
The fill color to use for rendering the text.getFont()
The font style as CSS `font` value.The offset of the text from its anchor point.int
The padding for the text's background.double
The rotation to apply to the text, in radians.double
getScale()
The scaling to apply to the text.The stroke to use for rendering the text.The horizontal text alignment based from the text's anchor point.The vertical baseline for aligning the text based on its anchor point.getType()
The unique type name of this class.boolean
Whether to rotate the text with the view.void
setBackgroundFill
(Fill backgroundFill) Sets the fill color to use for the background of the text.void
setBackgroundFill
(String fillColor) Sets the fill color to use for the background of the text.void
setBackgroundStroke
(Stroke backgroundStroke) Sets the stroke with which to render the texts background border.void
setBackgroundStroke
(String strokeColor, int strokeWidth) Sets the stroke with which to render the texts background border.void
Sets the fill color to use for rendering the text.void
Sets the fill color to use for rendering the text.void
Sets the font style as CSS `font` value.void
setOffset
(int x, int y) Sets the offset of the text from whatever it is anchored to, in pixels.void
setOffset
(TextStyle.TextOffset offset) Sets the offset of the text from whatever it is anchored to, in pixels.void
setPadding
(int padding) Sets the padding for the text's background.void
setRotateWithView
(boolean rotateWithView) Sets whether to rotate the text with the view.void
setRotation
(double rotation) Sets the rotation to apply to the text, in radians.void
setScale
(double scale) Sets the scaling factor to apply to the text.void
Sets the stroke to use for rendering the text.void
Sets the stroke to use for rendering the text.void
setTextAlign
(TextStyle.TextAlign textAlign) Sets the horizontal alignment based from the text's anchor point, including the offset set usingsetOffset(TextOffset)
.void
setTextBaseline
(TextStyle.TextBaseline textBaseline) Sets the vertical baseline for aligning the text based on its anchor point, including the offset set usingsetOffset(TextOffset)
.Methods inherited from class com.vaadin.flow.component.map.configuration.AbstractConfigurationObject
addChild, addNullableChild, addPropertyChangeListener, collectChanges, deepMarkAsDirty, getId, markAsDirty, notifyChange, notifyChange, removeChild, removePropertyChangeListener, setId, update
-
Constructor Details
-
TextStyle
public TextStyle()
-
-
Method Details
-
getType
Description copied from class:AbstractConfigurationObject
The unique type name of this class. Used by the client-side synchronization mechanism to determine which OpenLayers class to synchronize into.- Specified by:
getType
in classAbstractConfigurationObject
-
getFont
The font style as CSS `font` value.- Returns:
- the font style
-
setFont
Sets the font style as CSS `font` value. See CanvasRenderingContext2D.font. Default is13px sans-serif
.- Parameters:
font
- the new font style
-
getOffset
The offset of the text from its anchor point.- Returns:
- the offset
-
setOffset
Sets the offset of the text from whatever it is anchored to, in pixels. For example, a marker text is anchored to the marker's position, and then shifted by the specified offset. Default is{x: 0, y: 10}
- Parameters:
offset
- the new offset
-
setOffset
public void setOffset(int x, int y) Sets the offset of the text from whatever it is anchored to, in pixels. For example, a marker text is anchored to the marker's position, and then shifted by the specified offset. Default is{x: 0, y: 10}
- Parameters:
x
- the horizontal offset in pixelsy
- the vertical offset in pixels
-
getScale
public double getScale()The scaling to apply to the text.- Returns:
- the scale value
-
setScale
public void setScale(double scale) Sets the scaling factor to apply to the text. Default value is1
.- Parameters:
scale
- the new scaling factor.
-
getRotation
public double getRotation()The rotation to apply to the text, in radians.- Returns:
- the rotation, in radians
-
setRotation
public void setRotation(double rotation) Sets the rotation to apply to the text, in radians. Default value is0
.- Parameters:
rotation
- the new rotation, in radians
-
isRotateWithView
public boolean isRotateWithView()Whether to rotate the text with the view.- Returns:
- whether to rotate the text with the view
-
setRotateWithView
public void setRotateWithView(boolean rotateWithView) Sets whether to rotate the text with the view. Default value isfalse
.- Parameters:
rotateWithView
- whether to rotate the text with the view
-
getTextAlign
The horizontal text alignment based from the text's anchor point.- Returns:
- the horizontal alignment
-
setTextAlign
Sets the horizontal alignment based from the text's anchor point, including the offset set usingsetOffset(TextOffset)
. Default value isTextStyle.TextAlign.CENTER
.- Parameters:
textAlign
- the new alignment
-
getTextBaseline
The vertical baseline for aligning the text based on its anchor point.- Returns:
- the vertical baseline
-
setTextBaseline
Sets the vertical baseline for aligning the text based on its anchor point, including the offset set usingsetOffset(TextOffset)
. Default value isTextStyle.TextBaseline.MIDDLE
.- Parameters:
textBaseline
- the new baseline
-
getFill
The fill color to use for rendering the text.- Returns:
- the text's fill color
-
setFill
Sets the fill color to use for rendering the text. This is effectively the text's color, which can be complemented by an outline by settingsetStroke(Stroke)
. The fill's color value must be a valid CSS color. The default fill color is#333
.- Parameters:
fill
- the new fill color
-
setFill
Sets the fill color to use for rendering the text. This is effectively the text's color, which can be complemented by an outline by settingsetStroke(Stroke)
. The fill's color value must be a valid CSS color. The default fill color is#333
.- Parameters:
fillColor
- the new fill color
-
getStroke
The stroke to use for rendering the text.- Returns:
- the text's stroke
-
setStroke
Sets the stroke to use for rendering the text. This effectively renders an outline around the text, seesetFill(Fill)
for setting the text's main color. The stroke's color must be a valid CSS color, and its width is specified in pixels. The default stroke's color is#fff
, and the default width is3
pixels.- Parameters:
stroke
- the new stroke
-
setStroke
Sets the stroke to use for rendering the text. This effectively renders an outline around the text, seesetFill(Fill)
for setting the text's main color. The stroke's color must be a valid CSS color, and its width is specified in pixels. The default stroke's color is#fff
, and the default width is3
pixels.- Parameters:
strokeColor
- the new stroke colorstrokeWidth
- the new stroke width
-
getBackgroundFill
The fill color to use for the background of the text.- Returns:
- the text's background fill
-
setBackgroundFill
Sets the fill color to use for the background of the text. The fill's color must be a valid CSS color. By default, the text does not use a background color.- Parameters:
backgroundFill
- the new background fill color
-
setBackgroundFill
Sets the fill color to use for the background of the text. The fill's color must be a valid CSS color. By default, the text does not use a background color.- Parameters:
fillColor
- the new background fill color
-
getBackgroundStroke
The stroke with which to render the texts background border.- Returns:
- the text's background stroke
-
setBackgroundStroke
Sets the stroke with which to render the texts background border. The stroke's color must be a valid CSS color, and its width is specified in pixels. By default, the text does not use a background stroke.- Parameters:
backgroundStroke
- the new background stroke
-
setBackgroundStroke
Sets the stroke with which to render the texts background border. The stroke's color must be a valid CSS color, and its width is specified in pixels. By default, the text does not use a background stroke.- Parameters:
strokeColor
- the new background stroke colorstrokeWidth
- the new background stroke width
-
getPadding
public int getPadding()The padding for the text's background.- Returns:
- the background padding
-
setPadding
public void setPadding(int padding) Sets the padding for the text's background. The padding is applied to all sides of the background. Default value is0
.- Parameters:
padding
- the new padding
-