Class: MatchingView

MatchingView

View to draw Matching to HTML canvas.

Constructor

new MatchingView(matching, matchingHtmlElement, linkedMatchingView, onlyPermanentCanvas)

Construct a view with 2 superposed HTML canvas to draw a matching. If linkedMatchingView !== null then update method may also update linked views. If onlyPermanentCanvas then don't use of temporary canvas.
Parameters:
Name Type Default Description
matching Matching
matchingHtmlElement HTMLElement that will contains HTML canvas
linkedMatchingView null | MatchingView null
onlyPermanentCanvas boolean false
Source:

Members

canvasContainer

Returns the container of canvas.
Source:

linkedMatchingViews

Returns the view.
Source:

matching

Returns the matching.
Source:

Methods

_canvasClear(canvas)

Clear canvas.
Parameters:
Name Type Description
canvas HTMLElement
Source:

_drawPoint(canvas, point, color, radius)

Draw a point.
Parameters:
Name Type Default Description
canvas HTMLElement
point Point
color String black
radius number 5 > 0
Source:

_drawSegment(canvas, segment, color, lineWidth)

Draw a segment in color with its two endpoints in black (with default radius).
Parameters:
Name Type Default Description
canvas HTMLElement
segment Segment
color String black
lineWidth number 2 > 0
Source:

_pointToCanvasXY(canvas, point) → {Array}

Returns (x, y) coordinates of point in the canvas. The vertical coordinate is reversed to have (*, 0) in the bottom.
Parameters:
Name Type Description
canvas HTMLElement
point Point
Source:
Returns:
[number, number]
Type
Array

_updatePermanentCanvas(drawSegments)

Draw in the canvas all points and segments of this matching. If this._drawSegments === DRAW_SEGMENTS_CONSECUTIVE then draw also segments (in thin silver) of consecutive linked matchings. If this._drawSegments === DRAW_SEGMENTS_ALL then draw also segments (in thin silver) of all linked matchings.
Parameters:
Name Type Description
drawSegments number DRAW_SEGMENTS_ONLY, DRAW_SEGMENTS_CONSECUTIVE or DRAW_SEGMENTS_ALL
Source:

_updateTemporaryCanvas(currentPoint, nearestPoint, temporarySegment)

Draw in the canvas the moving current point (pointed by mouse) (if not null), its nearest point in big (if not null) and the segment being built (if not null).
Parameters:
Name Type Default Description
currentPoint null | Point null
nearestPoint null | Point null
temporarySegment null | Segment null
Source:

setDrawSegments(drawSegments)

Set drawSegment property from HTML element and update the view.
Parameters:
Name Type Description
drawSegments number DRAW_SEGMENTS_ONLY, DRAW_SEGMENTS_CONSECUTIVE or DRAW_SEGMENTS_ALL
Source:

update(options)

Update the temporary canvas. If options.currentPoint !== null then draw also the moving current point (pointed by mouse). If options.nearestPoint !== null then draw also its nearest point in big. If options.temporarySegment !== null then draw also the segment being built. If options.updatePermanent then update also the permanent canvas. If options.updateLinkedMatchingViews then update also other linked matching views. If this._drawSegments !== DRAW_SEGMENTS_CONSECUTIVE or DRAW_SEGMENTS_ALL then draw also segments of consecutive or all linked matchings.
Parameters:
Name Type Description
options table
Source: