Author: chinmoy
Date: 2009-07-29 22:06:54 -0700 (Wed, 29 Jul 2009)
New Revision: 17623

Modified:
   
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/PhylotreePlugin.java
   
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/actions/PhyloTreeImportAction.java
   
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/actions/PhyloTreeLayoutAction.java
   
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/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
Log:


Modified: 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/PhylotreePlugin.java
===================================================================
--- 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/PhylotreePlugin.java
      2009-07-30 03:15:33 UTC (rev 17622)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/PhylotreePlugin.java
      2009-07-30 05:06:54 UTC (rev 17623)
@@ -1,7 +1,14 @@
 package org.cytoscape.phylotree;
 
 
+import java.awt.Component;
+import java.awt.PopupMenu;
+
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+
 import cytoscape.Cytoscape;
+import cytoscape.layout.CyLayouts;
 import cytoscape.plugin.CytoscapePlugin;
 import cytoscape.util.CytoscapeAction;
 import org.cytoscape.phylotree.actions.PhyloTreeImportAction;
@@ -32,8 +39,26 @@
                
Cytoscape.getDesktop().getCyMenus().addCytoscapeAction((CytoscapeAction) 
menuAction);
                
                
+               
+               
                //(2) add another menu item: Layout->Phylotree layouts
-
+               
+               
+//             RectangularCladogram a = new RectangularCladogram();
+//             CyLayouts.addLayout(a,"Phylotree Layouts");
+//             
+//             
Cytoscape.getDesktop().update(Cytoscape.getDesktop().getGraphics());
+//             
+//             JMenu j = Cytoscape.getDesktop().getCyMenus().getLayoutMenu();
+//             JMenuItem jt;
+//             
+//             for(int i = 0; i<j.getItemCount(); i++)
+//             {
+//                     jt= j.getItem(i);
+//                     if(jt!=null)
+//                     System.out.println("Name: "+i+" "+jt.getText());
+//             }
+               
                PhyloTreeLayoutAction layoutAction = new 
PhyloTreeLayoutAction(new RectangularCladogram());
                
Cytoscape.getDesktop().getCyMenus().addCytoscapeAction((CytoscapeAction) 
layoutAction);
                
@@ -58,6 +83,7 @@
                layoutAction = new PhyloTreeLayoutAction(new 
CircularPhylogram());
                
Cytoscape.getDesktop().getCyMenus().addCytoscapeAction((CytoscapeAction) 
layoutAction);
                                
+               
        }
        
 }

Modified: 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/actions/PhyloTreeImportAction.java
===================================================================
--- 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/actions/PhyloTreeImportAction.java
        2009-07-30 03:15:33 UTC (rev 17622)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/actions/PhyloTreeImportAction.java
        2009-07-30 05:06:54 UTC (rev 17623)
@@ -14,6 +14,8 @@
 import org.cytoscape.phylotree.parser.*;
 import org.forester.io.parsers.PhylogenyParserException;
 import org.forester.io.parsers.phyloxml.PhyloXmlParser;
+
+import org.forester.phylogeny.data.*;
 import org.forester.phylogeny.Phylogeny;
 import org.forester.phylogeny.PhylogenyNode;
 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
@@ -22,6 +24,7 @@
 import java.io.IOException;
 import java.util.List;
 import java.util.Iterator;
+import java.util.Map;
 
 import cytoscape.layout.CyLayouts;
 
@@ -49,7 +52,15 @@
                }
                else if (pFormat.equalsIgnoreCase("phyloxml")){
                        loadnetwork_phyloXML(pFile);
-               }               
+               }
+               
+
+               // Apply default layout
+               CyLayouts.getLayout("slanted_cladogram").doLayout();
+               
+               // Apply visual style
+               Cytoscape.firePropertyChange(Cytoscape.VIZMAP_LOADED, null, 
"phyloVizMap.props");
+               
        }
        
        
@@ -97,11 +108,6 @@
                cyAttributes.setUserEditable("branchLength", false);
                cyAttributes.setUserVisible("branchLength", true);
                
-               // Apply default layout
-               CyLayouts.getLayout("slanted_cladogram").doLayout();
-               
-               // Apply visual style
-               Cytoscape.firePropertyChange(Cytoscape.VIZMAP_LOADED, null, 
"phyloVizMap.props");
 
        }
        
@@ -115,29 +121,87 @@
                        trees = parser.parse(); 
                }
                catch (PhylogenyParserException ppe){
-                       // give some message here
+                       System.out.println("PhloXML Parser error occured.");
                        return;
                }
                catch(IOException ioe){
-                       // give some message here
+                       System.out.println("I/O Error occured.");
                        return;
                }
 
                for (int i=0; i< trees.length; i++){
                        PhylogenyNodeIterator it = 
trees[i].iteratorLevelOrder();
-
+                       
+                       // Create a network
+                       CyNetwork cyNetwork = 
Cytoscape.createNetwork(trees[i].getName(), true);
+                       
+                       CyAttributes edgeAttributes = 
Cytoscape.getEdgeAttributes();
+                       CyAttributes nodeAttributes = 
Cytoscape.getNodeAttributes();
+                       
+                       // Add network attributes
+                       addNetworkAttributes(trees[i]);
+                       
                        // process each node, get node, edge and attributes     
                
-                       while (it.hasNext()){
+                       while (it.hasNext())
+                       {
                                PhylogenyNode node = (PhylogenyNode) it.next();
-                               //String nodeName = node.getNodeName();
-                               //NodeData nodeData = node.getNodeData(); // 
for attributes
-                               //Node parent = node.getParent(); // for edge
+                               PhylogenyNode parent = node.getParent(); // for 
edge
+                               
+                               // Add the node to the network
+                               CyNode cyNode = 
Cytoscape.getCyNode(node.getNodeName(), true);
+                               // Add the node's attributes
+                               NodeData nodeData = node.getNodeData();
+                               
+                               cyNetwork.addNode(cyNode);
+                               double length = 0.0;
+                               
+                               // If parent exists, add it as well as all 
edges connecting the two
+                               if(parent!=null)
+                               {
+                                       CyNode cyParent = 
Cytoscape.getCyNode(parent.getNodeName(), true);
+                                       // Add the parent's attributes
 
+                                       cyNetwork.addNode(cyParent);
+
+                                       
+                                       CyEdge cyEdge = 
Cytoscape.getCyEdge(cyParent, cyNode, Semantics.INTERACTION, "pp", true, true);
+                                       // Add the edge's attributes
+
+                                               length = 
node.getDistanceToParent();
+                                               System.out.println(length);
+                                       
+                                       
+                                       
edgeAttributes.setAttribute(cyEdge.getIdentifier(), "branchLength", length);
+                                       cyNetwork.addEdge(cyEdge);
+
+                               }
                        }
                }
 
-               //build Cytoscape network here, create Cytoscape attributes here
                
        }
+       
+       private void addNetworkAttributes(Phylogeny phy )
+       {
+               CyAttributes networkAttributes = 
Cytoscape.getNetworkAttributes();
+               
+               
+               
+               if(phy.getConfidence()!=null)
+                       
networkAttributes.setAttribute(phy.getName(),"Confidence",phy.getConfidence().getValue());
+               
+               if(phy.getDescription()!=null)
+                       
networkAttributes.setAttribute(phy.getName(),"Description",phy.getDescription());
+               
+               if(phy.getDistanceUnit()!=null)
+                       networkAttributes.setAttribute(phy.getName(),"Distance 
Unit",phy.getDistanceUnit());
+               
+//             if(phy.getDescription()!=null)
+//                     
networkAttributes.setAttribute(phy.getName(),"Description",phy.getDescription());
+//             if(phy.getDescription()!=null)
+//                     
networkAttributes.setAttribute(phy.getName(),"Description",phy.getDescription());
+               
+               
+       }
 
 }

Modified: 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/actions/PhyloTreeLayoutAction.java
===================================================================
--- 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/actions/PhyloTreeLayoutAction.java
        2009-07-30 03:15:33 UTC (rev 17622)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/actions/PhyloTreeLayoutAction.java
        2009-07-30 05:06:54 UTC (rev 17623)
@@ -1,12 +1,16 @@
 package org.cytoscape.phylotree.actions;
 
+import java.awt.Graphics;
 import java.awt.event.ActionEvent;
 
+
 import cytoscape.Cytoscape;
 import cytoscape.layout.AbstractLayout;
 import cytoscape.util.CytoscapeAction;
 
 import cytoscape.layout.CyLayouts;
