Interface used by IGraph to declare and obtain the defaults for ports at nodes and edges.
Inheritance Hierarchy
Remarks
Note that changing these defaults does not change properties of already created model items. Rather, only items created after the change are affected.
Examples
// Ports on nodes and edges have different IPortDefault instances.
// These can be retrieved from their owner type's defaults
// the defaults for node ports can be set on the IPortDefaults instance
// found at the Ports property of the node defaults
graph.nodeDefaults.ports.autoCleanUp = false
graph.nodeDefaults.ports.locationParameter =
FreeNodePortLocationModel.CENTER
// the defaults for edge ports can be set on the IPortDefaults instance
// found at the Ports property of the edge defaults
graph.edgeDefaults.ports.autoCleanUp = false
graph.edgeDefaults.ports.locationParameter =
BendAnchoredPortLocationModel.FIRST_BENDSee Also
Developer's Guide
API
- IPort, ports, ports, nodeDefaults, edgeDefaults
Members
No filters for this type
Properties
abstract
Examples
const node1 = graph.createNode()
const node2 = graph.createNode()
const port1_1 = graph.addPort(node1)
const port1_2 = graph.addPort(node1)
const port2 = graph.addPort(node2)
const edge1 = graph.createEdge(port1_1, port2)
const edge2 = graph.createEdge(port1_2, port2)
// enable auto cleanup
graph.nodeDefaults.ports.autoCleanUp = true
graph.remove(edge1)
// port1_1 is removed with the edge
console.log(graph.contains(port1_1)) // false
// port2 is not removed since edge2 still is linked to it
console.log(graph.contains(port2))
// disable auto cleanup
graph.nodeDefaults.ports.autoCleanUp = false
graph.remove(edge2)
// no port is removed with the edge now
console.log(graph.contains(port1_2)) // true
console.log(graph.contains(port2)) // trueSee Also
Developer's Guide
API
- remove
Implemented in
PortDefaults.autoCleanUpGets or sets the defaults for labels at ports.
Gets or sets the defaults for labels at ports.
abstract
Property Value
The label defaults.
Examples
graph.nodeDefaults.ports.labels.layoutParameter =
FreePortLabelModel.CENTERSee Also
Developer's Guide
Implemented in
PortDefaults.labelsGets or sets the location model parameter to use for ports.
Gets or sets the location model parameter to use for ports.
Depending on the setting of shareLocationParameterInstance, the getLocationParameterInstance method should return a clone of this instance or the very same instance.
abstract
Property Value
The parameter to use as a template.
Examples
graph.nodeDefaults.ports.style = new ShapePortStyle({
shape: ShapeNodeShape.ELLIPSE,
})
graph.nodeDefaults.ports.locationParameter =
FreeNodePortLocationModel.CENTERSee Also
Developer's Guide
API
- shareLocationParameterInstance, getLocationParameterInstance
Implemented in
PortDefaults.locationParameterabstract
Property Value
true if the reference should be shared; false otherwise.See Also
Implemented in
PortDefaults.shareLocationParameterInstanceabstract
Property Value
true if the reference should be shared; false otherwise.Examples
const n1 = graph.createNodeAt(new Point(0, 0))
const n2 = graph.createNodeAt(new Point(0, 50))
const n3 = graph.createNodeAt(new Point(0, 100))
const n4 = graph.createNodeAt(new Point(0, 150))
const defaultStyle = new ShapePortStyle({
renderSize: new Size(5, 5),
})
graph.nodeDefaults.ports.style = defaultStyle
// share style instances
graph.nodeDefaults.ports.shareStyleInstance = true
const p1 = graph.addPort(n1)
const p2 = graph.addPort(n2)
// p1.style === defaultStyle; p2.style === defaultStyle; p1.style === p2.style;
defaultStyle.renderSize = new Size(10, 10) // p1 and p2 both get larger
// clone style instances
graph.nodeDefaults.ports.shareStyleInstance = false
const p3 = graph.addPort(n3)
const p4 = graph.addPort(n4)
// p3.style !== defaultStyle; p4.style !== defaultStyle; p3.style !== p4.style;
defaultStyle.renderSize = new Size(20, 20) // p3 and p4 don't change their sizeSee Also
Implemented in
PortDefaults.shareStyleInstanceGets or sets the style to use for ports.
Gets or sets the style to use for ports.
Depending on the setting of shareStyleInstance, the getStyleInstance method should return a clone of this instance or the very same instance.
abstract
Property Value
The style to use as a template.
Examples
graph.nodeDefaults.ports.style = new ShapePortStyle({
shape: ShapeNodeShape.ELLIPSE,
})
graph.nodeDefaults.ports.locationParameter =
FreeNodePortLocationModel.CENTERSee Also
Implemented in
PortDefaults.styleMethods
Factory method that returns a location model parameter instance for use with newly created ports.
Factory method that returns a location model parameter instance for use with newly created ports.
Most implementations will yield either a clone or the locationParameter property if shareLocationParameterInstance is enabled, but they might use more complicated logic, too.
abstract
Parameters
- owner: IPortOwner
- The owner of the port that will be created.
Return Value
- IPortLocationModelParameter
- The parameter to use, which for most implementations is either a clone or the locationParameter property if shareLocationParameterInstance is enabled.
Implemented in
PortDefaults.getLocationParameterInstanceFactory method that returns a style instance for use with newly created ports.
Factory method that returns a style instance for use with newly created ports.
Most implementations will yield either, a clone of or the style property, if shareStyleInstance is enabled, but they might use more complicated logic, too.
abstract
Parameters
- owner: IPortOwner
- The owner of the port that will be created.
Return Value
- IPortStyle
- The style to use, which for most implementations is either a clone of or the style property, if shareStyleInstance is enabled.