Packagecom.yworks.graph.model
Classpublic class PortRelocationHandle
InheritancePortRelocationHandle Inheritance EdgeEndMoveHandle Inheritance Object

A sophisticated implementation of the IHandle interface the can be used to relocate a port. This class heavily relies on the implementation of the IEdgePortCandidateProvider that is queried from the IEdge this handle is acting on.

See also

IEdgePortCandidateProvider
getPortCandidates
EdgeDecorator.edgePortCandidateProviderDecorator


Public Properties
 PropertyDefined By
  addExistingPort : Boolean
Gets or sets a property that determines whether the existing port should be available as a possible port candidate, too.
PortRelocationHandle
  cursor : Cursor
[override] Provides the cursor to display when the mouse hovers over or drags this handle.
PortRelocationHandle
 Inheritedlocation : IPoint
[read-only] Returns a view of the location of the item.
EdgeEndMoveHandle
  maximumSnapDistance : Number
Gets or sets the maximum distance the pointer may be away of a candidate in order to be snapped to the candidate.
PortRelocationHandle
  portCandidateResolutionRecognizer : Function
The event recognizer that detects changes to the isPortCandidateResolutionEnabled property.
PortRelocationHandle
  resolvePortCandidates : Boolean
A value indicating whether PortCandidateValidity.DYNAMIC ports that are part of the port candidates should be resolved for the current mouse location.
PortRelocationHandle
 InheritedshowDummyEdge : Boolean
Gets or sets a property that determines whether to show a dummy edge during the drag operation.
EdgeEndMoveHandle
  showHitNodeCandidatesOnly : Boolean
Gets or sets a value indicating whether to show the candidates of hit nodes only.
PortRelocationHandle
  type : uint
[override] Returns the type of the handle that can be used by the rendering engine to render types differently.
PortRelocationHandle
 Inheritedx : Number
[read-only] Gets the current x coordinate of this point.
EdgeEndMoveHandle
 Inheritedy : Number
[read-only] Gets the current y coordinate of this point.
EdgeEndMoveHandle
Protected Properties
 PropertyDefined By
 InheriteddummyEdge : DefaultEdge
[read-only] Gets the dummy edge this instance uses during the edit.
EdgeEndMoveHandle
 Inheritededge : IEdge
[read-only] Gets the edge this instance acts upon.
EdgeEndMoveHandle
 InheritedinputModeContext : IInputModeContext
Gets or sets the context to operate on.
EdgeEndMoveHandle
 InheritedsourceEnd : Boolean
[read-only] Gets a value indicating whether the source end of the edge is handled by this instance.
EdgeEndMoveHandle
Public Methods
 MethodDefined By
  
PortRelocationHandle(graph:IGraph, edge:IEdge, sourceEnd:Boolean)
Creates a new instance.
PortRelocationHandle
  
cancelDrag(context:IInputModeContext, originalX:Number, originalY:Number):void
[override] Called by clients to indicate that the dragging has been canceled by the user.
PortRelocationHandle
  
dragFinished(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number):void
[override] Called by clients to indicate that the repositioning has just been finished.
PortRelocationHandle
  
handleMove(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number):Boolean
[override] Called by clients to indicate that the element has been dragged and its position should be updated.
PortRelocationHandle
  
[override] Called by clients to indicate that the element is going to be dragged.
PortRelocationHandle
Protected Methods
 MethodDefined By
  
configureDummy(dummy:DefaultEdge, edge:IEdge):void
[override] Configures the dummy edge to look like the given edge.
PortRelocationHandle
 Inherited
Factory method that creates the dummy edge that will be shown during the drag operation.
EdgeEndMoveHandle
 Inherited
Factory method that creates a dummy display object creator for the dummy edge during the drag operation.
EdgeEndMoveHandle
  
Factory method that creates the candidate for the existing port.
PortRelocationHandle
  
Factory method that creates the ICanvasObjectDescriptor that will be used to paint the IPortCandidates.
PortRelocationHandle
  
getClosestCandidate(context:IInputModeContext, x:Number, y:Number, candidates:Iterable):IPortCandidate
Finds the closest candidate to the given coordinates from the given set of candidates.
PortRelocationHandle
 Inherited
