Implementations of this class describe the constraint for a pointer location so that a SnapResult is considered to be snapped.
Remarks
This class usually does not need to be subclassed. Instead, the factory methods createPointConstraint, createLineConstraint, and createCircleConstraint should be called.
The location is a preferred location that satisfies this constraint.
Type Details
- yFiles module
- view
Constructors
Properties
A preferred location that satisfies this constraint.
Methods
Returns if the finalLocation
satisfies this constraint.
Remarks
Parameters
A map of options to pass to the method.
- finalLocation - Point
- The location to check.
Returns
- ↪boolean
true
, if thefinalLocation
satisfies this constraint,false
otherwise.
Tries to merge the current with the given constraint
.
Remarks
null
is returned.Parameters
A map of options to pass to the method.
- constraint - SnapConstraint
- The constraint that is tried to be merged into the current one.
Returns
- ↪SnapConstraint?
- The merged SnapConstraint or
null
if none could be found.
Static Methods
createCircleConstraint
(location: Point, unSnappedLocation: Point, snapDistance: number, center: Point, radius: number, startAngle?: number, endAngle?: number) : SnapConstraintCreates a constraint describing the points on a circle defined by the given center
and radius
.
Remarks
With the startAngle
and endAngle
the circle can be reduced to an arc. Both values are interpreted in radians clockwise from the positive x-axis.
If startAngle
and endAngle
are equal, the constraint uses the full circle, otherwise it uses the arc starting from startAngle
clockwise to endAngle
.
Parameters
A map of options to pass to the method.
- location - Point
- The preferred location on the circle.
- unSnappedLocation - Point
- The current not snapped pointer location.
- snapDistance - number
- A maximum distance that should be considered in tryMerge.
- center - Point
- The center of the circle.
- radius - number
- The radius of the circle.
- startAngle - number
- The start angle of the arc in radians.
- endAngle - number
- The end angle of the arc in radians.
Returns
- ↪SnapConstraint
- A configured SnapConstraint that describes the points on a circle.
createLineConstraint
(location: Point, unSnappedLocation: Point, snapDistance: number, direction: Point) : SnapConstraintCreates a constraint describing an affine line defined by the given location
and direction
.
Parameters
A map of options to pass to the method.
- location - Point
- The preferred location on the affine line.
- unSnappedLocation - Point
- The current not snapped pointer location.
- snapDistance - number
- A maximum distance that should be considered in tryMerge.
- direction - Point
- The direction vector of the affine line.
Returns
- ↪SnapConstraint
- A configured SnapConstraint that describes the affine line.
Creates a constraint describing the single valid given location
.
Parameters
A map of options to pass to the method.
- location - Point
- The location of the constraint.
Returns
- ↪SnapConstraint
- The configured SnapConstraint