- 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, orDynamicEntityLayercontain 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. -
MapViewcan 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
PropertiesTypePropertyDescriptionThe background color of this TextSymbol.The color of this TextSymbol.The halo color.The outline color. -
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDefines various decorations that can be applied to the text of this Symbol.static enumDefines various styles that can be applied to the text of this Symbol.static enumDefines how thick or thin the characters in text appear.static enumDefines horizontal alignment of the text within the Symbol.static enumDefines vertical alignment of the text within the Symbol.Nested classes/interfaces inherited from class com.esri.arcgisruntime.symbology.MarkerSymbol
MarkerSymbol.AngleAlignment -
Constructor Summary
ConstructorsConstructorDescriptionCreates 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 thebackgroundColorproperty.getColor()Gets the value of thecolorproperty.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 thehaloColorproperty.floatGets 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 theoutlineColorproperty.floatGets the width of the text symbol outline in device-independent pixels (DIPs).floatgetSize()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.voidsetBackgroundColor(int color) Deprecated, for removal: This API element is subject to removal in a future version.as of 200.0.0, replaced bysetBackgroundColor(Color)voidsetBackgroundColor(Color color) Sets the value of thebackgroundColorproperty.voidsetColor(int color) Deprecated, for removal: This API element is subject to removal in a future version.as of 200.0.0, replaced bysetColor(Color)voidSets the value of thecolorproperty.voidsetFontDecoration(TextSymbol.FontDecoration fontDecoration) Sets the decoration for the text being used by this Symbol.voidsetFontFamily(String fontFamily) Sets the FontFamily for the text being used by this Symbol.voidsetFontStyle(TextSymbol.FontStyle fontStyle) Sets the FontStyle for the text that is being used by this Symbol.voidsetFontWeight(TextSymbol.FontWeight fontWeight) Sets the FontWeight for the text that is being used by this Symbol.voidsetHaloColor(int haloColor) Deprecated, for removal: This API element is subject to removal in a future version.as of 200.0.0, replaced bysetHaloColor(Color)voidsetHaloColor(Color color) Sets the value of thehaloColorproperty.voidsetHaloWidth(float haloWidth) Sets the size of the halo around the text symbol in device-independent pixels (DIPs).voidsetHorizontalAlignment(TextSymbol.HorizontalAlignment horizontalAlignment) Sets the horizontal alignment of the text symbol relative to the symbol's mid-point location.voidsetOutlineColor(int outlineColor) Deprecated, for removal: This API element is subject to removal in a future version.as of 200.0.0, replaced bysetOutlineColor(Color)voidsetOutlineColor(Color color) Sets the value of theoutlineColorproperty.voidsetOutlineWidth(float outlineWidth) Sets the width of the text symbol outline in device-independent pixels (DIPs).voidsetSize(float size) Sets the size of the text in device-independent pixels (DIPs).voidSets the text displayed by this Symbol.voidsetVerticalAlignment(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, setOffsetYMethods 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
backgroundColorproperty - Since:
- 200.0.0
- See Also:
-
getBackgroundColor
Gets the value of thebackgroundColorproperty.- 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
backgroundColorproperty - Since:
- 200.0.0
- See Also:
-
setBackgroundColor
Sets the value of thebackgroundColorproperty.- 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 thebackgroundColorproperty- 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
colorproperty - Since:
- 200.0.0
- See Also:
-
getColor
Gets the value of thecolorproperty.- 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
colorproperty - Since:
- 200.0.0
- See Also:
-
setColor
Sets the value of thecolorproperty.- 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 thecolorproperty- 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.NONEif 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.NORMALif 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.NORMALif 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.MIDDLEif 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.CENTERif 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
haloColorproperty - Since:
- 200.0.0
- See Also:
-
getHaloColor
Gets the value of thehaloColorproperty.- 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
haloColorproperty - Since:
- 200.0.0
- See Also:
-
setHaloColor
Sets the value of thehaloColorproperty.- 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 thehaloColorproperty- 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
outlineColorproperty - Since:
- 200.0.0
- See Also:
-
getOutlineColor
Gets the value of theoutlineColorproperty.- 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
outlineColorproperty - Since:
- 200.0.0
- See Also:
-
setOutlineColor
Sets the value of theoutlineColorproperty.- 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 theoutlineColorproperty- 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)