The AddText method adds a text string to an annotation set. To add multiple lines of text, insert the characters !C as a carriage return.

The default values for text properties (managed by keywords) are based on the current ENVI preference settings.

Example


; Start the application
e = ENVI()
 
; Open an input file
file = FILEPATH('qb_boulder_msi', $
  ROOT_DIR=e.ROOT_DIR, SUBDIRECTORY = ['data'])
raster = e.OpenRaster(file)
 
; Display the raster layer
View = e.GetView()
RasterLayer = View.CreateLayer(raster)
 
; Create an annotation set using Geographic Lat/Lon
; WGS-84 as the spatial reference
annotation = ENVIAnnotationSet(/GEOGRAPHIC)
 
; Label the reservoir
annotation.AddText, $
  -105.20407487D, 39.99911740D, $ ; X and Y coordinates
  'Baseline!C Reservoir', $
  GLYPH_COLOR='light sky blue', $
  NAME='Reservoir label'
 
; Save the annotation set
outFile = e.GetTemporaryFilename()
annotation.Save, outFile
 
; Display the annotation layer
AnnLayer = View.CreateLayer(annotation)

Syntax


ENVIAnnotationSet.AddText, X, Y, Text [, Keywords=value]

Arguments


X

Specify a floating-point value with the X coordinate of the text string.

Y

Specify a floating-point value with the Y coordinate of the text string.

Text

Specify a scalar string with the text to add. To add multiple lines of text, insert the characters !C as a carriage return.

Keywords


BACKGROUND_COLOR (optional)

Specify a three-element byte array or string with a color name for the text background, when BACKGROUND_METHOD is set to 1 or 2. The default color is based on the current ENVI preference setting.

BACKGROUND_METHOD (optional)

Specify a string or integer indicating the background method to use for text. The choices are:

  • None or 0
  • Full or 1
  • Outline or 2 (default)

The following image shows the different choices:

ERROR (optional)

Set this keyword to a named variable that will contain any error message issued during execution of this routine. If no error occurs, the ERROR variable will be set to a null string (''). If an error occurs and the routine is a function, then the function result will be undefined.

When this keyword is not set and an error occurs, ENVI returns to the caller and execution halts. In this case, the error message is contained within !ERROR_STATE and can be caught using IDL's CATCH routine. See IDL Help for more information on !ERROR_STATE and CATCH.

See Manage Errors for more information on error handling in ENVI programming.

FONT_NAME (optional)

Specify a string with the font name to use. The default value is based on the current ENVI preference setting. If the font is not installed on your system, Helvetica will be used.

FONT_SIZE (optional)

Specify a floating-point value with the font size to use. The default value is 14.

FONT_STYLE (optional)

Specify a string or integer indicating the font style to use. The choices are:

  • Normal or 0
  • Bold or 1 (default)
  • Italic or 2
  • Bold Italic or 3

GLYPH_COLOR (optional)

Specify a three-element byte array or string with the color to use for text. The default color is based on the current ENVI preference setting.

HORIZONTAL_ALIGNMENT (optional)

Specify a string or floating-point value indicating the horizontal justification to use from the text anchor point. The choices are:

  • Left or 0
  • Center or 0.5 (default)
  • Right or 1.0
  • Other floating-point values to apply user-defined justifications

NAME (optional)

Set this keyword to a string with a custom name for the annotation item. This name will appear in the Layer Manager. The default value is "Text."

ROTATE_WITH_VIEW (optional)

Set this keyword to rotate the text accordingly whenever you rotate the view, instead of always orienting the text "north up" (the default behavior).

SCALE_ON_ZOOM (optional)

Set this keyword to resize the text accordingly whenever you zoom in or out of the display.

VERTICAL_ALIGNMENT (optional)

Specify a string or floating-point value indicating the vertical justification to use from the text anchor point. The choices are:

  • Bottom or 0
  • Center or 0.5
  • Top or 1.0
  • Other floating-point values to apply user-defined justifications

Version History


ENVI 5.6.1

Introduced

API Version


4.2

See Also


ENVIAnnotationSet