Legend class
This class represents a legend consisting of
- a text line at the top ("top title")
- optionally several more lines, each one preceded by a color rectangle.
Usage:
- Construct an legend: legend = Legend(args) by including its position "x" and "y", and the top title in the attributes argument.
- The legend gets drawn into the SvgSvgElement legendContainer using Svg.
- Set the desired position of legendContainer by setting its
"x" and "y" Svg attributes, and the top title. For convenience, do it with SVG.setAttr().
x and y must be relative to the container in which
labelsContainer
will be embedded (plotArea in next step 4). - Append
labelsContainer
to the desired SvgSvgElement type container of your particluar page layout: plotArea.append(axis.labelsContainer)
Constructors
-
Legend(Map<
LegA, String> legendAttributes, int nlines) -
Constructs a Legend with optional
legendAttributes
. If null, LEGEND_DEFAULT_ATTRIBUTES will apply. If not null the specified attributes will override the respective default ones. X and Y of these attributes may be specified absolutely, e.g. 1 0, 10px, .. or relatively to the legend container 5%, 60%, ... . The legend svg container can be accessed via the attribute legendContainer of this class.nlines
is 1 if only 1 legend line is to be added using setText(). Ifnlines
> 1, each time a legend text is added its position will be decremented by fontsize. The initial position of the first legend text is nlines*fontsize. If a toptitle is specified, set it at the top of the legend. A toptitle is to be stored in legendAttributesLegA.TOP_TITLE. Subtitles (each subtitle on a separate line
Properties
-
attrMap
↔ Map<
String, Map< LegA, String> > -
read / write
- bgRectangle ↔ RectElement
-
read / write
- colored_rect_width ↔ int
-
read / write
- curlineNo ↔ int
-
read / write
- dy ↔ int
-
read / write
- fontsize ↔ int
-
read / write
- LEGEND_ID → String
-
final
- legendContainer ↔ SvgSvgElement
-
read / write
- nlines ↔ int
-
read / write
- rectbordersize ↔ int
-
read / write
- text_marker_xoffset ↔ int
-
read / write
-
textElements
↔ Map<
String, TextElement> -
read / write
-
textMarkers
↔ Map<
String, RectElement> -
read / write
- TOP_TITLE_ID ↔ String
-
read / write
- topTitle ↔ String
-
read / write
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Methods
-
addBGRectangle_(
int deltay) → void -
Adds a rectangle to the legend container legendArea with covers the same
space as the current legendArea size.
This will make the legend area visible to the user.
deltay
defines the current rectangle height (to which rectbordersize is added). The following attributes from the legend attributes will apply: BG_OPACITY, BG_COLOR. -
genTextMarkerRectangle_(
String id, String stroke, int deltay) → RectElement -
Adds a text marker rectangle to the left of the text with
id
, with the fill color defined bystroke
. The rectangle is added to legendArea,deltay
defines the rectangles y coordinate offset from legendArea's origin. -
initSetText(
String id, String text, String stroke) → void -
Replaces the legend text with
id
by the newtext
and draws the text marker rectangle in front of the text.stroke
defines the color of the text marker rectangle.Ifstroke
is null, no rectangle will be drawn. -
removeText(
String id) → void -
Replaces the legend text and associated text marker rectangle of
id
. -
setText(
String id, String text, String stroke) → void -
Replaces the legend text with
id
by the newtext
.stroke
defines the color of the text marker rectangle. Ifstroke
is null, no rectangle will be drawn. If there is no legend text to replace, the legend text will be set initally fromtext
. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited
Static Properties
-
LEGEND_DEFAULT_ATTRIBUTES
→ Map<
LegA, String> -
Default attributes for legend
final