Gets the graph to use from the context.
EdgeEndMoveHandle
  
getPort(context:IInputModeContext, candidate:IPortCandidate, suggestedLocation:IPoint):IPort
Callback used during dragFinished() This implementation returns the result of IPortCandidate.createInstance() or calls IGraph.addPort() if the result was null.
PortRelocationHandle
  
getPortCandidates(context:IInputModeContext, edge:IEdge, sourcePort:Boolean):Iterable
Gets the possible candidates for the given edge.
PortRelocationHandle
 Inherited
Hides the original edge during the drag operation.
EdgeEndMoveHandle
  
Determines whether for the current gesture port candidate resolution is enabled in the specified context.
PortRelocationHandle
  
Tries to resolve a dynamic port candidate for the given location.
PortRelocationHandle
  
Updates the closest candidate for visual feedback.
PortRelocationHandle
  
setPort(context:IInputModeContext, edge:IEdge, setSourcePort:Boolean, portCandidate:IPortCandidate, suggestedLocation:IPoint):void
Callback that is triggered by dragFinished to actually change the port.
PortRelocationHandle
  
setPorts(context:IInputModeContext, edge:IEdge, sourcePort:IPort, targetPort:IPort):void
Finally sets the ports for the edge to the new values.
PortRelocationHandle
 Inherited
setPosition(x:Number, y:Number):void
Updates the position of the handle.
EdgeEndMoveHandle
  
setToPortCandidate(dummy:DefaultEdge, source:Boolean, candidate:IPortCandidate):void
Updates the dummy edge's visual appearance to reflect the new port candidate.
PortRelocationHandle
 Inherited
Unhides the original edge that was hidden during the drag operation.
EdgeEndMoveHandle
Property Detail
addExistingPortproperty
addExistingPort:Boolean

Gets or sets a property that determines whether the existing port should be available as a possible port candidate, too.

If this property is set to false, getPortCandidates will return only the ports provided by the IPortCandidateProvider in the node's lookup.

The default value is true.


Implementation
    public function get addExistingPort():Boolean
    public function set addExistingPort(value:Boolean):void

See also

cursorproperty 
cursor:Cursor[override]

Provides the cursor to display when the mouse hovers over or drags this handle.


Implementation
    public function get cursor():Cursor
    public function set cursor(value:Cursor):void
maximumSnapDistanceproperty 
maximumSnapDistance:Number

Gets or sets the maximum distance the pointer may be away of a candidate in order to be snapped to the candidate.

The distance is measured in view coordinates.

The default value is 50.0.


Implementation
    public function get maximumSnapDistance():Number
    public function set maximumSnapDistance(value:Number):void
portCandidateResolutionRecognizerproperty 
portCandidateResolutionRecognizer:Function

The event recognizer that detects changes to the isPortCandidateResolutionEnabled property. By default this is set to the EventRecognizers.MODIFIER_SHIFT. recognizer.


Implementation
    public function get portCandidateResolutionRecognizer():Function
    public function set portCandidateResolutionRecognizer(value:Function):void

See also

EventRecognizers
resolvePortCandidatesproperty 
resolvePortCandidates:Boolean

A value indicating whether PortCandidateValidity.DYNAMIC ports that are part of the port candidates should be resolved for the current mouse location.

By default this feature is enabled and the PortCandidateResolutionRecognizer is configured so that the resolution mechanism is used if the user holds the shift modifier during the gesture.

The default value is true.


Implementation
    public function get resolvePortCandidates():Boolean
    public function set resolvePortCandidates(value:Boolean):void

See also

showHitNodeCandidatesOnlyproperty 
showHitNodeCandidatesOnly:Boolean

Gets or sets a value indicating whether to show the candidates of hit nodes only. true if only candidates of hit nodes are shown; otherwise, false.


Implementation
    public function get showHitNodeCandidatesOnly():Boolean
    public function set showHitNodeCandidatesOnly(value:Boolean):void
typeproperty 
type:uint[override]

Returns the type of the handle that can be used by the rendering engine to render types differently.