+import cytoscape.layout.ui.LayoutMenu;
+import cytoscape.layout.ui.LayoutMenuManager;
 
 public class PhyloTreeLayoutAction extends CytoscapeAction{
        
@@ -16,13 +20,17 @@
                
                super(layout.toString());
                layout_name = layout.getName();
-               CyLayouts.addLayout(layout, null);
+               
                if(layout_name.equals("rectangular_cladogram")|| 
layout_name.equals("slanted_cladogram")
                                || layout_name.equals("radial_cladogram")
                                || layout_name.equals("circular_cladogram"))
                        setPreferredMenu("Layout.Phylotree Layouts.Cladogram 
Layouts");
                else
+               {
                        setPreferredMenu("Layout.Phylotree Layouts.Phylogram 
Layouts");
+                                       
+               }
+               CyLayouts.addLayout(layout, null);
                
        }
 

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-07-30 03:15:33 UTC (rev 17622)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/CommonFunctions.java
       2009-07-30 05:06:54 UTC (rev 17623)
@@ -321,8 +321,8 @@
                
                // Calculate the scaling factor
                
-               while(smallestLength * factor <= 50.0)
-                       factor *= 10.0;
+               while(smallestLength * factor <= 50.0) //50
+                       factor *= 10.0;                     //10
                
                
                return factor;          
@@ -330,7 +330,7 @@
        
        /**
         * Adds the bends to make the edges look rectangular
-        * * @param network - the network on which the bends are to be added
+        * @param network - the network on which the bends are to be added
         * @param networkView - the networkView on which bends are to be added
         * @param edge - the edge onto which bends are to be added
         */

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-07-30 03:15:33 UTC (rev 17622)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/CircularCladogram.java
  2009-07-30 05:06:54 UTC (rev 17623)
@@ -16,7 +16,7 @@
 
 public class CircularCladogram extends AbstractLayout{
        
-       static double BASE_RADIUS = 50.0;
+       static double BASE_RADIUS = 100.0;
        
        private LayoutProperties layoutProperties;
        

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-07-30 03:15:33 UTC (rev 17622)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/cladograms/RadialCladogram.java
    2009-07-30 05:06:54 UTC (rev 17623)
@@ -16,7 +16,7 @@
 
 public class RadialCladogram extends AbstractLayout{
        
-       static double BASE_RADIUS = 50.0;
+       static double BASE_RADIUS = 100.0;
        
        private LayoutProperties layoutProperties;
        

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-07-30 03:15:33 UTC (rev 17622)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/phylograms/CircularPhylogram.java
  2009-07-30 05:06:54 UTC (rev 17623)
@@ -16,7 +16,7 @@
 
 public class CircularPhylogram extends AbstractLayout{
 
-       static double BASE_RADIUS = 500.0;
+       static double BASE_RADIUS = 1000.0;
 
        private int numLeavesVisited = 0; //
        private LayoutProperties layoutProperties;
@@ -75,9 +75,9 @@
                JPanel panel = new JPanel(new GridLayout(0, 1));
                panel.add(layoutProperties.getTunablePanel());
 
-               
                return panel;
        }
+       
 
 
        /**
@@ -126,6 +126,9 @@
                        Edge edge = edgesIterator.next();
                        networkView.getEdgeView(edge).clearBends();
                }
+               
+
+               scalingFactor = commonFunctions.getScalingFactor(network);
                // Find the root of the tree
                Node root = commonFunctions.getTreeRoot(network);
                
@@ -193,8 +196,9 @@
                        Node ancestor = it.next();
                        totalRadius = totalRadius + 
commonFunctions.getBranchLength(network, ancestor);
                }
-               totalRadius = 
totalRadius+commonFunctions.getBranchLength(network, node);
                
+               totalRadius = 
totalRadius+(commonFunctions.getBranchLength(network, node));
+               
                // Reposition node
                
networkView.getNodeView(node).setXPosition(totalRadius*BASE_RADIUS*Math.cos(angle),true);
                
networkView.getNodeView(node).setYPosition(totalRadius*BASE_RADIUS*Math.sin(angle),true);

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-07-30 03:15:33 UTC (rev 17622)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/phylograms/RadialPhylogram.java
    2009-07-30 05:06:54 UTC (rev 17623)
@@ -16,7 +16,7 @@
 
 public class RadialPhylogram extends AbstractLayout{
 
-       static double BASE_RADIUS = 500.0;
+       static double BASE_RADIUS = 1000.0;
 
        private int numLeavesVisited = 0; //
        private LayoutProperties layoutProperties;
@@ -127,7 +127,8 @@
                        Edge edge = edgesIterator.next();
                        networkView.getEdgeView(edge).clearBends();
                }
-               
+
+               scalingFactor = commonFunctions.getScalingFactor(network);
                // Find the root of the tree
                Node root = commonFunctions.getTreeRoot(network);
                

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-07-30 03:15:33 UTC (rev 17622)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/phylograms/RectangularPhylogram.java
       2009-07-30 05:06:54 UTC (rev 17623)
@@ -119,13 +119,16 @@
 
                List<Edge> allEdges = network.edgesList();
                Iterator<Edge> edgesIterator = allEdges.iterator();
-
+               
                while(edgesIterator.hasNext())
                {
 
                        Edge edge = edgesIterator.next();
                        networkView.getEdgeView(edge).clearBends();
                }
+
+               scalingFactor = commonFunctions.getScalingFactor(network);
+               
                // Find the root of the tree
                Node root = commonFunctions.getTreeRoot(network);
                

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-07-30 03:15:33 UTC (rev 17622)
+++ 
csplugins/trunk/soc/chinmoy/phylotree/src/org/cytoscape/phylotree/layout/phylograms/SlantedPhylogram.java
   2009-07-30 05:06:54 UTC (rev 17623)
@@ -129,7 +129,8 @@
                        networkView.getEdgeView(edge).clearBends();
                }
                
-               
+
+               scalingFactor = commonFunctions.getScalingFactor(network);
                // Find the root of the tree
                Node root = commonFunctions.getTreeRoot(network);
                


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