Author: kono
Date: 2009-07-24 15:45:28 -0700 (Fri, 24 Jul 2009)
New Revision: 17561

Modified:
   csplugins/trunk/ucsd/kono/ShortestPath2/build.xml
   csplugins/trunk/ucsd/kono/ShortestPath2/resources/plugin.props
   
csplugins/trunk/ucsd/kono/ShortestPath2/src/org/cytoscape/analysis/shortestpath/ShortestPath.java
   
csplugins/trunk/ucsd/kono/ShortestPath2/src/org/cytoscape/analysis/shortestpath/ShortestPathPlugin.java
   
csplugins/trunk/ucsd/kono/ShortestPath2/src/org/cytoscape/analysis/shortestpath/internal/ShortestPathDialog.java
Log:
Table format had been modified.

Modified: csplugins/trunk/ucsd/kono/ShortestPath2/build.xml
===================================================================
--- csplugins/trunk/ucsd/kono/ShortestPath2/build.xml   2009-07-24 21:42:32 UTC 
(rev 17560)
+++ csplugins/trunk/ucsd/kono/ShortestPath2/build.xml   2009-07-24 22:45:28 UTC 
(rev 17561)
@@ -1,15 +1,14 @@
 <?xml version = "1.0"?>
-<project name="shortestPathPlugin2" default="all" basedir=".">
+<project name="ShortestPathPlugin2" default="all" basedir=".">
 
        <property name="src" location="src" />
        <property name="build" location="build" />
        <property name="build.compiler" value="modern" />
        <!-- path to Cytoscape under development (CVS) -->
        <property name="cylib" location="../cytoscape" />
-       <property name="lib" location="lib" />
        <property name="jar" location="jar" />
        <property name="doc" location="doc" />
-       <property name="projectName" value="shortestPathPlugin2" />
+       <property name="projectName" value="ShortestPathPlugin2" />
 
        <property name="cytoscape.plugin" value="${lib}/plugins" />
 
@@ -17,9 +16,6 @@
                <fileset dir="${cylib}">
                        <include name="**/*.jar" />
                </fileset>
-               <fileset dir="${lib}">
-                       <include name="**/*.jar" />
-               </fileset>
        </path>
 
        <target name="prepare" depends="clean">
@@ -40,20 +36,14 @@
        </target>
 
        <target name="jar" depends="compile" description="makes a jar for 
Cytoscape under development">
-               <mkdir dir="${jar}" />
-               <unzip dest="${build}">
-                       <fileset dir="${lib}" includes="*" />
-               </unzip>
-               <copy todir="build/org/cytoscape/view/ui/networkpanel" 
file="resources/plugin.props" />
-               <mkdir dir="build/org/cytoscape/view/ui/networkpanel/images"/>
-               <copy todir="build/org/cytoscape/view/ui/networkpanel/images">
-                       <fileset dir="images"/>
-               </copy>
-               <jar jarfile="${jar}/${projectName}.jar">
-                       <manifest>
-                               <attribute name="Cytoscape-Plugin" 
value="org.cytoscape.view.ui.networkpanel.NetworkBrowserPlugin" />
-                       </manifest>
+               
+               <copy todir="build/org/cytoscape/analysis/shortestpath" 
file="resources/plugin.props" />
+               
+               <jar jarfile="build/${projectName}.jar">
                        <fileset dir="${build}" />
+                       <manifest>
+                               <attribute name="Cytoscape-Plugin" 
value="org.cytoscape.analysis.shortestpath.ShortestPathPlugin" />
+                       </manifest>                     
                </jar>
        </target>
 
@@ -71,7 +61,7 @@
 
        <!-- Target to Run JavaDoc -->
        <target name="doc" description="Runs JavaDoc.">
-               <javadoc packagenames="cytoscape.groups.results.*" 
sourcepath="src" source="1.5" destdir="doc" classpathref="classpath_release">
+               <javadoc packagenames="org.cytoscape.analysis.shortestpath.*" 
sourcepath="src" source="1.5" destdir="doc" classpathref="classpath_release">
                        <link href="http://java.sun.com/j2se/1.5.0/docs/api/"; />
                        <link href="http://csbi.sourceforge.net/API/"; />
                        <link 
href="http://chianti.ucsd.edu/Cyto-2_4_1/javadoc/"; />

