Class: Node

Syntree.Node

Nodes are the meat of Syntree. They act like items in a linked list, containing references to their parents and children.

Constructor

new Node()

Source:

Extends

Members

_labelbbox :object

This Node's cached label BBox.
Type:
  • object
Source:

childBranches :Array.<Syntree.Branch>

Branches connecting to this Node's children.
Type:
Source:

children :Array.<Syntree.Node>

This Node's child Nodes.
Type:
Source:

deleted :boolean

Whether or not this element has been deleted. Needed to avoid double deletion.
Type:
  • boolean
Overrides:
Source:

editing :Boolean

Is this Node being edited?
Type:
  • Boolean
Source:

id :number

Session-unique identifier.
Type:
  • number
Overrides:
Source:
See:

labelContent :string

Label content.
Type:
  • string
Source:

lastSyncedPosition :object

The last position that was updated to the visual display.
Type:
  • object
Source:

parent :Syntree.Node

This Node's parent Node.
Type:
Source:

parentBranch :Syntree.Branch

Branch connecting to this Node's parent.
Type:
Source:

real :Boolean

Has this Node been saved at least once? Used so we can autodelete Nodes on reverse navigation.
Type:
  • Boolean
Source:

selectable

Whether or not this element is selectable. Selectable elements are Syntree.Node, Syntree.Branch, Syntree.Arrow.
Overrides:
Source:
See:

selected :boolean

Whether or not this element is selected.
Type:
  • boolean
Inherited From:
Source:
See:

x :number

This Node's x coordinate.
Type:
  • number
Source:

y :number

This Node's y coordinate.
Type:
  • number
Source:

Methods

__delete()

Custom addition to Syntree.Element#delete. Deletes connected Branches and Arrows as well.
Source:
See:

__deselect()

Custom addition to Syntree.SelectElement#deselect. Deletes if is not real.
Source:
See:

__updateGraphics()

Custom addition to Syntree.Element#updateGraphics
Source:
See:

addChild(newNode, indexopt)

Add a child at the specified index.
Parameters:
Name Type Attributes Default Description
newNode Syntree.Node the Node to attach
index number <optional>
Syntree.Node#children.length index at which to attach
Source:
See:

createGraphic()

Build needed graphical objects and compile them into a new instance of Graphic.
Source:
See:

delete()

Delete the element. Removes graphical elements, deregisters from Syntree.Workspace.page, and sets deleted property to true. Extend in sub-classes with '__delete()'.
Overrides:
Source:
See:

deselect()

Deselect the element. Controls the appearance and behavior of this element only. Other overarching management is handled by Syntree.Page.
Inherited From:
Source:
See:

editingAction(action)

Perform an editing action.
Parameters:
Name Type Description
action string type of editing action: init, update, save, or cancel
Source:
See:

getChildren()

Accessor function for Syntree.Node#children.
Source:
See:

getId() → {number}

Accessor function for property id.
Overrides:
Source:
See:
  • Syntree.Element.id
Returns:
the id of the element
Type
number

getLabelBBox() → {object}

Get this Node label's BBox. Returns cached BBox if exists.
Source:
See:
Returns:
- border box
Type
object

getLabelContent()

Accessor function for Syntree.Node#labelContent.
Source:
See:

getParent()

Accessor function for Syntree.Node#parent.
Source:
See:

getPath() → {string}

Get a path that acts like a border box for this Node's label. Used to get intersections for movement arrows.
Source:
See:
Returns:
- path string
Type
string

getPosition() → {object}

Get the position of this Node. Does not include panning transform.
Source:
See:
Returns:
- x and y coordinates
Type
object

getState(whichopt) → {boolean|object}

Grouped accessor function for selected, editing, real, and deleted. Mostly a leftover from when I didn't know what I was doing. Should probably turn this into something tht makes more sense, someday.
Parameters:
Name Type Attributes Description
which string <optional>
which state to return
Source:
See:
Returns:
- either the boolean value of the state, or an object of state names mapped to booleans (if no state name provided)
Type
boolean | object

isDeletable() → {boolean}

Whether or not this element is deletable. Deletable elements are Syntree.Node, Syntree.Branch, Syntree.Arrow. Syntree.Branch should never be deletable directly by the user. Branches should only be deleted automatically when their child node is deleted.
Overrides:
Source:
See:
  • Syntree.Node.__delete
Returns:
Type
boolean

isDeleted() → {boolean}

Accessor function for property deleted.
Overrides:
Source:
See:
  • Syntree.Element.deleted;
Returns:
whether or not the element is deleted
Type
boolean

isElement() → {boolean}

Whether or not this object is an element. Elements are Syntree.Node, Syntree.Branch, Syntree.Arrow.
Overrides:
Source:
Returns:
Type
boolean

isSelectable() → {boolean}

Accessor function for property selectable.
Overrides:
Source:
See:
Returns:
whether or not the element is selectable
Type
boolean

move(x, y, propogateopt) → {object}

Set this Node's x and y coordinates.
Parameters:
Name Type Attributes Default Description
x number x coordinate
y number y coordinate
propogate boolean <optional>
true set coordinates of descendant Nodes as well
Source:
See:
Returns:
- new x and y coordinates
Type
object

select()

Select the element. Controls the appearance and behavior of this element only. Deselecting previously selected element and other overarching management is handled by Syntree.Page.
Inherited From:
Source:
See:

setLabelContent()

Setter function for Syntree.Node#labelContent.
Source:
See:

updateGraphics()

Update the elements graphical representation. Mostly serves as a wrapper for Syntree.Graphic.update. Extend in sub-classes with '__updateGraphics()'.
Overrides:
Source:
See: