Author: clopes
Date: 2011-10-18 08:50:58 -0700 (Tue, 18 Oct 2011)
New Revision: 27213

Modified:
   cytoscapeweb/branches/compound/html-template/js/cytoscapeweb.js
   cytoscapeweb/branches/compound/html-template/js/tests.js
   cytoscapeweb/branches/compound/html-template/sample.html
   
cytoscapeweb/branches/compound/src-test/org/cytoscapeweb/model/converters/ExternalObjectConverterTest.as
   
cytoscapeweb/branches/compound/src/org/cytoscapeweb/model/converters/ExternalObjectConverter.as
   cytoscapeweb/branches/compound/src/org/cytoscapeweb/util/GraphUtils.as
   
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/components/GraphView.as
Log:
Added zIndex field to Node/Edge API objects.
Updated tests and reformatted code.

Modified: cytoscapeweb/branches/compound/html-template/js/cytoscapeweb.js
===================================================================
--- cytoscapeweb/branches/compound/html-template/js/cytoscapeweb.js     
2011-10-18 11:47:58 UTC (rev 27212)
+++ cytoscapeweb/branches/compound/html-template/js/cytoscapeweb.js     
2011-10-18 15:50:58 UTC (rev 27213)
@@ -2355,6 +2355,13 @@
      * @type Number
      * @memberOf org.cytoscapeweb.Node#
      */
+    /**
+     * The stacking order of the element.
+     * @property
+     * @name zIndex
+     * @type Number
+     * @memberOf org.cytoscapeweb.Node#
+     */
     
      // ===[ Edge 
]=================================================================================
     
@@ -2493,6 +2500,13 @@
      * @type Boolean
      * @memberOf org.cytoscapeweb.Edge#
      */
+    /**
+     * The stacking order of the element.
+     * @property
+     * @name zIndex
+     * @type Number
+     * @memberOf org.cytoscapeweb.Edge#
+     */
      
     // ===[ Layout 
]================================================================================
     
@@ -2699,7 +2713,9 @@
      * <p>An object that defines visual styles for nodes.</p>
      * <p>The possible node properties are as follows.  Each property can be 
prefixed by "compound"
      * and the first letter of the term is correspondingly capitalized (e.g. 
"color" becomes "compoundColor") for compound nodes.</p>
-     * <ul class="options"><li><code>shape</code> {{@link 
org.cytoscapeweb.NodeShape}}: Node shape name. The default value is 
"ELLIPSE".</li>
+     * <ul class="options">
+     *     <li><code>shape</code> {{@link org.cytoscapeweb.NodeShape}}: Node 
shape name. The default value for regular nodes is <code>"ELLIPSE"</code>.
+     *         Compound nodes can only be <code>"RECTANGLE"</code> or 
<code>"ROUNDRECT"</code>, and the former is the default 
<code>compoundShape</code>.</li>
      *     <li><code>size</code> {Number}: Node size, in pixels.
      *                                     It has the same effect of setting 
the same value (or mapper) to both <code>width</code> and <code>height</code>.
      *                                     The default value is 24.</li>

Modified: cytoscapeweb/branches/compound/html-template/js/tests.js
===================================================================
--- cytoscapeweb/branches/compound/html-template/js/tests.js    2011-10-18 
11:47:58 UTC (rev 27212)
+++ cytoscapeweb/branches/compound/html-template/js/tests.js    2011-10-18 
15:50:58 UTC (rev 27213)
@@ -1340,7 +1340,7 @@
        var parents = vis.parentNodes();
        
        same(xml[0].tagName.toLowerCase(), "graphml", "<graphml> tag");
-       same(xml.find("graph").length, parents.length + 1, "<graph> tag");
+       same(xml.find("node > graph").length, parents.length, "<graph> tag");
        same(xml.find("key").length, (schema.nodes.length + schema.edges.length 
- ignoredFields), "Number <key> tags");
        same(xml.find("node").length, nodes.length, "Number of nodes");
        same(xml.find("edge").length, edges.length, "Number of edges");

Modified: cytoscapeweb/branches/compound/html-template/sample.html
===================================================================
--- cytoscapeweb/branches/compound/html-template/sample.html    2011-10-18 
11:47:58 UTC (rev 27212)
+++ cytoscapeweb/branches/compound/html-template/sample.html    2011-10-18 
15:50:58 UTC (rev 27213)
@@ -31,7 +31,7 @@
                         compoundShape: "ROUND_RECTANGLE",
                         color: { defaultValue: "#cccccc", continuousMapper: { 
attrName: "weight", minValue: "#ffffff", maxValue: "#0b94b1" } },
                         opacity: 0.9,
-                        //size: "auto",//{ defaultValue: 20, continuousMapper: 
{ attrName: "weight",  minValue: 20, maxValue: 40 } },
+                        size: { defaultValue: 20, continuousMapper: { 
attrName: "weight",  minValue: 20, maxValue: 40 } },
                         borderWidth: 2,
                         borderColor: "#707070",
                         image: 