Modified: csplugins/trunk/ucsd/kono/ShortestPath2/resources/plugin.props
===================================================================
--- csplugins/trunk/ucsd/kono/ShortestPath2/resources/plugin.props      
2009-07-24 21:42:32 UTC (rev 17560)
+++ csplugins/trunk/ucsd/kono/ShortestPath2/resources/plugin.props      
2009-07-24 22:45:28 UTC (rev 17561)
@@ -6,20 +6,20 @@
 # -- The following properties are REQUIRED -- #
 
 # The plugin name that will be displayed to users
-pluginName=networkBrowser
+pluginName=ShortestPath2
 
 # Description used to give users information about the plugin such as what it 
does.  
 # Html tags are encouraged for formatting purposes.
-pluginDescription=Displays a list of groups created in a results panel.
+pluginDescription=Shortest Path plugin modified by Kei Ono
 
 # Plugin version number, this must be two numbers separated by a decimlal.  
Ex. 0.2, 14.03
-pluginVersion=1.0
+pluginVersion=2.0
 
 # Compatible Cytoscape version
 cytoscapeVersion=2.6
 
 # Category, use one of the categories listed on the website or create your own
-pluginCategory=Other
+pluginCategory=Analysis
 
 # -- The following properties are OPTIONAL -- #
 
@@ -31,4 +31,4 @@
 pluginAuthorsIntsitutions=Keiichiro Ono:UCSD
 
 # Date this plugin/plugin version was released
-releaseDate=July 1, 2009
+releaseDate=July 20, 2009

Modified: 
csplugins/trunk/ucsd/kono/ShortestPath2/src/org/cytoscape/analysis/shortestpath/ShortestPath.java
===================================================================
--- 
csplugins/trunk/ucsd/kono/ShortestPath2/src/org/cytoscape/analysis/shortestpath/ShortestPath.java
   2009-07-24 21:42:32 UTC (rev 17560)
+++ 
csplugins/trunk/ucsd/kono/ShortestPath2/src/org/cytoscape/analysis/shortestpath/ShortestPath.java
   2009-07-24 22:45:28 UTC (rev 17561)
@@ -1,27 +1,36 @@
 package org.cytoscape.analysis.shortestpath;
 
+import giny.model.Node;
 
+import java.io.BufferedWriter;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
 
-import java.util.*;
-
 import javax.swing.JOptionPane;
 
+import cytoscape.CyEdge;
 import cytoscape.CyNetwork;
 import cytoscape.CyNode;
-import cytoscape.CyEdge;
 import cytoscape.Cytoscape;
