C

GridConstraintProvider

A general grid constraint provider that snaps nodes and bends to the nearest grid location.

Remarks

Examples

Enabling grid snapping

const snapContext = new GraphSnapContext()

const gridInfo = new GridInfo(50, 50)
snapContext.nodeGridConstraintProvider = new GridConstraintProvider(gridInfo)
snapContext.bendGridConstraintProvider = new GridConstraintProvider(gridInfo)
snapContext.portGridConstraintProvider = new GridConstraintProvider(gridInfo)
snapContext.gridSnapType = GridSnapTypes.GRID_POINTS

graphEditorInputMode.snapContext = snapContext

Note that the grid visualization has to be enabled separately

graphComponent.renderTree.createElement(
  graphComponent.renderTree.backgroundGroup,
  gridInfo,
  new GridRenderer(),
)

Members

No filters for this type

Constructors

Creates a new instance using the given grid distances.

Parameters

gridSize: number
The distance in the newly created grid.
Creates a new instance using the given grid info.

Parameters

gridInfo: GridInfo
The grid info object.
Creates a new instance using the given grid specification.

Parameters

gridWidth: number
Width of the grid.
gridHeight: number
Height of the grid.

Properties

Gets or sets the grid info that describes the geometry of the grid.
final

Property Value

The grid info.
Gets the grid origin.
This implementation delegates to the gridInfo
readonlyfinal
Gets the grid height.
This implementation delegates to the gridInfo
readonlyfinal
Gets the grid width.
This implementation delegates to the gridInfo
readonlyfinal

Methods

Snaps the given location to the nearest grid point.
final

Parameters

context: IInputModeContext
The context in which the snapping should occur.
bend: IBend
The bend of which the coordinates should be snapped.
location: IMutablePoint
The coordinates to snap.
xSnapPolicy: SnapPolicy
The policy for the x-coordinate.
ySnapPolicy: SnapPolicy
The policy for the y-coordinate.

Return Value

boolean
Whether the point has been snapped.
Snaps the given location to the nearest grid point.
final

Parameters

context: IInputModeContext
The context in which the snapping should occur.
node: INode
The node of which the coordinates should be snapped.
location: IMutablePoint
The coordinates to snap.
xSnapPolicy: SnapPolicy
The policy for the x-coordinate.
ySnapPolicy: SnapPolicy
The policy for the y-coordinate.

Return Value

boolean
Whether the point has been snapped.

Static Methods

Snaps the given location to the nearest grid point.
static

Parameters

location: IMutablePoint
The location to snap.
gridInfo: GridInfo
The grid to which the snapping should occur.
xSnapPolicy: SnapPolicy
The policy for the x-coordinate.
ySnapPolicy: SnapPolicy
The policy for the y-coordinate.

Return Value

boolean
Whether the point has been snapped.