"http://chart.apis.google.com/chart?chs=300x300&cht=p&chd=e0:U-gh..bR";,
@@ -112,7 +112,7 @@
                 $("input").attr("disabled", true);
 
                 // init and draw
-                vis = new org.cytoscapeweb.Visualization(div_id, options);
+                vis = new org.cytoscapeweb.Visualization(div_id);
                 
                 vis.ready(function() {
                     showElapsedTime();
@@ -142,7 +142,9 @@
                             x += Math.random() * (evt.target.width/2) * 
(Math.round(x)%2==0 ? 1 : -1);
                             y += Math.random() * (evt.target.height/2) * 
(Math.round(y)%2==0 ? 1 : -1);
                         }
-                        var n = vis.addNode(x, y, { weight: Math.random(), 
label: "NEW", parent: parentId }, true);
+                        var n = vis.addNode(x, y, { weight: Math.random(), 
parent: parentId }, true);
+                        n.data.label = n.data.id;
+                        vis.updateData([n]);
                     })
                     .addContextMenuItem("Add new edge", "nodes", function(evt) 
{
                        _srcId = evt.target.data.id;

Modified: 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/model/converters/ExternalObjectConverter.as
===================================================================
--- 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/model/converters/ExternalObjectConverter.as
     2011-10-18 11:47:58 UTC (rev 27212)
+++ 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/model/converters/ExternalObjectConverter.as
     2011-10-18 15:50:58 UTC (rev 27213)
@@ -311,6 +311,7 @@
                 // Common Visual properties:
                 obj.opacity = ds.alpha;
                 obj.visible = ds.visible;
+                obj.zIndex = ds.parent != null ? ds.parent.getChildIndex(ds) : 
-1;
                 
                 if (ds is CompoundNodeSprite) {
                     n = ds as CompoundNodeSprite;
@@ -332,7 +333,6 @@
                     p = getGlobalCoordinate(n);
                     obj.x = p.x;
                     obj.y = p.y;
-                    
                     obj.rawX = p.x / zoom;
                     obj.rawY = p.y / zoom;
                 } else {

Modified: cytoscapeweb/branches/compound/src/org/cytoscapeweb/util/GraphUtils.as
===================================================================
--- cytoscapeweb/branches/compound/src/org/cytoscapeweb/util/GraphUtils.as      
2011-10-18 11:47:58 UTC (rev 27212)
+++ cytoscapeweb/branches/compound/src/org/cytoscapeweb/util/GraphUtils.as      
2011-10-18 15:50:58 UTC (rev 27213)
@@ -83,56 +83,32 @@
                 * 
                 * @param d             DisplayObject to bring to front 
                 */ 
-               public static function bringToFront(d:DisplayObject):void
-               {
-                       if (d != null)
-                       {
-                               if (d is CompoundNodeSprite)
-                               {
+               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())
-                                               {
+                                       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);
+                                                       if (ns is 
CompoundNodeSprite) {
+                                                               
GraphUtils.bringToFront(ns as CompoundNodeSprite);
                                                        }
                                                        
                                                        ns.visitEdges(toFront);
                                                }
                                        }
-                               }
-                               else
-                               {
+                               } else {
                                        GraphUtils.toFront(d);
                                }
                        }
                }
                
-               /*
-        public static function isFilteredOut(ds:DataSprite):Boolean {
-            var b:Boolean = ds.props.$filteredOut;
-            
-            if (ds is EdgeSprite) {
-                var e:EdgeSprite = EdgeSprite(ds);
-                b = b || e.source.props.$filteredOut || 
e.target.props.$filteredOut;
-            }
-            
-            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
@@ -387,29 +363,19 @@
                             return false;
                         });
                                                
-                                               if (node is CompoundNodeSprite)
-                                               {
-                                                       var 
cns:CompoundNodeSprite =
-                                                               node as 
CompoundNodeSprite;
+                                               if (node is CompoundNodeSprite) 
{
+                                                       var 
cns:CompoundNodeSprite = node as CompoundNodeSprite;
                                                        
                                                        // include all 
non-visited children
-                                                       
-                                                       for each (var 
child:NodeSprite in
-                                                               
CompoundNodes.getChildren(cns))
-                                                       {
-                                                               if 
(!visited[child])
-                                                               {
+                                                       for each (var 
child:NodeSprite in CompoundNodes.getChildren(cns)) {
+                                                               if 
(!visited[child]) {
                                                                        
toVisit.push(child);
                                                                }
                                                        }
                                                        
                                                        // include all 
non-visited parents
-                                                       
-                                                       for each (var 
parent:NodeSprite in
-                                                               
CompoundNodes.getParents(cns))
-                                                       {
-                                                               if 
(!visited[parent])
-                                                               {
+                                                       for each (var 
parent:NodeSprite in CompoundNodes.getParents(cns)) {
+                                                               if 
(!visited[parent]) {
                                                                        
toVisit.push(parent);
                                                                }
                                                        }

Modified: 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/components/GraphView.as
===================================================================
--- 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/components/GraphView.as
    2011-10-18 11:47:58 UTC (rev 27212)
+++ 
cytoscapeweb/branches/compound/src/org/cytoscapeweb/view/components/GraphView.as
    2011-10-18 15:50:58 UTC (rev 27213)
@@ -286,13 +286,9 @@
             }
         }
         
-        public function resetNode(n:NodeSprite):void
-               {
-            if (n != null)
-                       {
-                               if (n is CompoundNodeSprite &&
-                                       (n as 
CompoundNodeSprite).isInitialized())
-                               {
+        public function resetNode(n:NodeSprite):void {
+            if (n != null) {
+                               if (n is CompoundNodeSprite && (n as 
CompoundNodeSprite).isInitialized()) {
                                        n.size = CompoundNodes.size(n);
                                        n.fillColor = 
CompoundNodes.fillColor(n);
                                        n.lineWidth = 
CompoundNodes.lineWidth(n);
@@ -300,9 +296,7 @@
                                        n.alpha = CompoundNodes.alpha(n);
                                        n.shape = CompoundNodes.shape(n);
                                        n.filters = CompoundNodes.filters(n);
-                               }
-                               else
-                               {
+                               } else {
                        n.size = Nodes.size(n);
                        n.fillColor = Nodes.fillColor(n);
                        n.lineWidth = Nodes.lineWidth(n);
@@ -312,8 +306,7 @@
                        n.filters = Nodes.filters(n);
                                }
                                
-                               if (n.props.label != null)
-                               {
+                               if (n.props.label != null) {
                                        n.props.label.alpha = n.alpha;
                                }
             }
@@ -363,11 +356,9 @@
             }
         }
         
-        public function bringToFront(ds:DataSprite):void
-               {
+        public function bringToFront(ds:DataSprite):void {
             // Bring the node to front, too:
                        GraphUtils.bringToFront(ds);
-                       
             // Do not forget the node's label!
             GraphUtils.bringToFront(ds.props.label);
         }
@@ -387,21 +378,15 @@
                
         // ========[ PRIVATE METHODS 
]==============================================================
                
-               private function highlightSelectedNode(n:NodeSprite):void
-               {
-            if (n != null)
-                       {
-                               if (n is CompoundNodeSprite &&
-                                       (n as 
CompoundNodeSprite).isInitialized())
-                               {
+               private function highlightSelectedNode(n:NodeSprite):void {
+            if (n != null) {
+                               if (n is CompoundNodeSprite && (n as 
CompoundNodeSprite).isInitialized()) {
                                        n.fillColor = 
CompoundNodes.fillColor(n);
                        n.lineWidth = CompoundNodes.selectionLineWidth(n);
                        n.lineColor = CompoundNodes.lineColor(n);
                        n.alpha = CompoundNodes.selectionAlpha(n);
                        n.filters = CompoundNodes.filters(n, true);
-                               }
-                               else
-                               {
+                               } else {
                                        n.fillColor = Nodes.fillColor(n);
                                        n.lineWidth = 
Nodes.selectionLineWidth(n);
                                        n.lineColor = Nodes.lineColor(n);
@@ -409,8 +394,7 @@
                                        n.filters = Nodes.filters(n, true);
                                }
                                
-                               if (n.props.label != null)
-                               {
+                               if (n.props.label != null) {
                                        n.props.label.alpha = n.alpha;
                                }
             }

Modified: 
cytoscapeweb/branches/compound/src-test/org/cytoscapeweb/model/converters/ExternalObjectConverterTest.as
===================================================================
--- 
cytoscapeweb/branches/compound/src-test/org/cytoscapeweb/model/converters/ExternalObjectConverterTest.as
    2011-10-18 11:47:58 UTC (rev 27212)
+++ 
cytoscapeweb/branches/compound/src-test/org/cytoscapeweb/model/converters/ExternalObjectConverterTest.as
    2011-10-18 15:50:58 UTC (rev 27213)
@@ -269,8 +269,8 @@
             
             // NODES
             var props:Array = 
["data","shape","borderColor","borderWidth","opacity","visible","color",
-                               
"x","y","rawX","rawY","size","width","height"/*, "degree", "indegree", 
"outdegree"*/];
-            var attrs:Array = ["id"];
+                               
"x","y","rawX","rawY","size","width","height","zIndex"/*, "degree", "indegree", 
"outdegree"*/];
+            var attrs:Array = ["id","parent"];
             
             for each (var n:NodeSprite in data.nodes) {
                 o = ExternalObjectConverter.toExtElement(n, 1);
@@ -284,7 +284,7 @@
             
             // EDGES
             props = 
["data","color","width","opacity","visible","sourceArrowShape","targetArrowShape",
-                     
"sourceArrowColor","targetArrowColor","curvature","merged"];
+                     
"sourceArrowColor","targetArrowColor","curvature","merged","zIndex"];
             attrs = ["id","source","target","directed"];
             
             for each (var e:EdgeSprite in data.edges) {

-- 
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