Implementation
    public function get type():uint
    public function set type(value:uint):void
Constructor Detail
PortRelocationHandle()Constructor
public function PortRelocationHandle(graph:IGraph, edge:IEdge, sourceEnd:Boolean)

Creates a new instance.

Parameters
graph:IGraph — The graph or null. If the graph instance is not specified, the handle will try to receive the graph from the context that is passed in during initializeDrag.
 
edge:IEdge — The edge.
 
sourceEnd:Boolean — if set to true the source end will be subject to relocation, otherwise it will be the target port.
Method Detail
cancelDrag()method
override public function cancelDrag(context:IInputModeContext, originalX:Number, originalY:Number):void

Called by clients to indicate that the dragging has been canceled by the user.

This method may be called after the initial initializeDrag and zero or more invocations of handleMove. Implementations should reset the position of the items they modify to their initial state. Alternatively to this method the dragFinished method might be called.

Parameters

context:IInputModeContext — The context to retrieve information about the drag from.
 
originalX:Number — The value of the x property at the time of initializeDrag.
 
originalY:Number — The value of the y property at the time of initializeDrag.

configureDummy()method 
override protected function configureDummy(dummy:DefaultEdge, edge:IEdge):void

Configures the dummy edge to look like the given edge.

Parameters

dummy:DefaultEdge — The dummy edge that should mimic the given edge.
 
edge:IEdge — The edge to mimic.

createExistingPortCandidate()method 
protected function createExistingPortCandidate(currentPort:IPort):IPortCandidate

Factory method that creates the candidate for the existing port.

Parameters

currentPort:IPort — The port to create a candidate for.

Returns
IPortCandidate — The candidate or null.

See also

createPortCandidateDescriptor()method 
protected function createPortCandidateDescriptor():ICanvasObjectDescriptor

Factory method that creates the ICanvasObjectDescriptor that will be used to paint the IPortCandidates.

Returns
ICanvasObjectDescriptor — The descriptor to use for the rendering in the CanvasComponent.
dragFinished()method 
override public function dragFinished(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number):void

Called by clients to indicate that the repositioning has just been finished. This method may be called after the initial initializeDrag and zero or more invocations of handleMove. Alternatively to this method the cancelDrag method might be called.

Parameters

context:IInputModeContext — The context to retrieve information about the drag from.
 
originalX:Number — The value of the x property at the time of initializeDrag.
 
originalY:Number — The value of the y property at the time of initializeDrag.
 
newX:Number — The value of the x coordinate in the world coordinate system that the client wants the handle to be at. Depending on the implementation the x and y properties or may not be modified to reflect the new value. This is the same value as delivered in the last invocation of handleMove.
 
newY:Number — The value of the y coordinate in the world coordinate system that the client wants the handle to be at. Depending on the implementation the x and y properties or may not be modified to reflect the new value. This is the same value as delivered in the last invocation of handleMove.

getClosestCandidate()method 
protected function getClosestCandidate(context:IInputModeContext, x:Number, y:Number, candidates:Iterable):IPortCandidate

Finds the closest candidate to the given coordinates from the given set of candidates.

Parameters

context:IInputModeContext — The context in for which the closest handle candidate is sought.
 
x:Number — The horizontal location for which to find a candidate.
 
y:Number — The vertical location for which to find a candidate.
 
candidates:Iterable — The current set of candidates

Returns
IPortCandidate — The closes candidate or null.
getPort()method 
protected function getPort(context:IInputModeContext, candidate:IPortCandidate, suggestedLocation:IPoint):IPort

Callback used during dragFinished()

This implementation returns the result of IPortCandidate.createInstance() or calls IGraph.addPort() if the result was null.

Parameters

context:IInputModeContext — The context.
 
candidate:IPortCandidate — The candidate to get a port instance from.
 
suggestedLocation:IPoint — The suggested location for the port.

Returns
IPort — A non-null port instance.

See also

getPortCandidates()method 
protected function getPortCandidates(context:IInputModeContext, edge:IEdge, sourcePort:Boolean):Iterable

Gets the possible candidates for the given edge.

