A SnapReference to snap to locations on a grid.
Remarks
Type Details
- yFiles module
- view
Constructors
Creates a new snap reference using the provided information.
Parameters
A map of options to pass to the method.
- 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.
Gets which types of items may snap to this snap reference.
Defined in
Gets the tag that is associated with this snap reference.
Gets the weight/importance of this snap reference.
Methods
collectPointSnapResult
(evt: CollectSnapResultsEventArgs, movedItem: IModelItem, movedPoint: Point, gridSnapTypes: GridSnapTypes) : SnapResultCollects a valid SnapResult that snaps the movedPoint
to grid points or lines of the gridInfo depending on the gridSnapTypes
.
Remarks
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
A map of options to pass to the method.
- 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.
Returns
- ↪SnapResult?
- A valid snap result to a grid point or line or
null
if no such snap result could be found.
collectReshapedCornerSnapResult
(evt: CollectSnapResultsEventArgs, reshapeContext: ReshapeRectangleContext, reshapedItem: IModelItem, suggestedLayout: Rect) : SnapResultCollects a valid SnapResult that snaps the corner of the reshaped rectangle that corresponds to the reshapePosition to a grid point.
Remarks
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
A map of options to pass to the method.
- 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.
Returns
- ↪SnapResult?
- A valid snap result to a grid point or
null
if no such snap result could be found.
collectReshapedSideSnapResult
(evt: CollectSnapResultsEventArgs, reshapeContext: ReshapeRectangleContext, reshapedItem: IModelItem, suggestedLayout: Rect, snapType: SnapLineSnapTypes) : SnapResultCalculates a valid SnapResult that snaps the side of a reshaped rectangle described by the snapType
to a grid line.
Remarks
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
A map of options to pass to the method.
- 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.
Returns
- ↪SnapResult?
- A valid snap result on a grid line or
null
if no such snap result could be found.