Author: chinmoy
Date: 2009-08-07 02:25:23 -0700 (Fri, 07 Aug 2009)
New Revision: 17735

Modified:
   
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/CommonFunctions.java
   
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/CircularCladogram.java
   
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/RadialCladogram.java
   
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/RectangularCladogram.java
   
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/SlantedCladogram.java
   
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/phylograms/CircularPhylogram.java
   
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/phylograms/RadialPhylogram.java
   
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/phylograms/RectangularPhylogram.java
   
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/phylograms/SlantedPhylogram.java
   
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/visualstyle/DepthwiseSize.java
Log:
Cleanup

Modified: 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/CommonFunctions.java
===================================================================
--- 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/CommonFunctions.java
       2009-08-07 06:21:26 UTC (rev 17734)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/CommonFunctions.java
       2009-08-07 09:25:23 UTC (rev 17735)
@@ -14,6 +14,37 @@
 
 public class CommonFunctions {
        
+       
+       public boolean hasLeaf(CyNetwork network)
+       {
+               // Get all nodes
+               List<Node> nodesList = network.nodesList();
+               Iterator <Node> nodesListIterator = nodesList.iterator();
+               while(nodesListIterator.hasNext())
+               {
+                       Node node = nodesListIterator.next();
+                       if(network.getOutDegree(node)==0)
+                               return true;
+                                               
+               }
+               return false;
+       }
+       
+       public boolean isTree(CyNetwork network)
+       {
+               // Get all nodes
+               List<Node> nodesList = network.nodesList();
+               Iterator <Node> nodesListIterator = nodesList.iterator();
+               while(nodesListIterator.hasNext())
+               {
+                       Node node = nodesListIterator.next();
+                       
if(network.getInDegree(node)==0||network.getInDegree(node)==1)
+                               continue;
+                       else
+                               return false;
+               }
+               return true;
+       }
        /**
         * getTreeRoot(network)
         * Finds the root of the tree and returns it
@@ -286,11 +317,16 @@
                {
                        int [] incomingEdges = 
network.getAdjacentEdgeIndicesArray(node.getRootGraphIndex(), false, true, 
false);
                        
-                       int depth= getDepth(network, 
network.getEdge(incomingEdges[0]).getSource());
-                               
-                       
+                       int max = 0;
+                       for (int i = 0; i < incomingEdges.length; i++)
+                       {
+                               int depth = getLevel(network, 
network.getEdge(incomingEdges[i]).getSource()); 
+                               if(depth > max)
+                                       max = depth;
 
-                       return depth+1;
+                       }
+
+                       return max+1;
                }
        }
        /**

Modified: 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/CircularCladogram.java
===================================================================
--- 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/CircularCladogram.java
  2009-08-07 06:21:26 UTC (rev 17734)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/CircularCladogram.java
  2009-08-07 09:25:23 UTC (rev 17735)
@@ -15,22 +15,22 @@
 import giny.model.Node;
 
 public class CircularCladogram extends AbstractLayout{
-       
+
        static double BASE_RADIUS = 100.0;
-       
+
        private LayoutProperties layoutProperties;
-       
+
        CommonFunctions commonFunctions = new CommonFunctions();
-       
+
        private int numLeavesVisited = 0; //
-       
+
        public CircularCladogram()
        {
                super();
                layoutProperties = new LayoutProperties(getName());
                initialize_properties();                
        }
-       
+
        protected void initialize_properties()
        {       
                layoutProperties.initializeProperties();
@@ -44,7 +44,7 @@
        public void updateSettings() {
                updateSettings(false);
        }
-       
+
        /**
         *  DOCUMENT ME!
         *
@@ -100,67 +100,72 @@
                BASE_RADIUS += radius;
                construct();
        }
-       
+
        public void construct() {
                taskMonitor.setStatus("Initializing");
                initialize(); 
-               
 
-               // Find the root of the tree
-               Node root = commonFunctions.getTreeRoot(network);
+               // Verify that tree is indeed a tree
 
-               // Remove bends
+               
if(commonFunctions.hasLeaf(network)&&commonFunctions.isTree(network))
+               {
+                       // Find the root of the tree
+                       Node root = commonFunctions.getTreeRoot(network);
 
-               List<Edge> allEdges = network.edgesList();
-               Iterator<Edge> edgesIterator = allEdges.iterator();
+                       // Remove bends
 
-               while(edgesIterator.hasNext())
-               {
+                       List<Edge> allEdges = network.edgesList();
+                       Iterator<Edge> edgesIterator = allEdges.iterator();
 
-                       Edge edge = edgesIterator.next();
-                       networkView.getEdgeView(edge).clearBends();
-               }
-               numLeavesVisited = 0;
+                       while(edgesIterator.hasNext())
+                       {
 
-               // Obtain post order traversal of nodes starting from the root
-               List<Node> postOrderNodes = 
commonFunctions.postOrderTraverse(network, root);
+                               Edge edge = edgesIterator.next();
+                               networkView.getEdgeView(edge).clearBends();
+                       }
+                       numLeavesVisited = 0;
 
-               // Position each node
-               Iterator<Node> it = postOrderNodes.iterator();
-               while(it.hasNext())
-               {
-                       Node node = it.next();
-                       
-               
-                       // If leaf position it accordingly
-                       
if(network.getAdjacentEdgeIndicesArray(node.getRootGraphIndex(), false, false, 
true).length == 0)
-                               positionLeaf(node);
-                       else
-                               positionInternalNode(node);
-                               
-                               
-                       
-               }
-               
-               // Bend each edge to make it look circular
+                       // Obtain post order traversal of nodes starting from 
the root
+                       List<Node> postOrderNodes = 
commonFunctions.postOrderTraverse(network, root);
 
-               allEdges = network.edgesList();
-               edgesIterator = allEdges.iterator();
+                       // Position each node
+                       Iterator<Node> it = postOrderNodes.iterator();
+                       while(it.hasNext())
+                       {
+                               Node node = it.next();
 
-               while(edgesIterator.hasNext())
-               {
 
-                       Edge edge = edgesIterator.next();
-                       networkView.getEdgeView(edge).clearBends();
-                       commonFunctions.addCircularBends(network, networkView, 
edge);
+                               // If leaf position it accordingly
+                               
if(network.getAdjacentEdgeIndicesArray(node.getRootGraphIndex(), false, false, 
true).length == 0)
+                                       positionLeaf(node);
+                               else
+                                       positionInternalNode(node);
+
+
+
+                       }
+
+                       // Bend each edge to make it look circular
+
+                       allEdges = network.edgesList();
+                       edgesIterator = allEdges.iterator();
+
+                       while(edgesIterator.hasNext())
+                       {
+
+                               Edge edge = edgesIterator.next();
+                               networkView.getEdgeView(edge).clearBends();
+                               commonFunctions.addCircularBends(network, 
networkView, edge);
+                       }
+
                }
+               else
+                       System.out.println("The "+getName()+" layout can only 
be applied to trees.");
 
 
-               
-       
        }
-       
-       
+
+
        /**
         * positionLeaf(Node)
         * Positions the leaves
@@ -179,9 +184,9 @@
 
                networkView.getNodeView(node).setXPosition(nodeX,true);
                networkView.getNodeView(node).setYPosition(nodeY, true);        
-               
+
        }
-       
+
        /**
         * positionInternalNode(Node)
         * Positions the internal nodes
@@ -225,7 +230,7 @@
                double nodeX = radius * Math.cos(meanAngle); 
                double nodeY = radius * Math.sin(meanAngle); 
 
-               
+
                // Position
                networkView.getNodeView(node).setXPosition(nodeX,true);
                networkView.getNodeView(node).setYPosition(nodeY, true);
@@ -233,6 +238,6 @@
 
        }
 
-       
 
+
 }

Modified: 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/RadialCladogram.java
===================================================================
--- 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/RadialCladogram.java
    2009-08-07 06:21:26 UTC (rev 17734)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/RadialCladogram.java
    2009-08-07 09:25:23 UTC (rev 17735)
@@ -104,6 +104,10 @@
        public void construct() {
                taskMonitor.setStatus("Initializing");
                initialize(); 
+               
+               
if(commonFunctions.hasLeaf(network)&&commonFunctions.isTree(network))
+               {
+               
                // Remove bends
 
                List<Edge> allEdges = network.edgesList();
@@ -139,8 +143,10 @@
                                
                        
                }
-       
        }
+       else
+               System.out.println("The "+getName()+" layout can only be 
applied to trees.");
+       }
        
        
        /**

Modified: 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/RectangularCladogram.java
===================================================================
--- 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/RectangularCladogram.java
       2009-08-07 06:21:26 UTC (rev 17734)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/RectangularCladogram.java
       2009-08-07 09:25:23 UTC (rev 17735)
@@ -104,7 +104,9 @@
                taskMonitor.setStatus("Initializing");
                initialize(); 
 
-
+               
if(commonFunctions.hasLeaf(network)&&commonFunctions.isTree(network))
+               {
+               
                // Find the root of the tree
                Node root = commonFunctions.getTreeRoot(network);
                // Remove bends
@@ -151,6 +153,9 @@
                        networkView.getEdgeView(edge).clearBends();
                        commonFunctions.addRectangularBends(network, 
networkView, edge);
                }
+               }
+               else
+                       System.out.println("The "+getName()+" layout can only 
be applied to trees.");
 
 
 

Modified: 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/SlantedCladogram.java
===================================================================
--- 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/SlantedCladogram.java
   2009-08-07 06:21:26 UTC (rev 17734)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/SlantedCladogram.java
   2009-08-07 09:25:23 UTC (rev 17735)
@@ -105,7 +105,8 @@
                taskMonitor.setStatus("Initializing");
                initialize(); 
 
-
+               
if(commonFunctions.hasLeaf(network)&&commonFunctions.isTree(network))
+               {
                // Find the root of the tree
                Node root = commonFunctions.getTreeRoot(network);
                // Remove bends
@@ -139,8 +140,11 @@
                                
                        
                }
-       
        }
+       else
+               System.out.println("The "+getName()+" layout can only be 
applied to trees.");
+
+       }
        
        
        /**

Modified: 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/phylograms/CircularPhylogram.java
===================================================================
--- 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/phylograms/CircularPhylogram.java
  2009-08-07 06:21:26 UTC (rev 17734)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/phylograms/CircularPhylogram.java
  2009-08-07 09:25:23 UTC (rev 17735)
@@ -115,6 +115,9 @@
 
                // Intialize the common functions
                commonFunctions = new CommonFunctions();
+               
+               
if(commonFunctions.hasLeaf(network)&&commonFunctions.isTree(network))
+               {
                // Remove bends
 
                List<Edge> allEdges = network.edgesList();
@@ -174,6 +177,9 @@
                        commonFunctions.addCircularBends(network, networkView, 
edge);
                }
 
+               }
+               else
+                       System.out.println("The "+getName()+" layout can only 
be applied to trees.");
 
                
 

Modified: 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/phylograms/RadialPhylogram.java
===================================================================
--- 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/phylograms/RadialPhylogram.java
    2009-08-07 06:21:26 UTC (rev 17734)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/phylograms/RadialPhylogram.java
    2009-08-07 09:25:23 UTC (rev 17735)
@@ -115,7 +115,8 @@
 
                // Intialize the common functions
                commonFunctions = new CommonFunctions();
-
+               
if(commonFunctions.hasLeaf(network)&&commonFunctions.isTree(network))
+               {
                // Remove bends
 
                List<Edge> allEdges = network.edgesList();
@@ -162,6 +163,9 @@
                }
                                
                
+       }
+       else
+               System.out.println("The "+getName()+" layout can only be 
applied to trees.");
 
 
        }

Modified: 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/phylograms/RectangularPhylogram.java
===================================================================
--- 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/phylograms/RectangularPhylogram.java
       2009-08-07 06:21:26 UTC (rev 17734)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/phylograms/RectangularPhylogram.java
       2009-08-07 09:25:23 UTC (rev 17735)
@@ -115,6 +115,9 @@
 
                // Intialize the common functions
                commonFunctions = new CommonFunctions();
+               
+               
if(commonFunctions.hasLeaf(network)&&commonFunctions.isTree(network))
+               {
                // Remove bends
 
                List<Edge> allEdges = network.edgesList();
@@ -175,6 +178,9 @@
                        commonFunctions.addRectangularBends(network, 
networkView, edge);
                }
 
+       }
+       else
+               System.out.println("The "+getName()+" layout can only be 
applied to trees.");
 
                
 

Modified: 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/phylograms/SlantedPhylogram.java
===================================================================
--- 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/phylograms/SlantedPhylogram.java
   2009-08-07 06:21:26 UTC (rev 17734)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/phylograms/SlantedPhylogram.java
   2009-08-07 09:25:23 UTC (rev 17735)
@@ -117,6 +117,9 @@
 
                // Intialize the common functions
                commonFunctions = new CommonFunctions();
+               
+               
if(commonFunctions.hasLeaf(network)&&commonFunctions.isTree(network))
+               {
                // Remove bends
 
                List<Edge> allEdges = network.edgesList();
@@ -162,8 +165,11 @@
                        positionNodeX(node);
                        
                }
-                               
+               }
+               else
+                       System.out.println("The "+getName()+" layout can only 
be applied to trees.");
 
+
        }
        
        

Modified: 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/visualstyle/DepthwiseSize.java
===================================================================
--- 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/visualstyle/DepthwiseSize.java
    2009-08-07 06:21:26 UTC (rev 17734)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/visualstyle/DepthwiseSize.java
    2009-08-07 09:25:23 UTC (rev 17735)
@@ -116,9 +116,24 @@
                        {
                                Edge edge = 
network.getEdge(edgeIndicesArray[i]);
                                
edgeAttributes.setAttribute(edge.getIdentifier(),"Depth", depth);
+                               
                        }
                }
                
+               List<Edge> edgeList = network.edgesList();
+               Iterator<Edge> edgeListIterator = edgeList.iterator();
+               
+               while(edgeListIterator.hasNext())
+               {
+                       Edge edge = edgeListIterator.next();
+                       if(edge.getSource().getRootGraphIndex() == 
edge.getTarget().getRootGraphIndex())
+                               { 
+                                       int depth = 
nodeAttributes.getIntegerAttribute(edge.getSource().getIdentifier(), "Depth");
+                                       
edgeAttributes.setAttribute(edge.getIdentifier(),"Depth",depth);
+                               }
+               }
+               
+                       
                nodeAttributes.setUserVisible("Depth", false);
                edgeAttributes.setUserVisible("Depth", false);
                


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