Skip to main content

BaseNodeComponent

This component is what you must extend in any components you create to render nodes. It contains a few internal members that VisuallyJs needs, and also provides a number of helper methods you can use to manipulate the model object that your component represents.

The vertex this component represents is available on the class as data (a plain JS object), and $data() (a signal wrapping data).

Usage​

import { Component } from "@angular/core"
import { BaseNodeComponent } from "@visuallyjs/browser-ui-angular"

@Component({
template:`<div>
<strong>{{data.label}}</strong>
</div>`
})
export class MyNodeComponent extends BaseNodeComponent { }

Definition​

Class Members​

NameTypeDescription
$dataWritableSignal<ObjectData>This signal represents the underlying data for the vertex this component represents.
dataObjectDataData object for the vertex
zoomWritableSignal<number>This is a signal that provides the current zoom for the canvas the component is in. You can use this to selectively hide/show content based upon the zoom level.
addNewPort(type:string, data:ObjectData)voidInstructs the model to add a new port with the given data to the vertex this component represents. This will call the model's portFactory.
addPort(data:ObjectData)PortAdds a port with the given data to the vertex this component represents.
addToSelection()voidAdds the vertex this component represents to the current selection in the model.
cloneNode(options:SurfaceVertexCloneOptions)voidInstructs the model to clone this node - a new node which is a copy of this one will be added to the UI, with a position shifted slightly in X and Y from the cloned node.
cloneVertex(options:SurfaceVertexCloneOptions)voidClones this vertex, optionally setting to a given position, or offsetting from the original, and optionally magnetizing the new vertex's position, and flashing it to show the user where it is.
flashNode(duration:number, animName:string)voidFlash this Node
getNode()NodeGets the node that this component represents.
getPort(portId:string)PortGets the port with the given ID
getVertex()NodeGets the vertex that this component represents. Subclasses have getters that return more specific subclasses of Vertex.
removeFromSelection()voidRemoves the vertex this component represents from the current selection in the model.
removeNode()voidShortcut method to remove the node (and therefore this whole component)
removePort(portId:string)voidRemoves the port with the given id.
removeVertex()voidRemoves the vertex this component represents from the data model, which will cause this component to be cleaned up.
setAsSelection()voidSets the vertex this component represents as the current selection in the model.
updateNode(data:ObjectData)voidShortcut method to update the current data backing this node, for convenience.
updateVertex(data:ObjectData)voidShortcut method to update the current data backing this vertex, for convenience.