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:

  1. Construct an legend: legend = Legend(args) by including its position "x" and "y", and the top title in the attributes argument.
  2. The legend gets drawn into the SvgSvgElement legendContainer using Svg.
  3. 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).
  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(). If nlines > 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
hashCode → int
The hash code for this object. [...]
read-only, inherited
LEGEND_ID → String
final
legendContainer ↔ SvgSvgElement
read / write
nlines ↔ int
read / write
rectbordersize ↔ int
read / write
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited
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

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 by stroke. 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 new text and draws the text marker rectangle in front of the text. stroke defines the color of the text marker rectangle.If stroke is null, no rectangle will be drawn.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
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 new text. stroke defines the color of the text marker rectangle. If stroke is null, no rectangle will be drawn. If there is no legend text to replace, the legend text will be set initally from text.
toString() → String
Returns a string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator. [...]
inherited

Static Properties

LEGEND_DEFAULT_ATTRIBUTES → Map<LegA, String>
Default attributes for legend
final

Static Methods

setAttr(Element el, Map<LegA, String> attr) → void
Sets the Svg attributes for e from a attr.