Author: onursumer
Date: 2011-07-01 04:54:28 -0700 (Fri, 01 Jul 2011)
New Revision: 25998

Modified:
   cytoscapeweb/branches/compound/html-template/compound.html
   cytoscapeweb/branches/compound/html-template/js/compound.js
   cytoscapeweb/branches/compound/src/org/cytoscapeweb/model/GraphProxy.as
   
cytoscapeweb/branches/compound/src/org/cytoscapeweb/model/converters/ExternalObjectConverter.as
   
cytoscapeweb/branches/compound/src/org/cytoscapeweb/model/converters/GraphMLConverter.as
   
cytoscapeweb/branches/compound/src/org/cytoscapeweb/model/converters/XGMMLConverter.as
   cytoscapeweb/branches/compound/src/org/cytoscapeweb/util/CompoundNodes.as
   cytoscapeweb/branches/compound/src/org/cytoscapeweb/util/Edges.as
   cytoscapeweb/branches/compound/src/org/cytoscapeweb/util/GraphUtils.as
   cytoscapeweb/branches/compound/src/org/cytoscapeweb/util/Nodes.as
   cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/ExternalMediator.as
   cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/GraphMediator.as
   
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/components/GraphView.as
   
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/components/GraphVis.as
   
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/layout/CompoundSpringEmbedder.as
   
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/render/CompoundNodeRenderer.as
   
cytoscapeweb/branches/compound/src/org/cytoscapeweb/vis/data/CompoundNodeSprite.as
Log:
- Filtering mechanism is redefined to prevent inconsistency for compound nodes. 
Previously, a node is considered as filtered out only if it is actually 
filtered out. Now, in addition to this criteria, a node is also considered as 
filtered out, if at least one of its parents is filtered out. isFilteredOut 
function of GraphUtils class is modified in this direction. After filtering 
operation, it is also required to update compound bounds and labels, to keep 
compounds consistent.
- CompoundSpringEmbedder (CoSE) is modified to ignore filtered nodes during 
layout operation.
- After some operations such as selection and dragging, it was possible for a 
compound node to be brought front without its children. This was causing child 
nodes to be displayed behind the parent compound node sprite. This behavior is 
fixed by modifying the function bringToFront of GraphUtils.
- In CompoundNodes class, constant names ALL_CHILDREN, SELECTED_CHILDREN, and 
NON_SELECTED_CHILDREN  are renamed to ALL, SELECTED and NON_SELECTED 
respectively.

Modified: cytoscapeweb/branches/compound/html-template/compound.html
===================================================================
--- cytoscapeweb/branches/compound/html-template/compound.html  2011-06-30 
23:06:50 UTC (rev 25997)
+++ cytoscapeweb/branches/compound/html-template/compound.html  2011-07-01 
11:54:28 UTC (rev 25998)
@@ -36,7 +36,8 @@
                <input id="to-svg" type="button" value="To SVG"></input>
                <input id="to-png" type="button" value="To PNG"></input>
                <input id="to-sif" type="button" value="To SIF"></input>
-               <input id="json-test" type="button" value="JSON Test"></input>
+               <input id="json-test" type="button" value="JSON"></input>
+               <input id="filter" type="button" value="Filter 
Selected"></input>
                <br/>
                <input id="cose" type="button" value="CoSE"></input>
                <input id="fd" type="button" value="FD"></input>

Modified: cytoscapeweb/branches/compound/html-template/js/compound.js
===================================================================
--- cytoscapeweb/branches/compound/html-template/js/compound.js 2011-06-30 
23:06:50 UTC (rev 25997)
+++ cytoscapeweb/branches/compound/html-template/js/compound.js 2011-07-01 
11:54:28 UTC (rev 25998)
@@ -453,29 +453,8 @@
        return data;
 }
 
-function readDataFromFile(filename)
-{
-       var input = fopen(getScriptPath(filename), 0); // open file for reading
-       var content;
-       
-       // if the file is successfully opened
-       if(input != -1)
-       {
-               // read all file content
-           var length = flength(input);     
-           content = fread(input, length);     
-           fclose(input);
-           
-           alert("file opened!");
-       }
-       else
-       {
-               alert("wrong input!");
-       }
-       
-       return content;
-}
 
+
 /**
  * Creates a sample network object model data containing both simple and
  * compound nodes.
@@ -616,6 +595,21 @@
     }
 }
 
+function visibility(element)
+{
+       var selectedNodes = vis.selected();
+       
+       for (var i=0; i < selectedNodes.length; i++)
+       {
+               if (element.data.id == selectedNodes[i].data.id)
+               {
+                       return false;
+               }
+       }
+       
+       return true;
+}
+
 /*
  * Add items to context menu
  */
@@ -718,6 +712,10 @@
         vis.draw(options);
     });
        
+       $("#filter").click(function(evt) {
+        vis.filter('all', visibility, true);
+    });
+       
        $("#in-graphml").click(function(evt) {
         var network = createGraphmlData();
         options.network = network;
@@ -762,5 +760,3 @@
                vis.exportNetwork('sif', 'export.php?type=xml');
     });
 }
-
-// TODO read from input file...

Modified: 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/model/GraphProxy.as
===================================================================
--- cytoscapeweb/branches/compound/src/org/cytoscapeweb/model/GraphProxy.as     
2011-06-30 23:06:50 UTC (rev 25997)
+++ cytoscapeweb/branches/compound/src/org/cytoscapeweb/model/GraphProxy.as     
2011-07-01 11:54:28 UTC (rev 25998)
@@ -341,7 +341,7 @@
                                                // get non-selected children of 
the current compound
                                                children = 
CompoundNodes.getChildren(
                                                        (ns as 
CompoundNodeSprite),
-                                                       
CompoundNodes.NON_SELECTED_CHILDREN);
+                                                       
CompoundNodes.NON_SELECTED);
                                                
                                                // concat the new children with 
the map
                                                for each (node in children)

Modified: 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/model/converters/ExternalObjectConverter.as
===================================================================
--- 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/model/converters/ExternalObjectConverter.as
     2011-06-30 23:06:50 UTC (rev 25997)
+++ 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/model/converters/ExternalObjectConverter.as
     2011-07-01 11:54:28 UTC (rev 25998)
@@ -342,7 +342,7 @@
                                                nodesArray.push(nodeObject);
                                        }
                                }
-                               else if (ns.data.parentId == null)
+                               else if (ns.props.parentId == null)
                                {
                                        // create & store node object
                                        nodeObject = toExtNodeObject(ns, 
lookup);

Modified: 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/model/converters/GraphMLConverter.as
===================================================================
--- 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/model/converters/GraphMLConverter.as
    2011-06-30 23:06:50 UTC (rev 25997)
+++ 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/model/converters/GraphMLConverter.as
    2011-07-01 11:54:28 UTC (rev 25998)
@@ -511,7 +511,7 @@
                                        // include only parentless nodes' data
                                        if (parentId == null)
                                        {
-                                               if (ds.data.parentId == null)
+                                               if (ds.props.parentId == null)
                                                {
                                                        plainData.push(ds.data);
                                                }

Modified: 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/model/converters/XGMMLConverter.as
===================================================================
--- 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/model/converters/XGMMLConverter.as
      2011-06-30 23:06:50 UTC (rev 25997)
+++ 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/model/converters/XGMMLConverter.as
      2011-07-01 11:54:28 UTC (rev 25998)
@@ -813,7 +813,7 @@
                                                // include only parentless 
nodes' data
                                                if (parentId == null)
                                                {
-                                                       if (ds.data.parentId == 
null)
+                                                       if (ds.props.parentId 
== null)
                                                        {
                                                                
sprites.push(ds);
                                                        }

Modified: 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/util/CompoundNodes.as
===================================================================
--- cytoscapeweb/branches/compound/src/org/cytoscapeweb/util/CompoundNodes.as   
2011-06-30 23:06:50 UTC (rev 25997)
+++ cytoscapeweb/branches/compound/src/org/cytoscapeweb/util/CompoundNodes.as   
2011-07-01 11:54:28 UTC (rev 25998)
@@ -15,9 +15,9 @@
 
        public class CompoundNodes
        {
-               public static const ALL_CHILDREN:String = "all";
-               public static const SELECTED_CHILDREN:String = "selected";
-               public static const NON_SELECTED_CHILDREN:String = 
"non-selected";
+               public static const ALL:String = "all";
+               public static const SELECTED:String = "selected";
+               public static const NON_SELECTED:String = "non-selected";
                
                private static var _properties:Object;
                private static var _configProxy:ConfigProxy;
@@ -331,7 +331,7 @@
                 * @param cns   compound node sprite whose children are 
collected 
                 */
                public static function getChildren(cns:CompoundNodeSprite,
-                       type:String = CompoundNodes.ALL_CHILDREN) : Array
+                       type:String = CompoundNodes.ALL) : Array
                {
                        var children:Array = new Array();
                        var condition:Boolean;
@@ -340,7 +340,7 @@
                        {
                                for each (var ns:NodeSprite in cns.getNodes())
                                {
-                                       if (type === 
CompoundNodes.SELECTED_CHILDREN)
+                                       if (type === CompoundNodes.SELECTED)
                                        {
                                                if (ns.props.$selected)
                                                {
@@ -351,7 +351,7 @@
                                                        condition = false;
                                                }
                                        }
-                                       else if (type === 
CompoundNodes.NON_SELECTED_CHILDREN)
+                                       else if (type === 
CompoundNodes.NON_SELECTED)
                                        {
                                                if (ns.props.$selected)
                                                {
@@ -393,29 +393,39 @@
                 * up to root are collected by default, type can be selected and
                 * non-selected parents.
                 * 
-                * @param cns   compound node sprite whose parents are 
collected 
+                * @param ns    node sprite whose parents are collected 
                 */
-               public static function getParents(cns:CompoundNodeSprite,
-                                                                               
   type:String = CompoundNodes.ALL_CHILDREN) : Array
+               public static function getParents(ns:NodeSprite,
+                                                                               
   type:String = CompoundNodes.ALL) : Array
                {
                        var parents:Array = new Array();
                        var condition:Boolean;
                        var parent:NodeSprite;
+                       var parentId:String;
                        
-                       if (cns != null)
+                       if (ns != null)
                        {
+                               if (ns is CompoundNodeSprite)
+                               {
+                                       parentId = (ns as 
CompoundNodeSprite).parentId;
+                               }
+                               else
+                               {
+                                       parentId = ns.props.parentId;
+                               }
+                               
                                //for each (var ns:NodeSprite in cns.getNodes())
-                               while (cns.parentId != null)
+                               while (parentId != null)
                                {
                                        // get parent
-                                       parent = 
graphProxy.getNode(cns.parentId);
+                                       parent = graphProxy.getNode(parentId);
                                        
                                        if (parent == null)
                                        {
                                                break;
                                        }
                                        
-                                       if (type === 
CompoundNodes.SELECTED_CHILDREN)
+                                       if (type === CompoundNodes.SELECTED)
                                        {
                                                if (parent.props.$selected)
                                                {
@@ -426,7 +436,7 @@
                                                        condition = false;
                                                }
                                        }
-                                       else if (type === 
CompoundNodes.NON_SELECTED_CHILDREN)
+                                       else if (type === 
CompoundNodes.NON_SELECTED)
                                        {
                                                if (parent.props.$selected)
                                                {
@@ -451,7 +461,7 @@
                                        }
                                        
                                        // advance to next node
-                                       cns = parent as CompoundNodeSprite;
+                                       parentId = (parent as 
CompoundNodeSprite).parentId;
                                }
                        }
                        

Modified: cytoscapeweb/branches/compound/src/org/cytoscapeweb/util/Edges.as
===================================================================
--- cytoscapeweb/branches/compound/src/org/cytoscapeweb/util/Edges.as   
2011-06-30 23:06:50 UTC (rev 25997)
+++ cytoscapeweb/branches/compound/src/org/cytoscapeweb/util/Edges.as   
2011-07-01 11:54:28 UTC (rev 25998)
@@ -156,12 +156,36 @@
             return style.getValue(propName, e.data) as Number;
         }
         
-        public static function visible(e:EdgeSprite):Boolean {
-            var vis:Boolean = !GraphUtils.isFilteredOut(e);
-
+        public static function visible(e:EdgeSprite):Boolean
+               {
+                       var vis:Boolean = true;
+                       
+                       if (GraphUtils.isFilteredOut(e))
+                       {
+                               vis = false;
+                       }
+                       /*
+                       else if (!Nodes.visible(e.source) ||
+                               !Nodes.visible(e.target))
+                       {
+                               vis = false;
+                       }
+                       */
+                       else
+                       {
+                               var merged:Boolean = configProxy.edgesMerged;
+                               
+                               vis = (merged && e.props.$merged) ||
+                                       (!merged && !e.props.$merged);
+                       }
+                       
+                       /*
+                       var vis:Boolean = !GraphUtils.isFilteredOut(e);
+                       
             var merged:Boolean = configProxy.edgesMerged;
             vis = vis && ( (merged && e.props.$merged) || (!merged && 
!e.props.$merged) );
-            
+            */
+                       
             return vis;
         }
         

Modified: cytoscapeweb/branches/compound/src/org/cytoscapeweb/util/GraphUtils.as
===================================================================
--- cytoscapeweb/branches/compound/src/org/cytoscapeweb/util/GraphUtils.as      
2011-06-30 23:06:50 UTC (rev 25997)
+++ cytoscapeweb/branches/compound/src/org/cytoscapeweb/util/GraphUtils.as      
2011-07-01 11:54:28 UTC (rev 25998)
@@ -61,15 +61,67 @@
         }
 
         // ========[ PUBLIC METHODS 
]===============================================================
-
-        public static function bringToFront(d:DisplayObject):void {
-            if (d != null) {
-                var p:DisplayObjectContainer = d.parent;
-                if (p != null)
-                   p.setChildIndex(d, p.numChildren-1);
-            }
-        }
         
+               /**
+                * Brings the given display object to the front of the stage. 
This
+                * function does not taken compound nodes into account. Use 
bringToFront 
+                * function for full compatibility with compound graphs.
+                * 
+                * @param d             DisplayObject to bring to front
+                */
+               public static function toFront(d:DisplayObject):void {
+                       if (d != null) {
+                               var p:DisplayObjectContainer = d.parent;
+                               if (p != null)
+                                       p.setChildIndex(d, p.numChildren-1);
+                       }
+               }
+               
+               /**
+                * Brings the given display object to the front of the stage. 
If the
+                * given display object is a CompoundNodeSprite, also brings all
+                * its children and edges inside the compound node to the front.
+                * 
+                * @param d             DisplayObject to bring to front 
+                */ 
+               public static function bringToFront(d:DisplayObject):void
+               {
+                       if (d != null)
+                       {
+                               if (d is CompoundNodeSprite)
+                               {
+                                       var cns:CompoundNodeSprite = d as 
CompoundNodeSprite;
+                                       
+                                       // bring the compound node sprite as 
well as all its
+                                       // children and the edges inside the 
compound to the front.
+                                       
+                                       GraphUtils.toFront(cns);
+                                       
+                                       if (cns.isInitialized() &&
+                                               !cns.allChildrenInvisible())
+                                       {
+                                               for each (var ns:NodeSprite in 
cns.getNodes())
+                                               {
+                                                       GraphUtils.toFront(ns);
+                                                       
+                                                       if (ns is 
CompoundNodeSprite)
+                                                       {
+                                                               
GraphUtils.bringToFront(
+                                                                       ns as 
CompoundNodeSprite);
+                                                       }
+                                                       
+                                                       ns.visitEdges(toFront);
+                                               }
+                                       }
+                               }
+                               else
+                               {
+                                       GraphUtils.toFront(d);
+                               }
+                       }
+               }
+               
+               /*
         public static function isFilteredOut(ds:DataSprite):Boolean {
             var b:Boolean = ds.props.$filteredOut;
             
@@ -80,7 +132,52 @@
             
             return b;
         }
-        
+        */
+               
+               /**
+                * If the given data sprite is filtered out, returns true. If a 
+                * NodeSprite itself is not filtered out, but at least one of 
its
+                * parents is filtered out, then the node is also considered as
+                * filtered out. Similarly, if an EdgeSprite is not filtered 
out, but
+                * either its source or target is filtered out, then the edge 
is also
+                * considered as filtered out.
+                * 
+                * @param ds    DataSprite to be checked
+                * @return              true if filtered out, false otherwise
+                */
+               public static function isFilteredOut(ds:DataSprite):Boolean
+               {
+                       var filtered:Boolean = ds.props.$filteredOut;
+                       
+                       if (ds is EdgeSprite)
+                       {
+                               var e:EdgeSprite = EdgeSprite(ds);
+                               
+                               // if an edge is not filtered out, but either 
its target or
+                               // its source is filtered out, then the edge 
should also be
+                               // filtered out
+                               filtered = filtered || isFilteredOut(e.source) 
||
+                                       isFilteredOut(e.target);
+                       }
+                       else if (ds is NodeSprite)
+                       {
+                               // if a node is not filtered out, but at least 
one of its
+                               // parents is filtered out, then the node 
should also be
+                               // filtered out
+                               for each (var parent:CompoundNodeSprite in
+                                       CompoundNodes.getParents(ds as 
NodeSprite))
+                               {
+                                       if (parent.props.$filteredOut)
+                                       {
+                                               filtered = true;
+                                               break;
+                                       }
+                               }
+                       }
+                       
+                       return filtered;
+               }
+               
         public static function getBounds(data:Data, 
                                          ignoreNodeLabels:Boolean,
                                          ignoreEdgeLabels:Boolean):Rectangle {

Modified: cytoscapeweb/branches/compound/src/org/cytoscapeweb/util/Nodes.as
===================================================================
--- cytoscapeweb/branches/compound/src/org/cytoscapeweb/util/Nodes.as   
2011-06-30 23:06:50 UTC (rev 25997)
+++ cytoscapeweb/branches/compound/src/org/cytoscapeweb/util/Nodes.as   
2011-07-01 11:54:28 UTC (rev 25998)
@@ -34,9 +34,10 @@
     
     import org.cytoscapeweb.ApplicationFacade;
     import org.cytoscapeweb.model.ConfigProxy;
+    import org.cytoscapeweb.model.data.VisualStyleBypassVO;
     import org.cytoscapeweb.model.data.VisualStyleVO;
-    import org.cytoscapeweb.model.data.VisualStyleBypassVO;
     import org.cytoscapeweb.view.render.NodeRenderer;
+    import org.cytoscapeweb.vis.data.CompoundNodeSprite;
     
     
     public class Nodes {
@@ -173,8 +174,9 @@
             return style.getValue(propName, n.data);
         }
         
-        public static function visible(n:NodeSprite):Boolean {
-            return !n.props.$filteredOut;
+        public static function visible(n:NodeSprite):Boolean
+               {
+            return !GraphUtils.isFilteredOut(n);
         }
         
         public static function filters(n:NodeSprite, 
selectNow:Boolean=false):Array {

Modified: 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/ExternalMediator.as
===================================================================
--- 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/ExternalMediator.as    
    2011-06-30 23:06:50 UTC (rev 25997)
+++ 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/ExternalMediator.as    
    2011-07-01 11:54:28 UTC (rev 25998)
@@ -480,7 +480,7 @@
                                                        {
                                                                childList = 
CompoundNodes.getChildren(
                                                                        
cNodeSprite,
-                                                                       
CompoundNodes.NON_SELECTED_CHILDREN);
+                                                                       
CompoundNodes.NON_SELECTED);
                                                        }
                                                        // otherwise add all 
children of the compound
                                                        // to the list of nodes 
to be removed
@@ -510,11 +510,11 @@
                                                {
                                                        parentId = (ns as 
CompoundNodeSprite).parentId;
                                                }
-                                               else if (ns.data.parentId != 
null)
+                                               else if (ns.props.parentId != 
null)
                                                {
                                                        // TODO we always use 
CompoundNodeSprites, so
                                                        // this condition will 
never be true
-                                                       parentId = 
ns.data.parentId;
+                                                       parentId = 
ns.props.parentId;
                                                }
                                                else
                                                {

Modified: 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/GraphMediator.as
===================================================================
--- cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/GraphMediator.as   
2011-06-30 23:06:50 UTC (rev 25997)
+++ cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/GraphMediator.as   
2011-07-01 11:54:28 UTC (rev 25998)
@@ -276,6 +276,14 @@
                 vis.updateLabels(Groups.EDGES);
             }
             separateDisconnected();
+                       
+                       // it is required to update compound bounds after 
filtering in order
+                       // to keep compound bounds valid with respect to its 
children
+                       vis.updateAllCompoundBounds();
+                       
+                       // it is also required to operate compound node 
labeler, to update
+                       // compound node labels
+                       vis.compoundNodeLabeler.operate();
         }
 
         public function resetDataSprite(ds:DataSprite):void
@@ -835,7 +843,7 @@
                                        {
                                                // TODO we always use 
CompoundNodeSprite instances,
                                                // so this condition will never 
be true
-                                               parentId = ns.data.parentId
+                                               parentId = ns.props.parentId
                                        }
                                        
                                        while (parentId != null)

Modified: 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/components/GraphView.as
===================================================================
--- 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/components/GraphView.as
    2011-06-30 23:06:50 UTC (rev 25997)
+++ 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/components/GraphView.as
    2011-07-01 11:54:28 UTC (rev 25998)
@@ -327,9 +327,11 @@
             }
         }
         
-        public function bringToFront(ds:DataSprite):void {
+        public function bringToFront(ds:DataSprite):void
+               {
             // Bring the node to front, too:
-            GraphUtils.bringToFront(ds);
+                       GraphUtils.bringToFront(ds);
+                       
             // Do not forget the node's label!
             GraphUtils.bringToFront(ds.props.label);
         }

Modified: 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/components/GraphVis.as
===================================================================
--- 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/components/GraphVis.as 
    2011-06-30 23:06:50 UTC (rev 25997)
+++ 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/components/GraphVis.as 
    2011-07-01 11:54:28 UTC (rev 25998)
@@ -514,7 +514,8 @@
                        var bounds:Rectangle;
                        var allChildren:Array = CompoundNodes.getChildren(cns);
                        
-                       if (allChildren.length > 0)
+                       if (allChildren.length > 0
+                               && !cns.allChildrenInvisible())
                        {
                                for each (var ns:NodeSprite in allChildren)
                                {
@@ -752,11 +753,11 @@
                                if (ns is CompoundNodeSprite &&
                                        (ns as 
CompoundNodeSprite).isInitialized())
                                {
-                                       updateAllBounds(ns as 
CompoundNodeSprite);
+                                       this.updateAllBounds(ns as 
CompoundNodeSprite);
                                }
                        }
                        
-                       updateCompoundBounds(cns);
+                       this.updateCompoundBounds(cns);
                        cns.render();
                }
     }

Modified: 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/layout/CompoundSpringEmbedder.as
===================================================================
--- 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/layout/CompoundSpringEmbedder.as
   2011-06-30 23:06:50 UTC (rev 25997)
+++ 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/layout/CompoundSpringEmbedder.as
   2011-07-01 11:54:28 UTC (rev 25998)
@@ -4,6 +4,7 @@
        import flare.vis.data.NodeSprite;
        import flare.vis.operator.layout.Layout;
        
+       import org.cytoscapeweb.util.GraphUtils;
        import org.cytoscapeweb.util.Groups;
        import org.cytoscapeweb.view.layout.ivis.layout.CoSEOptions;
        import org.cytoscapeweb.view.layout.ivis.layout.GeneralOptions;
@@ -39,6 +40,11 @@
                        this._ivisLayout = new CoSELayout();
                }
                
+               /**
+                * Sets the layout options provided by the options object. 
+                * 
+                * @param options       object that contains layout options.
+                */
                public function setOptions(options:Object):void
                {
                        // set layout parameters
@@ -80,22 +86,6 @@
                        
coseOpts.setMultiLevelScaling(options.multiLevelScaling);
                        
                        /*
-                       layoutQuality:                   "default",     // 
Layout Quality
-                       incremental:                     false, // Incremental
-                       uniformLeafNodeSizes:    false, // Uniform Leaf Node 
Sizes
-                       tension:                                 50,    // 
Spring
-                       repulsion:                               50,    // 
Repulsion
-                       smartDistance:                   true,  // Smart Range 
Calculation
-                       gravitation:                     50,    // Gravity
-                       gravityDistance:                 50,    // Gravity Range
-                       compoundGravitation:     50,    // Compound Gravity
-                       compoundGravityDistance: 50,    // Compound Gravity 
Range
-                       restLength:                              50,    // 
Desired Edge Length
-                       smartRestLength:                 true,  // Smart Edge 
Length Calculation
-                       multiLevelScaling:               false  // Multi-Level 
Scaling
-                       */
-                       
-                       /*
                        trace ("layoutQuality: " + options.layoutQuality);
                        trace ("incremental: " + options.incremental);
                        trace ("uniformLeafNodeSizes: " + 
options.uniformLeafNodeSizes);
@@ -135,12 +125,21 @@
                        }
                }
                
+               /**
+                * Updates the given node sprite by copying corresponding 
LNode's x and
+                * y coordinates.
+                * 
+                * @param ns    node sprite to be updated
+                */
                protected function updateNode(ns:NodeSprite):void
                {       
                        var node:LNode = this._cwToLayout[ns];
                        
-                       ns.x = node.getCenterX();
-                       ns.y = node.getCenterY();
+                       if (node != null)
+                       {
+                               ns.x = node.getCenterX();
+                               ns.y = node.getCenterY();
+                       }
                }
                
                /**
@@ -167,7 +166,9 @@
                                {
                                        cns = ns as CompoundNodeSprite;
                                        
-                                       if (cns.parentId == null)
+                                       // ignore filtered-out nodes
+                                       if (cns.parentId == null &&
+                                               !GraphUtils.isFilteredOut(cns))
                                        {
                                                this.createNode(cns,
                                                        null,
@@ -181,7 +182,11 @@
                        for each (var es:EdgeSprite in
                                visualization.data.group(Groups.REGULAR_EDGES))
                        {
-                               this.createEdge(es, this._ivisLayout);
+                               // ignore filtered-out edges
+                               if (!GraphUtils.isFilteredOut(es))
+                               {
+                                       this.createEdge(es, this._ivisLayout);
+                               }
                        }
                        
                        gm.updateBounds();
@@ -253,9 +258,12 @@
                                // for each NodeModel in the node set create an 
LNode
                                for each (var cns:CompoundNodeSprite in 
node.getNodes())
                                {
-                                       this.createNode(cns,
-                                               node,
-                                               layout);
+                                       if (!GraphUtils.isFilteredOut(cns))
+                                       {
+                                               this.createNode(cns,
+                                                       node,
+                                                       layout);
+                                       }
                                }
                                
                                lNode.updateBounds();

Modified: 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/render/CompoundNodeRenderer.as
===================================================================
--- 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/render/CompoundNodeRenderer.as
     2011-06-30 23:06:50 UTC (rev 25997)
+++ 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/render/CompoundNodeRenderer.as
     2011-07-01 11:54:28 UTC (rev 25998)
@@ -65,7 +65,8 @@
                                ns = (d as CompoundNodeSprite);
                                
                                if (!ns.isInitialized() ||
-                                       ns.bounds == null)
+                                       ns.bounds == null ||
+                                       ns.allChildrenInvisible())
                                {
                                        // no child or bounds set yet,
                                        // render with default size & shape     
                                
@@ -109,7 +110,8 @@
                                // bring (recursively) child nodes & edges 
inside the compound
                                // to the front, otherwise they remain on the 
back side of
                                // the compound node.
-                               this.raiseChildren(ns);
+                               //this.raiseChildren(ns);
+                               GraphUtils.bringToFront(ns);
                        }
                        else
                        {

Modified: 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/vis/data/CompoundNodeSprite.as
===================================================================
--- 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/vis/data/CompoundNodeSprite.as
  2011-06-30 23:06:50 UTC (rev 25997)
+++ 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/vis/data/CompoundNodeSprite.as
  2011-07-01 11:54:28 UTC (rev 25998)
@@ -3,6 +3,8 @@
        import flare.vis.data.NodeSprite;
        
        import flash.geom.Rectangle;
+       
+       import org.cytoscapeweb.util.Nodes;
 
        /**
         * This class represents a Compound Node with its child nodes, bounds 
and
@@ -145,6 +147,20 @@
                        return initialized;
                }
                
+               public function allChildrenInvisible() : Boolean
+               {
+                       var invisible:Boolean = true; 
+                       
+                       for each (var ns:NodeSprite in this.getNodes())
+                       {
+                               if (Nodes.visible(ns))
+                               {
+                                       invisible = false;
+                               }
+                       }
+                       
+                       return invisible;
+               }
                
                /**
                 * Adds the given node sprite to the child map of the compound 
node.
@@ -172,7 +188,7 @@
                                else
                                {
                                        // TODO what to do if a NodeSprite is 
added? 
-                                       ns.data.parentId = this.data.id;
+                                       ns.props.parentId = this.data.id;
                                }
                                
                        }
@@ -208,7 +224,7 @@
                                }
                                else
                                {
-                                       ns.data.parentId = null;
+                                       ns.props.parentId = null;
                                }
                                
                                // remove the node from the list of child nodes 

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to