Packagecom.kapit.diagram.proxies
Classpublic class KDLProxy
InheritanceKDLProxy Inheritance DiagramProxy

The proxy between the DiagramView and the layout algorithms. It enables loading graph description from the diagrammer of the DiagramView and also affects graph elements properties on the Diagram elements of the correspondant diagram. This class enables to maintain abstraction between the Diagrammer and the Graph layout while maintaining high performance and synchronization level between them.


Example
This sample shows how to use layout algorithms with DiagramView
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
 xmlns:diagctl="com.kapit.diagram.controls. 
 xmlns:diagview="com.kapit.diagram.view.
 layout="absolute" preinitialize="init();" xmlns:proxies="com.kapit.diagram.proxies.>
 
<mx:XML xmlns="" id="svglib">
<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns:k="http://schemas.kapit.fr/svg/2007/" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" version="1.0" width="1024" height="800" id="sgvlib">
<defs id="defs1">
<style type="text/css">
<![CDATA[
.basic { 
action-accept:annotation;
}
.bg { 
action-click:link;
action-accept:link;
}
]]>
</style>
</defs>
<g
 k:spriteid="rounded-rectangle"
 k:groupid="Basic"
 id="grrectangle"
 class="basic" transform="translate(116.20044,0)">
 <rect
  style="fill:#e1eaf5;fill-opacity:0.8;stroke:#6996cf;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
  id="rect3157"
  y="18.47105" x="137.22656"
  rx="10" ry="10"
  height="60.609154" width="98.994949" />
    <path
       class="bg"
       id="rect31552"
       style="fill:none;fill-opacity:0;stroke:#6996cf;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0"
       d="M 137.22656,18.47105 L 236.22151,18.47105 L 236.22151,79.080204 L 137.22656,79.080204 L 137.22656,18.47105 z" />  
</g>
</svg>
</mx:XML> 
<mx:Script>
 <![CDATA[

  import com.kapit.diagram.library.SVGAssetLibrary;

  import com.kapit.diagram.proxies.KDLProxy;
  import com.kapit.diagram.layouts.utils.Constants;  

  private var proxy:KDLProxy;
            
        [Bindable]
        public var LAYOUT_ARRAY:Array = [
            {label:"Circular", data:Constants.CIRCULAR_LAYOUT},
            {label:"Hierarchical Tree", data:Constants.HIERARCHICAL_LAYOUT},
            {label:"Radial", data:Constants.RADIAL_LAYOUT},
            {label:"Balloon", data:Constants.BALLOON_LAYOUT},
            {label:"Hierarchical-Cyclic", data:Constants.SUGIYAMA_LAYOUT}, 
            {label:"Static Organic", data:Constants.STATIC_GEM_LAYOUT},
            {label:"Animated Organic", data:Constants.ANIMATED_FORCEDIRECTED_LAYOUT},
            {label:"Orthogonal", data:Constants.ORTHOGONAL_LAYOUT}            
        ];
            
  public function init():void
  {
   var lib:SVGAssetLibrary=new SVGAssetLibrary(svglib);
  }
  public function initDiagram():void
  {
   diagram.multipanel=false;
   diagram.selectionenabled=true;
   diagram.keyboardenabled=true;
   diagram.dragenabled=true;
   diagram.dropenabled=true;   
   
   proxy = new KDLProxy(diagram);
   proxy.importGraph();
   proxy.exportGraph(LAYOUT_ARRAY[0].data);
   params.diagramProxy = proxy;
  } 
   
        private function closeHandler(event:Event):void {
   proxy.exportGraph(ComboBox(event.target).selectedItem.data);
   params.diagramProxy = proxy;
        }   
 ]]>
</mx:Script>
<mx:ApplicationControlBar  width="100%" height="50" horizontalAlign="right">
<diagctl:SVGAssetLibraryGroupButton width="150" groupid="Basic" 
  cornerRadius="10" paddingLeft="8" paddingBottom="0" paddingTop="0"
  useHandCursor="true" toolTip="Drag & drop" labelPlacement="right" textAlign="left"/>
</mx:ApplicationControlBar>
<mx:HBox left="10" top="60" bottom="10" right="10" horizontalGap="10">
<mx:VBox>
        <mx:ComboBox dataProvider="{LAYOUT_ARRAY}" width="150" color="0x000000"
            close="closeHandler(event);"/>
<proxies:GenericDialog id="params" autoLayout="true"> 
</proxies:GenericDialog>
</mx:VBox>

<diagview:DiagramView width="100%" height="100%" id="diagram" creationComplete="initDiagram();">
</diagview:DiagramView>
</mx:HBox>
</mx:Application>
  



Public Properties
 PropertyDefined by
 InheritedanimatedOrganicLayout : AnimatedForceDirectedLayout
DiagramProxy
 InheritedanimationDuration : uint = 1000
DiagramProxy
 InheritedballoonLayout : BalloonLayout
DiagramProxy
 InheritedcenterPoint : Point
DiagramProxy
 InheritedcircularLayout : SingleCycleCircularLayout
DiagramProxy
 InheritedconstraintManager : ConstraintManager
DiagramProxy
 InheriteddefaultLayout : int
DiagramProxy
 InheritededgeLinkMap : Dictionary
DiagramProxy
 InheritedexportSuccess : Boolean
Export status
DiagramProxy
 Inheritedgraph : IGraph
DiagramProxy
 InheritedgroupProxies : Dictionary
Included group proxies to be handled by this Diagram Proxy
DiagramProxy
 InheritedhierarchicalLayout : HierarchicalLayout
DiagramProxy
 InheritedlayoutConstaints : XML
DiagramProxy
 InheritedlayoutConstraints : XML
DiagramProxy
 InheritedlayoutOnDiagramChanged : Boolean
DiagramProxy
  layoutOptions : GenericDialog
The "layout Options" panel that controls layouts' parameters
KDLProxy
 InheritedlinkEdgeMap : Dictionary
DiagramProxy
 InheritedmindMapLayout : MindMapLayout
DiagramProxy
  moveRootToCenter : Boolean
KDLProxy
 InheritednodeSpriteMap : Dictionary
DiagramProxy
 InheritedorganicLayout : StaticGEMLayout
DiagramProxy
 InheritedorthogonalLayout : OrthogonalLayout
DiagramProxy
 InheritedradialLayout : RadialLayout
DiagramProxy
  renderer : Object
KDLProxy
  rootNode : INode
KDLProxy
 InheritedselectedProxy : DiagramProxy
Selected Proxy in the DiagramView (the proxy of a selected group in the DiagramView)
DiagramProxy
  source : Object
KDLProxy
 InheritedspriteNodeMap : Dictionary
DiagramProxy
 InheritedstoredParameters : Array
User defined layout parameters
DiagramProxy
 InheritedsugiyamaLayout : SugiyamaLayout
DiagramProxy
 InheritedtopLevelProxy : DiagramProxy
DiagramProxy
 Inheritedtweeners : Array
Animation tweeners
DiagramProxy
  withAnimation : Boolean
KDLProxy
Protected Properties
 PropertyDefined by
 Inherited_constraintNodes : Dictionary
DiagramProxy
 Inherited_edgeLinkMap : Dictionary
DiagramProxy
 Inherited_exportSuccess : Boolean = false
DiagramProxy
 Inherited_finishTime : int
DiagramProxy
 Inherited_graph : IGraph
DiagramProxy
 Inherited_groupProxies : Dictionary
DiagramProxy
 Inherited_linkEdgeMap : Dictionary
DiagramProxy
 Inherited_nodeSpriteMap : Dictionary
DiagramProxy
 Inherited_numberOfIteration : int
DiagramProxy
 Inherited_selectedProxy : DiagramProxy
DiagramProxy
 Inherited_spriteNodeMap : Dictionary
DiagramProxy
 Inherited_startTime : int
DiagramProxy
 Inherited_storedParametersMap : Array
DiagramProxy
 Inherited_topLevelProxy : DiagramProxy
DiagramProxy
 Inherited_tweeners : Array
DiagramProxy
Public Methods
 MethodDefined by
  
Builds a DiagramProxy instance that is used as an interface between a graph (Structure Model) and DiagramView (Renderer and Data Source)
KDLProxy
 Inherited
addDiagramGroupAsMetaNode(group:DiagramGroup, withExternalLinks:Boolean = true):IGraph
Adds a metanode as a graph to the general graph description of this DiagramProxy from a DiagramGroup instance and returns it.
DiagramProxy
 Inherited
addDiagramLinkAsEdge(link:DiagramLink, customGraph:IGraph = null, customEdgeLinkMap:Dictionary = null, customLinkEdgeMap:Dictionary = null, customSpriteNodeMap:Dictionary = null):IEdge
Adds a edge to the graph description of this DiagramProxy from a DiagramEdge instance and returns it.
DiagramProxy
 Inherited
addDiagramSpriteAsNode(sprite:DiagramSprite, customGraph:IGraph = null, customNodeSpriteMap:Dictionary = null, customSpriteNodeMap:Dictionary = null, customConstraintManager:ConstraintManager = null, customConstraintNodes:Dictionary = null):INode
Adds a node to the graph description of this DiagramProxy from a DiagramSprite instance and returns it.
DiagramProxy
 Inherited
Adds an item (a DiagramObject) to this DiagramProxy (graph and renderer references)
DiagramProxy
 Inherited
DiagramProxy
 Inherited
animateGroupLinks(edges:Array, customTweeners:Array = null, withAnimation:Boolean = true):void
Animates Group In/Out Links
DiagramProxy
 Inherited
doAnimatedTransition(outEdges:Array = null, customGraph:IGraph = null, customNodeSpriteMap:Dictionary = null, customEdgeLinkMap:Dictionary = null, customTweeners:Array = null, withAnimation:Boolean = true, doTransition:Boolean = true):void
Performs an animated transition from old sprites position to new positions grabbed from the graph (usually after layout)
DiagramProxy
  
exportGraph(layoutType:int):void
KDLProxy
 Inherited
getLayoutFromType(layoutType:int, customGraph:IGraph = null):Layout
Returns a Layout subclass instance according to a layoutType from the Constants class.
DiagramProxy
 Inherited
DiagramProxy
  
handleAddItem(addEvent:DiagramEvent):void
Detects any item add in the DiagramView by catching DiagramEvent.ELEMENT_ADDED event and updates the DiagramProxy elements according to that changes (maps and graph)
KDLProxy
  
handleAffilateItem(affilateItem:DiagramEvent):void
KDLProxy
  
Finalizes a drag operation of a progressive layout (sprites are supposed to be in the Sprite Layer)
KDLProxy
  
Handles the dragging process of nodes for progressive layouts, by updating the position of dragged nodes.
KDLProxy
  
andles the start of drag operation for progressive layouts.
KDLProxy
  
KDLProxy
  
KDLProxy
  
handlePropertyChanged(propertyEvent:DiagramEvent):void
KDLProxy
  
handleRemoveItem(removeEvent:DiagramEvent):void
Detects any item removal in the DiagramView by catching the DiagramEvent.ELEMENT_REMOVED event and updates the DiagramProxy elements according to that changes (maps and graph)
KDLProxy
  
KDLProxy
  
KDLProxy
  
importGraph():IGraph
KDLProxy
  
initMaps():void
KDLProxy
  
layoutSelection(layoutType:uint, sprites:Array, customOutEdges:Array = null, withAnimation:Boolean = true, doTransition:Boolean = true, tweeners:Array = null, minX:Number = 0, minY:Number = 0):IGraph
KDLProxy
 Inherited
Removes a DiagramGroup references from this DiagramProxy
DiagramProxy
 Inherited
