Polyline class
The purpose of this class is to draw (plot) the values of a 1D array as a curve. Drawing is performed using SVG, Scalable Vector Graphics. The drawn curve is a SVG "polyline". The user can control many polyline attributes. Usage:
- Construct an polyline: pl = Polyline(args).
- Result: The polyline was drawn into the SvgSvgElement polylineContainer.
- Append polylineContainer to the desired SvgSvgElement type container (e.g. named dataArea) of your particluar page layout: dataArea.append(pl.polylineContainer) NOTE 1: The array values are plotted "equidistant" (= linear x scaling) NOTE 2: A computer screen or a screen windows has a limited amount of pixels, e.g. around 200, 1000, 2000, 4000 in horizontal (or vertical) direction, depending on the device. This class allows one to plot large arrays effciently. Array sizes with 10000, 100000 or even a million points can be handled. Internally, a suitable compression algorithm is used, see pub package https://pub.dev/packages/smart_arrays_compress. NOTE 3: The polylineContainer of several Polylines may be appended to the same dataArea (see above). The result will be a "polyline multi view" to visualize several arrays at the same time.
Constructors
-
Polyline(Float64List array, int ixFirst, int ixLast, int dataAreaWidth, int dataAreaHeight, YZoomRegion zoomRegion, double ymin, double ymax, Map<
PyA, String> uAttr) -
Draws (plots)
array
into polylineContainer. The latter must be appended to your desired SvgSvgElement container ("data area") to make the plot visible.ixFirst
- first index ofarray
that gets plotted. If null, 0 is assumed.ixLast
- last index ofarray
that gets plotted. If null, the array's maximum index is assumed.dataAreaWidth
- the width of the polyline's data area in pixels.dataAreaHeight
- the height of the polyline's data area in pixels.zoomRegion
- If null, the array will be plotted such that it fits entirely into the data area, but inset from the borders of this area by the attributes POLYLINE_INSETX and POLYLINE_INSETY. If not null:zoomRegion
defines the y (intensity) viewport ofarray
. A typical use is zooming into a plot, e.g. if the GUI provides a tool to draw a rectangle around a desired section of a polyline plot already displayed on the screen. From this rectangle (in screen coordinates) an app would derive the respective intensity (y) range with respect to the displayed polyline, and compute a new Polyline by feeding the y region into the constructor to obtains to "zoom" in.ymin
,ymax
- If null, the intensity (y) scale of the plot is computed such that the maximum intensity betweenixFirst
andixLast
gets displayed at the top of the data area, and the minimum intensity at the bottom (= "automatic y scaling"). If not null: Defines which 2 intensity values should be used to be displayed at the top and bottom of the data area. A typical use is "interactive shifting a zoomed-in polyline along x while retaining its y scaling": For this case compute a new Polyline withymin
andymax
set to the respective values of the polyline displaying the previous x viewport as soon as viewport changes.uAttr
: User-defined polyline attributes. If null, POLYLINE_DEFAULT_ATTRIBUTES are used. Otherwise you can change here colors, scaling and layout parameters, and more drawing features. The attributes specified here will override their respective defaults. attr will become the combined map of effective attributes. See PyA for all options. NOTE 1: In addition to the polyline a list of points in form of circles or other shapes will be drawn if attrPyA.POINT_LIST is not null. NOTE 2: In addition to the polyline a text will be drawn at the end of the polyline if attrPyA.MARKER_TEXT is not null or empty. NOTE 3: In addition to the polyline an icon ("selection icon") will be drawn at the end of the polyline if attrPyA.DRAW_SELECTION_ICON is "true". The icon size is attrPyA.SELECTION_ICON_WIDTH. attrPyA.SELECTION_ICON_OUTSIDE = "true" ensures that the icon remains inside the data area. NOTE 4: You can display a polyline rotated, e.g. by 90 degrees, by specifying a rotation and or translation operator in attrPyA.ROTATE, e.g "rotate(-90) translate(${-axisLength/2}, ${someOffset})". The syntax must conform to SVG. NOTE 5: The maximum y value can be set to the optional reference value refYmax. All respective y values are scaled accordingly. This feature can be used to display several polylines in a plot area which are scaled with respect to each store_quota, with a desired one to be the reference. If refYmax is not used while displaying several polylines at the same time in the same area, each respective graph would would be scaled and displayed such that its ymax will be visible inside the area at y = 0 + insety to fit into dataAreaHeight-insety.
Properties
- a ↔ double
-
read / write
- array ↔ Float64List
-
read / write
-
attr
↔ Map<
PyA, String> -
read / write
- b ↔ double
-
read / write
- clipDataAtYBoundary ↔ bool
-
read / write
- cpd ↔ CompressedArray1D
-
read / write
- dataAreaHeight ↔ int
-
read / write
- dataAreaWidth ↔ int
-
read / write
- effectivePolylineHeight ↔ int
-
read / write
- effectivePolylineWidth ↔ int
-
read / write
- insetx ↔ int
-
read / write
- insety ↔ int
-
read / write
- insety2 ↔ int
-
read / write
- isSelected → bool
-
read-only
- ixFirst ↔ int
-
read / write
- ixLast ↔ int
-
read / write
-
pointShapes
↔ List<
GeometryElement> -
read / write
- polyline ↔ PolylineElement
-
read / write
- polylineContainer ↔ SvgSvgElement
-
read / write
- polylineMarker ↔ TextElement
-
read / write
- refYmax ↔ double
-
read / write
- selectionIcon ↔ RectElement
-
read / write
- strokeWidth ↔ int
-
read / write
- useWebgl ↔ bool
-
read / write
- xmax ↔ double
-
read / write
- xmin ↔ double
-
read / write
- xscale ↔ double
-
read / write
- xselectionIcon ↔ int
-
read / write
- xsFirst ↔ int
-
read / write
- xshift ↔ int
-
read / write
- xsLast ↔ int
-
read / write
- xValues ↔ Float64List
-
read / write
- ymax ↔ double
-
read / write
- ymin ↔ double
-
read / write
- yscale ↔ double
-
read / write
- yselectionIcon ↔ int
-
read / write
- yshift1 ↔ int
-
read / write
- yshift2 ↔ int
-
read / write
- ysLast ↔ int
-
read / write
- ysMax ↔ int
-
read / write
- ysMin ↔ int
-
read / write
- yysMax ↔ double
-
read / write
- yysMin ↔ double
-
read / write
- zoomRegion ↔ YZoomRegion
-
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
-
addMarkerText(
int xs, int ys) → void -
Adds a text to the polyline in the polyline's color
from attrPyA.MARKER_TEXT, if present, at the screen position
xs, ys
. If te text is appended tight of the polyline it requires that the user extended polyAttrPyA.INSETX by the length of the text in pixels. -
addPointShapes(
) → void -
Adds a list of points to polylineContainer. The list must be
given in POLYLINE_POINT_LIST (list of strings): shape,x1,y1,x2,y2,...
in the polyline coordinates units.
shape
defines how the points are drawn, e.g. as a circle. SQUARE_EMPTY, CIRCLE_EMPTY, ... -
addSelectionIcon(
int xs, int ys) → void -
Adds a selection rectangle at
xs, ys
of polylineContainer Ifxs
is null, the last rectangle is redrawn if there was one. -
assertIndexes(
) → void -
createPointShape(
int mxs, int mys, String shape) → GeometryElement -
Creates a point shape for the screen position
mxs, mys
with the geometric formshape
. -
genPolyline(
) → void - Generatey the svg polyline element from the xypairs
-
getAbsoluteIndexFromScreenX(
int x) → double -
This polyline displays a given range of a data array.
x
must be given in pixels relative to dataArea's origin. Then this function returns an absolute index between 0 and npointsInDisplayRegion (of the original uncompressed array). -
getRelativeIndexFromScreenX(
int x) → double -
This polyline displays a range from a data array.
x
must be given in pixels relative to dataArea's origin. Then this function returns a relative index with respect to cpd.uIndices0
ranging from cpd.uIndices0
to cpd.uIndicescpd.uIndices.length-1
-
getSelectionRectangleMath(
) → Rectangle< num> - Returns the specs of the selectionRect.
-
remove(
) → void - Removes this polyline from dataArea if not webgl.
-
removeSelectionIcon(
) → void - Removes the selection icon if there
-
setSelected(
bool select) → void - Sets selection state, changes stroke of polyline and filling of selectionRect.
-
toggleSelected(
) → void - Reverses selection state
-
xphysToXscreen(
double x) → double - Converts physical x coordinate to screen x coordinate, which is returned relative to the data area. NOTE: This method assumes x coordinates increasing vom left to right. Therefore for nmr we always feed in indexes! MUST have the type of PhysicalToScreen.
-
yphysToYscreen(
double y) → double - Converts physical y coordinate to screen y coordinate, which is returned relative to the data area. Formula: see .odt document in specpad source tree in the folder "manuals". have the type of PhysicalToScreen.
-
yScreenToYphys(
int yscreen) → double -
Converts screen y coordinate
yscreen
which is given relative to the data area, to physical y coordinate. This conversion is the inverse operation ofyphysToXscreen(double y)
and is valid for this polyline by using the constants a and b computed byyphysToXscreen
. If this method is called prior to callingyphysToXscreen
the constants a and b and not available yet, null is returned. -
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