Class: Visualiser

Visualiser

Visualiser implementation.

new Visualiser(panel)

Parameters:
Name Type Description
panel jsgl.Panel Panel for visualisation.
Author:
  • Jakub Melezinek
Source:

Members

<static> downwardsDoubleArrow :String

Go to parent arrow - ⇑.
Type:
  • String
Source:

<static> northEastArrow :String

Came from left child arrow - ↗.
Type:
  • String
Source:

<static> northWestArrow :String

Came from right child arrow - ↖.
Type:
  • String
Source:

<static> southEastDoubleArrow :String

Go to right child arrow - ⇘.
Type:
  • String
Source:

<static> southWestDoubleArrow :String

Go to left child arrow - ⇙.
Type:
  • String
Source:

<static> upwardsDoubleArrow :String

Go to parent arrow - ⇑.
Type:
  • String
Source:

Methods

addElement(element) → {Number}

Safely add given jsglElement to jsglPanel.
Parameters:
Name Type Description
element jsgl.elements.AbstractElement A jsglElements to add.
Source:
Returns:
Return number of actually added elements.
Type
Number

addElements(elements) → {Number}

Safely add given jsglElements to jsglPanel.
Parameters:
Name Type Description
elements jsgl.elements.AbstractElement[] Array of jsglElements to add to jsglPanel.
Source:
Returns:
Return number of actually added elements.
Type
Number

addNodeElements(node) → {Number}

Securely add all jsglElements of given node to jsglPanel.
Parameters:
Name Type Description
node btv.BinaryTree
Source:
Returns:
Return number of actually added elements.
Type
Number

animateAddArrayElem(length)

Animate (re)creating and adding an arrayElement.
Parameters:
Name Type Description
length Number
Source:

animateAddAssistNodeElemAt(node, nodeAt)

Animate (re)creating and adding node's nodeElement at given node location.
Parameters:
Name Type Description
node btv.BinaryTreeNode Which node will be displayed on given location.
nodeAt btv.BinaryTreeNode | Number
Source:

animateAddAssistNodeElemNextTo(node, nodeNextTo)

Animate (re)creating and adding node's nodeElement next to given node location.
Parameters:
Name Type Description
node btv.BinaryTreeNode Which node will be displayed.
nodeNextTo btv.BinaryTreeNode | Number A node or an index of a node next to which the first node will be displayed.
Source:

animateAddEdgeElem(node)

Animate (re)creating and adding node's edgeElement.
Parameters:
Name Type Description
node btv.BinaryTreeNode
Source:

animateAddNodeElem(node)

Animate (re)creating and adding node's nodeElement his index location.
Parameters:
Name Type Description
node btv.BinaryTreeNode Which node will be displayed on his normal location.
Source:

animateAddNodeElemAt(node, nodeAt)

Animate (re)creating and adding node's nodeElement at given node location.
Parameters:
Name Type Description
node btv.BinaryTreeNode Which node will be displayed on his normal location.
nodeAt btv.BinaryTreeNode | Number
Source:

animateAddNodeElemNextTo(node, nodeNextTo)

Animate (re)creating and adding node's nodeElement next to given node location.
Parameters:
Name Type Description
node btv.BinaryTreeNode Which node will be displayed.
nodeNextTo btv.BinaryTreeNode | Number The node will be displayed next to this node.
Source:

animateChangeAssistNode(node, text, struckThrough)

Animate changing node's nodeElement.
Parameters:
Name Type Description
node btv.BinaryTreeNode
text String
struckThrough Boolean
Source:

animateChangeAssistNodeShowParam(node, text, struckThrough, show)

Animate changing (or showing of changing) node's nodeElement.
Parameters:
Name Type Description
node btv.BinaryTreeNode
text String
struckThrough Boolean
show Boolean
Source:

animateEnd(algorithm)

End animation, that fire endAnimationListeners of given algorithm.
Parameters:
Name Type Description
algorithm btv.AbstractAlgorithm This algorithm's end animation chain listeners will be invoked
Source:

animateMoveNextTo(node, nodeNextTo)