Removes an item (a DiagramObject) to this DiagramProxy (graph and renderer references)
DiagramProxy
 Inherited
Removes a DiagramLink references from this DiagramProxy
DiagramProxy
 Inherited
Removes a DiagramSprite references from this DiagramProxy
DiagramProxy
  
selectProxy(event:MouseEvent):void
Selects a DiagramProxy of a selected Group and updates the layout options
KDLProxy
 Inherited
Inflicts an ungroup operation in the Diagram to the graph structure and Renderer-GraphLayout maps.
DiagramProxy
 Inherited
DiagramProxy
 Inherited
updateRendererFromGraph(element:IGraphItem, withAnimation:Boolean = true, update:Boolean = false):void
inheritDoc
DiagramProxy
Protected Methods
 MethodDefined by
 Inherited
Returns an Edge type given a DiagramLinkType
DiagramProxy
 Inherited
getIntermediatePoint(point1:Point, point2:Point, isHorizontal:Boolean):Point
Determines the intermediate point that links two points in an orthogonal fashion
DiagramProxy
 Inherited
Returns a DiagramLinkType according to an edgeType int (from the Constants class)
DiagramProxy
 Inherited
initLayouts():void
DiagramProxy
  
switchToStraightLineType(nonStraightEdgesArray:Array, tweeners:Array = null):void
KDLProxy
 Inherited
updateDiagramLinkFromEdge(edge:IEdge, customGraph:IGraph = null, customEdgeLinkMap:Dictionary = null, customTweeners:Array = null, withAnimation:Boolean = true):void
Updates the DiagramLink referenced by a edge (via the map _edgeLinkMap) by applying the edge properties on it (path).
DiagramProxy
 Inherited
updateDiagramSpriteFromNode(node:INode, customGraph:IGraph = null, customNodeSpriteMap:Dictionary = null, customTweeners:Array = null, withAnimation:Boolean = true, update:Boolean = false):void
Updates the DiagramSprite referenced by a node (via the map _nodeSpriteMap) by applying the node properties on it (placement and size).
DiagramProxy
 Inherited
updateEdgeExtremities(edge:IEdge, customGraph:IGraph = null, customEdgeLinkMap:Dictionary = null):void
Updates Edge Extremities given its extremity nodes position.
DiagramProxy
 Inherited
updateEdgePointsFromLink(edge:IEdge, link:DiagramLink):void
Updates edge points from a DiagramLink
DiagramProxy
 Inherited
updateEdgesFromLinks(customGraph:IGraph = null, customedgeLinkMap:Dictionary = null, customNodeSpriteMap:Dictionary = null, customGroupProxies:Dictionary = null):void
Updates graph nodes from their respective sprites
DiagramProxy
 Inherited
Updates node properties (size and position) from a given DiagramSprite
DiagramProxy
 Inherited
updateNodesFromSprites(customGraph:IGraph = null, customNodeSpriteMap:Dictionary = null, customGroupProxies:Dictionary = null):void
Updates graph nodes from their respective sprites
DiagramProxy
Property detail
layoutOptionsproperty
layoutOptions:GenericDialog  [read-write]

The "layout Options" panel that controls layouts' parameters

Implementation
    public function get layoutOptions():GenericDialog
    public function set layoutOptions(value:GenericDialog):void
moveRootToCenterproperty 
moveRootToCenter:Boolean  [read-write]Implementation
    public function get moveRootToCenter():Boolean
    public function set moveRootToCenter(value:Boolean):void
rendererproperty 
renderer:Object  [read-write]

Implementation
    public function get renderer():Object
    public function set renderer(value:Object):void
rootNodeproperty 
rootNode:INode  [read-write]Implementation
    public function get rootNode():INode
    public function set rootNode(value:INode):void
sourceproperty 
source:Object  [read-write]

Implementation
    public function get source():Object
    public function set source(value:Object):void
withAnimationproperty 
withAnimation:Boolean  [read-write]

