Class: Page

Syntree.Page

Acts as an intermediate controller between Workspace and elements of the tree.

Constructor

new Page()

Source:

Members

allElements :object

All Elements on the page, referenced by id.
Type:
  • object
Source:

background

The which is the background of the page.
Source:

group :object

An SVG group of all elements on the page. Used for panning.
Type:
  • object
Source:
See:

selectedElement :Syntree.SelectableElement

The currently selected SelectableElement.
Type:
Source:

Methods

_enablePanning()

Make custom handlers and attach them for panning functionality.
Source:

addTree(treeopt, parentopt, indexopt)

Add a tree to the page. If you do not provide a parent Node, the main tree will be replaced.
Parameters:
Name Type Attributes Default Description
tree Syntree.Tree <optional>
the Tree object to add.
parent Syntree.Node <optional>
the Node to which the root of the Tree will be added
index number <optional>
0 the index at which to add the root of Tree
Source:

createMovementArrow(node) → {Syntree.Arrow}

Create a movement arrow from the selected Node to the clicked Node.
Parameters:
Name Type Description
node Syntree.Node the node that was clicked
Source:
Returns:
- the new Arrow
Type
Syntree.Arrow

deleteTree()

A wrapper function around Node.delete, allowing us to easily delete a whole subtree.
Source:
See:

deregister(element)

Remove the specified Element from the list of all elements.
Parameters:
Name Type Description
element Syntree.Element the element to deregister
Source:
See:

deselect()

Deselect the currently selected Element.
Source:
See:

getElementsByType(type) → {object}

Get all Elements, filtered by given type.
Parameters:
Name Type Description
type string a string representing the Element type to filter by
Source:
Returns:
- all matching Elements, referenced by id
Type
object

getNearestNode(a, bopt, conditionopt) → {object|boolean}

Get the Node nearest to the given coordinates or Element.
Parameters:
Name Type Attributes Description
a number | Syntree.Element x coordinate or Element to search from
b number <optional>
if a is a an x coordinate, the corresponding y coordinate
condition function <optional>
function that must return true for a Node to be considered in the search
Source:
Returns:
- data object on success, false on failure
Type
object | boolean

getSelected()

Accessor function for Page.selectedElement.
Source:
See:

getSVGString() → {string}

Get a string of SVG markup representing all marked objects on the page.
Source:
Returns:
- the SVG string
Type
string

getTransform() → {object}

Get the panning transform matrix.
Source:
See:
Returns:
- deltax, deltay, and the global transform matrix
Type
object

isRegistered(element) → {boolean}

Check if given Element is registered with Page.
Parameters:
Name Type Description
element Syntree.Element the element to check
Source:
Returns:
- whether or not the element is registered
Type
boolean
Select the most recently selected child of the currently selected node, or creates a child if one does not exist. Defaults to the left-most child if no most recently selected.
Parameters:
Name Type Attributes Default Description
fcreate boolean <optional>
false force creation instead of navigation
Source:
Select the node in the specified direction, or create a node there if one does not exist.
Parameters:
Name Type Attributes Default Description
direction string 'left' or 'right'
fcreate boolean <optional>
false force create instead of navigate
Source:
See:
Select the parent of the currently selected Node
Source:

nodeEditing(type, nodeopt)

Execute an editing action on given Node.
Parameters:
Name Type Attributes Default Description
type string 'init', 'update', 'toggle', 'save', 'cancel'
node Syntree.Node <optional>
Syntree.Page.selectedNode the node to target
Source:

openTree(treestring, parentopt, indexopt)

Create a Tree from a treestring, and then add it to the page. If you do not provide a parent Node, the main tree will be replaced.
Parameters:
Name Type Attributes Default Description
treestring Syntree.Tree the treestring which the Tree will build from
parent Syntree.Node <optional>
the Node to which the root of the Tree will be added
index number <optional>
0 the index at which to add the root of Tree
Source:

register(element)

Add an Element to the list of all elements.
Parameters:
Name Type Description
element Syntree.Element the element to register
Source:
See:

select(element)

Select the given Element. (And deselect the previous Element.)
Parameters:
Name Type Description
element Syntree.Element the element to select
Source:
See: