- All Implemented Interfaces:
JsonSerializable
To display text in a MapView
or SceneView
,
create a TextSymbol. Specify whether a string or attribute value is displayed by the setText(String)
.
Define the appearance and position of the text using
colorProperty()
, setSize(float)
, setFontStyle(FontStyle)
, or
setVerticalAlignment(VerticalAlignment)
, for example.
Position the text by applying it to a Graphic
based on any type of geometry - point, multipoint,
polyline, or polygon. Add the graphic to the GraphicsOverlay.getGraphics()
collection and add the
GraphicsOverlay
to the MapView
or SceneView
collection of graphics overlays.
TextSymbol is also used to define the appearance of layer and grid based labels:
- Layers such as
FeatureLayer
,ArcGISSceneLayer
, orDynamicEntityLayer
contain label definitions that specify how labels are displayed. You can useLabelDefinition.getTextSymbol()
to define a label appearance within a scale range. To display these labels, add a collection of these label definitions to a layer. -
MapView
can display a coordinate system grid with specific label styles at different resolutions. You can define the appearance of these labels usingGrid.setTextSymbol(int, Symbol)
.
- Since:
- 100.0.0
-
Property Summary
TypePropertyDescriptionThe background color of this TextSymbol.The color of this TextSymbol.The halo color.The outline color. -
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Defines various decorations that can be applied to the text of this Symbol.static enum
Defines various styles that can be applied to the text of this Symbol.static enum
Defines how thick or thin the characters in text appear.static enum
Defines horizontal alignment of the text within the Symbol.static enum
Defines vertical alignment of the text within the Symbol.Nested classes/interfaces inherited from class com.esri.arcgisruntime.symbology.MarkerSymbol
MarkerSymbol.AngleAlignment
-
Constructor Summary
ConstructorDescriptionCreates a new TextSymbol with default values.TextSymbol
(float size, String text, int color, TextSymbol.HorizontalAlignment horizontalAlignment, TextSymbol.VerticalAlignment verticalAlignment) Deprecated, for removal: This API element is subject to removal in a future version.TextSymbol
(float size, String text, Color color, TextSymbol.HorizontalAlignment horizontalAlignment, TextSymbol.VerticalAlignment verticalAlignment) Creates a new TextSymbol with the given size, text, and color along with the horizontal and vertical alignment relative to the mid-point of this Symbol. -
Method Summary
Modifier and TypeMethodDescriptionThe background color of this TextSymbol.The color of this TextSymbol.Gets the value of thebackgroundColor
property.getColor()
Gets the value of thecolor
property.Gets the type of font decoration for the text symbol.Gets the FontFamily being used by this Symbol's text.Gets the FontStyle of the text that is being used by this Symbol.Gets the FontWeight of the text being displayed by this Symbol.Gets the value of thehaloColor
property.float
Gets the size of the halo around the text symbol in device-independent pixels (DIPs).Gets the horizontal alignment of the text symbol relative to the symbol's mid-point location.Gets the value of theoutlineColor
property.float
Gets the width of the text symbol outline in device-independent pixels (DIPs).float
getSize()
Gets the Symbol's text size in device-independent pixels (DIPs).getText()
Gets the text displayed by this Symbol.Gets the vertical alignment of the text symbol relative to the symbol's mid-point location.The halo color.The outline color.void
setBackgroundColor
(int color) Deprecated, for removal: This API element is subject to removal in a future version.as of 200.0.0, replaced bysetBackgroundColor(Color)
void
setBackgroundColor
(Color color) Sets the value of thebackgroundColor
property.void
setColor
(int color) Deprecated, for removal: This API element is subject to removal in a future version.as of 200.0.0, replaced bysetColor(Color)
void
Sets the value of thecolor
property.void
setFontDecoration
(TextSymbol.FontDecoration fontDecoration) Sets the decoration for the text being used by this Symbol.void
setFontFamily
(String fontFamily) Sets the FontFamily for the text being used by this Symbol.void
setFontStyle
(TextSymbol.FontStyle fontStyle) Sets the FontStyle for the text that is being used by this Symbol.void
setFontWeight
(TextSymbol.FontWeight fontWeight) Sets the FontWeight for the text that is being used by this Symbol.void
setHaloColor
(int haloColor) Deprecated, for removal: This API element is subject to removal in a future version.as of 200.0.0, replaced bysetHaloColor(Color)
void
setHaloColor
(Color color) Sets the value of thehaloColor
property.void
setHaloWidth
(float haloWidth) Sets the size of the halo around the text symbol in device-independent pixels (DIPs).void
setHorizontalAlignment
(TextSymbol.HorizontalAlignment horizontalAlignment) Sets the horizontal alignment of the text symbol relative to the symbol's mid-point location.void
setOutlineColor
(int outlineColor) Deprecated, for removal: This API element is subject to removal in a future version.as of 200.0.0, replaced bysetOutlineColor(Color)
void
setOutlineColor
(Color color) Sets the value of theoutlineColor
property.void
setOutlineWidth
(float outlineWidth) Sets the width of the text symbol outline in device-independent pixels (DIPs).void
setSize
(float size) Sets the size of the text in device-independent pixels (DIPs).void
Sets the text displayed by this Symbol.void
setVerticalAlignment
(TextSymbol.VerticalAlignment verticalAlignment) Sets the vertical alignment of the text symbol relative to the symbol's mid-point location.Methods inherited from class com.esri.arcgisruntime.symbology.MarkerSymbol
getAngle, getAngleAlignment, getLeaderOffsetX, getLeaderOffsetY, getOffsetX, getOffsetY, setAngle, setAngleAlignment, setLeaderOffsetX, setLeaderOffsetY, setOffsetX, setOffsetY
Methods inherited from class com.esri.arcgisruntime.symbology.Symbol
createSwatchAsync, createSwatchAsync, createSwatchAsync, createSwatchAsync, createSwatchAsync, createSwatchAsync, createSwatchAsync, createSwatchAsync, createSwatchAsync, createSwatchAsync, fromJson, getUnknownJson, getUnsupportedJson, toJson
-
Property Details
-
backgroundColor
The background color of this TextSymbol.The default value is transparent Color.BLACK.
Attempting to set the color to null will throw a NullPointerException exception.
- Since:
- 200.0.0
- See Also:
-
color
The color of this TextSymbol.The default value is
Color.BLACK
.Attempting to set the color to null will throw a NullPointerException exception.
- Since:
- 200.0.0
- See Also:
-
haloColor
The halo color.The default value is transparent.
Attempting to set the color to null will throw a NullPointerException exception.
- Since:
- 200.0.0
- See Also:
-
outlineColor
The outline color.Default value is transparent.
Attempting to set the color to null will throw a NullPointerException exception.
- Since:
- 200.0.0
- See Also:
-
-
Constructor Details
-
TextSymbol
public TextSymbol()Creates a new TextSymbol with default values.The default values are:
- Color, black
- Size, 8.0
- FontStyle,
TextSymbol.FontStyle.NORMAL
- FontWeight,
TextSymbol.FontWeight.NORMAL
- HorizontalAlignment,
TextSymbol.HorizontalAlignment.CENTER
- VerticalAlignment,
TextSymbol.VerticalAlignment.MIDDLE
- FontDecoration,
TextSymbol.FontDecoration.NONE
- Since:
- 100.0.0
-
TextSymbol
@Deprecated(since="200.0.0", forRemoval=true) public TextSymbol(float size, String text, int color, TextSymbol.HorizontalAlignment horizontalAlignment, TextSymbol.VerticalAlignment verticalAlignment) Deprecated, for removal: This API element is subject to removal in a future version.as of 200.0.0, replaced byTextSymbol(float, String, Color, HorizontalAlignment, VerticalAlignment)
Creates a new TextSymbol with the given size, text, and color along with the horizontal and vertical alignment relative to the mid-point of this Symbol.- Parameters:
size
- the size of the Symbol's texttext
- the text to be displayedcolor
- an integer representing the text color as 0xAARRGGBBhorizontalAlignment
- the horizontal alignment of the Symbol's textverticalAlignment
- the vertical alignment of the Symbol's text- Throws:
IllegalArgumentException
- if text is nullIllegalArgumentException
- if horizontalAlignment is nullIllegalArgumentException
- if verticalAlignment is null- Since:
- 100.0.0
-
TextSymbol
public TextSymbol(float size, String text, Color color, TextSymbol.HorizontalAlignment horizontalAlignment, TextSymbol.VerticalAlignment verticalAlignment) Creates a new TextSymbol with the given size, text, and color along with the horizontal and vertical alignment relative to the mid-point of this Symbol.- Parameters:
size
- the size of the Symbol's texttext
- the text to be displayedcolor
- the text colorhorizontalAlignment
- the horizontal alignment of the Symbol's textverticalAlignment
- the vertical alignment of the Symbol's text- Throws:
IllegalArgumentException
- if text is nullNullPointerException
- if color is nullIllegalArgumentException
- if horizontalAlignment is nullIllegalArgumentException
- if verticalAlignment is null- Since:
- 200.0.0
-
-
Method Details
-
backgroundColorProperty
The background color of this TextSymbol.The default value is transparent Color.BLACK.
Attempting to set the color to null will throw a NullPointerException exception.
- Returns:
- the
backgroundColor
property - Since:
- 200.0.0
- See Also:
-
getBackgroundColor
Gets the value of thebackgroundColor
property.- Property description:
- The background color of this TextSymbol.
The default value is transparent Color.BLACK.
Attempting to set the color to null will throw a NullPointerException exception.
- Returns:
- the value of the
backgroundColor
property - Since:
- 200.0.0
- See Also:
-
setBackgroundColor
Sets the value of thebackgroundColor
property.- Property description:
- The background color of this TextSymbol.
The default value is transparent Color.BLACK.
Attempting to set the color to null will throw a NullPointerException exception.
- Parameters:
color
- the value for thebackgroundColor
property- Since:
- 200.0.0
- See Also:
-
setBackgroundColor
Deprecated, for removal: This API element is subject to removal in a future version.as of 200.0.0, replaced bysetBackgroundColor(Color)
Sets the background color of this TextSymbol using an ARGB(alpha, red, green, blue) color value.ARGB integer color values range from 0x00000000 to 0xFFFFFFFF with each pair of hex values representing either the alpha, red, green, or blue channels. For the alpha channel, a value of 00 means fully transparent and a value of FF is opaque.
- Parameters:
color
- an integer representing the text background color using the form 0xAARRGGBB- Since:
- 100.4.0
-
colorProperty
The color of this TextSymbol.The default value is
Color.BLACK
.Attempting to set the color to null will throw a NullPointerException exception.
- Returns:
- the
color
property - Since:
- 200.0.0
- See Also:
-
getColor
Gets the value of thecolor
property.- Property description:
- The color of this TextSymbol.
The default value is
Color.BLACK
.Attempting to set the color to null will throw a NullPointerException exception.
- Returns:
- the value of the
color
property - Since:
- 200.0.0
- See Also:
-
setColor
Sets the value of thecolor
property.- Property description:
- The color of this TextSymbol.
The default value is
Color.BLACK
.Attempting to set the color to null will throw a NullPointerException exception.
- Parameters:
color
- the value for thecolor
property- Since:
- 200.0.0
- See Also:
-
setColor
Deprecated, for removal: This API element is subject to removal in a future version.as of 200.0.0, replaced bysetColor(Color)
Sets the color of this TextSymbol using an ARGB(alpha, red, green, blue) color value.ARGB integer color values range from 0x00000000 to 0xFFFFFFFF with each pair of hex values representing either the alpha, red, green, or blue channels. For the alpha channel, a value of 00 means fully transparent and a value of FF is opaque.
- Parameters:
color
- an integer representing the text color using the form 0xAARRGGBB- Since:
- 100.0.0
-
getFontDecoration
Gets the type of font decoration for the text symbol.The default value is
TextSymbol.FontDecoration.NONE
.FontDecoration.NONE
if an error occurs.- Returns:
- the font decoration of this symbol's text
- Since:
- 100.0.0
- See Also:
-
setFontDecoration
Sets the decoration for the text being used by this Symbol.FontDecoration adds effects on top of the text.
- Parameters:
fontDecoration
- the new font decoration for this Symbol's text- Throws:
IllegalArgumentException
- if input is null- Since:
- 100.0.0
- See Also:
-
getFontFamily
Gets the FontFamily being used by this Symbol's text.Default value is an empty string.
- Returns:
- the font family the Symbol's text
- Since:
- 100.0.0
- See Also:
-
setFontFamily
Sets the FontFamily for the text being used by this Symbol. This can be as specific as 'arial' or as generic as 'sans-serif'.- Parameters:
fontFamily
- the new font family for this Symbol's text- Since:
- 100.0.0
-
getFontStyle
Gets the FontStyle of the text that is being used by this Symbol.The default value is
TextSymbol.FontStyle.NORMAL
. ReturnsFontStyle.NORMAL
if an error occurs.- Returns:
- the font style the Symbol's text
- Since:
- 100.0.0
- See Also:
-
setFontStyle
Sets the FontStyle for the text that is being used by this Symbol.A FontStyle changes the appearance of text by leaning the text.
- Parameters:
fontStyle
- the new font style for this Symbol's text- Throws:
IllegalArgumentException
- if input is null- Since:
- 100.0.0
-
getFontWeight
Gets the FontWeight of the text being displayed by this Symbol.Font weight describes how thick or thin characters in text are displayed. The default value is
TextSymbol.FontWeight.NORMAL
. ReturnsFontWeight.NORMAL
if an error occurs.- Returns:
- the font weight being used by this Symbol's text
- Since:
- 100.0.0
- See Also:
-
setFontWeight
Sets the FontWeight for the text that is being used by this Symbol.Font weight describes how thick or thin characters in text are displayed.
- Parameters:
fontWeight
- the new font weight for this Symbol's text- Throws:
IllegalArgumentException
- if input is null- Since:
- 100.0.0
-
getSize
public float getSize()Gets the Symbol's text size in device-independent pixels (DIPs).The default value is 8.0.
- Returns:
- the size of the Symbol's text in dp
- Since:
- 100.0.0
-
setSize
public void setSize(float size) Sets the size of the text in device-independent pixels (DIPs).Setting the size of the text to 0.0 will cause the text not to be displayed.
- Parameters:
size
- the new size of this Symbol's text in dp, greater than 0.0 to be visible- Throws:
ArcGISRuntimeException
- if size less than 0.0- Since:
- 100.0.0
-
getText
Gets the text displayed by this Symbol.Default value is an empty string.
- Returns:
- the text of this Symbol
- Since:
- 100.0.0
- See Also:
-
setText
Sets the text displayed by this Symbol.The alignment of the text has to do with the positioning of the text in relation to the mid-point of this Symbol.
- Parameters:
text
- the new text for this Symbol- Since:
- 100.0.0
- See Also:
-
getVerticalAlignment
Gets the vertical alignment of the text symbol relative to the symbol's mid-point location.The default value is
TextSymbol.VerticalAlignment.MIDDLE
. ReturnsVerticalAlignment.MIDDLE
if an error occurs.- Returns:
- the vertical alignment of the Symbol's text
- Since:
- 100.0.0
- See Also:
-
setVerticalAlignment
Sets the vertical alignment of the text symbol relative to the symbol's mid-point location.The default value is
TextSymbol.VerticalAlignment.MIDDLE
.- Parameters:
verticalAlignment
- the new vertical alignment for the Symbol's text- Throws:
IllegalArgumentException
- if input is null- Since:
- 100.0.0
- See Also:
-
getHorizontalAlignment
Gets the horizontal alignment of the text symbol relative to the symbol's mid-point location.The default value is
TextSymbol.HorizontalAlignment.CENTER
. ReturnsHorizontalAlignment.CENTER
if an error occurs.- Returns:
- the horizontal alignment of the Symbol's text
- Since:
- 100.0.0
- See Also:
-
setHorizontalAlignment
Sets the horizontal alignment of the text symbol relative to the symbol's mid-point location.- Parameters:
horizontalAlignment
- the new horizontal alignment for the Symbol's text- Throws:
IllegalArgumentException
- if input is null- Since:
- 100.0.0
- See Also:
-
haloColorProperty
The halo color.The default value is transparent.
Attempting to set the color to null will throw a NullPointerException exception.
- Returns:
- the
haloColor
property - Since:
- 200.0.0
- See Also:
-
getHaloColor
Gets the value of thehaloColor
property.- Property description:
- The halo color.
The default value is transparent.
Attempting to set the color to null will throw a NullPointerException exception.
- Returns:
- the value of the
haloColor
property - Since:
- 200.0.0
- See Also:
-
setHaloColor
Sets the value of thehaloColor
property.- Property description:
- The halo color.
The default value is transparent.
Attempting to set the color to null will throw a NullPointerException exception.
- Parameters:
color
- the value for thehaloColor
property- Since:
- 200.0.0
- See Also:
-
setHaloColor
Deprecated, for removal: This API element is subject to removal in a future version.as of 200.0.0, replaced bysetHaloColor(Color)
Sets the halo color using an ARGB(alpha, red, green, blue) color value.Halo displays a color along the outside border of a letter.
ARGB integer color values range from 0x00000000 to 0xFFFFFFFF with each pair of hex values representing either the alpha, red, green, or blue channels. For the alpha channel, a value of 00 means fully transparent and a value of FF is opaque.
- Parameters:
haloColor
- an integer representing the halo color using the form 0xAARRGGBB- Since:
- 100.0.0
- See Also:
-
getHaloWidth
public float getHaloWidth()Gets the size of the halo around the text symbol in device-independent pixels (DIPs).Default value is 0.0.
- Returns:
- the width of the halo in device-independent pixels (DIPs)
- Since:
- 100.0.0
- See Also:
-
setHaloWidth
public void setHaloWidth(float haloWidth) Sets the size of the halo around the text symbol in device-independent pixels (DIPs).The default value is 0.0.
Setting to 0.0 will cause the halo not to be displayed.
- Parameters:
haloWidth
- the new width of the halo in device-independent pixels (DIPs)- Throws:
ArcGISRuntimeException
- if haloWidth less than 0.0- Since:
- 100.0.0
- See Also:
-
outlineColorProperty
The outline color.Default value is transparent.
Attempting to set the color to null will throw a NullPointerException exception.
- Returns:
- the
outlineColor
property - Since:
- 200.0.0
- See Also:
-
getOutlineColor
Gets the value of theoutlineColor
property.- Property description:
- The outline color.
Default value is transparent.
Attempting to set the color to null will throw a NullPointerException exception.
- Returns:
- the value of the
outlineColor
property - Since:
- 200.0.0
- See Also:
-
setOutlineColor
Sets the value of theoutlineColor
property.- Property description:
- The outline color.
Default value is transparent.
Attempting to set the color to null will throw a NullPointerException exception.
- Parameters:
color
- the value for theoutlineColor
property- Since:
- 200.0.0
- See Also:
-
setOutlineColor
Deprecated, for removal: This API element is subject to removal in a future version.as of 200.0.0, replaced bysetOutlineColor(Color)
Sets the outline color using an ARGB(alpha, red, green, blue) color value.Outline displays a color along the inside border of a letter.
ARGB integer color values range from 0x00000000 to 0xFFFFFFFF with each pair of hex values representing either the alpha, red, green, or blue channels. For the alpha channel, a value of 00 means fully transparent and a value of FF is opaque.
- Parameters:
outlineColor
- an integer representing the outline color using the form 0xAARRGGBB- Since:
- 100.0.0
- See Also:
-
getOutlineWidth
public float getOutlineWidth()Gets the width of the text symbol outline in device-independent pixels (DIPs).The default value is 0.0.
- Returns:
- the width of the outline in device-independent pixels (DIPs)
- Since:
- 100.0.0
- See Also:
-
setOutlineWidth
public void setOutlineWidth(float outlineWidth) Sets the width of the text symbol outline in device-independent pixels (DIPs).Setting to 0.0 will cause the outline not to be displayed.
- Parameters:
outlineWidth
- the new width of the outline in device-independent pixels (DIPs)- Throws:
ArcGISRuntimeException
- if outlineWidth less than 0.0- Since:
- 100.0.0
- See Also:
-
TextSymbol(float, String, Color, HorizontalAlignment, VerticalAlignment)