Implementation
    public function get withAnimation():Boolean
    public function set withAnimation(value:Boolean):void
Constructor detail
KDLProxy()constructor
public function KDLProxy(view:DiagramView)

Builds a DiagramProxy instance that is used as an interface between a graph (Structure Model) and DiagramView (Renderer and Data Source)

Parameters
view:DiagramView — DiagramView from which the DiagramProxy is initialised and updated
Method detail
exportGraph()method
public override function exportGraph(layoutType:int):void

Parameters
layoutType:int
handleAddItem()method 
public function handleAddItem(addEvent:DiagramEvent):void

Detects any item add in the DiagramView by catching DiagramEvent.ELEMENT_ADDED event and updates the DiagramProxy elements according to that changes (maps and graph)

Parameters
addEvent:DiagramEvent — Event notifying that an item has been added to the DiagramView and that the DiagramProxy must be updated.
handleAffilateItem()method 
public function handleAffilateItem(affilateItem:DiagramEvent):voidParameters
affilateItem:DiagramEvent
handleDragFinished()method 
public override function handleDragFinished(event:DiagramDragEvent):void

Finalizes a drag operation of a progressive layout (sprites are supposed to be in the Sprite Layer)

Parameters
event:DiagramDragEvent — DiagramDragEvent
handleDragging()method 
public override function handleDragging(event:DiagramDragEvent):void

Handles the dragging process of nodes for progressive layouts, by updating the position of dragged nodes.

Parameters
event:DiagramDragEvent — Detected Drag Event
handleDragStarted()method 
public override function handleDragStarted(event:DiagramDragEvent):void

andles the start of drag operation for progressive layouts.
This method can be extended to handle more operations

Parameters
event:DiagramDragEvent — DiagramDragEvent
handleGroupCreated()method 
public function handleGroupCreated(groupEvent:DiagramEvent):voidParameters
groupEvent:DiagramEvent
handleGroupUngrouped()method 
public function handleGroupUngrouped(groupEvent:DiagramEvent):voidParameters
groupEvent:DiagramEvent
handlePropertyChanged()method 
public function handlePropertyChanged(propertyEvent:DiagramEvent):void

Parameters
propertyEvent:DiagramEvent
handleRemoveItem()method 
public function handleRemoveItem(removeEvent:DiagramEvent):void

Detects any item removal in the DiagramView by catching the DiagramEvent.ELEMENT_REMOVED event and updates the DiagramProxy elements according to that changes (maps and graph)

Parameters
removeEvent:DiagramEvent — Event notifying that an item has been removed from the DiagramView and that the DiagramProxy must be updated.
handleSelectionRemoved()method 
public function handleSelectionRemoved(removeEvent:DiagramEvent):voidParameters
removeEvent:DiagramEvent
handleStopAnimation()method 
public function handleStopAnimation(event:TweenEngineEvent):voidParameters
event:TweenEngineEvent
importGraph()method 
public override function importGraph():IGraph

Returns
IGraph
initMaps()method 
public function initMaps():void
layoutSelection()method 
public override function layoutSelection(layoutType:uint, sprites:Array, customOutEdges:Array = null, withAnimation:Boolean = true, doTransition:Boolean = true, tweeners:Array = null, minX:Number = 0, minY:Number = 0):IGraphParameters
layoutType:uint
 
sprites:Array
 
customOutEdges:Array (default = null)
 
withAnimation:Boolean (default = true)
 
doTransition:Boolean (default = true)
 
tweeners:Array (default = null)
 
minX:Number (default = 0)
 
minY:Number (default = 0)

Returns
IGraph
selectProxy()method 
public function selectProxy(event:MouseEvent):void

Selects a DiagramProxy of a selected Group and updates the layout options

Parameters
event:MouseEvent — MouseEvent
switchToStraightLineType()method 
protected function switchToStraightLineType(nonStraightEdgesArray:Array, tweeners:Array = null):voidParameters
nonStraightEdgesArray:Array
 
tweeners:Array (default = null)