Defines how text is displayed using characteristics such as font, size, color, and position. More...
Header: | #include <TextSymbol.h> |
Since: | Esri::ArcGISRuntime 100.0 |
Inherits: | Esri::ArcGISRuntime::MarkerSymbol |
Public Functions
TextSymbol(QObject *parent = nullptr) | |
TextSymbol(const QString &text, const QColor &color, float size, Esri::ArcGISRuntime::HorizontalAlignment hAlign, Esri::ArcGISRuntime::VerticalAlignment vAlign, QObject *parent = nullptr) | |
virtual | ~TextSymbol() override |
QColor | backgroundColor() const |
QColor | color() const |
Esri::ArcGISRuntime::FontDecoration | fontDecoration() const |
QString | fontFamily() const |
Esri::ArcGISRuntime::FontStyle | fontStyle() const |
Esri::ArcGISRuntime::FontWeight | fontWeight() const |
QColor | haloColor() const |
float | haloWidth() const |
Esri::ArcGISRuntime::HorizontalAlignment | horizontalAlignment() const |
bool | isKerningEnabled() const |
QColor | outlineColor() const |
float | outlineWidth() const |
void | setBackgroundColor(const QColor &backgroundColor) |
void | setColor(const QColor &color) |
void | setFontDecoration(Esri::ArcGISRuntime::FontDecoration fontDecoration) |
void | setFontFamily(const QString &fontFamily) |
void | setFontStyle(Esri::ArcGISRuntime::FontStyle fontStyle) |
void | setFontWeight(Esri::ArcGISRuntime::FontWeight fontWeight) |
void | setHaloColor(const QColor &haloColor) |
void | setHaloWidth(float haloWidth) |
void | setHorizontalAlignment(Esri::ArcGISRuntime::HorizontalAlignment hAlign) |
void | setKerningEnabled(bool kerningEnabled) |
void | setOutlineColor(const QColor &outlineColor) |
void | setOutlineWidth(float outlineWidth) |
void | setSize(float size) |
void | setText(const QString &text) |
void | setVerticalAlignment(Esri::ArcGISRuntime::VerticalAlignment vAlign) |
float | size() const |
QString | text() const |
Esri::ArcGISRuntime::VerticalAlignment | verticalAlignment() const |
bool | operator!=(const Esri::ArcGISRuntime::TextSymbol &other) const |
bool | operator==(const Esri::ArcGISRuntime::TextSymbol &other) const |
Detailed Description
To display text in a MapView or SceneView, create a TextSymbol. Specify whether a string or attribute value is displayed by the text. Define the appearance and position of the text using color, size, fontStyle, or 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::graphics 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, or DynamicEntityLayer contain label definitions that specify how labels are displayed. You can use LabelDefinition::textSymbol 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 using Grid::setTextSymbol(int, Esri::ArcGISRuntime::Symbol*).
Example:
Create a TextSymbol and apply it to a Graphic:
auto* textSymbol = new TextSymbol("Redlands", QColor(Qt::black), 12.0, HorizontalAlignment::Right, VerticalAlignment::Middle, this); Point point(-117,34); auto* graphic = new Graphic(point, textSymbol, this);
Relevant samples:
- Configure clusters: Add client side feature reduction on a point feature layer that is not pre-configured with clustering.
- Display a grid: Display coordinate system grids including Latitude/Longitude, MGRS, UTM and USNG on a map view. Also, toggle label visibility and change the color of grid lines and grid labels.
- Display subtype feature layer: Displays a composite layer of all the subtype values in a feature class.
- Show labels on layer in 3D: This sample demonstrates how to display custom labels in a 3D scene.
- Show labels on layers: Display custom labels on a feature layer.
See also Symbol.
Member Function Documentation
[explicit]
TextSymbol::TextSymbol (QObject *parent = nullptr)
Creates a text symbol with default values.
- parent - The optional parent QObject.
The default values are:
- color, black
- size, 8.0
- fontStyle, FontStyle::Normal
- fontWeight, FontWeight::Normal
- horizontalAlignment, HorizontalAlignment::Center
- verticalAlignment, VerticalAlignment::Middle
- fontDecoration, FontDecoration::None
TextSymbol::TextSymbol (const QString &text, const QColor &color, float size, Esri::ArcGISRuntime::HorizontalAlignment hAlign , Esri::ArcGISRuntime::VerticalAlignment vAlign , QObject *parent = nullptr)
Creates a text symbol with the given size, text, and color along with the horizontal and vertical alignment relative to the mid-point of this symbol.
- text - The text to be displayed.
- color - The color of the text symbol.
- size - The size of the text symbol.
- hAlign - The horizontal alignment of the text.
- vAlign - The vertical alignment of the text.
- parent - The optional parent QObject.
[override virtual]
TextSymbol::~TextSymbol ()
Destructor.
QColor TextSymbol::backgroundColor () const
Returns the color for the text symbol background.
The default value is transparent.
See also setBackgroundColor().
QColor TextSymbol::color() const
Returns the color of the text.
The default value is black.
See also setColor().
Esri::ArcGISRuntime::FontDecoration TextSymbol::fontDecoration () const
Returns the type of font decoration for the text symbol.
The default value is FontDecorationNone.
See also setFontDecoration().
QString TextSymbol::fontFamily () const
Returns the font family for the text.
This can be as specific as 'arial' or as generic as 'sans-serif', for example.
See also setFontFamily().
Esri::ArcGISRuntime::FontStyle TextSymbol::fontStyle () const
Returns the font style for the text.
Returns FontStyle::Normal if an error occurs.
See also setFontStyle().
Esri::ArcGISRuntime::FontWeight TextSymbol::fontWeight () const
Returns the font weight for the text.
Font weight describes how thick or thin characters in text are displayed. The default value is FontWeightNormal.
See also setFontWeight().
QColor TextSymbol::haloColor () const
Returns the color for the halo around the text symbol.
The default value is transparent.
See also setHaloColor().
float TextSymbol::haloWidth () const
Returns the size of the halo around the text symbol in device-independent pixels (DIPs).
The default value is 0.0.
See also setHaloWidth().
Esri::ArcGISRuntime::HorizontalAlignment TextSymbol::horizontalAlignment () const
Returns the horizontal alignment of the text symbol relative to the symbol's mid-point location.
The default value is HorizontalAlignment::Center. Returns HorizontalAlignment::Center if an error occurs.
See also setHorizontalAlignment().
bool TextSymbol::isKerningEnabled () const
Returns whether kerning (visual adjustments to the spacing between characters in the text) is enabled.
Determines whether to adjust the spacing between characters in the text string.
The default value is false
.
QColor TextSymbol::outlineColor () const
Returns the color for the text symbol outline.
See also setOutlineColor().
float TextSymbol::outlineWidth () const
Returns the width of the text symbol outline in device-independent pixels (DIPs).
The default value is 0.0.
See also setOutlineWidth().
void TextSymbol::setBackgroundColor (const QColor &backgroundColor )
Sets the color for the text symbol background to backgroundColor.
See also backgroundColor().
void TextSymbol::setColor (const QColor &color)
Sets the color of the text.
See also color().
void TextSymbol::setFontDecoration (Esri::ArcGISRuntime::FontDecoration fontDecoration )
Sets the fontDecoration of the text.
See also fontDecoration.
void TextSymbol::setFontFamily (const QString &fontFamily )
Sets the fontFamily for the text.
See also fontFamily.
void TextSymbol::setFontStyle (Esri::ArcGISRuntime::FontStyle fontStyle )
Sets the fontStyle for the text.
See also fontStyle.
void TextSymbol::setFontWeight (Esri::ArcGISRuntime::FontWeight fontWeight )
Sets the fontWeight for the text.
See also fontWeight.
void TextSymbol::setHaloColor (const QColor &haloColor )
Sets the color of the halo to haloColor.
See also haloColor.
void TextSymbol::setHaloWidth (float haloWidth )
Sets the width of the outline in device independent pixels (DIPs) to haloWidth.
See also haloWidth.
void TextSymbol::setHorizontalAlignment (Esri::ArcGISRuntime::HorizontalAlignment hAlign )
Sets the hAlign for the text.
See also horizontalAlignment.
void TextSymbol::setKerningEnabled (bool kerningEnabled )
Sets whether kerning (visual adjustments to the spacing between characters in the text) is enabled to kerningEnabled.
The default value is false
.
See also isKerningEnabled.
void TextSymbol::setOutlineColor (const QColor &outlineColor )
Sets the color of the outline to outlineColor.
See also outlineColor.
void TextSymbol::setOutlineWidth (float outlineWidth )
Sets the width of the outline in device independent pixels (DIPs) to outlineWidth.
See also outlineWidth.
void TextSymbol::setSize (float size)
Sets the size of the text in device independent pixels (DIPs).
See also size.
void TextSymbol::setText (const QString &text)
Sets the text to display for the symbol.
See also text.
void TextSymbol::setVerticalAlignment (Esri::ArcGISRuntime::VerticalAlignment vAlign )
Sets the vAlign for the text.
See also verticalAlignment.
float TextSymbol::size() const
Returns the font size of the text symbol.
The default value is 8.0.
See also setSize().
QString TextSymbol::text() const
Returns the text of the text symbol.
The default value is an empty string.
See also setText().
Esri::ArcGISRuntime::VerticalAlignment TextSymbol::verticalAlignment () const
Returns the vertical alignment of the text symbol relative to the symbol's mid-point location.
The default value is VerticalAlignment::Middle. Returns VerticalAlignment::Middle if an error occurs.
See also setVerticalAlignment().
[since Esri::ArcGISRuntime 200.2]
bool TextSymbol::operator!=(const Esri::ArcGISRuntime::TextSymbol &other) const
Inequality operator. Returns true
if this object and other are not equal.
This function was introduced in Esri::ArcGISRuntime 200.2.
See also TextSymbol::operator==.
[since Esri::ArcGISRuntime 200.1]
bool TextSymbol::operator==(const Esri::ArcGISRuntime::TextSymbol &other) const
Returns a bool that tests if this text symbol is equal to another text symbol.
- other - The text symbol to be compared.
This function was introduced in Esri::ArcGISRuntime 200.1.