Packagecom.yworks.canvas.input.snapLines
Classpublic class SnapResult
InheritanceSnapResult Inheritance flash.events.EventDispatcher
Subclasses SnapLineSnapResult

This is the abstract base class used by the implementations of SnapContext to model the result of the mouse being snapped to a certain coordinate. It carries a weight and can be used to obtain an IDisplayObjectCreator that will be included in the view if the result is actually snapped after all other results with higher weight have been snapped.

See also

SnapContext
IDisplayObjectCreator
isSnapped
snap


Public Properties
 PropertyDefined By
  nullResult : SnapResult
[static] [read-only] A SnapResult representing that there is no snapping of the x or y coordinate.
SnapResult
  tag : Object
[read-only] The tag associated with this result.
SnapResult
  weight : Number
[read-only] Yields the weight of this result, the higher the weight, the more important it is.
SnapResult
Protected Properties
 PropertyDefined By
  _tag : Object
The tag associated with this result.
SnapResult
  _weight : Number
Yields the weight of this result, the higher the weight, the more important it is.
SnapResult
Public Methods
 MethodDefined By
  
compareTo(snapResultA:Object, snapResultB:Object):int
[static] Compares the weights of the two SnapResults.
SnapResult
  
createPointSnapResult(location:IPoint, weight:Number, tag:Object, creator:IDisplayObjectCreator, snapType:uint):SnapResult
[static] Factory method that creates a SnapResult that snaps to a given location.
SnapResult
  
createResizeSnapResult(weight:Number, delta:Number, tag:Object, rectangles:Iterable, size:Number, orientation:SnapLineOrientation, resourceKey:ResourceKey):SnapResult
[static] Factory method that creates a SnapResult that snaps to a given size.
SnapResult
  
Returns a display object creator to visualize this snap result.
SnapResult
  
isSnapped(unsnappedCoordinates:IPoint, finalSnapState:SnapState):Boolean
Checks whether this instance is still snapped given the final mouse coordinates.
SnapResult
  
snap(unsnappedCoordinates:IPoint, currentSnapState:SnapState):void
Core method that performs the actual snapping.
SnapResult
  
valueOf():Object
Returns the weight of this result.
SnapResult
Property Detail
_tagproperty
protected var _tag:Object

The tag associated with this result. If more than one result uses the same tag (not null), only the one with the highest weight will be rendered.

_weightproperty 
protected var _weight:Number

Yields the weight of this result, the higher the weight, the more important it is.

nullResultproperty 
nullResult:SnapResult  [read-only]

A SnapResult representing that there is no snapping of the x or y coordinate.


Implementation
    public static function get nullResult():SnapResult
tagproperty 
tag:Object  [read-only]

The tag associated with this result. If more than one result uses the same tag (not null), only the one with the highest weight will be rendered.


Implementation
    public function get tag():Object

See also

weightproperty 
weight:Number  [read-only]

Yields the weight of this result, the higher the weight, the more important it is.


Implementation
    public function get weight():Number
Method Detail
compareTo()method
public static function compareTo(snapResultA:Object, snapResultB:Object):int

Compares the weights of the two SnapResults.

Parameters

snapResultA:Object — The first SnapResult to compare.
 
snapResultB:Object — The second SnapResult to compare.

Returns
int — The comparison of the weights of the two SnapResults.
createPointSnapResult()method 
public static function createPointSnapResult(location:IPoint, weight:Number, tag:Object, creator:IDisplayObjectCreator, snapType:uint):SnapResult

Factory method that creates a SnapResult that snaps to a given location.

Parameters

location:IPoint — The location to snap to.
 
weight:Number — The weight to assign to the result.
 
tag:Object — The tag to use.
 
creator:IDisplayObjectCreator — The display object creator to use.
 
snapType:uint — The type of the snapping operation to apply.

Returns
SnapResult — A result that snaps to the provided location using the provided mode.

See also

createResizeSnapResult()method 
public static function createResizeSnapResult(weight:Number, delta:Number, tag:Object, rectangles:Iterable, size:Number, orientation:SnapLineOrientation, resourceKey:ResourceKey):SnapResult

Factory method that creates a SnapResult that snaps to a given size.

Parameters

weight:Number — The weight to assign to the result.
 
delta:Number — The value to add to the mouse coordinates to snap to that result.
 
tag:Object — The tag associated with this result. If more than one result uses the same tag (not null), only the one with the highest weight will be rendered.
 
rectangles:Iterable — An Iterable of IRectangles containing the bounds of the resized objects as well as the bounds of the (non-resizing) rectangular objects the snapped size was based upon.
 
size:Number — The equal size the resized objects snapped to.
 
orientation:SnapLineOrientation — The orientation of the resize gesture.
 
resourceKey:ResourceKey — The key that shall be used to create an appropriate IDisplayObjectCreator implementation for this snap result.

Returns
SnapResult — A result that snaps to the provided size using the provided mode.
getDisplayObjectCreator()method 
public function getDisplayObjectCreator(snapContext:SnapContext):IDisplayObjectCreator

Returns a display object creator to visualize this snap result. This method has to be overridden by subclasses.

Parameters

snapContext:SnapContext

Returns
IDisplayObjectCreator
isSnapped()method 
public function isSnapped(unsnappedCoordinates:IPoint, finalSnapState:SnapState):Boolean

Checks whether this instance is still snapped given the final mouse coordinates. This implementation simply returns false.

Parameters

unsnappedCoordinates:IPoint — The unsnapped coordinates.
 
finalSnapState:SnapState — The final snap state that has been used by the client.

Returns
Boolean — Whether the coordinates are still snapped for this instance.
snap()method 
public function snap(unsnappedCoordinates:IPoint, currentSnapState:SnapState):void

Core method that performs the actual snapping. This implementation does nothing.

Parameters

unsnappedCoordinates:IPoint — The coordinates prior to the snapping.
 
currentSnapState:SnapState — The currently snapped coordinates and the state of the snapping. This instance can be modified by subclasses.

See also

valueOf()method 
public function valueOf():Object

Returns the weight of this result.

Returns
Object — The weight of this result.

See also