C

SnapGrid

A SnapReference to snap to locations on a grid.
Inheritance Hierarchy

Remarks

Instances of this class are created by collectGridSnapReferences for INodes, IBend, and IPorts if the corresponding nodeGridConstraintProvider, bendGridConstraintProvider, and portGridConstraintProvider are set.

Members

Show:

Constructors

Creates a new snap reference using the provided information.

Parameters

gridInfo: GridInfo
The information about the grid to snap to.
weight: number
The weight (importance) of this snap reference. If more than one snap reference is snapped to, the one with the greater weight will be used.
snappableItems: GraphItemTypes
The graph item types that may snap to this snap reference.
tag?: any
A tag that is associated with this snap reference - see tag for a typical use of this value.

Properties

Gets the information about the grid to snap to.
readonlyfinal
Gets which types of items may snap to this snap reference.
readonlyfinal
Gets the tag that is associated with this snap reference.
The tag is most commonly used for the snap result tag.
readonlyfinal
Gets the weight/importance of this snap reference.
Greater values indicate greater importance.
readonlyfinal

Methods

Collects a valid SnapResult that snaps the movedPoint to grid points or lines of the gridInfo depending on the gridSnapTypes.

A snap result is considered to be valid if the distance between the movedPoint and the grid point or line is not bigger than the gridSnapDistance.

If a valid SnapResult is found, it is added to the evt and returned.

Parameters

evt: CollectSnapResultsEventArgs
The arguments describing the movement the SnapResult shall be created for.
movedItem: IModelItem
The item that is currently moved.
movedPoint: Point
The location that shall be snapped to the grid.
gridSnapTypes: GridSnapTypes
The snap types of the grid to consider.

Return Value

SnapResult
A valid snap result to a grid point or line or null if no such snap result could be found.
Collects a valid SnapResult that snaps the corner of the reshaped rectangle that corresponds to the reshapePosition to a grid point.

The reshape behavior of the rectangle relative to the pointer movement is described by the reshapeContext and a snap result is only considered to be valid if the necessary pointer delta resulting in the snap is not bigger than the gridSnapDistance.

If a valid SnapResult is found, it is added to the evt and returned.

Parameters

evt: CollectSnapResultsEventArgs
The arguments describing the movement the SnapResult shall be created for.
reshapeContext: ReshapeRectangleContext
The reshape context that contains information about the nature of the resize.
reshapedItem: IModelItem
The item that is currently reshaped.
suggestedLayout: Rect
The layout of the item as it would be if the pointer location would not be snapped.

Return Value

SnapResult
A valid snap result to a grid point or null if no such snap result could be found.
Calculates a valid SnapResult that snaps the side of a reshaped rectangle described by the snapType to a grid line.

The snapType describes which side of the rectangle should be snapped. No combined SnapLineSnapTypes are supported. If snap results shall be created for multiple sides, this method should be called for each side individually.

The reshape behavior of the rectangle relative to the pointer movement is described by the reshapeContext and a snap result is only considered to be valid, if the necessary pointer delta resulting in the snap is not bigger than the gridSnapDistance.

If a valid SnapResult is found, it is added to the evt and returned.

Parameters

evt: CollectSnapResultsEventArgs
The arguments describing the movement the SnapResult shall be created for.
reshapeContext: ReshapeRectangleContext
The reshape context that contains information about the nature of the resize.
reshapedItem: IModelItem
The item that is currently reshaped.
suggestedLayout: Rect
The layout of the item as it would be if the pointer location would not be snapped.
snapType: SnapLineSnapTypes
The side of the reshaped rectangle that shall be snapped.

Return Value

SnapResult
A valid snap result on a grid line or null if no such snap result could be found.