This implementation uses the IEdgePortCandidateProvider from the edge's lookup to retrieve the candidate sets. If addExistingPort is enabled, the existing port will be part of the candidates.

Parameters

context:IInputModeContext — The context that is used to retrieve the candidates for.
 
edge:IEdge — The edge.
 
sourcePort:Boolean — Whether to look for source port candidates.

Returns
Iterable — A non-null iterable over the candidates.

See also

handleMove()method 
override public function handleMove(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number):Boolean

Called by clients to indicate that the element has been dragged and its position should be updated.

This method may be called more than once after an initial initializeDrag and will be followed by either dragFinished or cancelDrag.

Parameters

context:IInputModeContext — The value of the x property at the time of initializeDrag.
 
originalX:Number — The value of the y property at the time of initializeDrag.
 
originalY:Number — The value of the x coordinate in the world coordinate system that the client wants the handle to be at. Depending on the implementation the x property may or may not be modified to reflect the new value.
 
newX:Number — The value of the y coordinate in the world coordinate system that the client wants the handle to be at. Depending on the implementation the y property may or may not be modified to reflect the new value.
 
newY:Number

Returns
Boolean — Whether the move had any visual effect. This is a hint to the engine to optimize invalidation.
initializeDrag()method 
override public function initializeDrag(context:IInputModeContext):void

Called by clients to indicate that the element is going to be dragged.

This call will be followed by one or more calls to handleMove, and a final dragFinished or cancelDrag.

Parameters

context:IInputModeContext — The context to retrieve information about the drag from.

isPortCandidateResolutionEnabled()method 
protected function isPortCandidateResolutionEnabled(context:IInputModeContext):Boolean

Determines whether for the current gesture port candidate resolution is enabled in the specified context.

This implementation checks whether the context is provided by a HandleInputMode, if the portCandidateResolutionRecognizer recognizes its lastMouseEvent and its currentHandles location is equal to this location.

Parameters

context:IInputModeContext — The context to inspect.

Returns
Booleantrue if port candidates may be resolved; otherwise false.

See also

resolveCandidate
HandleInputMode.lastMouseEvent
HandleInputMode.currentHandle
location
resolveCandidate()method 
protected function resolveCandidate(context:IInputModeContext, candidate:IPortCandidate, location:IPoint):IPortCandidate

Tries to resolve a dynamic port candidate for the given location.

Parameters

context:IInputModeContext — The context in which the candidate is resolved.
 
candidate:IPortCandidate — The candidate.
 
location:IPoint — The current location.

Returns
IPortCandidate — A candidate.

See also

IPortCandidate.getPortCandidateAt
setClosestCandidate()method 
protected function setClosestCandidate(closest:IPortCandidate):void

Updates the closest candidate for visual feedback.

Parameters

closest:IPortCandidate

setPort()method 
protected function setPort(context:IInputModeContext, edge:IEdge, setSourcePort:Boolean, portCandidate:IPortCandidate, suggestedLocation:IPoint):void

Callback that is triggered by dragFinished to actually change the port.

Parameters

context:IInputModeContext — The context.
 
edge:IEdge — The edge to change ports.
 
setSourcePort:Boolean — Whether to set the source port. false for target ports.
 
portCandidate:IPortCandidate — The candidate that has been chosen.
 
suggestedLocation:IPoint — The suggested location for the port.

See also

setPorts()method 
protected function setPorts(context:IInputModeContext, edge:IEdge, sourcePort:IPort, targetPort:IPort):void

Finally sets the ports for the edge to the new values.

Parameters

context:IInputModeContext — The context in which the ports are set.
 
edge:IEdge — The edge to set the ports for.
 
sourcePort:IPort — The new source port.
 
targetPort:IPort — The new target port.

setToPortCandidate()method 
protected function setToPortCandidate(dummy:DefaultEdge, source:Boolean, candidate:IPortCandidate):void

Updates the dummy edge's visual appearance to reflect the new port candidate.

Parameters

dummy:DefaultEdge — The dummy edge.
 
source:Boolean — Whether to update the source or target port.
 
candidate:IPortCandidate — The new candidate to indicate.