Element: compound.autotext, gstructure.autotext
Type
callback
Syntax
<class>.autotext = "{"
<name> = <value>
...
"}"
Description
This element is not strictly a callback but is a set of rules describing how
a compound (or gstructure) entity object should be auto-annotated. It is invoked
by a graphic window's auto-annotation procedure (window.annotate).
Autotext definitions are defined at a class level, rather than on individual
compound or gstructure objects. When auto-annotation is invoked for a graphic
window it is applied to one or more entity groups. Each group is traversed for
entities which are candidates for labelling. Only compound and gstructures are
examined, and only those whose class has a .autotext
definition become candidates. The .autotext definition
is then evaluated for each candidate, i.e. a compound (or gstructure) object.
The result of the evaluation process then determines whether the object is to
be labelled, what the label text is, and what its symbology is. It is then drawn.
A.autotext definition comprises a set of assignments
in the form of name=value statements. The assignments set properties
which together determine the labelling process for the object.
Unlike other language callbacks, there are no macro statements in the definition,
but the assigment values can contain function references which themselves
may contain macro code. However for optimum performance, there should be as
few references to the object (available via the this
identifier) as possible, and function macro calls should be avoided. Assignments
containing this are evaluated for every compound/gstructure
object being labelled, other assignments are evaluated once only for each entity
group being processed.
Before discussing the individual assignment options, here is a simple example which
labels objects of a compound class:
# Define the class
atable maps
compound ~maps.park_t {
entity e[]
string name
}
# Define a textstyle
font ~maps.fntPark,'Arial,10',-sys,-var;# -var specified for scalable/rotatable text
textstyle ~maps.tsPark,-fo=~maps.fntPark,-su='p'
# Define how an object of this class is labelled
~maps.park_t.autotext = {
text = this.name ;# Evaluated for every object
textstyle = ~maps.tsPark ;# Evaluated once
text_height = 10 ;# Evaluated once
}
The fewer assignments that are evaluated for every object (only
1 in our example), the quicker the auto-annotation process.
Options
All options are in the form of assignments: name=value.
Objects may be labelled with text and/or a symbol. The 2 rules determining
this are as follows:
The object is labelled with text only if the text option
is present and its value is not an empty string.
A symbol is displayed over the object if the symbol_text
option is present. If a symbol is required without text, the symbol_text
value should be a single space. The symbol is rendered using markerstyle symbol
and the text (if any) is rendered over the symbol.
If neither of these rules are satisfied no labelling is performed.
Available options are as follows:
- alpha=<num>
Alpha transparency value between 0 and 1 for the display of text. 1
is fully opaque, 0 is fully transparent. The default is 1. When a transparency
value is supplied, clash testing is not performed.
- angle=<num>
Angle of the base line of text. The default is 0 (horizontal). The
measure of the angle (e.g. degrees, radians) is assumed to be the value of
the system string angle_mode. This
option should usually not be included, since readable text angles are derived
automatically from the items being labelled, and its use can upset clashing,
but it is useful when combined with the leader option.
- area_maximum=<num>
A maximum display area (in screen pixels) for area-type entities (e.g. polygons).
If a graphic primitive's screen area is above this value it is not labelled.
- area_minimum=<num>
A minimum display area (in screen pixels) for area-type entities (e.g. polygons).
If a graphic primitive's screen area is below this value it is not labelled.
There is no default maximum.
- area_use_symbol=<num>
A numeric value specifying whether to draw symbol in area-type entities
(e.g. polygons). The value can be 1 (always draw symbol), 0 (never
draw symbol) or -1 (draw symbol instead of text if the
entity screen area is below area_minimum). The default is 0.
- area_variable_height=<num>
A boolean value specifying whether text height should vary. If the value
is true then text height for area-type entities (e.g. polygons) is
computed from the entity area. If the value is false (the default), the text is
always the value of text_height.
- brightness=<num>
Brightness intensity between -1 and +1 for display of text. The default
is 0.
- clash_test=<num>
A boolean value specifying whether clash testing is to be performed on autotext.
If the value is true then text is tested
against other items to avoid obscuration. This may result in text not being displayed if a suitable place cannot be found. If
the value is false, then text is always
displayed but may clash with other items. The default value is false.
- color=<color>
A color value which can be used to overwrite the color within textstyle.
- fill=<fillstyle>
Define the fill characteristics of the text frame. This can be a color, tile,
hatchstyle, graduation or composite fillstyle. If omitted, the frame is not
filled. This attribute is applied only when a frame style (frame)
option is present and non-zero.
- fit_in_window=<num>
When labelling polygon or point-type entities, if text is partially off-screen
re-position it so all characters are visible. If the layer being auto-annotated
has tile-mode set, this is the default
behavior (1) and cannot be changed. If tile-mode is not set, then the default
behavior is not to re-position the text (0).
- frame=<num>
When labelling polygon or point-type entities, put a frame around the label text. The value of <num>
indicates the frame style and can be one of the following:
Value |
Shape |
0 |
No frame (the default) |
1 |
Rectangle |
2 |
Square |
3 |
Ellipse |
4 |
Circle |
5 |
Diamond |
6 |
Lozenge |
7 |
Button |
- frame_outline=<num>
A boolean value specifying whether the frame outline is to be shown (when
frame is present and non-zero). The default value is true.
This applies only when labelling polygon or point-type entities.
- label_all=<num>
A boolean value specifying whether all compound children should be labelled
(true) or just the first successful one (false). The default
value is false. This option is ignored for gstructures.
- leader=<point>
When this directive is present, the text used to auto-annotate an entity is
drawn at <point> (usually offset from
the entity), and a leader line is drawn from the text to a control position
on the entity (computed automatically), or the point specified by the location
directive. If omitted, or if the leader line lies completely within the rectangle formed
by the text (or its frame, if visible), then no leader line is drawn.
- leader_linestyle=<color|linestyle> (alternative
name: leader_ls)
The linestyle used when a leader line is specified (see the leader directive).
The line is drawn from the leader point to the entity control point.
- line_offset_factor=<num>
An offset for parallel polyline labelling with a line_position
of T or B. This offset is
the gap between the polyline and the text label. The value is a numeric factor
of text_height.
- line_position=<string>
An indication of where to label polyline-type entities (vector, lines, arcs,
polygon edges). The value should be one of T (above),
B (below) or M (astride).
The default is M
- location=<point>
By default the location for text is computed automatically, but inclusion of
this directive will override the location. This can adversely affect performance
so it is better to omit it unless exact text positioning is critical.
- point_position=<string>
A preference for where to label point-type entities (node, polynode, small
areas). The value should be a combination of L,R,T,B and M for
left, right, top, bottom and middle. The default is B
- polygon_edges=<num>
A boolean value specifying whether polygon entities should be labelled along
the edge (true) or within the bounding area (false). The default
value is false.
- symbol=<markerstyle> (alternative names:
symbol_ms, symbol_markerstyle)
Add a symbol of a specified markerstyle to polyline-type entities (vector, lines,
arcs, polygon edges). Every distinct section of the polyline will be symbolized.
- symbol_clash_test=<num>
A boolean value specifying whether clash testing is to be performed on symbols. If the
value is true then symbol is tested against
other items to avoid obscuration. This may result in symbol
not being displayed if a suitable place cannot be found. If the value is false,
then symbol is always displayed but may clash with
other items. The default value is the value of clash_test.
- symbol_height=<num>
The height of symbol. If omitted, a zero value is assumed, which results
in a suitable.
- symbol_location=<point>
By default the location for a symbol is computed automatically, but inclusion of
this directive will override the location. This can adversely affect performance
so it is better to omit it unless exact symbol positioning is critical.
- symbol_text=<string>
The text to appear centred on the symbol hotspot. If a symbol is to be shown
without text this assignment must be present with a value of ' ' (a single
space character). If omitted, no symbol is displayed.
- symbol_text_height=<num>
The character height for symbol_text. If omitted, the default height (def_text_height)
is used.
- symbol_text_style=<textstyle> (alternative
names: symbol_ts, symbol_textstyle)
The textstyle for symbol_text, including font, aspect ratio etc. If
omitted, the default text style (def_ts) is used.
The textstyle can have a scalable or fixed font.
- symbol_thresholds=<nums>
2 meter scale factors. If the window's meter-per-pixel value
(window.mpp)
is less than
the first value or greater/equal to the second, the entity is not labelled
with symbol. The default values are 0,0 meaning "label always".
- symbol_visibility=<num>
A boolean value specifying whether symbol is to be visible (assuming
all other criteria have been satisfied). By setting this to false,
symbol display can be suppressed. The default value is true.
- text=<string>
The text to appear alongside or within the graphic primitive. Multiple text lines are
permitted but they may be combined or wrapped according to circumstance.
If the value is omitted or is an empty string then the entity is not labelled
with text, but it may still have an associated symbol.
- text_height=<num>
The character height for text. If omitted, the default height (def_text_height)
is used.
- text_style=<textstyle> (alternative
names: ts, textstyle)
The textstyle for text, including font, aspect ratio etc. If omitted,
the default text style (def_ts) is used. The textstyle
can have a scalable or fixed font.
- text_thresholds=<nums>
2 meter scale factors. If the window's meter-per-pixel value
(window.mpp)
is less than
the first value or greater/equal to the second, the entity is not labelled
with text. The default values are 0,0 meaning "label always".
- text_visibility=<num>
A boolean value specifying whether text is to be visible (assuming
all other criteria have been satisfied). By setting this to false,
text display can be suppressed. The default value is true.
- word_wrap=<num>
A preferred character position to be used when wrapping text into multiple
lines. The default value is 10.
Example
Consider the following example to auto-annotate a road class:
road_t.autotext = {
# How to label road features
text=this.m_street_name
textstyle=tsRoad ;# a textstyle
text_height=8
line_position='m'
clash_test=1
symbol=^(road_markerstyle(this));# a string function returning a markerstyle name
symbol_text=his.m_highway_number
symbol_text_height=8
symbol_textstyle=tsHighwaySignText;# a textstyle
}
Note that the values for text, symbol_text and symbol
will be evaluated for every entity.
See Also