Packagecom.yworks.graph.model
Classpublic class PortRelocationHandle
ImplementsIHandle, IPoint

A sophisticated implementation of the IHandle interface the can be used to relocate a port.



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
Provides the cursor to display when the mouse hovers over or drags this handle.
PortRelocationHandle
  dummyEdge : DefaultEdge
[read-only]
PortRelocationHandle
  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
  showDummyEdge : Boolean
Gets or sets a property that determines whether to show a dummy edge during the drag operation.
PortRelocationHandle
  type : uint
Returns a view of the center of the handle.
PortRelocationHandle
  x : Number
[read-only] Gets the current x coordinate of this point.
PortRelocationHandle
  y : Number
[read-only] Gets the current y coordinate of this point.
PortRelocationHandle
Public Methods
 MethodDefined by
  
PortRelocationHandle(graph:IGraph, edge:IEdge, sourcePort:Boolean)
Creates a new instance.
PortRelocationHandle
  
cancelDrag(context:IInputModeContext, originalX:Number, originalY:Number):void
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
Called by clients to indicate that the repositioning has just been finished.
PortRelocationHandle
  
handleMove(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number, dx:Number, dy:Number):Boolean
Called by clients to indicate that the element has been dragged and its position should be updated.
PortRelocationHandle
  
Called by clients to indicate that the element is going to be dragged.
PortRelocationHandle
  
setPosition(x:Number, y:Number):void
Updates the position of the handle.
PortRelocationHandle
Protected Methods
 MethodDefined by
  
configureDummy(dummy:DefaultEdge, edge:IEdge):void
Configures the dummy edge to look like the given edge.
PortRelocationHandle
  
Factory method that creates the dummy edge that will be shown during the drag operation.
PortRelocationHandle
  
Factory method that creates a dummy paintable for the dummy edge during the drag operation.
PortRelocationHandle
  
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(x:Number, y:Number, candidates:Iterable):IPortCandidate
Finds the closest candidate to the given coordinates from the given set of candidates.
PortRelocationHandle
  
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
  
Hides the original edge that during the drag operation.
PortRelocationHandle
  
Updates the closes candidate for visual feedback.
PortRelocationHandle
  
setPorts(edge:IEdge, sourcePort:IPort, targetPort:IPort):void
Finally sets the ports for the edge to the new values.
PortRelocationHandle
  
setToPortCandidate(dummy:DefaultEdge, source:Boolean, candidate:IPortCandidate):void
Updates the dummy edge's visual appearance to reflect the new port candidate.
PortRelocationHandle
  
Unhides the original edge that was hidden during the drag operation.
PortRelocationHandle
Property detail
addExistingPortproperty
addExistingPort:Boolean  [read-write]

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  [read-write]

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
dummyEdgeproperty 
dummyEdge:DefaultEdge  [read-only]Implementation
    public function get dummyEdge():DefaultEdge
maximumSnapDistanceproperty 
maximumSnapDistance:Number  [read-write]

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
showDummyEdgeproperty 
showDummyEdge:Boolean  [read-write]

Gets or sets a property that determines whether to show a dummy edge during the drag operation.

The default value is true.

Implementation
    public function get showDummyEdge():Boolean
    public function set showDummyEdge(value:Boolean):void
typeproperty 
type:uint  [read-write]

Returns a view of the center of the handle.

The point describes the current world coordinate of the element that can be modified by this handle.

Implementation
    public function get type():uint
    public function set type(value:uint):void
xproperty 
x:Number  [read-only]

Gets the current x coordinate of this point.

Depending on context the values returned may change over time.

Implementation
    public function get x():Number
yproperty 
y:Number  [read-only]

Gets the current y coordinate of this point.

Depending on context the values returned may change over time.

Implementation
    public function get y():Number
Constructor detail
PortRelocationHandle()constructor
public function PortRelocationHandle(graph:IGraph, edge:IEdge, sourcePort:Boolean)

Creates a new instance.

Parameters
graph:IGraph — The graph or null. If the graph is null, the handle will try to receive the graph from the canvas that is passed to initializeDrag.
 
edge:IEdge — The edge.
 
sourcePort:Boolean — if set to true the source port will be subject to relocation, otherwise it will be the target port.
Method detail
cancelDrag()method
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 canvas in which the element is being repositioned.
 
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 
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.

See also

createDummyEdge()method 
protected function createDummyEdge():DefaultEdge

Factory method that creates the dummy edge that will be shown during the drag operation.

Returns
DefaultEdge — The dummy edge instance to use.

See also

createDummyEdgePaintable()method 
protected function createDummyEdgePaintable(dummy:DefaultEdge):IPaintable

Factory method that creates a dummy paintable for the dummy edge during the drag operation.

Parameters
dummy:DefaultEdge — The dummy edge to create a paintable for.

Returns
IPaintable — A paintable that shows the dummy edge.

See also

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 
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 canvas in which the element is being repositioned.
 
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(x:Number, y:Number, candidates:Iterable):IPortCandidate

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

Parameters
x:Number — The current set of candidates
 
y:Number
 
candidates:Iterable

Returns
IPortCandidate
getPort()method 
protected function getPort(candidate:IPortCandidate):IPort

Callback used during dragFinished()

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

Parameters
candidate:IPortCandidate — The candidate to get a port instance from.

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 canvas.
 
edge:IEdge — The edge.
 
sourcePort:Boolean — Whether to look for source port candidates.

Returns
Iterable — A non-null iterable over the candidates.
handleMove()method 
public function handleMove(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number, dx:Number, dy: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 — The delta of the x coordinates since the last call to this method.
 
dx:Number — The delta of the y coordinates since the last call to this method.
 
dy:Number

Returns
Boolean — Whether the move had any visual effect. This is a hint to the engine to optimize invalidation.
hideOriginalEdge()method 
protected function hideOriginalEdge(canvas:CanvasComponent, edge:IEdge):void

Hides the original edge that during the drag operation.

Parameters
canvas:CanvasComponent — The edge to hide.
 
edge:IEdge — The canvas to hide the edge from.

See also

initializeDrag()method 
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 canvas in which the element is going to be repositioned.
setClosestCandidate()method 
protected function setClosestCandidate(closest:IPortCandidate):void

Updates the closes candidate for visual feedback.

Parameters
closest:IPortCandidate
setPorts()method 
protected function setPorts(edge:IEdge, sourcePort:IPort, targetPort:IPort):void

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

Parameters
edge:IEdge — The edge to set the ports for.
 
sourcePort:IPort — The new source port.
 
targetPort:IPort — The new target port.
setPosition()method 
public function setPosition(x:Number, y:Number):void

Updates the position of the handle.

Parameters
x:Number
 
y:Number
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.
unhideOriginalEdge()method 
protected function unhideOriginalEdge(edge:IEdge, canvas:CanvasComponent):void

Unhides the original edge that was hidden during the drag operation.

Parameters
edge:IEdge — The edge to unhide.
 
canvas:CanvasComponent — The canvas the edge was hidden from.

See also