Animate moving given node's nodeElement to given location.
Parameters:
Name Type Description
node btv.BinaryTreeNode
nodeNextTo btv.BinaryTreeNode | Number A node or an index of a node
Source:

animateMoveNextToArrayElem(node)

Animate moving given node's nodeElement next to array location.
Parameters:
Name Type Description
node btv.BinaryTreeNode
Source:

animateMoveTo(node, nodeTo)

Animate moving given node's nodeElement next to given node location.
Parameters:
Name Type Description
node btv.BinaryTreeNode
nodeTo btv.BinaryTreeNode | Number A node or an index of a node
Source:

animateMoveToIndexLoc(nodes)

Animate moving given nodes' nodeElements and edgeElement to their index locations.
Parameters:
Name Type Description
nodes btv.BinaryTreeNode[]
Source:

animateRedrawTree(tree)

Animate redrawing given tree.
Parameters:
Name Type Description
tree btv.BinaryTree
Source:

animateRemoveArrayElem()

Animate removing an arrayElement.
Source:

animateRemoveElement(element)

Animate removing given element.
Parameters:
Name Type Description
element jsgl.elements.AbstractElement
Source:

animateRemoveElements(elements)

Animate removing given elements.
Parameters:
Name Type Description
elements Array.<jsgl.elements.AbstractElement>
Source:

animateRemoveNode(node)

Animate removing a nodeElement and an edgeElement.
Parameters:
Name Type Description
node btv.BinaryTreeNode
Source:

animateSelectNode(node)

Animate selecting of a given node.
Parameters:
Name Type Description
node btv.BinaryTreeNode
Source:

animateShowAssistNodeElemAt(node, nodeAt)

Animate (re)creating and showing node's nodeElement at given node location.
Parameters:
Name Type Description
node btv.BinaryTreeNode Which node will be displayed on given location.
nodeAt btv.BinaryTreeNode | Number
Source:

animateShowAssistNodeElemNextTo(node, nodeNextTo)

Animate (re)creating and showing node's nodeElement next to given node location.
Parameters:
Name Type Description
node btv.BinaryTreeNode Which node will be displayed.
nodeNextTo btv.BinaryTreeNode | Number A node or an index of a node next to which the first node will be displayed.
Source:

animateShowChangeAssistNode(node, text, struckThrough)

Animate showing of changing node's nodeElement.
Parameters:
Name Type Description
node btv.BinaryTreeNode
text String
struckThrough Boolean
Source:

animateShowComparSign(node1, isGreater, node2)

Animate (re)creating and showing a comparisonSignElement.
Parameters:
Name Type Description
node1 btv.BinaryTreeNode Node on the left/top - the moving one.
isGreater Boolean | Number True if node1 is greater than or equal to node2, false if is smaller. 1 if is greater, 0 if is equal, -1 if is smaller.
node2 btv.BinaryTreeNode Node on the right/botton - the static one.
Source:

animateShowInsertToArrayElem(node, index)

Animate showing of inserting to arrayElement.
Parameters:
Name Type Description
node btv.BinaryTreeNode
index Number
Source:

animateShowNodeElem(node)

Animate (re)creating and showing node's nodeElement at his index location location.
Parameters:
Name Type Description
node btv.BinaryTreeNode Which node will be displayed on his normal location.
Source:

animateShowNodeElemAt(node, nodeAt)

Animate (re)creating and showing node's nodeElement at given node location.
Parameters:
Name Type Description
node btv.BinaryTreeNode Which node will be displayed on his normal location.
nodeAt btv.BinaryTreeNode | Number
Source:

animateShowNodeElemNextTo(node, nodeNextTo)

Animate (re)creating and showing node's nodeElement next to given node location.
Parameters:
Name Type Description
node btv.BinaryTreeNode Which node will be displayed.
nodeNextTo btv.BinaryTreeNode | Number A node or an index of a node next to which the first node will be displayed.
Source:

animateShowRemoveNode(node)

Animate showing of removing a nodeElement and an edgeElement.
Parameters:
Name Type Description
node btv.BinaryTreeNode
Source:

animateShowSelectNode(node)

Animate showing of selecting of a given node.
Parameters:
Name Type Description
node btv.BinaryTreeNode
Source:

