Packagecom.yworks.canvas.input
Classpublic class NodeEffectInputMode
InheritanceNodeEffectInputMode Inheritance Object
Implements IInputMode, IConcurrentInputMode

This input mode allows to easily create hover effects on nodes.

This is no ready-to-use input mode: one has to extend this class with a custom implementation and override the method drawOverlay. Also, createMouseOverTweenListener and createMouseOutTweenListener have to be overridden to return a custom tween listener.

Despite its name, this input mode can be used to create hover effects for other model items, too.



Public Properties
 PropertyDefined By
  controller : ConcurrencyController
[write-only] Used by clients to provide this instance with a ConcurrencyController.
NodeEffectInputMode
  enabled : Boolean
Whether the input mode is enabled.
NodeEffectInputMode
  mouseOutDuration : uint
The duration of the animation that is triggered when the mouse leaves a node.
NodeEffectInputMode
  mouseOutEasingFunction : Function
The function that determines the interpolation between 0 and 1 for the animation that is triggered when the mouse leaves a node.
NodeEffectInputMode
  mouseOverDuration : uint
The duration of the animation that is triggered when the mouse enters a node.
NodeEffectInputMode
  mouseOverEasingFunction : Function
The function that determines the interpolation between 0 and 1 for the animation that is triggered when the mouse enters a node.
NodeEffectInputMode
  preferredCursor : Cursor
[read-only] Returns the cursor this mode would like to have displayed in the To indicate that this mode does not have any preferences implementations should return null.
NodeEffectInputMode
  useOverlayHitArea : Boolean
Wether to use the overlay as the node's hit area or to query the nodeStyles IBoundsProvider for the node bounds to determine whether the mouse is still hovering over the node.
NodeEffectInputMode
Protected Properties
 PropertyDefined By
  _canvas : GraphCanvasComponent
[read-only] The graph canvas this input mode is installed into.
NodeEffectInputMode
  context : IInputModeContext
[read-only] The context this input mode is installed into.
NodeEffectInputMode
  currentObject : ICanvasObject
The ICanvasObject which is currently hovered over.
NodeEffectInputMode
  overlaySprite : Sprite
The Sprite to draw the effect node on.
NodeEffectInputMode
Public Methods
 MethodDefined By
  
cancel():void
Called by the client to unconditionally cancel all editing.
NodeEffectInputMode
  
Installs this mode into the given canvas.
NodeEffectInputMode
  
stop():Boolean
Called by the client in order to stop a current editing progress.
NodeEffectInputMode
  
Uninstalls this mode from the given canvas.
NodeEffectInputMode
Protected Methods
 MethodDefined By
  
Creates a new IDisplayObjectContext instance which is used by drawNodeStyle as context to render the node.
NodeEffectInputMode
  
createMouseOutTweenListener(overlay:Sprite):Object
Create an object that implements the animation effect triggered when the mouse leaves a node.
NodeEffectInputMode
  
createMouseOverTweenListener(overlay:Sprite):Object
Create an object that implements the animation effect triggered when the mouse is moved over a node.
NodeEffectInputMode
  
Create the sprite that will be used to draw the hover effect.
NodeEffectInputMode
  
drawNodeStyle(node:INode):void
Let the node.style draw itself on the current overlay.
NodeEffectInputMode
  
drawOverlay(canvasObject:ICanvasObject, overlay:Sprite):void
Draw the visual representation of the node during a hover effect.
NodeEffectInputMode
  
endHover():void
End the hovering.
NodeEffectInputMode
  
getHitObject(stageX:Number, stageY:Number):ICanvasObject
Find a canvas object that is hit at the given mouse hover coordinates.
NodeEffectInputMode
  
isOverCanvas(evt:MouseEvent):Boolean
Tests whether the mouse is currently over the canvas.
NodeEffectInputMode
  
overlayMouseDown(event:MouseEvent):void
Called when mouse was pressed over the overlay sprite.
NodeEffectInputMode
  
Sets the user tag provider for a node styled with TemplateNodeStyle.
NodeEffectInputMode
  
Starts the hovering.
NodeEffectInputMode
Property Detail
_canvasproperty
_canvas:GraphCanvasComponent  [read-only]

The graph canvas this input mode is installed into.


Implementation
    protected function get _canvas():GraphCanvasComponent
contextproperty 
context:IInputModeContext  [read-only]

The context this input mode is installed into.


Implementation
    protected function get context():IInputModeContext
controllerproperty 
controller:ConcurrencyController  [write-only]

Used by clients to provide this instance with a ConcurrencyController.

Note that implementations may not depend on this property being set. The controller can be used to acquire and release an input mutex.


Implementation
    public function set controller(value:ConcurrencyController):void
currentObjectproperty 
protected var currentObject:ICanvasObject

The ICanvasObject which is currently hovered over.

May be null if no object is hovered over.

enabledproperty 
enabled:Boolean

Whether the input mode is enabled.

The default value is true.


Implementation
    public function get enabled():Boolean
    public function set enabled(value:Boolean):void
mouseOutDurationproperty 
mouseOutDuration:uint

The duration of the animation that is triggered when the mouse leaves a node.


Implementation
    public function get mouseOutDuration():uint
    public function set mouseOutDuration(value:uint):void
mouseOutEasingFunctionproperty 
mouseOutEasingFunction:Function

The function that determines the interpolation between 0 and 1 for the animation that is triggered when the mouse leaves a node.


Implementation
    public function get mouseOutEasingFunction():Function
    public function set mouseOutEasingFunction(value:Function):void
mouseOverDurationproperty 
mouseOverDuration:uint

The duration of the animation that is triggered when the mouse enters a node.


Implementation
    public function get mouseOverDuration():uint
    public function set mouseOverDuration(value:uint):void
mouseOverEasingFunctionproperty 
mouseOverEasingFunction:Function

The function that determines the interpolation between 0 and 1 for the animation that is triggered when the mouse enters a node.


Implementation
    public function get mouseOverEasingFunction():Function
    public function set mouseOverEasingFunction(value:Function):void
overlaySpriteproperty 
protected var overlaySprite:Sprite

The Sprite to draw the effect node on.

The Sprite is created by createOverlaySprite()

May be null if no effect is displayed.

preferredCursorproperty 
preferredCursor:Cursor  [read-only]

Returns the cursor this mode would like to have displayed in the

To indicate that this mode does not have any preferences implementations should return null.


Implementation
    public function get preferredCursor():Cursor
useOverlayHitAreaproperty 
useOverlayHitArea:Boolean

Wether to use the overlay as the node's hit area or to query the nodeStyles IBoundsProvider for the node bounds to determine whether the mouse is still hovering over the node.


Implementation
    public function get useOverlayHitArea():Boolean
    public function set useOverlayHitArea(value:Boolean):void
Method Detail
cancel()method
public function cancel():void

Called by the client to unconditionally cancel all editing. This will be called prior to the uninstalling of this instance. In order to stop an active input mode manually, client code should use the following idiom:

	     if ( !mode.stop() ){
	       mode.cancel();
	     }
	     

createDisplayObjectContext()method 
protected function createDisplayObjectContext():IDisplayObjectContext

Creates a new IDisplayObjectContext instance which is used by drawNodeStyle as context to render the node.

This context can be used by the node style renderer to draw the effect node differently.

Returns
IDisplayObjectContext
createMouseOutTweenListener()method 
protected function createMouseOutTweenListener(overlay:Sprite):Object

Create an object that implements the animation effect triggered when the mouse leaves a node.

If this method is not overridden, it returns a listener that does nothing except hiding the overlay when the animation has ended.

Parameters

overlay:Sprite — The current overlay.

Returns
Object — An object that implements onTweenUpdate( value:Object ):void and onTweenEnd( value:Object ):void.

The value object will be a number between 0 and 1.

createMouseOverTweenListener()method 
protected function createMouseOverTweenListener(overlay:Sprite):Object

Create an object that implements the animation effect triggered when the mouse is moved over a node.

If this method is not overridden, it returns a listener that does nothing.

Parameters

overlay:Sprite — The current overlay.

Returns
Object — An object that implements onTweenUpdate( value:Object ):void and onTweenEnd( value:Object ):void.

The value object will be a number between 0 and 1.

createOverlaySprite()method 
protected function createOverlaySprite():Sprite

Create the sprite that will be used to draw the hover effect.

This implementation creates a simple sprite and configures it to catch the mouse down events (and call overlayMouseDown()). Subclasses which do further configuration may create the sprite by calling this implementation (var sprite:Sprite = super.createOverlaySprite();).

Returns
Sprite — A new sprite instance.
drawNodeStyle()method 
protected function drawNodeStyle(node:INode):void

Let the node.style draw itself on the current overlay.

Parameters

node:INode — The node that is being hovered.

drawOverlay()method 
protected function drawOverlay(canvasObject:ICanvasObject, overlay:Sprite):void

Draw the visual representation of the node during a hover effect. The normal appearance of the node can conveniently be drawn on the overlay using drawNodeStyle( INode ).

This method should also take care of the correct positioning of the overlay sprite.

Parameters

canvasObject:ICanvasObject — A canvas object that contains the current node as its userObject. This canvas object will usually extend Sprite.
 
overlay:Sprite — The current overlay.

endHover()method 
protected function endHover():void

End the hovering.

Called when the mouse isn't hovering over the node anymore.

This implementation creates a new Tween with a listener created by createMouseOutTweenListener() and an easing function defined by mouseOutTweenEasingFunction. It also releases the mutex.

getHitObject()method 
protected function getHitObject(stageX:Number, stageY:Number):ICanvasObject

Find a canvas object that is hit at the given mouse hover coordinates.

This implementation detects canvas objects for nodes. Custom implementations may verify for other model items.

Parameters

stageX:Number — horizontal stage coordinate of the current mouse hover event
 
stageY:Number — vertical stage coordinate of the current mouse hover

Returns
ICanvasObject — A canvas object that was hit at the given stage coordinates, or null
install()method 
public function install(context:IInputModeContext):void

Installs this mode into the given canvas.

Installation ususally means registering some event listeners on the canvasComponent or on canvasComponent.root.

When this instance gets uninstalled from the context the same context instance will be passed to it.

Implementations may hold a reference to the context instance and use it while they are being installed.

Parameters

context:IInputModeContext — The context that this instance shall be installed into. The same instance will be passed to this instance during uninstall. A reference to the context may be kept and queried during the time the mode is installed.

isOverCanvas()method 
protected function isOverCanvas(evt:MouseEvent):Boolean

Tests whether the mouse is currently over the canvas.

This method is asked by the handler for mouse events befor getHitObject is asked. If the hover effect should be available when the mouse is hovering over a (transparent) object which is not a child of the canvas (e.g. the overview component) this method can be overridden to return always true

Parameters

evt:MouseEvent — The mouse event to test.

Returns
Booleantrue if the mouse is hovering over the canvas.
overlayMouseDown()method 
protected function overlayMouseDown(event:MouseEvent):void

Called when mouse was pressed over the overlay sprite.

Implementations can use this callback to detect mouse clicks on the overlay.

This implementation stops the event from propagation. Otherwise, the canvas would handle the mouse clicks as if there was no overlay.

Parameters

event:MouseEvent — The mouse event.

setUserTagProvider()method 
protected function setUserTagProvider(node:INode, dummy:INode, style:TemplateNodeStyle):void

Sets the user tag provider for a node styled with TemplateNodeStyle.

This method is called by drawNodeStyle when the hovered node is styled using TemplateNodeStyle. Its purpose is to ensure that the renderer for the dummy node gets the user tag for the original node.

This implementation copies the user tag of the original node by reference if the style's userTagProvider is of type TagOwnerUserTagProvider, otherwise it wraps the tag provider. This should work in most cases.

Parameters

node:INode — The original node.
 
dummy:INode — A dummy node which is drawn on the overlay.
 
style:TemplateNodeStyle — The template style instance of the dummy node. Actually, it's a clone of the original node's style.

startHover()method 
protected function startHover(newObj:ICanvasObject):void

Starts the hovering.

Called when the mouse hovers over a new node.

This implementation creates the overlaySprite using createOverlaySprite() and a new Tween with a listener created by createMouseOverTweenListener() and an easing function defined by mouseOverTweenEasingFunction. It also requests the mutex.

Parameters

newObj:ICanvasObject — The canvas object the mouse is hovering over.

stop()method 
public function stop():Boolean

Called by the client in order to stop a current editing progress. This should stop the current edit, if one is in progress and possibly commit all of the changes. If stopping is not possible, this method can return false

Returns
Booleantrue if and only if the editing has been stopped or there was no edit in progress
uninstall()method 
public function uninstall(context:IInputModeContext):void

Uninstalls this mode from the given canvas. This code should clean up all changes made to the canvas in the install method. After a mode has been uninstalled it can be installed again into the same or another canvas.

Parameters

context:IInputModeContext — The context to deregister from. This is the same instance that had been passed to install during installation.