C

BridgeManager

Helper class that calculates visual hints in a path where said path crosses an obstacle.
Inheritance Hierarchy

Remarks

Most notably this feature is used to render crossings of IEdges with other edges.

To set up bridges in a GraphComponent at the least the following is necessary:

Creating a BridgeManager for a GraphControl
// Create a BridgeManager and bind it to the GraphComponent
const bridgeManager = new BridgeManager()
bridgeManager.canvasComponent = graphComponent
// Add an obstacle provider that queries graph items (notably edges)
// for obstacles which can then be bridged
bridgeManager.addObstacleProvider(new GraphObstacleProvider())

Furthermore, an edge style that supports bridges is necessary; PolylineEdgeStyle is a good choice. Various other properties can be set to change the defaults, e.g. how bridges appear, or which way bridges point.

See Also

Developer's Guide

Demos

Shows the capabilities of the BridgeManager class for inserting bridges into edge paths.

Members

Show:

Constructors

Initializes a new instance of the BridgeManager class.
Initially the defaultBridgeCreator will be set to an instance that will delegate to the set of Default properties in this class and the insertDefaultCustomBridge method respectively.

Parameters

Properties

Gets or sets the BridgeCrossingPolicy mode that is used by this instance.
Gets or sets the canvasComponent that should be managed by this instance.
This method will install a preparation stage for the IRenderContext in the provided canvasComponent via the ILookup.lookup mechanism.
final

See Also

Developer's Guide
Gets or sets a value that determines whether curves (cubic and quadratic) should be considered as obstacles.
This can be a costly operation so the default is false.
final
Gets or sets the default implementation of the IBridgeCreator that will be used if addBridges is invoked with a null callback argument.
Gets or sets the default BridgeCrossingStyle that will be used by the default implementation of the IBridgeCreator that is initially assigned to the defaultBridgeCreator property.
The default value is BridgeCrossingStyle.ARC.
conversionfinal

See Also

Developer's Guide
API
getCrossingStyle
Gets or sets the default height of a bridge that will be used by the default implementation of the IBridgeCreator that is initially assigned to the defaultBridgeCreator property.

This property has no effect if defaultBridgeCrossingStyle is BridgeCrossingStyle.GAP, BridgeCrossingStyle.ARC_SCALED, BridgeCrossingStyle.RECTANGLE_SCALED, or BridgeCrossingStyle.TWO_SIDES_SCALED. In case of a scaled crossing style the height is determined by the defaultBridgeWidth.

The default value is 5.0d.

final

See Also

API
getBridgeHeight
Gets or sets the default BridgeOrientationStyle for bridges that will be used by the default implementation of the IBridgeCreator that is initially assigned to the defaultBridgeCreator property.
conversionfinal

See Also

API
getOrientationStyle
Gets or sets the default width of a bridge at a single obstacle.

The width of a bridge at a single orthogonal crossing typically corresponds to this property. For non-orthogonal crossings and if the value of the maximumBridgeWidth property is larger than this property, the actual bridge width increases as the intersection angles decrease to maintain a constant distance between the visible edge path and the obstacle.

A bridge that spans multiple obstacles at once can have a larger width than defaultBridgeWidth and maximumBridgeWidth.

The default value is 10.0 and maximumBridgeWidth has the same default value.

final

See Also

API
getBridgeWidth
Gets or sets the maximum width of a bridge at a single obstacle.

A bridge at a single orthogonal crossing typically has a width of defaultBridgeWidth. For non-orthogonal crossings, the actual width increases as the intersection angles decrease to maintain a constant distance between the visible edge path and the obstacle. This property specifies the maximum bridge width, as it would become very large for small angles. Bridges will have at least width defaultBridgeWidth, even if this property is set to a smaller value.

A bridge that spans multiple obstacles at once can have a larger width than maximumBridgeWidth.

For curved obstacles (PathType.CUBIC_TO and PathType.QUAD_TO), the bridge width is always defaultBridgeWidth.

The default value is 10.0 and defaultBridgeWidth has the same default value, which means that the actual bridge width is constant and does not depend on the intersection angle.