animateShowTree(ratio)

Animate showing the tree.
Parameters:
Name Type Description
ratio Number
Source:

animateStart(algorithm)

Start animation, that create new btv.AnimatorsArrayList object and fire startAnimationListeners of given algorithm.
Parameters:
Name Type Description
algorithm btv.AbstractAlgorithm This algorithm's start animation chain listeners will be invoked
Source:

animateSwapNodeElems(node1, node2)

Animate swapping given nodes.
Parameters:
Name Type Description
node1 btv.BinaryTreeNode
node2 btv.BinaryTreeNode
Source:

createArrayElement(length) → {btv.elements.ArrayElement}

Factory method, that create btv.elements.ArrayElement. This element represents an array as a group of rectangles and labels.
Parameters:
Name Type Description
length Number
Source:
See:
Returns:
Extended jsgl.elements.GroupElement representing an array.
Type
btv.elements.ArrayElement

createComparisonSignElement(text, location) → {btv.elements.ComparisonSignElement}

Factory method, that create btv.elements.ComparisonSignElement. This element represents a comparison sign as a group of a rectangle and a label.
Parameters:
Name Type Description
text String
location jsgl.Vector2D
Source:
See:
Returns:
Extended jsgl.elements.GroupElement representing a comparison sign.
Type
btv.elements.ComparisonSignElement

createEdgeElement(from, to) → {btv.elements.EdgeElement}

Factory method, that create btv.elements.EdgeElement. This element represents an edge from a parent node to a child node as a group of lines.
Parameters:
Name Type Description
from btv.BinaryTreeNode
to btv.BinaryTreeNode
Source:
See:
Returns:
Extended jsgl.elements.GroupElement representing an edge.
Type
btv.elements.EdgeElement

createNodeElement(node, location) → {btv.elements.NodeElement}

Factory method, that create btv.elements.NodeElement. This element represents a node as a group of a circle and a label.
Parameters:
Name Type Description
node btv.BinaryTreeNode
location jsgl.Vector2D
Source:
See:
Returns:
Extended jsgl.elements.GroupElement representing a node.
Type
btv.elements.NodeElement

createStepElement(node, location) → {btv.elements.NodeElement}

Factory method, that create btv.elements.StepElement. This element represents an assistant node as a group of a circle and a label.
Parameters:
Name Type Description
node btv.BinaryTreeNode
location jsgl.Vector2D
Source:
See:
Returns:
Extended jsgl.elements.GroupElement representing a node.
Type
btv.elements.NodeElement

getMoveSpeed()

Source:

getSelectedNode() → {btv.BinaryTreeNode}

Source:
Returns:
selected node or null
Type
btv.BinaryTreeNode

getStepDuration()

Source:

pauseAnimation()

Pause animation.
Source:

playAnimation()

Play animation.
Source:

redrawTree(tree)

Parameters:
Name Type Description
tree btv.BinaryTree
Source:

removeElement(element) → {Number}

Safely remove given jsglElement from jsglPanel.
Parameters:
Name Type Description
element jsgl.elements.AbstractElement A jsglElements to remove.
Source:
Returns:
Return number of actually removed elements.
Type
Number

removeElements(elements) → {Number}

Safely remove given jsglElements added to jsglPanel.
Parameters:
Name Type Description
elements jsgl.elements.AbstractElement[] Array of jsglElements to remove.
Source:
Returns:
Return number of actually removed elements.
Type
Number

removeNodeElements(node) → {Number}

Securely remove all jsglElements added to jsglPanel referenced from the node.
Parameters:
Name Type Description
node btv.BinaryTree
Source:
Returns:
Return number of actually removed elements.
Type
Number

setMoveSpeed(speed)

Parameters:
Name Type Description
speed Number Speed of move of graphic elements in animations in px/ms.
Source:

setSelectedNode(node)

Parameters:
Name Type Description
node btv.BinaryTreeNode
Source:

setStepDuration(duration)

Parameters:
Name Type Description
duration Number Duration of show animations in ms.
Source:

skipAnimationForward()

Skip whole animation.
Source: