Packagecom.yworks.canvas
Classpublic class CanvasComponent
InheritanceCanvasComponent Inheritance mx.core.UIComponent
ImplementsILookup
SubclassesGraphCanvasComponent, GraphOverviewComponent

A basic UI component for showing canvas objects.



Public Properties
 PropertyDefined by
  autoDrag : Boolean
Gets or sets a property that causes the canvas to automatically pan the view when the mouse gets dragged within the autoDragInsets of the canvas.
CanvasComponent
  autoDragInsets : ImmutableRectangle
Gets or sets the auto drag insets.
CanvasComponent
  autoMouseWheelZoom : Boolean
Determines whether the mouse wheel should be used for zooming.
CanvasComponent
  backgroundAlpha : Number
[write-only] Sets the alpha value of the canvas background color.
CanvasComponent
  backgroundColor : uint
[write-only] Sets the background color of the canvas.
CanvasComponent
  center : Point
The world coordinate at the center of the canvas component.
CanvasComponent
  contentRect : Rectangle
Gets and sets the Rectangle in world coordinates that holds the contents.
CanvasComponent
  context : ICanvasContext
[read-only] Returns an implementation of ICanvasContext that describes the state of this canvas control.
CanvasComponent
  cursor : Cursor
Get or set the cursor instance that will be displayed for this canvas.
CanvasComponent
  doubleClickSize : ISize
The size of the area within which the user must click twice for the two clicks to be considered a double-click.
CanvasComponent
  doubleClickTime : int
The time that may elapse between two consecutive mouse clicks so the last click is still considered a double click.
CanvasComponent
  dragSize : ISize
The area in view coordinates the mouse may stay in before a movement is considered a drag.
CanvasComponent
  dragTime : int
The value of the drag time.
CanvasComponent
  editable : Boolean
Property that sets the editable state of this canvas.
CanvasComponent
  hitTestRadius : Number
Specifies the radius of the area around the mouse in view coordinates in which an IHitTestable may lie to be considered a valid hit.
CanvasComponent
  horizontalLineScrollSize : Number
The amount to scroll when an arrow button of the horizontal scrollbar is pressed, in pixels.
CanvasComponent
  horizontalPageScrollSize : Number
Specifies the amount to scroll when the horizontal scroll bar track is pressed, in pixels.
CanvasComponent
  horizontalScrollPolicy : String
Specifies the visibility policy for the horizontal scrollbar.
CanvasComponent
  horizontalScrollPosition : Number
The current position of the horizontal scroll bar.
CanvasComponent
  inputMode : IInputMode
Specifies the single IInputMode instance that shall be installed for this canvas.
CanvasComponent
  inputModeContext : IInputModeContext
The InputModeContext property.
CanvasComponent
  inputModeContextLookupChain : LookupChain
[read-only] Retrieves the LookupChain that can be used to decorate the lookup call in the inputModeContext.
CanvasComponent
  inputModes : List
[read-only] Returns the internal list of currently installed IInputModes.
CanvasComponent
  lastCanvasMouseEvent : CanvasMouseEvent
[read-only] Gets the last CanvasMouseEvent that was dispatched by this instance.
CanvasComponent
  maxZoom : Number
The maxZoom property.
CanvasComponent
  minZoom : Number
The minZoom property.
CanvasComponent
  mouseWheelZoomFactor : Number
The factor by which the zoom level changes when the mouse wheel is turned.
CanvasComponent
  treeDirty : Boolean
Property that determines whether the whole canvasObjectTree is redrawn upon the next invocation of updateDisplayList().
CanvasComponent
  treePartiallyDirty : Boolean
Property that determines whether the canvasObjectTree is redrawn partially upon the next invocation of updateDisplayList().
CanvasComponent
  verticalLineScrollSize : Number
The amount to scroll when an arrow button of the vertical scrollbar is pressed, in pixels.
CanvasComponent
  verticalPageScrollSize : Number
Specifies the amount to scroll when the vertical scroll bar track is pressed, in pixels.
CanvasComponent
  verticalScrollPolicy : String
Specifies the visibility policy for the vertical scrollbar.
CanvasComponent
  verticalScrollPosition : Number
The current position of the vertical scroll bar.
CanvasComponent
  viewPoint : Point
The current view point.
CanvasComponent
  viewPort : IRectangle
[read-only] Returns the currently visible viewing region in world coordinates.
CanvasComponent
  zoom : Number
The zoom factor for this canvas control.
CanvasComponent
  zoomIfCanvasHit : Boolean
Whether the mouse wheel triggers zooming whenever the mouse is over the canvas area (true) or whether the canvas needs focus to trigger zooming (false).
CanvasComponent
Protected Properties
 PropertyDefined by
  _viewPoint : Point
CanvasComponent
Public Methods
 MethodDefined by
  
Constructor.
CanvasComponent
  
addCanvasObject(userObject:Object, descriptor:ICanvasObjectDescriptor = null, group:ICanvasObjectGroup = null):ICanvasObject
Adds an element to the internal canvas object tree to the specified group.
CanvasComponent
  
Adds a new ICanvasObjectGroup to the root of the canvas object tree.
CanvasComponent
  
Adds a new ICanvasObjectGroup to the specified group in the current canvas object tree.
CanvasComponent
  
Adds an IPaintable instance to the scene graph using CanvasObjectDescriptor.Instance as the ICanvasObjectDescriptor.
CanvasComponent
  
collectCanvasObjects(x:Number, y:Number, elementFoundCallback:Function):void
Collects all canvas object instances that are hit at the given coordinate set.
CanvasComponent
  
createSprite():Sprite
Creates a sprite containing a complete copy of the current canvas object tree.
CanvasComponent
  
fitContent():void
Adjusts the view port to fully encompass the current content rectangle.
CanvasComponent
  
Updates the content rectangle and adjusts the viewport to encompass the contents.
CanvasComponent
  
forceRepaint():void
Invalidates this canvas component and causes a repaint of all display objects that are visible in this canvas component.
CanvasComponent
  
getCanvasObject(worldX:Number, worldY:Number):ICanvasObject
Returns the top most canvas object instance that is hit at the given coordinate set.
CanvasComponent
  
getCanvasObjects(worldX:Number, worldY:Number):Iterable
Returns a list of all canvas objects in hit order at the given world coordinate location.
CanvasComponent
  
getCanvasRect():Rectangle
Returns a rectangle defined by the available space for displaying the CanvasObjectTree within this Component, in stage coordinates.
CanvasComponent
  
getHits(stageX:Number, stageY:Number, useShape:Boolean = true):Array
Returns an array of ICanvasObjects that are hit by the given coords.
CanvasComponent
  
Marks a component so that its updateDisplayList() method gets called during a later screen update.
CanvasComponent
  
isCanvasHit(target:DisplayObject, stageX:Number, stageY:Number):Boolean
Checks whether the point at stageX,stageY is within the canvas bounds and target is a child of the canvas.
CanvasComponent
  
iterateHits(x:Number, y:Number, root:ICanvasObjectGroup = null, filter:Function = null):Iterator
Iterates all hit elements in the canvas below the given group that are accepted by a given filter.
CanvasComponent
  
lookup(type:Class):Object
CanvasComponent
  
print(bitmap:Boolean = true, borderSize:uint = 5, backgroundFill:* = 0xFFFFFF):void
Prints the current canvas object tree.
CanvasComponent
  
Converts a point in world coordinates to view coordinates.
CanvasComponent
  
Converts a point in view coordinates to world coordinates.
CanvasComponent
  
updateContentRect(margins:IRectangle = null):void
Updates the contentRect to encompass the bounds by all elements in the current scene graph upon the next invocation of updateDisplayList.
CanvasComponent
  
zoomTo(px:Number, py:Number, theZoom:Number):void
Sets the zoom level and view port center to the given values.
CanvasComponent
Protected Methods
 MethodDefined by
  
Adjusts the mouse cursor based on the given mouse event and the cursor property.
CanvasComponent
  
CanvasComponent
  
Factory method for the InputModeContext property.
CanvasComponent
  
disposeListeners(eventDispatcher:IEventDispatcher):void
Unregister all event listeners that were registered with the stage.
CanvasComponent
  
initListeners(eventDispatcher:IEventDispatcher):void
Initialize all event listeners that should be registered with the stage.
CanvasComponent
  
inputModeContextLookup(type:Class):Object
Callback that is used by the default implementation of inputModeContext to resolve lookup calls.
CanvasComponent
  
If the autoMouseWheelZoom property is set to true, this method will adjust the current zoom level.
CanvasComponent
  
onAdd(event:FlexEvent):void
Called when the component is added to the display list.
CanvasComponent
  
onAutoDragChanged(oldValue:Boolean, newValue:Boolean):void
Called when the autoDrag property changes.
CanvasComponent
  
Called when the autoDragInsets property changes.
CanvasComponent
  
Callback method that is called when the mouse has been clicked.
CanvasComponent
  
Callback method that is called when a mouse button has been pressed.
CanvasComponent
  
Callback method that is called when the mouse gets dragged.
CanvasComponent
  
Callback method that is called when the mouse has been moved and the mouse button has not been pressed.
CanvasComponent
  
Callback method that is called when a mouse button has been released.
CanvasComponent
  
Callback method that is called when the mouse wheel has been turned.
CanvasComponent
  
Callback that is invoked when the ContentRect property changes.
CanvasComponent
  
Callback that is called when the editable property changes.
CanvasComponent
  
onHitTestRadiusChanged(oldValue:Number, newValue:Number):void
Callback that is invoked when the hitTestRadius property changed.
CanvasComponent
  
onInputModeChanged(oldValue:IInputMode, newValue:IInputMode):void
Callback that is invoked when the inputMode property changes.
CanvasComponent
  
onInputModeContextChanged(oldInputModeContext:IInputModeContext, newInputModeContext:IInputModeContext):void
Called when the inputModeContext property value changes and after initialization of the field.
CanvasComponent
  
onMouseDown(evt:MouseEvent):void
Tries to gain the focus, if the canvas area was hit.
CanvasComponent
  
onMouseMove(evt:MouseEvent):void
Calls onCanvasMouseDragged or onCanvasMouseMoved with the corresponding CanvasMouseEvent.
CanvasComponent
  
onMouseUp(evt:MouseEvent):void
Calls onCanvasMouseUp and possibly onCanvasMouseClicked with the corresponding CanvasMouseEvent.
CanvasComponent
  
onMouseWheel(evt:MouseEvent):void
Calls onCanvasMouseWheel with the corresponding CanvasMouseEvent.
CanvasComponent
  
onRemove(event:FlexEvent):void
Called when the component is removed from the display list.
CanvasComponent
  
Callback that is invoked when the view port property changes.
CanvasComponent
  
updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
CanvasComponent
  
updateTree(partially:Boolean = false):void
Repaints the display list
CanvasComponent
  
update the viewport bounds upon the next invocation of updateDisplayList.
CanvasComponent
Events
 EventSummaryDefined by
   Dispatched when the autoDrag property changes.CanvasComponent
   Dispatched when the autoDragInsets property changes.CanvasComponent
   Dispatched when the mouse is clicked.CanvasComponent
   Dispatched when the mouse is double clicked.CanvasComponent
   Dispatched when the mouse is pressed.CanvasComponent
   Dispatched when the mouse is dragged.CanvasComponent
   Dispatched when the mouse is moved.CanvasComponent
   Dispatched when the mouse is released.CanvasComponent
   Dispatched when the mousewheel moves.CanvasComponent
   Dispatched when the contentRect property changes.CanvasComponent
   Dispatched when the editable property changes.CanvasComponent
   Dispatched when the inputMode property changes.CanvasComponent
   Dispatched when the inputModeContext property changes.CanvasComponent
   Dispatched when the canvas has been invalidated.CanvasComponent
   Dispatched when one of the scrollbars changes its scroll position.CanvasComponent
   Dispatched when the viewPoint property changes.CanvasComponent
   Dispatched when the viewPort property changes.CanvasComponent
   Dispatched when the zoom property changes.CanvasComponent
Public Constants
 ConstantDefined by
  AUTO_DRAG_CHANGED : String = "autoDragChanged"
[static]
CanvasComponent
  AUTO_DRAG_INSETS_CHANGED : String = "autoDragInsetsChanged"
[static]
CanvasComponent
  CONTENT_RECT_CHANGED : String = "contentRectChanged"
[static]
CanvasComponent
  EDITABLE_CHANGED : String = "editableChanged"
[static]
CanvasComponent
  INPUT_MODE_CHANGED : String = "inputModeChanged"
[static]
CanvasComponent
  INPUT_MODE_CONTEXT_CHANGED : String = "inputModeContextChanged"
[static]
CanvasComponent
  INVALIDATED : String = "invalidated"
[static]
CanvasComponent
  VIEWPORT_CHANGED : String = "viewPortChanged"
[static]
CanvasComponent
Property detail
autoDragproperty
autoDrag:Boolean  [read-write]

Gets or sets a property that causes the canvas to automatically pan the view when the mouse gets dragged within the autoDragInsets of the canvas.

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

See also

autoDragInsetsproperty 
autoDragInsets:ImmutableRectangle  [read-write]

Gets or sets the auto drag insets.

If the mouse is being dragged within the insets of the canvas specified using this field, the control will automatically scroll.

Implementation
    public function get autoDragInsets():ImmutableRectangle
    public function set autoDragInsets(value:ImmutableRectangle):void

See also

autoMouseWheelZoomproperty 
autoMouseWheelZoom:Boolean  [read-write]

Determines whether the mouse wheel should be used for zooming. If set to false this task can be performed by custom IInputMode implementations using the CanvasMouseEvent of type CanvasMouseEvent.CANVAS_MOUSE_WHEEL.

The default value is true.

Implementation
    public function get autoMouseWheelZoom():Boolean
    public function set autoMouseWheelZoom(value:Boolean):void
backgroundAlphaproperty 
backgroundAlpha:Number  [write-only]

Sets the alpha value of the canvas background color.

The default value is 1.0.

Implementation
    public function set backgroundAlpha(value:Number):void
backgroundColorproperty 
backgroundColor:uint  [write-only]

Sets the background color of the canvas.

Implementation
    public function set backgroundColor(value:uint):void
centerproperty 
center:Point  [read-write]

The world coordinate at the center of the canvas component.

Can be used to move the view port.

Implementation
    public function get center():Point
    public function set center(value:Point):void
contentRectproperty 
contentRect:Rectangle  [read-write]

Gets and sets the Rectangle in world coordinates that holds the contents.

This influences the display of the scroll bars. If the content rectangle is not currently visible in the viewport, scroll bars will be displayed, unless they are turned off completely.

Implementation
    public function get contentRect():Rectangle
    public function set contentRect(value:Rectangle):void
contextproperty 
context:ICanvasContext  [read-only]

Returns an implementation of ICanvasContext that describes the state of this canvas control.

Implementation
    public function get context():ICanvasContext
cursorproperty 
cursor:Cursor  [read-write]

Get or set the cursor instance that will be displayed for this canvas.

The cursor is shown if the mouse pointer is currently located in the canvas area or if the user started a dragging gesture over the canvas.

Note that when this property is set, cursorManager.removeAllCursors() will be called to ensure that the new cursor is actually displayed.

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

See also

doubleClickSizeproperty 
doubleClickSize:ISize  [read-write]

The size of the area within which the user must click twice for the two clicks to be considered a double-click.

Implementation
    public function get doubleClickSize():ISize
    public function set doubleClickSize(value:ISize):void

See also

doubleClickTimeproperty 
doubleClickTime:int  [read-write]

The time that may elapse between two consecutive mouse clicks so the last click is still considered a double click.

Implementation
    public function get doubleClickTime():int
    public function set doubleClickTime(value:int):void

See also

dragSizeproperty 
dragSize:ISize  [read-write]

The area in view coordinates the mouse may stay in before a movement is considered a drag. If the mouse is moved within this area longer than dragTime milliseconds, the movement will be considered a drag, nevertheless The larger the area the later a mouse movement will be recognized as a drag. This influences the click-sensitivity, since a mouse button release is only considered a click if there was no drag since the last mouse button press.

The default value is (5,5).

Implementation
    public function get dragSize():ISize
    public function set dragSize(value:ISize):void

See also

dragTimeproperty 
dragTime:int  [read-write]

The value of the drag time. This value indicates the amount of time in milliseconds that may pass before a mouse movement is considered a drag when the mouse stays within its dragSize area. The higher the value the later a mouse movement will be recognized as a drag. This influences the click-sensitivity, since a mouse button release is only considered a click if there was no drag since the last mouse button press.

The default value is 300.

Implementation
    public function get dragTime():int
    public function set dragTime(value:int):void

See also

editableproperty 
editable:Boolean  [read-write]

Property that sets the editable state of this canvas.

IInputMode implementations should honor this property. Events will still be delivered to the IInputModes, however they should not modify the model.

Implementation
    public function get editable():Boolean
    public function set editable(value:Boolean):void
hitTestRadiusproperty 
hitTestRadius:Number  [read-write]

Specifies the radius of the area around the mouse in view coordinates in which an IHitTestable may lie to be considered a valid hit.

This value can be queried from within the IHitTestable implementation from the ICanvasContext.hitTestRadius

The default value is 4.0.

Implementation
    public function get hitTestRadius():Number
    public function set hitTestRadius(value:Number):void
horizontalLineScrollSizeproperty 
horizontalLineScrollSize:Number  [read-write]

The amount to scroll when an arrow button of the horizontal scrollbar is pressed, in pixels.

Implementation
    public function get horizontalLineScrollSize():Number
    public function set horizontalLineScrollSize(value:Number):void
horizontalPageScrollSizeproperty 
horizontalPageScrollSize:Number  [read-write]

Specifies the amount to scroll when the horizontal scroll bar track is pressed, in pixels.

Implementation
    public function get horizontalPageScrollSize():Number
    public function set horizontalPageScrollSize(value:Number):void
horizontalScrollPolicyproperty 
horizontalScrollPolicy:String  [read-write]

Specifies the visibility policy for the horizontal scrollbar.

Implementation
    public function get horizontalScrollPolicy():String
    public function set horizontalScrollPolicy(value:String):void

See also

mx.core.ScrollPolicy
horizontalScrollPositionproperty 
horizontalScrollPosition:Number  [read-write]

The current position of the horizontal scroll bar. This is equal to the distance in pixels between the left edge of the scrollable surface and the leftmost piece of the surface that is currently visible.

The default value is 0.

Implementation
    public function get horizontalScrollPosition():Number
    public function set horizontalScrollPosition(value:Number):void
inputModeproperty 
inputMode:IInputMode  [read-write]

Specifies the single IInputMode instance that shall be installed for this canvas.

Implementation
    public function get inputMode():IInputMode
    public function set inputMode(value:IInputMode):void
inputModeContextproperty 
inputModeContext:IInputModeContext  [read-write]

The InputModeContext property.

This context object is passed to IInputMode instances during installation and removal.

If the field has not yet been initialized upon first access, the factory method createInputModeContext will be called.

Upon change the onInputModeContextChanged method will be called.

Implementation
    public function get inputModeContext():IInputModeContext
    public function set inputModeContext(value:IInputModeContext):void

See also

inputModeContextLookupChainproperty 
inputModeContextLookupChain:LookupChain  [read-only]

Retrieves the LookupChain that can be used to decorate the lookup call in the inputModeContext.

Implementation
    public function get inputModeContextLookupChain():LookupChain
inputModesproperty 
inputModes:List  [read-only]

Returns the internal list of currently installed IInputModes.

This is a mutable list. To install new instances simply add them to the list and remove them to uninstall them.

Implementation
    public function get inputModes():List

See also

lastCanvasMouseEventproperty 
lastCanvasMouseEvent:CanvasMouseEvent  [read-only]

Gets the last CanvasMouseEvent that was dispatched by this instance.

Implementation
    public function get lastCanvasMouseEvent():CanvasMouseEvent
maxZoomproperty 
maxZoom:Number  [read-write]

The maxZoom property.

The zoom property cannot be set to a value greater than maxZoom.

The default value is 500.

Implementation
    public function get maxZoom():Number
    public function set maxZoom(value:Number):void
minZoomproperty 
minZoom:Number  [read-write]

The minZoom property.

The zoom property cannot be set to a value less than minZoom.

Implementation
    public function get minZoom():Number
    public function set minZoom(value:Number):void
mouseWheelZoomFactorproperty 
mouseWheelZoomFactor:Number  [read-write]

The factor by which the zoom level changes when the mouse wheel is turned. The default value is 1.2.

Implementation
    public function get mouseWheelZoomFactor():Number
    public function set mouseWheelZoomFactor(value:Number):void
treeDirtyproperty 
treeDirty:Boolean  [read-write]

Property that determines whether the whole canvasObjectTree is redrawn upon the next invocation of updateDisplayList().

Implementation
    public function get treeDirty():Boolean
    public function set treeDirty(value:Boolean):void
treePartiallyDirtyproperty 
treePartiallyDirty:Boolean  [read-write]

Property that determines whether the canvasObjectTree is redrawn partially upon the next invocation of updateDisplayList().

Implementation
    public function get treePartiallyDirty():Boolean
    public function set treePartiallyDirty(value:Boolean):void
verticalLineScrollSizeproperty 
verticalLineScrollSize:Number  [read-write]

The amount to scroll when an arrow button of the vertical scrollbar is pressed, in pixels.

Implementation
    public function get verticalLineScrollSize():Number
    public function set verticalLineScrollSize(value:Number):void
verticalPageScrollSizeproperty 
verticalPageScrollSize:Number  [read-write]

Specifies the amount to scroll when the vertical scroll bar track is pressed, in pixels.

Implementation
    public function get verticalPageScrollSize():Number
    public function set verticalPageScrollSize(value:Number):void
verticalScrollPolicyproperty 
verticalScrollPolicy:String  [read-write]

Specifies the visibility policy for the vertical scrollbar.

Implementation
    public function get verticalScrollPolicy():String
    public function set verticalScrollPolicy(value:String):void

See also

mx.core.ScrollPolicy
verticalScrollPositionproperty 
verticalScrollPosition:Number  [read-write]

The current position of the vertical scroll bar. This is equal to the distance in pixels between the top edge of the scrollable surface and the topmost piece of the surface that is currently visible.

The default value is 0.

Implementation
    public function get verticalScrollPosition():Number
    public function set verticalScrollPosition(value:Number):void
_viewPointproperty 
protected var _viewPoint:Point
viewPointproperty 
viewPoint:Point  [read-write]

The current view point. The view point is the point in world coordinates that is mapped to the top left corner point in the current viewport.

Implementation
    public function get viewPoint():Point
    public function set viewPoint(value:Point):void
viewPortproperty 
viewPort:IRectangle  [read-only]

Returns the currently visible viewing region in world coordinates.

Implementation
    public function get viewPort():IRectangle
zoomproperty 
zoom:Number  [read-write]

The zoom factor for this canvas control.

A zoom level of 1.0 will make each unit in world-coordinate space appear exactly one unit in screen coordinates wide.

If this property is written, the canvas will zoom to the new value while keeping the center of view at the same world coordinates.

The default value is 1.0.

This property can be used as the source for data binding.

Implementation
    public function get zoom():Number
    public function set zoom(value:Number):void
zoomIfCanvasHitproperty 
zoomIfCanvasHit:Boolean  [read-write]

Whether the mouse wheel triggers zooming whenever the mouse is over the canvas area (true) or whether the canvas needs focus to trigger zooming (false).

When the canvas component has focus, the mouse wheel will always trigger zooming.

The default value is true.

Implementation
    public function get zoomIfCanvasHit():Boolean
    public function set zoomIfCanvasHit(value:Boolean):void
Constructor detail
CanvasComponent()constructor
public function CanvasComponent()

Constructor.

Method detail
addCanvasObject()method
public function addCanvasObject(userObject:Object, descriptor:ICanvasObjectDescriptor = null, group:ICanvasObjectGroup = null):ICanvasObject

Adds an element to the internal canvas object tree to the specified group.

The descriptor will be queried for the various implementations for the given userObject at rendering time.

Parameters
userObject:Object — The object to be added
 
descriptor:ICanvasObjectDescriptor (default = null) — the descriptor related to the object
 
group:ICanvasObjectGroup (default = null) — The canvas object group related to the object

Returns
ICanvasObject — An ICanvasObject that can be used to control the rendering order and to later remove the element from the tree.
addGroup()method 
public function addGroup():ICanvasObjectGroup

Adds a new ICanvasObjectGroup to the root of the canvas object tree.

Returns
ICanvasObjectGroup — The newly created group.
addGroupToGroup()method 
public function addGroupToGroup(toGroup:ICanvasObjectGroup):ICanvasObjectGroup

Adds a new ICanvasObjectGroup to the specified group in the current canvas object tree. Can be used to build hgroups of ICanvasObject's that can be moved within the canvas object tree.

Parameters
toGroup:ICanvasObjectGroup — the group to add the new group to.

Returns
ICanvasObjectGroup — the newly created group.
addInputMode()method 
yworks_internal function addInputMode(mode:IInputMode):voidParameters
mode:IInputMode
addPaintable()method 
public function addPaintable(paintable:IPaintable, group:ICanvasObjectGroup = null):ICanvasObject

Adds an IPaintable instance to the scene graph using CanvasObjectDescriptor.Instance as the ICanvasObjectDescriptor. This method is equivalent to calling addCanvasObject(object,ICanvasObjectDescriptor) with CanvasObjectDescriptor.instance as the second argument an a non-null first argument.

Parameters
paintable:IPaintable — The paintable instance to use
 
group:ICanvasObjectGroup (default = null)

Returns
ICanvasObject — Tthe handle for the newly created scene graph element
adjustCursor()method 
protected function adjustCursor(evt:CanvasMouseEvent):void

Adjusts the mouse cursor based on the given mouse event and the cursor property.

Parameters
evt:CanvasMouseEvent
collectCanvasObjects()method 
public function collectCanvasObjects(x:Number, y:Number, elementFoundCallback:Function):void

Collects all canvas object instances that are hit at the given coordinate set.

Parameters
x:Number — the x coordinate of the query in the world coordinate system
 
y:Number — the y coordinate of the query in the world coordinate system
 
elementFoundCallback:Function — A callback that is called when a canvas object is considered a hit. the callback takes an ICanvasObject as a parameter.
createChildren()method 
protected override function createChildren():void

createInputModeContext()method 
protected function createInputModeContext():IInputModeContext

Factory method for the InputModeContext property. This method will be called upon first access to the inputModeContext property.

Returns
IInputModeContext — A new instance of IInputModeContext that has this instance set as it's canvasComponent and uses this instance's inputModeContextLookup for lookup queries.
createSprite()method 
public function createSprite():Sprite

Creates a sprite containing a complete copy of the current canvas object tree.

This method is useful for custom printing. The created sprite can be transformed and added to a flash.printing.PrintJob.

Returns
Sprite — A copy of the canvas.
disposeListeners()method 
protected function disposeListeners(eventDispatcher:IEventDispatcher):void

Unregister all event listeners that were registered with the stage. This method is called whenever this canvas component is removed from the display list.

Parameters
eventDispatcher:IEventDispatcher — The stage
fitContent()method 
public function fitContent():void

Adjusts the view port to fully encompass the current content rectangle. The zoom level will be at least 1.

fitGraphBounds()method 
public function fitGraphBounds():void

Updates the content rectangle and adjusts the viewport to encompass the contents.

This method combines the calls to updateContentRect() and fitContent().

See also

forceRepaint()method 
public function forceRepaint():void

Invalidates this canvas component and causes a repaint of all display objects that are visible in this canvas component.

getCanvasObject()method 
public function getCanvasObject(worldX:Number, worldY:Number):ICanvasObject

Returns the top most canvas object instance that is hit at the given coordinate set.

Parameters
worldX:Number — the x coordinate of the query in the world coordinate system
 
worldY:Number — the y coordinate of the query in the world coordinate system

Returns
ICanvasObject — The top most canvas object that is hit at the given coordinates.
getCanvasObjects()method 
public function getCanvasObjects(worldX:Number, worldY:Number):Iterable

Returns a list of all canvas objects in hit order at the given world coordinate location.

The order of the elements in the list is the natural hit test order, i.e. elements painted on top of others will be reported first in the list.

Parameters
worldX:Number — the x coordinate for the query
 
worldY:Number — the y coordinate for the query

Returns
Iterable — a list of canvas objects that are hit in reverse painting order
getCanvasRect()method 
public function getCanvasRect():Rectangle

Returns a rectangle defined by the available space for displaying the CanvasObjectTree within this Component, in stage coordinates.

Returns
Rectangle — A rectangle defined by the available space for displayint the CanvasObjectTree.
getHits()method 
public function getHits(stageX:Number, stageY:Number, useShape:Boolean = true):Array

Returns an array of ICanvasObjects that are hit by the given coords.

Note that this method uses the flas internal hit test which may be faster than using getCanvasObject/getCanvasObjects

Parameters
stageX:Number — Whether to use only the bounding box (false) or the detailed shape (true) for the hittest.
 
stageY:Number
 
useShape:Boolean (default = true)

Returns
Array — An Array of ICanvasObjects that are hit.
initListeners()method 
protected function initListeners(eventDispatcher:IEventDispatcher):void

Initialize all event listeners that should be registered with the stage. This method is called whenever this canvas component is added to the display list.

Parameters
eventDispatcher:IEventDispatcher — The stage
inputModeContextLookup()method 
protected function inputModeContextLookup(type:Class):Object

Callback that is used by the default implementation of inputModeContext to resolve lookup calls.

Parameters
type:Class — The Type to query

Returns
Object — The result of the query.

See also

invalidateDisplayList()method 
public override function invalidateDisplayList():void

Marks a component so that its updateDisplayList() method gets called during a later screen update.

isCanvasHit()method 
public function isCanvasHit(target:DisplayObject, stageX:Number, stageY:Number):Boolean

Checks whether the point at stageX,stageY is within the canvas bounds and target is a child of the canvas.

Parameters
target:DisplayObject — A display object that was the target of an event.
 
stageX:Number — The x coordinate to check (stage coordinates)
 
stageY:Number — The y coordinate to check (stage coordinates)

Returns
Booleantrue if target is a child of the canvas and stageX, stageY is within the canvas bounds
iterateHits()method 
public function iterateHits(x:Number, y:Number, root:ICanvasObjectGroup = null, filter:Function = null):Iterator

Iterates all hit elements in the canvas below the given group that are accepted by a given filter. Hit testing is performed using the IHitTestable instance returned for each visible ICanvasObject in the current scene graph.

Parameters
x:Number — the x coordinate to perform the hit test at
 
y:Number — the y coordinate to perform the hit test at
 
root:ICanvasObjectGroup (default = null) — the root of the scene graph to use
 
filter:Function (default = null) — A filter function that decides whether a given canvas object should be considered for testing at all.

Returns
Iterator — a live iterable of the elements that are hit

See also

lookup()method 
public function lookup(type:Class):ObjectParameters
type:Class

Returns
Object
mouseWheelZoom()method 
protected function mouseWheelZoom(evt:CanvasMouseEvent):void

If the autoMouseWheelZoom property is set to true, this method will adjust the current zoom level. If the Ctrl key modifier has been pressed this method will keep the world coordinates at the current mouse position, i.e. the zoom will not necessarily be into the center of the canvas.

Parameters
evt:CanvasMouseEventCanvasMouseEvent to be interpreted.
onAdd()method 
protected function onAdd(event:FlexEvent):void

Called when the component is added to the display list.

Calls initListeners, passing the stage as the eventDispatcher.

Parameters
event:FlexEvent
onAutoDragChanged()method 
protected function onAutoDragChanged(oldValue:Boolean, newValue:Boolean):void

Called when the autoDrag property changes.

Dispatches the CanvasComponent.AUTO_DRAG_CHANGED event.

Parameters
oldValue:Boolean
 
newValue:Boolean

See also

onAutoDragInsetsChanged()method 
protected function onAutoDragInsetsChanged(oldValue:ImmutableRectangle, newValue:ImmutableRectangle):void

Called when the autoDragInsets property changes.

Dispatches the CanvasComponent.AUTO_DRAG_INSETS_CHANGED event.

Parameters
oldValue:ImmutableRectangle
 
newValue:ImmutableRectangle

See also

onCanvasMouseClicked()method 
protected function onCanvasMouseClicked(evt:CanvasMouseEvent):void

Callback method that is called when the mouse has been clicked. The clickCount property of the event can be queried to determine whether a double click has occured.

This callback will be called after the onMouseUp() method has been invoked and only if the mouse has not been moved by a great amount since the last onMouseDown event.

This method will dispatch the CanvasMouseEvent.CANVAS_MOUSE_CLICK event. Subclasses overriding this method should make sure to invoke the super class implementation.

Parameters
evt:CanvasMouseEvent — The canvas mouse event that descibes the mouse gesture.

See also

onCanvasMouseDown()method 
protected function onCanvasMouseDown(evt:CanvasMouseEvent):void

Callback method that is called when a mouse button has been pressed.

This method will dispatch the CanvasMouseEvent.CANVAS_MOUSE_DOWN event. Subclasses overriding this method should make sure to invoke the super class implementation.

Parameters
evt:CanvasMouseEvent — The canvas mouse event that descibes the mouse gesture.

See also

onCanvasMouseDragged()method 
protected function onCanvasMouseDragged(evt:CanvasMouseEvent):void

Callback method that is called when the mouse gets dragged. Moving the mouse while at least one button is pressed is considered dragging.

This method will dispatch the CanvasMouseEvent.CANVAS_MOUSE_DRAG event. Subclasses overriding this method should make sure to invoke the super class implementation.

Parameters
evt:CanvasMouseEvent — The canvas mouse event that descibes the mouse gesture.

See also

onCanvasMouseMoved()method 
protected function onCanvasMouseMoved(evt:CanvasMouseEvent):void

Callback method that is called when the mouse has been moved and the mouse button has not been pressed. If the mouse button has been pressed, onCanvasMouseDragged method would have been called instead.

This method will dispatch the CanvasMouseEvent.CANVAS_MOUSE_MOVE event. Subclasses overriding this method should make sure to invoke the super class implementation.

Parameters
evt:CanvasMouseEvent — The canvas mouse event that descibes the mouse gesture.

See also