final
Gets or sets a threshold value for the zoom level below which no bridge calculation is performed.
The calculation of bridges can be costly if there are many of them visible in the viewport. As they are also only weakly visible at low zoom levels, this feature is a good option for speeding up the rendering process. The default value is 0.3d.
final

Methods

Core method that will add bridges to a GeneralPath using the IBridgeCreator callback to determine the type of the bridges.
This method may return path itself if no crossings have been determined. Otherwise, it will return a new path instance that has the bridges added at the corresponding places.

Parameters

context: IRenderContext
The context to use.
path: GeneralPath
The path to calculate the bridged variant for.
callback?: IBridgeCreator
The callback or null that determines the appearance of the bridges.

Return Value

GeneralPath
The path that might have been augmented by the bridges.
Adds another IObstacleProvider to query for obstacles.
The IObstacleProvider.getObstacles method will be invoked during construction of the obstacles.

Parameters

provider: IObstacleProvider
The provider instance to use for later queries.

See Also

API
registerObstacles, removeObstacleProvider
Disposes of this instance by resetting the canvasComponent property to null.
Gets a hash code that describes the current state of the obstacles.
This method can be used to get a concise, digest snapshot of the current obstacle locations. Storing that result and comparing it to another snapshot later allows to determine quickly whether obstacles have changed since the last call. This is helpful, e.g. in implementations of IEdgeStyle that support bridges to not recreate the edge path (including bridges) in IVisualCreator.updateVisual if no obstacles changed.

Parameters

context: IRenderContext
The context to inspect.

Return Value

number
A hash of the state of the obstacles.
Implementation that will be called by the default value of the defaultBridgeCreator to satisfy requests to IBridgeCreator.createCustomBridge.
This implementation will insert a gap style bridge by first creating a line to start and then moving to end.

Parameters

context: IRenderContext
The context for the call.
path: GeneralPath
The path to append the next segment to.
start: Point
The coordinates of the starting point of the bridge.
end: Point
The coordinates of the ending point of the bridge.
gapLength: number
The distance between the starting point and the end point.

See Also

API
createCustomBridge
Installs this manager for the specified canvasComponent.
protected

Parameters

canvasComponent: CanvasComponent
Dynamically registers an obstacle path with the context during the rendering.
Normally all obstacles will be registered initially by method registerObstacles. This method can be called during the rendering phase to register additional obstacles at a later point in time.

Parameters

context: IRenderContext
The context to register the obstacles with.
path: GeneralPath
The path that describes the obstacles.

See Also

API
registerObstacleLine
Dynamically registers a single obstacle cubic curve with the context during the rendering.
Normally all obstacles will be registered initially by method registerObstacles. This method can be called during the rendering phase to register additional obstacles at a later point in time.

Parameters

context: IRenderContext
The context to register the obstacles with.
p1: Point
The coordinates of the starting point of the line.
cp1: Point
The coordinates of the first control point of the curve.
cp2: Point
The coordinates of the second control point of the curve.
p2: Point
The coordinates of the ending point of the line.

See Also

API
registerObstacleLine
Dynamically registers a single obstacle line with the context during the rendering.
Normally all obstacles will be registered initially by method registerObstacles. This method can be called during the rendering phase to register additional obstacles at a later point in time.

Parameters

context: IRenderContext
The context to register the obstacles with.
p1: Point
The coordinates of the first point of the line.
p2: Point
The coordinates of the second point of the line.
Dynamically registers a single obstacle quadratic curve with the context during the rendering.
Normally all obstacles will be registered initially by method registerObstacles. This method can be called during the rendering phase to register additional obstacles at a later point in time.

Parameters

context: IRenderContext
The context to register the obstacles with.
p1: Point
The coordinates of the starting point of the line.
cp: Point
The coordinates of the control point of the curve.
p2: Point
The coordinates of the ending point of the line.

See Also

API
registerObstacleLine
Called to initialize the context with the obstacles.
protected

Parameters

context: IRenderContext
The context that will be used to store the obstacles within.

See Also

API
registerObstacle, registerObstacleLine
Removes a previously added IObstacleProvider from the list of registered providers.

Parameters

provider: IObstacleProvider
The provider instance to remove from this instance.

See Also

API
addObstacleProvider
Reverts the install method.
protected

Parameters

canvasComponent: CanvasComponent