-import cytoscape.data.*;
-//import cytoscape.data.Semantics;
+import cytoscape.data.CyAttributes;
 import cytoscape.giny.CytoscapeRootGraph;
 import cytoscape.view.CyNetworkView;
 
 /**
  * 
- * Class to calculate the shortest path between 2 nodes in the network 
+ * Class to calculate the shortest path between 2 nodes in the network
  * considering the network as a directed or undirected graph.
  * 
  * @author mrsva
- *
+ * 
  */
 public class ShortestPath {
 
@@ -30,7 +39,7 @@
        private CytoscapeRootGraph root;
        private CyAttributes NodeAttributes;
        private CyAttributes EdgeAttributes;
-       //private boolean debug = true;
+       // private boolean debug = true;
        private boolean undirected;
        private boolean incoming;
        private boolean outcoming;
@@ -41,31 +50,34 @@
 
        /**
         * Get the selected nodes and calculate the shortest path
-        * @param directed use this parameter to indicate if the network is 
directed
+        * 
+        * @param directed
+        *            use this parameter to indicate if the network is directed
         */
-       public void calculate(boolean directed,String attribute) {
+       public List<Node> calculate(boolean directed, String attribute) {
                network = Cytoscape.getCurrentNetwork();
                view = Cytoscape.getCurrentNetworkView();
                NodeAttributes = Cytoscape.getNodeAttributes();
                EdgeAttributes = Cytoscape.getEdgeAttributes();
                root = Cytoscape.getRootGraph();
                selectedAttribute = attribute;
-               
-               if(!selectedAttribute.equals("Hop Distance"))
-               {
+
+               if (!selectedAttribute.equals("Hop Distance")) {
                        byte type = EdgeAttributes.getType(selectedAttribute);
-               
-                       if(type == EdgeAttributes.TYPE_INTEGER)
+
+                       if (type == EdgeAttributes.TYPE_INTEGER)
                                attributeIsInt = true;
-                       else if(type == EdgeAttributes.TYPE_FLOATING)
+                       else if (type == EdgeAttributes.TYPE_FLOATING)
                                attributeIsDouble = true;
                        else {
-                               
JOptionPane.showMessageDialog(view.getComponent(), 
-                               "The Attribute selected is no longer availible. 
Please update the attribute list");
-                               return;
+                               JOptionPane
+                                               .showMessageDialog(
+                                                               
view.getComponent(),
+                                                               "The Attribute 
selected is no longer availible. Please update the attribute list");
+                               return null;
                        }
                }
-               
+
                if (directed) {
                        setDirected();
                } else {
@@ -73,39 +85,42 @@
                }
                int[] selNodes = view.getSelectedNodeIndices();
                if (selNodes.length != 2) {
-                       JOptionPane.showMessageDialog(view.getComponent(), 
-                                       "You should select 2 nodes to get the 
shortest path between them");
+                       JOptionPane
+                                       .showMessageDialog(view.getComponent(),
+                                                       "You should select 2 
nodes to get the shortest path between them");
                }
                int result = 0;
                int node1 = selNodes[1];
                int node2 = selNodes[0];
-               CyNode n1 = (CyNode)network.getNode(node1);
-               CyNode n2 = (CyNode)network.getNode(node2);
-               
+               CyNode n1 = (CyNode) network.getNode(node1);
+               CyNode n2 = (CyNode) network.getNode(node2);
+
                if (directed) {
-                        result = 
JOptionPane.showConfirmDialog(view.getComponent(),"Source node = " +
-                                       n1.getIdentifier() +
-                                       "\nTarget node = " +
-                                       n2.getIdentifier() +
-                                       "\n \n Do you want to switch them 
around?");                    
-                       
+                       result = 
JOptionPane.showConfirmDialog(view.getComponent(),
+                                       "Source node = " + n1.getIdentifier() + 
"\nTarget node = "
+                                                       + n2.getIdentifier()
+                                                       + "\n \n Do you want to 
switch them around?");
+
                        if (result == 0) {
                                int tmp = node1;
                                node1 = node2;
                                node2 = tmp;
-                               
+
                        }
                }
-               if (result == 2) return; 
-               List shortestPath = getShortestPath(node1,node2);
-               
-               if (shortestPath == null){
+               if (result == 2)
+                       return null;
+
+               List<Node> shortestPath = getShortestPath(node1, node2);
+
+               if (shortestPath == null) {
                        JOptionPane.showMessageDialog(view.getComponent(),
                                        "There is no path between the selected 
nodes");
-               }
-               else {
+               } else {
                        network.setSelectedNodeState(shortestPath, true);
+
                }
+               return shortestPath;
        }
 
        /**
@@ -143,114 +158,219 @@
        /**
         * Calculates the shortest path between node1 and node2
         * 
-        * The algorithm is based on the code from dijkstra() function from 
NetworkX:
+        * The algorithm is based on the code from dijkstra() function from
+        * NetworkX:
         * 
         * 
http://networkx.sourceforge.net/Reference/NX.paths-module.html#dijkstra
         * 
         * but I didn't used the weight to calculate the distance. To do this, 
just
         * change the line:
         * 
-        * <pre>int vwLength = tmp.intValue() + 1;</pre>
+        * <pre>
+        * int vwLength = tmp.intValue() + 1;
+        * </pre>
         * 
         * in the source code to:
         * 
-        * <pre>int vwLength = tmp.intValue() + getWeight();</pre>
+        * <pre>
+        * int vwLength = tmp.intValue() + getWeight();
+        * </pre>
         * 
-        * and implement the method <pre>getWeight()</pre>.
+        * and implement the method
         * 
+        * <pre>
+        * getWeight()
+        * </pre>
+        * 
+        * .
+        * 
         * NetworkX website: http://networkx.sourceforge.net/
         * 
-        * @param node1 source node
-        * @param node2 target node
-        * @return list of nodes in the path between node1 and node2. If there 
is no path, returns null
+        * @param node1
+        *            source node
+        * @param node2
+        *            target node
+        * @return list of nodes in the path between node1 and node2. If there 
is no
+        *         path, returns null
         */
-       public List getShortestPath(int node1, int node2) {
+       public List<Node> getShortestPath(int node1, int node2) {
                boolean foundContradictory = false;
-               if (node1 == node2) return null;
-               int nnodes = root.getNodeCount();
-               CyNode cynode1 = (CyNode) network.getNode(node1);
-               CyNode cynode2 = (CyNode) network.getNode(node2);
-               HashMap dist = new HashMap();
-               HashMap paths = new HashMap();
-               List tmpList = new ArrayList();
+               if (node1 == node2)
+                       return null;
+
+               selectedAttribute = "Hop Distance";
+               setUndirected();
+               network = Cytoscape.getCurrentNetwork();
+               view = Cytoscape.getCurrentNetworkView();
+               NodeAttributes = Cytoscape.getNodeAttributes();
+               EdgeAttributes = Cytoscape.getEdgeAttributes();
+               root = Cytoscape.getRootGraph();
+               Node cynode1 = network.getNode(node1);
+               Node cynode2 = network.getNode(node2);
+
+               final Map<Node, Double> dist = new HashMap<Node, Double>();
+               final Map<Node, List<Node>> paths = new HashMap<Node, 
List<Node>>();
+
+               List<Node> tmpList = new ArrayList<Node>();
+
                tmpList.add(cynode1);
                paths.put(cynode1, tmpList);
-               Hashtable seen = new Hashtable();
-               seen.put(cynode1, new Double(0));
-               List fringe = new ArrayList();
+               Hashtable<Node, Double> seen = new Hashtable<Node, Double>();
+               seen.put(cynode1, 0.0);
+               List<Node> fringe = new ArrayList<Node>();
                fringe.add(cynode1);
+
+               Node v;
                while (!fringe.isEmpty()) {
-                       CyNode v = (CyNode) fringe.get(0);
+                       v = fringe.get(0);
                        int nv = root.getIndex(v);
                        int vnv = network.getIndex(v);
                        fringe.remove(0);
                        dist.put(v, seen.get(v));
-                       if (nv == node2) break;
-                       int[] adjEdges = 
network.getAdjacentEdgeIndicesArray(vnv,undirected,incoming,outcoming);
+                       if (nv == node2)
+                               break;
+
+                       int[] adjEdges = 
network.getAdjacentEdgeIndicesArray(vnv,
+                                       undirected, incoming, outcoming);
                        int[] adjNodes = new int[adjEdges.length];
                        for (int i = 0; i < adjNodes.length; i++) {
                                int node = 
network.getEdgeSourceIndex(adjEdges[i]);
-                               if (node == nv) 
+                               if (node == nv)
                                        node = 
network.getEdgeTargetIndex(adjEdges[i]);
                                adjNodes[i] = node;
                        }
-                       if ((adjEdges.length == 0) && (paths.size() == 1)) 
return null;
+                       if ((adjEdges.length == 0) && (paths.size() == 1))
+                               return null;
                        for (int n = 0; n < adjNodes.length; n++) {
                                int nw = adjNodes[n];
                                CyNode w = (CyNode) network.getNode(nw);
                                Double tmp = (Double) dist.get(v);
-                               CyEdge edge = 
(CyEdge)network.getEdge(adjEdges[n]);
+                               CyEdge edge = (CyEdge) 
network.getEdge(adjEdges[n]);
                                double vwLength = tmp.doubleValue() + 
getWeight(edge);
                                if (dist.containsKey(w)) {
-                                       Double tmp2 = (Double)dist.get(w);
-                                       if (vwLength < tmp2.doubleValue()){
+                                       Double tmp2 = (Double) dist.get(w);
+                                       if (vwLength < tmp2.doubleValue()) {
                                                if (!foundContradictory) {
                                                        
System.err.println("Contraditory paths found");
-                                                       foundContradictory=true;
+                                                       foundContradictory = 
true;
                                                }
                                        }
+                               } else {
+                                       Double tmp3 = (Double) seen.get(w);
+                                       if ((!seen.containsKey(w))
+                                                       || (vwLength < 
tmp3.doubleValue())) {
+                                               seen.put(w, new 
Double(vwLength));
+                                               fringe.add(w);
+                                               List tmpList2 = new ArrayList();
+                                               tmpList2.add(w);
+                                               List tmpList3 = (List) 
paths.get(v);
+                                               List tmpList4 = new ArrayList();
+                                               tmpList4.addAll(tmpList3);
+                                               tmpList4.addAll(tmpList2);
+                                               paths.put(w, tmpList4);
+                                       }
                                }
-                                       else {
-                                               Double tmp3 = (Double) 
seen.get(w);
-                                               if ((!seen.containsKey(w)) || 
(vwLength < tmp3.doubleValue())) {
-                                                       seen.put(w, new 
Double(vwLength));
-                                                       fringe.add(w);
-                                                       List tmpList2 = new 
ArrayList();
-                                                       tmpList2.add(w);
-                                                       List tmpList3 = 
(List)paths.get(v);
-                                                       List tmpList4 = new 
ArrayList();
-                                                       
tmpList4.addAll(tmpList3);
-                                                       
tmpList4.addAll(tmpList2);
-                                                       paths.put(w, tmpList4);
-                                               }
-                                       }
                        }
                }
-               List path = (List) paths.get(cynode2);
-               double pathDist = ((Double)dist.get(cynode2)).doubleValue();
+
+               List<Node> path = paths.get(cynode2);
+
+               Double pathDist = dist.get(cynode2);
+
                if (attributeIsNegLog && pathDist != 0.0) {
-                       pathDist = Math.pow(10,-pathDist);
+                       pathDist = Math.pow(10, -pathDist);
                }
-               JOptionPane.showMessageDialog(view.getComponent(), 
-                       "Length of Path is " + pathDist);
+               // JOptionPane.showMessageDialog(view.getComponent(),
+               // "Length of Path is "
+               // + pathDist);
                return path;
        }
 
-       
-       private double getWeight(CyEdge edge) { 
-               
-               if(selectedAttribute.equals("Hop Distance"))
+       private double getWeight(CyEdge edge) {
+
+               if (selectedAttribute.equals("Hop Distance"))
                        return 1;
-               
-               else if(attributeIsInt)
-                       return 
EdgeAttributes.getIntegerAttribute(edge.getIdentifier(),selectedAttribute).doubleValue();
+
+               else if (attributeIsInt)
+                       return 
EdgeAttributes.getIntegerAttribute(edge.getIdentifier(),
+                                       selectedAttribute).doubleValue();
                else {
-                       double attr = 
EdgeAttributes.getDoubleAttribute(edge.getIdentifier(),selectedAttribute).doubleValue();
+                       double attr = EdgeAttributes.getDoubleAttribute(
+                                       edge.getIdentifier(), 
selectedAttribute).doubleValue();
                        if (attributeIsNegLog) {
                                attr = -Math.log10(attr);
                        }
-                       return attr;    
+                       return attr;
                }
        }
+
+       public void searchAll() {
+               CyNetwork net = Cytoscape.getCurrentNetwork();
+               Random rnd = new Random(System.currentTimeMillis());
+               List<Node> nodes = net.nodesList();
+               
+               final Set<String> pairs = new HashSet<String>();
+
+               try {
+                       FileOutputStream fos = new FileOutputStream("path_"
+                                       + net.getTitle() + ".txt");
+                       OutputStreamWriter osw = new OutputStreamWriter(fos);
+                       BufferedWriter bw = new BufferedWriter(osw);
+                       StringBuilder builder = new StringBuilder();
+                       
+
+                       Node node2;
+                       Node node1;
+                       int index = 0;
+                       String pairName;
+                       String pairNameR;
+                       
+                       builder.append("Index\tPath\tPath Length\n");
+                       while(index < 1000) {
+                               node1 = nodes.get(rnd.nextInt(nodes.size()));
+                               node2 = nodes.get(rnd.nextInt(nodes.size()));
+                               
if(node1.getIdentifier().equals(node2.getIdentifier()))
+                                       continue;
+                               
+                               pairName = node1.getIdentifier() + ":" + 
node2.getIdentifier();
+                               pairNameR = node2.getIdentifier() + ":" + 
node1.getIdentifier();
+                               if(pairs.contains(pairName) || 
pairs.contains(pairNameR))
+                                       continue;
+                               pairs.add(pairName);
+                               pairs.add(pairNameR);
+                               
+                               builder.append("Pair " + (index+1) + ":\t");
+                               builder.append(node1.getIdentifier() + " to "
+                                               + node2.getIdentifier() + "\t");
+
+                               List<Node> path = 
getShortestPath(node1.getRootGraphIndex(),
+                                               node2.getRootGraphIndex());
+
+                               
+                               if (path != null) {
+                                       builder.append(path.size() + "\t");
+                                       
+                                       for (Node n2 : path) {
+                                               
builder.append(n2.getIdentifier() + "\t");
+                                       }
+                                       builder.append("\n");
+                               } else {
+                                       builder.append("0\t");
+                                       builder.append("No Path!!\n");
+                               }
+                               index++;
+                               
+                       }
+                       bw.write(builder.toString());
+                       
+                       bw.close();
+                       osw.close();
+                       fos.close();
+
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+               
+               System.out.println("Path search done!!");
+       }
 }
-

Modified: 
csplugins/trunk/ucsd/kono/ShortestPath2/src/org/cytoscape/analysis/shortestpath/ShortestPathPlugin.java
===================================================================
--- 
csplugins/trunk/ucsd/kono/ShortestPath2/src/org/cytoscape/analysis/shortestpath/ShortestPathPlugin.java
     2009-07-24 21:42:32 UTC (rev 17560)
+++ 
csplugins/trunk/ucsd/kono/ShortestPath2/src/org/cytoscape/analysis/shortestpath/ShortestPathPlugin.java
     2009-07-24 22:45:28 UTC (rev 17561)
@@ -10,15 +10,13 @@
 import javax.swing.JMenu;
 import javax.swing.JMenuItem;
 import javax.swing.SwingUtilities;
-import javax.swing.JOptionPane;
 
 import org.cytoscape.analysis.shortestpath.internal.ShortestPathDialog;
 
 import cytoscape.Cytoscape;
 import cytoscape.data.CyAttributes;
-import cytoscape.view.CyNetworkView;
+import cytoscape.plugin.CytoscapePlugin;
 import cytoscape.view.CytoscapeDesktop;
-import cytoscape.plugin.CytoscapePlugin;
 
 /**
  * Plugin for Cytoscape to find the shortest path between 2 nodes in a network.
@@ -56,6 +54,11 @@
 
                // Now add our default
                addMenuItem(menu, "Hop Distance");
+               
+               JMenuItem item = new JMenuItem("Search All");
+               SearchAllMenuActionListener va = new 
SearchAllMenuActionListener();
+               item.addActionListener(va);
+               menu.add(item);
 
                //Finds all attributes that are integers or doubles, and adds 
them to list
                for(int i = 0; i < attributeNames.length; i++)
@@ -97,7 +100,22 @@
                        });
                }
        }
+       
+       private class SearchAllMenuActionListener extends AbstractAction {
 
+               public SearchAllMenuActionListener () {
+               }
+
+               public void actionPerformed(ActionEvent ev) {
+                       SwingUtilities.invokeLater(new Runnable() {
+                               public void run() {
+                                       ShortestPath alg = new ShortestPath();
+                                       alg.searchAll();
+                               }
+                       });
+               }
+       }
+
   public void propertyChange(PropertyChangeEvent evt) {
     if ( evt.getPropertyName() == CytoscapeDesktop.NETWORK_VIEW_CREATED ){
       // Recreate the menu

Modified: 
csplugins/trunk/ucsd/kono/ShortestPath2/src/org/cytoscape/analysis/shortestpath/internal/ShortestPathDialog.java
===================================================================
--- 
csplugins/trunk/ucsd/kono/ShortestPath2/src/org/cytoscape/analysis/shortestpath/internal/ShortestPathDialog.java
    2009-07-24 21:42:32 UTC (rev 17560)
+++ 
csplugins/trunk/ucsd/kono/ShortestPath2/src/org/cytoscape/analysis/shortestpath/internal/ShortestPathDialog.java
    2009-07-24 22:45:28 UTC (rev 17561)
@@ -1,88 +1,91 @@
 package org.cytoscape.analysis.shortestpath.internal;
 
-
-
+import java.awt.Frame;
+import java.awt.GridLayout;
 import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 
-import javax.swing.*;
-import javax.swing.WindowConstants.*;
-import javax.swing.border.*;
+import javax.swing.BorderFactory;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JDialog;
+import javax.swing.JPanel;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.EtchedBorder;
 
 import org.cytoscape.analysis.shortestpath.ShortestPath;
 
-import java.awt.Frame;
-import java.awt.GridLayout;
-import java.awt.event.*;
-
 import cytoscape.Cytoscape;
 import cytoscape.data.CyAttributes;
-import cytoscape.view.CyNetworkView;
-import cytoscape.plugin.CytoscapePlugin;
 
 /**
  * Plugin for Cytoscape to find the shortest path between 2 nodes in a network.
  * It is possible to find the shortest path in directed and undirected networks
  * 
  * @author mrsva
- *
+ * 
  */
 public class ShortestPathDialog extends JDialog implements ActionListener {
        String selectedAttribute = null;
        JCheckBox dirButton;
        JCheckBox logButton;
 
-       public ShortestPathDialog (Frame parent, String attribute) {
+       public ShortestPathDialog(Frame parent, String attribute) {
                super(parent, false);
                this.selectedAttribute = attribute;
                setDefaultCloseOperation(DISPOSE_ON_CLOSE);
-               setTitle("Find Shorted Path using "+selectedAttribute);
+               setTitle("Find Shorted Path using " + selectedAttribute);
 
                JPanel dataPanel = new JPanel();
                BoxLayout layout = new BoxLayout(dataPanel, 
BoxLayout.PAGE_AXIS);
-    dataPanel.setLayout(layout);
+               dataPanel.setLayout(layout);
 
-               JPanel checkBoxes = new JPanel(new GridLayout(2,1));
+               JPanel checkBoxes = new JPanel(new GridLayout(2, 1));
                // Set up our radio buttons (Directed vs Undirected)
                dirButton = new JCheckBox("Calculate path assuming directed 
edges");
                dirButton.setSelected(false);
                checkBoxes.add(dirButton);
 
-               logButton = new JCheckBox("Weights are expectation values (will 
use negative log)");
+               logButton = new JCheckBox(
+                               "Weights are expectation values (will use 
negative log)");
                {
                        logButton.setSelected(false);
                        checkBoxes.add(logButton);
                        // Is the negative log option available?
                        CyAttributes EdgeAttributes = 
Cytoscape.getEdgeAttributes();
                        byte type = EdgeAttributes.getType(selectedAttribute);
-                       if(type == EdgeAttributes.TYPE_INTEGER) {
+                       if (type == EdgeAttributes.TYPE_INTEGER) {
                                // No
                                logButton.setEnabled(false);
                        }
                }
                checkBoxes.add(logButton);
-               checkBoxes.setBorder(new CompoundBorder(
-                  BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
-                  new EmptyBorder(10,10,10,10)));
+               checkBoxes.setBorder(new CompoundBorder(BorderFactory
+                               .createEtchedBorder(EtchedBorder.LOWERED), new 
EmptyBorder(10,
+                               10, 10, 10)));
 
                dataPanel.add(checkBoxes);
 
-    // Create the button box
-    JPanel buttonBox = new JPanel();
-    JButton doneButton = new JButton("Done");
-    doneButton.setActionCommand("done");
-    doneButton.addActionListener(this);
+               // Create the button box
+               JPanel buttonBox = new JPanel();
+               JButton doneButton = new JButton("Done");
+               doneButton.setActionCommand("done");
+               doneButton.addActionListener(this);
 
-    JButton findButton = new JButton("Find Shortest Path");
-    findButton.setActionCommand("find");
-    findButton.addActionListener(this);
-    buttonBox.add(doneButton);
-    buttonBox.add(findButton);
-    
buttonBox.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
+               JButton findButton = new JButton("Find Shortest Path");
+               findButton.setActionCommand("find");
+               findButton.addActionListener(this);
+               buttonBox.add(doneButton);
+               buttonBox.add(findButton);
+               buttonBox.setBorder(BorderFactory
+                               .createEtchedBorder(EtchedBorder.LOWERED));
 
-    dataPanel.add(buttonBox);
-    setContentPane(dataPanel);
+               dataPanel.add(buttonBox);
+               setContentPane(dataPanel);
        }
-       
+
        public void actionPerformed(ActionEvent e) {
                if ("done".equals(e.getActionCommand())) {
                        setVisible(false);
@@ -94,9 +97,9 @@
                                sp.setNegativeLog(false);
                        }
                        if (dirButton.isSelected()) {
-                               sp.calculate(true,selectedAttribute); 
+                               sp.calculate(true, selectedAttribute);
                        } else {
-                               sp.calculate(false,selectedAttribute); 
+                               sp.calculate(false, selectedAttribute);
                        }
                }
        }


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