Class TextSymbol

All Implemented Interfaces:
JsonSerializable

public final class TextSymbol extends MarkerSymbol
Defines how text is displayed using characteristics such as font, size, color, and position.

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:

Since:
100.0.0
  • Property Details

  • Constructor Details

  • Method Details

    • backgroundColorProperty

      public ObjectProperty<Color> 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

      public Color getBackgroundColor()
      Gets the value of the backgroundColor 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

      public void setBackgroundColor(Color color)
      Sets the value of the backgroundColor 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 the backgroundColor property
      Since:
      200.0.0
      See Also:
    • setBackgroundColor

      @Deprecated(since="200.0.0", forRemoval=true) public void setBackgroundColor(int color)
      Deprecated, for removal: This API element is subject to removal in a future version.
      as of 200.0.0, replaced by setBackgroundColor(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

      public ObjectProperty<Color> 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

      public Color getColor()
      Gets the value of the color 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

      public void setColor(Color color)
      Sets the value of the color 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 the color property
      Since:
      200.0.0
      See Also:
    • setColor

      @Deprecated(since="200.0.0", forRemoval=true) public void setColor(int color)
      Deprecated, for removal: This API element is subject to removal in a future version.
      as of 200.0.0, replaced by setColor(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

      public TextSymbol.FontDecoration 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

      public void setFontDecoration(TextSymbol.FontDecoration fontDecoration)
      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

      public String 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

      public void setFontFamily(String fontFamily)
      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

      public TextSymbol.FontStyle getFontStyle()
      Gets the FontStyle of the text that is being used by this Symbol.

      The default value is TextSymbol.FontStyle.NORMAL. Returns FontStyle.NORMAL if an error occurs.

      Returns:
      the font style the Symbol's text
      Since:
      100.0.0
      See Also:
    • setFontStyle

      public void setFontStyle(TextSymbol.FontStyle fontStyle)
      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

      public TextSymbol.FontWeight 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. Returns FontWeight.NORMAL if an error occurs.

      Returns:
      the font weight being used by this Symbol's text
      Since:
      100.0.0
      See Also:
    • setFontWeight

      public void setFontWeight(TextSymbol.FontWeight fontWeight)
      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

      public String 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

      public void setText(String text)
      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

      public TextSymbol.VerticalAlignment getVerticalAlignment()
      Gets the vertical alignment of the text symbol relative to the symbol's mid-point location.

      The default value is TextSymbol.VerticalAlignment.MIDDLE. Returns VerticalAlignment.MIDDLE if an error occurs.

      Returns:
      the vertical alignment of the Symbol's text
      Since:
      100.0.0
      See Also:
    • setVerticalAlignment

      public void setVerticalAlignment(TextSymbol.VerticalAlignment verticalAlignment)
      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

      public TextSymbol.HorizontalAlignment getHorizontalAlignment()
      Gets the horizontal alignment of the text symbol relative to the symbol's mid-point location.

      The default value is TextSymbol.HorizontalAlignment.CENTER. Returns HorizontalAlignment.CENTER if an error occurs.

      Returns:
      the horizontal alignment of the Symbol's text
      Since:
      100.0.0
      See Also:
    • setHorizontalAlignment

      public void setHorizontalAlignment(TextSymbol.HorizontalAlignment horizontalAlignment)
      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

      public ObjectProperty<Color> 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

      public Color getHaloColor()
      Gets the value of the haloColor 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

      public void setHaloColor(Color color)
      Sets the value of the haloColor 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 the haloColor property
      Since:
      200.0.0
      See Also:
    • setHaloColor

      @Deprecated(since="200.0.0", forRemoval=true) public void setHaloColor(int haloColor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      as of 200.0.0, replaced by setHaloColor(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

      public ObjectProperty<Color> 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

      public Color getOutlineColor()
      Gets the value of the outlineColor 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

      public void setOutlineColor(Color color)
      Sets the value of the outlineColor 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 the outlineColor property
      Since:
      200.0.0
      See Also:
    • setOutlineColor

      @Deprecated(since="200.0.0", forRemoval=true) public void setOutlineColor(int outlineColor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      as of 200.0.0, replaced by setOutlineColor(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: