();
+ private GoReader goReader = null;
+ private boolean pwaysRead = false;
+ private GoMap goMap = null;
+
+ private String martexport;
+ private String pgdb;
+ private String pathwayroot;
+
+ /**
+ *
+ * The program requires 4 args:
+ * Gene ontology database (e.g. "C:\\gene_ontology.obo")
+ * Pathway database (e.g. "C:\\databases\\Rn_39_34i.pgdb")
+ * Pathways (e.g. "C:\\WPClient\\Rattus_norvegicus")
+ * Table from GOid to Ensembl (e.g. C:\\mart_export1.txt") *
+ */
+ public static void main(String[] args) throws DataException, ConverterException
+ {
+ GoTermDistributionGUI x = new GoTermDistributionGUI(
+ new File (args[0]), args[1], args[2], args[3]);
+ x.run();
+ }
+
+ public static void goTermDistribution(String[]args,String[]organism) throws DataException, ConverterException
+ {
+ GoTermDistributionGUI x = new GoTermDistributionGUI(
+ new File (args[3]), args[0] + organism[0], args[1] + organism[1], args[4]);
+ x.run();
+ }
+
+ public GoTermDistributionGUI(File oboFile,
+ String pgdb,
+ String pathwayroot, String martexport)
+ {
+ goReader = new GoReader (oboFile);
+ this.pgdb = pgdb;
+ this.martexport = martexport;
+ this.pathwayroot = pathwayroot;
+ }
+
+ public void readPathwayData()
+ {
+ try
+ {
+ genidInPway = GenidPway.getGenidPways(pgdb, pathwayroot);
+ }
+ catch(DataException e)
+ {
+ System.out.println("Error!");
+ }
+ catch(ConverterException e)
+ {
+ System.out.println("Error!");
+ }
+
+ System.out.println("Pathways read");
+
+ goMap = new GoMap (new File (martexport));
+
+ goMap.calculateNM (goReader.getRoots(), genidInPway);
+
+ pwaysRead = true;
+ }
+
+ public void run () throws DataException, ConverterException
+ {
+ // create a new frame
+ final JFrame frame = new JFrame("GOTerm Distribution");
+
+ // When click on exit, exit the frame
+ frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
+
+ // set the size of the frame
+ frame.setSize(350,570);
+ frame.setLayout(new BorderLayout());
+
+ // create a new panel
+ JPanel canvasButtons = new JPanel();
+
+ GoTreeModel model = new GoTreeModel(goReader.getRoots());
+ final JTree tree = new JTree(model) {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String convertValueToText (
+ Object value,
+ boolean selected,
+ boolean expended,
+ boolean leaf,
+ int row,
+ boolean hasFocus)
+ {
+ if (!pwaysRead || !(value instanceof GoTerm))
+ {
+ return "" + value;
+ }
+ GoTerm goterm = (GoTerm)value;
+
+ // get the number of genes in this term
+ int m = goMap.getM(goterm);
+
+ // get the number of genes the term overlaps with all the pathway genes
+ int n = goMap.getN(goterm);
+
+ // create a string with the goterm name, and the n and m values
+ // (see above) and print it to the console
+ double percentage = ((double)n/(double)m)*100;
+ return goterm.getName() + " " + "("+n+"/"+m+") ("+String.format("%3.1f", percentage)+"%)";
+ }
+ };
+
+ // set the selectionmodel (only one branch can be selected at one time)
+ tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
+
+ // create two new buttons, using the makeButton method
+ JButton calcButton = makeButton("Calculate");
+ JButton closeButton = makeButton("Close");
+
+ // add the functionality to the close button
+ closeButton.addActionListener(
+ new ActionListener(){
+ public void actionPerformed(ActionEvent ae){
+ // close the program when the button is clicked
+ frame.dispose();
+ }
+ }
+ );
+
+ // add the functionality to the calculate button
+ calcButton.addActionListener(
+ new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ae)
+ {
+ if (!pwaysRead)
+ {
+ readPathwayData();
+ tree.invalidate(); // cause repaint
+ }
+ }
+ });
+
+ // add the buttons to the canvas
+ canvasButtons.add(calcButton);
+ canvasButtons.add(closeButton);
+
+ // add the canvas to the frame
+ frame.add(canvasButtons, BorderLayout.SOUTH);
+
+ // create a scroll pane containing the tree
+ JScrollPane scrollPane = new JScrollPane(tree);
+
+ // add the canvas to the frame
+ frame.add(scrollPane, BorderLayout.CENTER);
+ // Show the frame
+ frame.setVisible(true);
+ }
+
+ /**
+ * create a new JButton of a preferred size, and the text centered.
+ */
+ //TODO: move to utility class or deprecate
+ public static JButton makeButton(String name)
+ {
+ // create a new button
+ JButton button = new JButton(name);
+
+ // set the size of the button
+ Dimension sizeButton = new Dimension(130,30);
+ button.setPreferredSize(sizeButton);
+
+ // center the text (horizontally and vertically) in the button
+ button.setVerticalTextPosition(AbstractButton.CENTER);
+ button.setHorizontalTextPosition(AbstractButton.CENTER);
+
+ // return the button
+ return button;
+ }
+
+ public static void printMemUsage (String msg)
+ {
+ Runtime runtime = Runtime.getRuntime();
+ runtime.gc();
+ long mem = runtime.totalMemory() - runtime.freeMemory();
+ System.out.println((mem >> 20) + "Mb used: " + msg);
+ }
+
+}
diff --git a/tools/readme.txt b/tools/readme.txt
index 86923ba8..2866b0fd 100644
--- a/tools/readme.txt
+++ b/tools/readme.txt
@@ -1,118 +1,118 @@
-Here is a list of all tools subdirectories, with a description.
-
-AtlastMapper
- maps data on pathways by connecting WikiPathways webservice with
- Atlas webservice.
- See also http://atlas.wikipathways.org/
-
-ComponentTest
- This was a test to see how well swing handles mouseover events,
- to support the plan to make swing components out of all gpml objects.
- status: not in active use
-
-convert
- Scripts to convert a batch of pathways automatically, and
- even test roundtrip conversion of GPML<->GenMAPP.
- status: useful but outdated. Needs work.
-
-cytoscape-gpml
- Cytoscape plugin to load GPML pathways as Cytoscape networks
- status: active. You need cytoscape libraries to compile this.
-
-dailybuild
- used to contain continuous build script. Continous build script
- has moved to http://svn.bigcat.unimaas.nl/buildsystem
- Now only contains a script to get a few code metrics
- (file size, lines of code) and a script to fix license headers.
- status: in active use
-
-debian
- attempt to create ubuntu / debian package for pathvisio
- status: work in progress
-
-downloader
- webstart that downloads
- Derby databases and places them in the correct folder.
- Used on http://www.pathvisio.org/Download
-
-get_defaults
- script that reads GPML.xsd and generates the attribute
- table for PathwayElement.java
- Use this whenever GPML.xsd is modified.
-
-gexview
- Attempt for a program to view imported microarray data as a heatmap.
- May not compile, don't worry about it.
- status: work in progress.
-
-gpmldiff
- Scripts and testcases for generating / applying a "diff" of
- two gpml files
-
-KeggConverter
- converts Kegg to GPML
-
-lucene-indexer
- program to maintain a cache of wikipathways pathways
- and have it indexed
-
-makeGdb
- program to make Derby databases based amongst others on HMDB
- status: I'll move this to the bridgedb repo, where it belongs
-
-mappdiff
- script to compate two GenMAPP MAPP files,
- used as a test-case for roundtrip conversion
- status: should be merged with the "convert" directory,
- they belong together.
-
-path2java
- program to convert an SVG path to a series of java Graphics2D calls
-
-pathway_metabolizer
- script by andra to convert labels to metabolites
- by guessing the right metabolite ID
-
-pathwaywiki
- This script was used to generate the first version of WikiPathways!
- status: won't even work again. can I delete this?
-
-perl
- perl library with some useful routines for dealing with GPML files.
- Now also contains script to do pathway inference
- Pathway inference script should really be in a separate directory.
- various perl scripts for dealing with pathways,
- including
- gpmlbuilder
- mappbuilder-like tool to make gpml
- based on a list of genes
- webservice_example example script
- that makes use of the wikipathways webservice
-
-php_pathvisio
- gpml to svg converter in php, written by Andra
-
-project2008
- project by a student group. This will be moved to a plugin
- status: work in progress.
-
-ReactomeConverter
- converts reactome pathways to GPML. Doesnt work very well,
- but it takes layout info directly from Reactome, so
- it might still be useful in addition to
- BioPAX conversion.
-
-superpathways
- Cytoscape plugin by Helen, merges multiple pathways from
- wikipathways into a Cytoscape network
-
-syscodeTable
- script to generate a html table from our syscode file
- status: will be moved to bridgedb or deleted
-
-wikipathways-maintenance
- scripts for maintenance of pathways, using the webservice
- status: useful as example code
-
-wikipathways-search
- this is the code for http://search.wikipathways.org
+Here is a list of all tools subdirectories, with a description.
+
+AtlastMapper
+ maps data on pathways by connecting WikiPathways webservice with
+ Atlas webservice.
+ See also http://atlas.wikipathways.org/
+
+ComponentTest
+ This was a test to see how well swing handles mouseover events,
+ to support the plan to make swing components out of all gpml objects.
+ status: not in active use
+
+convert
+ Scripts to convert a batch of pathways automatically, and
+ even test roundtrip conversion of GPML<->GenMAPP.
+ status: useful but outdated. Needs work.
+
+cytoscape-gpml
+ Cytoscape plugin to load GPML pathways as Cytoscape networks
+ status: active. You need cytoscape libraries to compile this.
+
+dailybuild
+ used to contain continuous build script. Continous build script
+ has moved to http://svn.bigcat.unimaas.nl/buildsystem
+ Now only contains a script to get a few code metrics
+ (file size, lines of code) and a script to fix license headers.
+ status: in active use
+
+debian
+ attempt to create ubuntu / debian package for pathvisio
+ status: work in progress
+
+downloader
+ webstart that downloads
+ Derby databases and places them in the correct folder.
+ Used on http://www.pathvisio.org/Download
+
+get_defaults
+ script that reads GPML.xsd and generates the attribute
+ table for PathwayElement.java
+ Use this whenever GPML.xsd is modified.
+
+gexview
+ Attempt for a program to view imported microarray data as a heatmap.
+ May not compile, don't worry about it.
+ status: work in progress.
+
+gpmldiff
+ Scripts and testcases for generating / applying a "diff" of
+ two gpml files
+
+KeggConverter
+ converts Kegg to GPML
+
+lucene-indexer
+ program to maintain a cache of wikipathways pathways
+ and have it indexed
+
+makeGdb
+ program to make Derby databases based amongst others on HMDB
+ status: I'll move this to the bridgedb repo, where it belongs
+
+mappdiff
+ script to compate two GenMAPP MAPP files,
+ used as a test-case for roundtrip conversion
+ status: should be merged with the "convert" directory,
+ they belong together.
+
+path2java
+ program to convert an SVG path to a series of java Graphics2D calls
+
+pathway_metabolizer
+ script by andra to convert labels to metabolites
+ by guessing the right metabolite ID
+
+pathwaywiki
+ This script was used to generate the first version of WikiPathways!
+ status: won't even work again. can I delete this?
+
+perl
+ perl library with some useful routines for dealing with GPML files.
+ Now also contains script to do pathway inference
+ Pathway inference script should really be in a separate directory.
+ various perl scripts for dealing with pathways,
+ including
+ gpmlbuilder
+ mappbuilder-like tool to make gpml
+ based on a list of genes
+ webservice_example example script
+ that makes use of the wikipathways webservice
+
+php_pathvisio
+ gpml to svg converter in php, written by Andra
+
+project2008
+ project by a student group. This will be moved to a plugin
+ status: work in progress.
+
+ReactomeConverter
+ converts reactome pathways to GPML. Doesnt work very well,
+ but it takes layout info directly from Reactome, so
+ it might still be useful in addition to
+ BioPAX conversion.
+
+superpathways
+ Cytoscape plugin by Helen, merges multiple pathways from
+ wikipathways into a Cytoscape network
+
+syscodeTable
+ script to generate a html table from our syscode file
+ status: will be moved to bridgedb or deleted
+
+wikipathways-maintenance
+ scripts for maintenance of pathways, using the webservice
+ status: useful as example code
+
+wikipathways-search
+ this is the code for http://search.wikipathways.org
diff --git a/tools/superpathways/build.xml b/tools/superpathways/build.xml
index 0bf0d1d9..100940c8 100644
--- a/tools/superpathways/build.xml
+++ b/tools/superpathways/build.xml
@@ -1,146 +1,146 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ -->
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tools/superpathways/plugin.props b/tools/superpathways/plugin.props
index 8ed74d95..19a8dd2c 100644
--- a/tools/superpathways/plugin.props
+++ b/tools/superpathways/plugin.props
@@ -1,34 +1,34 @@
-#plugin.props
-
-# This props file should be filled out and included in the plugin jar file. This props file will be used
-# to put information into the Plugin Manager about the plugin
-
-# -- The following properties are REQUIRED -- #
-
-# The plugin name that will be displayed to users, white space within name is not allowed
-pluginName=Superpathways-Plugin
-
-# Description used to give users information about the plugin such as what it does.
-# Html tags are encouraged for formatting purposes.
-pluginDescription=The Superpathways plugin for Cytoscape is to help merge multiple pathways into a single Cytoscape network.This plugin makes it possible to select multiple pathways from Wiki Pathways and load them in a single network. The plugin would merge nodes that represent the same biological entity (e.g. gene, protein or molecule).
-
-# Plugin version number, this must be two numbers separated by a decimlal. Ex. 0.2, 14.03
-pluginVersion=1.2
-
-# Compatible Cytoscape version. If there are more than one version, seperate by ",".
-cytoscapeVersion=2.6
-
-# Category, use one of the categories listed on the http://cytoscape.org/plugins2.php site
-pluginCategory=Network and Attribute I/O
-
-# -- The following properties are OPTIONAL -- #
-
-# URL to a website that gives more information about your plugin, Ex. http://my-lab-site.org
-projectURL=http://www.bigcat.unimaas.nl/tracprojects/pathvisio/wiki/SuperPathways
-
-# List of authors. Note each author and institution pair are separated by a : (colon)
-# each additional author institution pair must be separated from other pairs bye a ; (semicolon)
-pluginAuthorsInstitutions=Xuemin Liu:Iowa State University
-
-# If this plugin is never meant to be downloaded except as part of a plugin (not common) add this property. Default is "no"
-themeOnly=no
+#plugin.props
+
+# This props file should be filled out and included in the plugin jar file. This props file will be used
+# to put information into the Plugin Manager about the plugin
+
+# -- The following properties are REQUIRED -- #
+
+# The plugin name that will be displayed to users, white space within name is not allowed
+pluginName=Superpathways-Plugin
+
+# Description used to give users information about the plugin such as what it does.
+# Html tags are encouraged for formatting purposes.
+pluginDescription=The Superpathways plugin for Cytoscape is to help merge multiple pathways into a single Cytoscape network.This plugin makes it possible to select multiple pathways from Wiki Pathways and load them in a single network. The plugin would merge nodes that represent the same biological entity (e.g. gene, protein or molecule).
+
+# Plugin version number, this must be two numbers separated by a decimlal. Ex. 0.2, 14.03
+pluginVersion=1.2
+
+# Compatible Cytoscape version. If there are more than one version, seperate by ",".
+cytoscapeVersion=2.6
+
+# Category, use one of the categories listed on the http://cytoscape.org/plugins2.php site
+pluginCategory=Network and Attribute I/O
+
+# -- The following properties are OPTIONAL -- #
+
+# URL to a website that gives more information about your plugin, Ex. http://my-lab-site.org
+projectURL=http://www.bigcat.unimaas.nl/tracprojects/pathvisio/wiki/SuperPathways
+
+# List of authors. Note each author and institution pair are separated by a : (colon)
+# each additional author institution pair must be separated from other pairs bye a ; (semicolon)
+pluginAuthorsInstitutions=Xuemin Liu:Iowa State University
+
+# If this plugin is never meant to be downloaded except as part of a plugin (not common) add this property. Default is "no"
+themeOnly=no
diff --git a/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/CommonNodeView.java b/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/CommonNodeView.java
index 1b0d10b3..e7d54ee9 100644
--- a/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/CommonNodeView.java
+++ b/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/CommonNodeView.java
@@ -1,476 +1,476 @@
-// PathVisio,
-// a tool for data visualization and analysis using Biological Pathways
-// Copyright 2006-2011 BiGCaT Bioinformatics
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-package org.pathvisio.cytoscape.superpathways;
-
-import java.awt.Color;
-import java.io.File;
-import java.rmi.RemoteException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-
-import javax.swing.JFileChooser;
-import javax.swing.JOptionPane;
-
-import org.bridgedb.BridgeDb;
-import org.bridgedb.DataSource;
-import org.bridgedb.IDMapper;
-import org.bridgedb.IDMapperException;
-import org.bridgedb.Xref;
-import org.bridgedb.bio.Organism;
-import org.pathvisio.core.debug.Logger;
-import org.pathvisio.core.model.ConverterException;
-import org.pathvisio.core.model.ObjectType;
-import org.pathvisio.core.model.Pathway;
-import org.pathvisio.core.model.PathwayElement;
-import org.pathvisio.core.preferences.GlobalPreference;
-import org.pathvisio.wikipathways.webservice.WSPathway;
-import org.wikipathways.client.WikiPathwaysClient;
-
-import cytoscape.CyEdge;
-import cytoscape.CyNetwork;
-import cytoscape.CyNode;
-import cytoscape.Cytoscape;
-import cytoscape.data.CyAttributes;
-import cytoscape.data.Semantics;
-import cytoscape.layout.CyLayoutAlgorithm;
-import cytoscape.layout.CyLayouts;
-import cytoscape.layout.LayoutProperties;
-import cytoscape.layout.Tunable;
-
-
-public class CommonNodeView {
-
- // List selectedPwsNameId;
- List mSelectedPwsID;
-
- List mSelectedPwsNameID;
-
- SuperpathwaysClient mClient;
-
- Map nodePairByTranslation;
-
- List colorPool;
-
- protected boolean interrupted; // to enable cancel of the network merge
-
- static String dbLocation = GlobalPreference.getDataDir().toString()
- + "/gene databases/";
-
- public CommonNodeView(List pwId, List pwNameID, SuperpathwaysClient c) {
- mSelectedPwsID = pwId;
- mClient = c;
- mSelectedPwsNameID=pwNameID;
- nodePairByTranslation = new HashMap();
- interrupted = false;
-
- }
-
- public void interrupt() {
- interrupted = true;
- }
-
- public List getColorPool() {
- return colorPool;
- }
-
- public Map getNodePairByTranslation() {
- return nodePairByTranslation;
- }
-
- public commonNodePathwayPair findCommonNode(String pw1ID, String pw1NameID, String pw2ID, String pw2NameID) throws ClassNotFoundException, IDMapperException {
- commonNodePathwayPair cnPwPair = new commonNodePathwayPair();
-
- int commonNode = 0;
-
- // Create a client to the WikiPathways web service
- WikiPathwaysClient client = mClient.getStub();
-
- // Download these two pathways from WikiPathways by passing their id
- WSPathway wsPathway1 = new WSPathway();
- WSPathway wsPathway2 = new WSPathway();
- try {
- wsPathway1 = client.getPathway(pw1ID);
- wsPathway2 = client.getPathway(pw2ID);
-
- } catch (RemoteException e) {
- Logger.log.error(
- "Unable to get the pathway due to the RemoteException", e);
- } catch (ConverterException e) {
- Logger.log.error(
- "Unable to get the pathway due to the ConverterException",
- e);
- }
- // Create two corresponding pathway objects
- Pathway pathway1 = new Pathway();
- Pathway pathway2 = new Pathway();
- try {
- pathway1 = WikiPathwaysClient.toPathway(wsPathway1);
- pathway2 = WikiPathwaysClient.toPathway(wsPathway2);
- } catch (ConverterException e) {
- Logger.log.error(
- "Unable to get the pathway due to the RemoteException", e);
- }
-
- List XrefListPw1 = new ArrayList();
- List XrefListPw2 = new ArrayList();
- List XrefListCommonNode = new ArrayList();
-
- // create the list of Xref for the pathway1: XrefListPw1
- System.out.println("Xref info of one pathway: " + pw1ID);
- for (PathwayElement pw1Elm : pathway1.getDataObjects()) {
- // Only take elements with type DATANODE (genes, proteins,
- // metabolites)
-
- if (pw1Elm.getObjectType() == ObjectType.DATANODE) {
-
- String id = pw1Elm.getGeneID();
- DataSource ds = pw1Elm.getDataSource();
- if (!checkString(id) || ds == null) {
- continue; // Skip empty id/codes
- }
- // System.out.println("before translation: ");
- // System.out.println(pw1Elm.getXref().toString());
-
- XrefListPw1.add(pw1Elm.getXref());
- }
-
- }
-
- // deternmine which database to be loaded according to the species of
- // pathway2
- Organism organism = Organism.fromLatinName(pathway2.getMappInfo()
- .getOrganism());
- // System.out.println("The organism for pathway2 is " + organism);
-
- IDMapper gdb = mClient.getPlugin().getIDMapper(organism);
-
- // create the list of Xref for the pathway2: XrefListPw2
- System.out.println("Xref info of the other pathway: " + pw2ID);
- for (PathwayElement pw2Elm : pathway2.getDataObjects()) {
- if (pw2Elm.getObjectType() == ObjectType.DATANODE) {
-
- if (interrupted)
- return null;
-
- boolean isMapped = false;
-
- String id = pw2Elm.getGeneID();
- DataSource ds = pw2Elm.getDataSource();
- if (!checkString(id) || ds == null)
- continue; // Skip empty
- // id/codes
-
- // System.out.println(pw2Elm.getXref().toString());
- XrefListPw2.add(pw2Elm.getXref());
-
- for (int k = 0; k < XrefListPw1.size(); k++) {
- try {
- Set xrefs2 = gdb.mapID(pw2Elm.getXref());
- if (xrefs2.contains(XrefListPw1.get(k))) {
- isMapped = true;
-
- System.out.println(pw2Elm.getXref().toString()
- + "======" + XrefListPw1.get(k).toString());
- // this map is for later use--when merging pathways
- nodePairByTranslation.put(pw2Elm.getXref(),
- XrefListPw1.get(k));
- }
- } catch (IDMapperException e) {
- Logger.log
- .error(
- "Problem while getting the all the Xrefs for the pathwayElement of pw2!",
- e);
- System.out
- .println("Problem while getting the all the Xrefs for the pathwayElement of pw2!");
- break;
- }
- }
-
- if ((XrefListPw1.contains(pw2Elm.getXref().toString()) || isMapped)
- && !XrefListCommonNode.contains(pw2Elm.getXref()
- .toString())) {
- // maybe need to change later!!
- commonNode = commonNode + 1;
- XrefListCommonNode.add(pw2Elm.getXref().toString());
-
- }
- }
- }
-
- // the following code is for printing out the common nodes returned by
- // the code
- System.out.println("The common node: ");
- for (int k = 0; k < XrefListCommonNode.size(); k++) {
- System.out.println(XrefListCommonNode.get(k));
- }
-
- cnPwPair.pathway1NameID = pw1NameID;
- cnPwPair.pathway2NameID = pw2NameID;
- cnPwPair.commonNodeNumber = commonNode;
- cnPwPair.geneIDListOfCommonNode = XrefListCommonNode;
- return cnPwPair;
- }
-
- public List findCommonNodeForPathwaysGroup() throws ClassNotFoundException, IDMapperException {
- List commonNodeInfoPwGroup = new ArrayList();
-
- System.out.println("For Databases: " + dbLocation);
-
- Object[] arrayOfSelectedPwsId = mSelectedPwsID.toArray();
- Object[] arrayOfSelectedPwsNameId = mSelectedPwsNameID.toArray();
-
- int len = arrayOfSelectedPwsId.length;
-
- for (int i = 0; i < len; i++) {
- for (int j = i + 1; j < len; j++) {
-
- if (interrupted)
- return null;
-
- commonNodeInfoPwGroup.add(findCommonNode(
- (String) arrayOfSelectedPwsId[i], (String) arrayOfSelectedPwsNameId[i],
- (String) arrayOfSelectedPwsId[j], (String) arrayOfSelectedPwsNameId[j]));
- }
- }
-
- return commonNodeInfoPwGroup;
- }
-
- public Map drawCommonNodeView() throws ClassNotFoundException, IDMapperException {
-
- if (interrupted)
- return null;
-
- Map pwNameToColor=new HashMap();
-
- colorPool = new ArrayList();
-
- String[] shapePool = { "Diamond", "Hexagon", "Parallelogram",
- "Round Rectange", "Rectangle", "Ellipse", "Triangle", "Octagon" };
-
- List cnInfoPwGroup = findCommonNodeForPathwaysGroup();
-
- CyNetwork cyNetwork = Cytoscape
- .createNetwork("Common Node View", false);
-
-
- CyAttributes nodeAtts = Cytoscape.getNodeAttributes();
- CyAttributes edgeAtts = Cytoscape.getEdgeAttributes();
-
- if (interrupted)
- return null;
- CyNode[] groupPwsIcons = new CyNode[mSelectedPwsID.size()];
- for (int i = 0; i < mSelectedPwsID.size(); i++) {
- groupPwsIcons[i] = Cytoscape.getCyNode(mSelectedPwsNameID.get(i), true);
- cyNetwork.addNode(groupPwsIcons[i]);
- nodeAtts.setAttribute(mSelectedPwsNameID.get(i), "node.fontSize", "10");
-
- }
-
- if (interrupted)
- return null;
- CyEdge[] groupEdges = new CyEdge[cnInfoPwGroup.size()];
- int[] commonNodeNumber = new int[cnInfoPwGroup.size()];
- int numberOfEdges = 0;
- for (int j = 0; j < cnInfoPwGroup.size(); j++) {
- commonNodePathwayPair temp = cnInfoPwGroup.get(j);
- if (temp.commonNodeNumber != 0) {
- CyNode n1 = Cytoscape.getCyNode(temp.pathway1NameID, false);
- CyNode n2 = Cytoscape.getCyNode(temp.pathway2NameID, false);
- groupEdges[numberOfEdges] = Cytoscape.getCyEdge(n1, n2, Semantics.INTERACTION, "pp", true);
- commonNodeNumber[numberOfEdges] = temp.commonNodeNumber;
- cyNetwork.addEdge(groupEdges[numberOfEdges]);
- edgeAtts.setAttribute(groupEdges[numberOfEdges].getIdentifier(), "weight", commonNodeNumber[numberOfEdges]);
- numberOfEdges++;
- }
- }
-
- int numberOfSelectedPws = mSelectedPwsID.size();
- double division1 = 360 / numberOfSelectedPws;
- double division2 = 50 / numberOfSelectedPws;
-
- for (int i = 0; i < mSelectedPwsID.size(); i++) {
-
- // String temp=getRandomColorInString();
-
- //use hsv and convert it to rgb
- double h2=i*division1;
- double s2=i*division2;
- double v2=i*division2;
-
- int h=Double.valueOf(h2).intValue();
- int s=Double.valueOf(s2).intValue();
- int v=Double.valueOf(v2).intValue();
- System.out.println("value of h "+ h);
- RGB tempRGB=hsvToRgb(h, 100, 100);
- String temp=String.valueOf(Double.valueOf(tempRGB.r).intValue())+", "+String.valueOf(Double.valueOf(tempRGB.g).intValue())+", "+String.valueOf(Double.valueOf(tempRGB.b).intValue());
- System.out.println("after conversion hsv to rgb"+ temp);
-
- nodeAtts.setAttribute(groupPwsIcons[i].getIdentifier(),
- "node.fillColor", temp);
-
- //this part is for storing the info into the pwNameToColor
- String pwNameID=mSelectedPwsNameID.get(i);
- int index2 = pwNameID.lastIndexOf("(");
- String pwName = pwNameID.substring(0, index2);
- System.out.println(Double.valueOf(tempRGB.r).intValue()+";"+Double.valueOf(tempRGB.g).intValue()+";"+Double.valueOf(tempRGB.b).intValue());
- Color result=new Color(Double.valueOf(tempRGB.r).intValue(), Double.valueOf(tempRGB.g).intValue(),Double.valueOf(tempRGB.b).intValue());
- pwNameToColor.put(pwName,result);
-
- colorPool.add(temp);
- nodeAtts.setAttribute(groupPwsIcons[i].getIdentifier(),
- "node.shape", shapePool[i % shapePool.length]);
- // re-use shapes from the shapePool when the number of
- // selected Pws is larger than 8
- }
-
- for (int j = 0; j < numberOfEdges; j++) {
- edgeAtts.setAttribute(groupEdges[j].getIdentifier(), "edge.label",
- String.valueOf(commonNodeNumber[j]));
- }
-
-
- // display the common node view
- Cytoscape.createNetworkView(cyNetwork, "Common Node View");
-
-
-
- //the following code is for set the edge-weighted spring embedded layout (weight=the number of shared nodes)
- CyLayoutAlgorithm alg = CyLayouts.getLayout("force-directed");
- LayoutProperties props = alg.getSettings();
- Tunable weightAttribute = props.get("edge_attribute");
- weightAttribute.setValue("weight");
- alg.updateSettings();
- Cytoscape.getCurrentNetworkView().applyLayout(alg);
-
-
- return pwNameToColor;
- }
-
- private static boolean checkString(String string) {
- return string != null && string.length() > 0;
- }
-
- /*
- * public static Color getRandomColor() { Random numGen = new Random();
- * return new Color(numGen.nextInt(256), numGen.nextInt(256),
- * numGen.nextInt(256)); }
- */
-
- public static String getRandomColorInString() {
- Random numGen = new Random();
- return new String(numGen.nextInt(256) + ", " + numGen.nextInt(256)
- + ", " + numGen.nextInt(256));
- }
-
- public static RGB hsvToRgb(int h, int s, int v) {
- RGB result = new RGB();
- int i;
- double f, p, q, t;
-
- // Make sure our arguments stay in-range
- h = Math.max(0, Math.min(360, h));
- s = Math.max(0, Math.min(100, s));
- v = Math.max(0, Math.min(100, v));
-
- // We accept saturation and value arguments from 0 to 100 because that's
- // how Photoshop represents those values. Internally, however, the
- // saturation and value are calculated from a range of 0 to 1. We make
- // That conversion here.
- double s2 = (double)s / 100;
- double v2 = (double)v / 100;
-
- if (s2 == 0) {
- // Achromatic (grey)
- result.r = Math.round(v2 * 255);
- result.g = Math.round(v2 * 255);
- result.b = Math.round(v2 * 255);
- return result;
- }
-
- double h2 = (double)h / 60; // sector 0 to 5
- double i2 = Math.floor(h2);
- i = Double.valueOf(i2).intValue();
- f = h2 - i; // factorial part of h
- p = v2 * (1 - s2);
- q = v2 * (1 - s2 * f);
- t = v2 * (1 - s2 * (1 - f));
-
- switch (i) {
-
- case 0:
- result.r = v2;
- result.g = t;
- result.b = p;
- break;
- case 1:
- result.r = q;
- result.g = v2;
- result.b = p;
- break;
- case 2:
- result.r = p;
- result.g = v2;
- result.b = t;
- break;
- case 3:
- result.r = p;
- result.g = q;
- result.b = v2;
- break;
- case 4:
- result.r = t;
- result.g = p;
- result.b = v2;
- break;
- default: // case 5:
- result.r = v2;
- result.g = p;
- result.b = q;
- }
-
- result.r = Math.round(result.r * 255);
- result.g = Math.round(result.g * 255);
- result.b = Math.round(result.b * 255);
-
- return result;
-
- }
-
- public static class commonNodePathwayPair {
- public String pathway1NameID;
-
- public String pathway2NameID;
-
- public int commonNodeNumber;
-
- public List geneIDListOfCommonNode = null;
- }
-
- public static class RGB {
- public double r;
-
- public double g;
-
- public double b;
- }
-}
+// PathVisio,
+// a tool for data visualization and analysis using Biological Pathways
+// Copyright 2006-2011 BiGCaT Bioinformatics
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package org.pathvisio.cytoscape.superpathways;
+
+import java.awt.Color;
+import java.io.File;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+
+import javax.swing.JFileChooser;
+import javax.swing.JOptionPane;
+
+import org.bridgedb.BridgeDb;
+import org.bridgedb.DataSource;
+import org.bridgedb.IDMapper;
+import org.bridgedb.IDMapperException;
+import org.bridgedb.Xref;
+import org.bridgedb.bio.Organism;
+import org.pathvisio.core.debug.Logger;
+import org.pathvisio.core.model.ConverterException;
+import org.pathvisio.core.model.ObjectType;
+import org.pathvisio.core.model.Pathway;
+import org.pathvisio.core.model.PathwayElement;
+import org.pathvisio.core.preferences.GlobalPreference;
+import org.pathvisio.wikipathways.webservice.WSPathway;
+import org.wikipathways.client.WikiPathwaysClient;
+
+import cytoscape.CyEdge;
+import cytoscape.CyNetwork;
+import cytoscape.CyNode;
+import cytoscape.Cytoscape;
+import cytoscape.data.CyAttributes;
+import cytoscape.data.Semantics;
+import cytoscape.layout.CyLayoutAlgorithm;
+import cytoscape.layout.CyLayouts;
+import cytoscape.layout.LayoutProperties;
+import cytoscape.layout.Tunable;
+
+
+public class CommonNodeView {
+
+ // List selectedPwsNameId;
+ List mSelectedPwsID;
+
+ List mSelectedPwsNameID;
+
+ SuperpathwaysClient mClient;
+
+ Map nodePairByTranslation;
+
+ List colorPool;
+
+ protected boolean interrupted; // to enable cancel of the network merge
+
+ static String dbLocation = GlobalPreference.getDataDir().toString()
+ + "/gene databases/";
+
+ public CommonNodeView(List pwId, List pwNameID, SuperpathwaysClient c) {
+ mSelectedPwsID = pwId;
+ mClient = c;
+ mSelectedPwsNameID=pwNameID;
+ nodePairByTranslation = new HashMap();
+ interrupted = false;
+
+ }
+
+ public void interrupt() {
+ interrupted = true;
+ }
+
+ public List getColorPool() {
+ return colorPool;
+ }
+
+ public Map getNodePairByTranslation() {
+ return nodePairByTranslation;
+ }
+
+ public commonNodePathwayPair findCommonNode(String pw1ID, String pw1NameID, String pw2ID, String pw2NameID) throws ClassNotFoundException, IDMapperException {
+ commonNodePathwayPair cnPwPair = new commonNodePathwayPair();
+
+ int commonNode = 0;
+
+ // Create a client to the WikiPathways web service
+ WikiPathwaysClient client = mClient.getStub();
+
+ // Download these two pathways from WikiPathways by passing their id
+ WSPathway wsPathway1 = new WSPathway();
+ WSPathway wsPathway2 = new WSPathway();
+ try {
+ wsPathway1 = client.getPathway(pw1ID);
+ wsPathway2 = client.getPathway(pw2ID);
+
+ } catch (RemoteException e) {
+ Logger.log.error(
+ "Unable to get the pathway due to the RemoteException", e);
+ } catch (ConverterException e) {
+ Logger.log.error(
+ "Unable to get the pathway due to the ConverterException",
+ e);
+ }
+ // Create two corresponding pathway objects
+ Pathway pathway1 = new Pathway();
+ Pathway pathway2 = new Pathway();
+ try {
+ pathway1 = WikiPathwaysClient.toPathway(wsPathway1);
+ pathway2 = WikiPathwaysClient.toPathway(wsPathway2);
+ } catch (ConverterException e) {
+ Logger.log.error(
+ "Unable to get the pathway due to the RemoteException", e);
+ }
+
+ List XrefListPw1 = new ArrayList();
+ List XrefListPw2 = new ArrayList();
+ List XrefListCommonNode = new ArrayList();
+
+ // create the list of Xref for the pathway1: XrefListPw1
+ System.out.println("Xref info of one pathway: " + pw1ID);
+ for (PathwayElement pw1Elm : pathway1.getDataObjects()) {
+ // Only take elements with type DATANODE (genes, proteins,
+ // metabolites)
+
+ if (pw1Elm.getObjectType() == ObjectType.DATANODE) {
+
+ String id = pw1Elm.getGeneID();
+ DataSource ds = pw1Elm.getDataSource();
+ if (!checkString(id) || ds == null) {
+ continue; // Skip empty id/codes
+ }
+ // System.out.println("before translation: ");
+ // System.out.println(pw1Elm.getXref().toString());
+
+ XrefListPw1.add(pw1Elm.getXref());
+ }
+
+ }
+
+ // deternmine which database to be loaded according to the species of
+ // pathway2
+ Organism organism = Organism.fromLatinName(pathway2.getMappInfo()
+ .getOrganism());
+ // System.out.println("The organism for pathway2 is " + organism);
+
+ IDMapper gdb = mClient.getPlugin().getIDMapper(organism);
+
+ // create the list of Xref for the pathway2: XrefListPw2
+ System.out.println("Xref info of the other pathway: " + pw2ID);
+ for (PathwayElement pw2Elm : pathway2.getDataObjects()) {
+ if (pw2Elm.getObjectType() == ObjectType.DATANODE) {
+
+ if (interrupted)
+ return null;
+
+ boolean isMapped = false;
+
+ String id = pw2Elm.getGeneID();
+ DataSource ds = pw2Elm.getDataSource();
+ if (!checkString(id) || ds == null)
+ continue; // Skip empty
+ // id/codes
+
+ // System.out.println(pw2Elm.getXref().toString());
+ XrefListPw2.add(pw2Elm.getXref());
+
+ for (int k = 0; k < XrefListPw1.size(); k++) {
+ try {
+ Set xrefs2 = gdb.mapID(pw2Elm.getXref());
+ if (xrefs2.contains(XrefListPw1.get(k))) {
+ isMapped = true;
+
+ System.out.println(pw2Elm.getXref().toString()
+ + "======" + XrefListPw1.get(k).toString());
+ // this map is for later use--when merging pathways
+ nodePairByTranslation.put(pw2Elm.getXref(),
+ XrefListPw1.get(k));
+ }
+ } catch (IDMapperException e) {
+ Logger.log
+ .error(
+ "Problem while getting the all the Xrefs for the pathwayElement of pw2!",
+ e);
+ System.out
+ .println("Problem while getting the all the Xrefs for the pathwayElement of pw2!");
+ break;
+ }
+ }
+
+ if ((XrefListPw1.contains(pw2Elm.getXref().toString()) || isMapped)
+ && !XrefListCommonNode.contains(pw2Elm.getXref()
+ .toString())) {
+ // maybe need to change later!!
+ commonNode = commonNode + 1;
+ XrefListCommonNode.add(pw2Elm.getXref().toString());
+
+ }
+ }
+ }
+
+ // the following code is for printing out the common nodes returned by
+ // the code
+ System.out.println("The common node: ");
+ for (int k = 0; k < XrefListCommonNode.size(); k++) {
+ System.out.println(XrefListCommonNode.get(k));
+ }
+
+ cnPwPair.pathway1NameID = pw1NameID;
+ cnPwPair.pathway2NameID = pw2NameID;
+ cnPwPair.commonNodeNumber = commonNode;
+ cnPwPair.geneIDListOfCommonNode = XrefListCommonNode;
+ return cnPwPair;
+ }
+
+ public List findCommonNodeForPathwaysGroup() throws ClassNotFoundException, IDMapperException {
+ List commonNodeInfoPwGroup = new ArrayList();
+
+ System.out.println("For Databases: " + dbLocation);
+
+ Object[] arrayOfSelectedPwsId = mSelectedPwsID.toArray();
+ Object[] arrayOfSelectedPwsNameId = mSelectedPwsNameID.toArray();
+
+ int len = arrayOfSelectedPwsId.length;
+
+ for (int i = 0; i < len; i++) {
+ for (int j = i + 1; j < len; j++) {
+
+ if (interrupted)
+ return null;
+
+ commonNodeInfoPwGroup.add(findCommonNode(
+ (String) arrayOfSelectedPwsId[i], (String) arrayOfSelectedPwsNameId[i],
+ (String) arrayOfSelectedPwsId[j], (String) arrayOfSelectedPwsNameId[j]));
+ }
+ }
+
+ return commonNodeInfoPwGroup;
+ }
+
+ public Map drawCommonNodeView() throws ClassNotFoundException, IDMapperException {
+
+ if (interrupted)
+ return null;
+
+ Map pwNameToColor=new HashMap();
+
+ colorPool = new ArrayList();
+
+ String[] shapePool = { "Diamond", "Hexagon", "Parallelogram",
+ "Round Rectange", "Rectangle", "Ellipse", "Triangle", "Octagon" };
+
+ List cnInfoPwGroup = findCommonNodeForPathwaysGroup();
+
+ CyNetwork cyNetwork = Cytoscape
+ .createNetwork("Common Node View", false);
+
+
+ CyAttributes nodeAtts = Cytoscape.getNodeAttributes();
+ CyAttributes edgeAtts = Cytoscape.getEdgeAttributes();
+
+ if (interrupted)
+ return null;
+ CyNode[] groupPwsIcons = new CyNode[mSelectedPwsID.size()];
+ for (int i = 0; i < mSelectedPwsID.size(); i++) {
+ groupPwsIcons[i] = Cytoscape.getCyNode(mSelectedPwsNameID.get(i), true);
+ cyNetwork.addNode(groupPwsIcons[i]);
+ nodeAtts.setAttribute(mSelectedPwsNameID.get(i), "node.fontSize", "10");
+
+ }
+
+ if (interrupted)
+ return null;
+ CyEdge[] groupEdges = new CyEdge[cnInfoPwGroup.size()];
+ int[] commonNodeNumber = new int[cnInfoPwGroup.size()];
+ int numberOfEdges = 0;
+ for (int j = 0; j < cnInfoPwGroup.size(); j++) {
+ commonNodePathwayPair temp = cnInfoPwGroup.get(j);
+ if (temp.commonNodeNumber != 0) {
+ CyNode n1 = Cytoscape.getCyNode(temp.pathway1NameID, false);
+ CyNode n2 = Cytoscape.getCyNode(temp.pathway2NameID, false);
+ groupEdges[numberOfEdges] = Cytoscape.getCyEdge(n1, n2, Semantics.INTERACTION, "pp", true);
+ commonNodeNumber[numberOfEdges] = temp.commonNodeNumber;
+ cyNetwork.addEdge(groupEdges[numberOfEdges]);
+ edgeAtts.setAttribute(groupEdges[numberOfEdges].getIdentifier(), "weight", commonNodeNumber[numberOfEdges]);
+ numberOfEdges++;
+ }
+ }
+
+ int numberOfSelectedPws = mSelectedPwsID.size();
+ double division1 = 360 / numberOfSelectedPws;
+ double division2 = 50 / numberOfSelectedPws;
+
+ for (int i = 0; i < mSelectedPwsID.size(); i++) {
+
+ // String temp=getRandomColorInString();
+
+ //use hsv and convert it to rgb
+ double h2=i*division1;
+ double s2=i*division2;
+ double v2=i*division2;
+
+ int h=Double.valueOf(h2).intValue();
+ int s=Double.valueOf(s2).intValue();
+ int v=Double.valueOf(v2).intValue();
+ System.out.println("value of h "+ h);
+ RGB tempRGB=hsvToRgb(h, 100, 100);
+ String temp=String.valueOf(Double.valueOf(tempRGB.r).intValue())+", "+String.valueOf(Double.valueOf(tempRGB.g).intValue())+", "+String.valueOf(Double.valueOf(tempRGB.b).intValue());
+ System.out.println("after conversion hsv to rgb"+ temp);
+
+ nodeAtts.setAttribute(groupPwsIcons[i].getIdentifier(),
+ "node.fillColor", temp);
+
+ //this part is for storing the info into the pwNameToColor
+ String pwNameID=mSelectedPwsNameID.get(i);
+ int index2 = pwNameID.lastIndexOf("(");
+ String pwName = pwNameID.substring(0, index2);
+ System.out.println(Double.valueOf(tempRGB.r).intValue()+";"+Double.valueOf(tempRGB.g).intValue()+";"+Double.valueOf(tempRGB.b).intValue());
+ Color result=new Color(Double.valueOf(tempRGB.r).intValue(), Double.valueOf(tempRGB.g).intValue(),Double.valueOf(tempRGB.b).intValue());
+ pwNameToColor.put(pwName,result);
+
+ colorPool.add(temp);
+ nodeAtts.setAttribute(groupPwsIcons[i].getIdentifier(),
+ "node.shape", shapePool[i % shapePool.length]);
+ // re-use shapes from the shapePool when the number of
+ // selected Pws is larger than 8
+ }
+
+ for (int j = 0; j < numberOfEdges; j++) {
+ edgeAtts.setAttribute(groupEdges[j].getIdentifier(), "edge.label",
+ String.valueOf(commonNodeNumber[j]));
+ }
+
+
+ // display the common node view
+ Cytoscape.createNetworkView(cyNetwork, "Common Node View");
+
+
+
+ //the following code is for set the edge-weighted spring embedded layout (weight=the number of shared nodes)
+ CyLayoutAlgorithm alg = CyLayouts.getLayout("force-directed");
+ LayoutProperties props = alg.getSettings();
+ Tunable weightAttribute = props.get("edge_attribute");
+ weightAttribute.setValue("weight");
+ alg.updateSettings();
+ Cytoscape.getCurrentNetworkView().applyLayout(alg);
+
+
+ return pwNameToColor;
+ }
+
+ private static boolean checkString(String string) {
+ return string != null && string.length() > 0;
+ }
+
+ /*
+ * public static Color getRandomColor() { Random numGen = new Random();
+ * return new Color(numGen.nextInt(256), numGen.nextInt(256),
+ * numGen.nextInt(256)); }
+ */
+
+ public static String getRandomColorInString() {
+ Random numGen = new Random();
+ return new String(numGen.nextInt(256) + ", " + numGen.nextInt(256)
+ + ", " + numGen.nextInt(256));
+ }
+
+ public static RGB hsvToRgb(int h, int s, int v) {
+ RGB result = new RGB();
+ int i;
+ double f, p, q, t;
+
+ // Make sure our arguments stay in-range
+ h = Math.max(0, Math.min(360, h));
+ s = Math.max(0, Math.min(100, s));
+ v = Math.max(0, Math.min(100, v));
+
+ // We accept saturation and value arguments from 0 to 100 because that's
+ // how Photoshop represents those values. Internally, however, the
+ // saturation and value are calculated from a range of 0 to 1. We make
+ // That conversion here.
+ double s2 = (double)s / 100;
+ double v2 = (double)v / 100;
+
+ if (s2 == 0) {
+ // Achromatic (grey)
+ result.r = Math.round(v2 * 255);
+ result.g = Math.round(v2 * 255);
+ result.b = Math.round(v2 * 255);
+ return result;
+ }
+
+ double h2 = (double)h / 60; // sector 0 to 5
+ double i2 = Math.floor(h2);
+ i = Double.valueOf(i2).intValue();
+ f = h2 - i; // factorial part of h
+ p = v2 * (1 - s2);
+ q = v2 * (1 - s2 * f);
+ t = v2 * (1 - s2 * (1 - f));
+
+ switch (i) {
+
+ case 0:
+ result.r = v2;
+ result.g = t;
+ result.b = p;
+ break;
+ case 1:
+ result.r = q;
+ result.g = v2;
+ result.b = p;
+ break;
+ case 2:
+ result.r = p;
+ result.g = v2;
+ result.b = t;
+ break;
+ case 3:
+ result.r = p;
+ result.g = q;
+ result.b = v2;
+ break;
+ case 4:
+ result.r = t;
+ result.g = p;
+ result.b = v2;
+ break;
+ default: // case 5:
+ result.r = v2;
+ result.g = p;
+ result.b = q;
+ }
+
+ result.r = Math.round(result.r * 255);
+ result.g = Math.round(result.g * 255);
+ result.b = Math.round(result.b * 255);
+
+ return result;
+
+ }
+
+ public static class commonNodePathwayPair {
+ public String pathway1NameID;
+
+ public String pathway2NameID;
+
+ public int commonNodeNumber;
+
+ public List geneIDListOfCommonNode = null;
+ }
+
+ public static class RGB {
+ public double r;
+
+ public double g;
+
+ public double b;
+ }
+}
diff --git a/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/CustomNodeGenerator.java b/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/CustomNodeGenerator.java
index 8489e38e..5655750f 100644
--- a/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/CustomNodeGenerator.java
+++ b/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/CustomNodeGenerator.java
@@ -1,66 +1,66 @@
-// PathVisio,
-// a tool for data visualization and analysis using Biological Pathways
-// Copyright 2006-2011 BiGCaT Bioinformatics
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-package org.pathvisio.cytoscape.superpathways;
-
-import giny.model.Node;
-
-import java.awt.Paint;
-import java.awt.Shape;
-import java.awt.geom.Rectangle2D;
-import java.io.File;
-
-import cytoscape.CyNetwork;
-import cytoscape.Cytoscape;
-import ding.view.DNodeView;
-
-public class CustomNodeGenerator {
-
- String pieLocation;
- Node node;
-
-
- public CustomNodeGenerator(String loc, Node n) {
- pieLocation = new String(loc);
- node = n;
- }
-
- // to create custom node graphics
- public void createCustomNode(CyNetwork cyNetwork) {
- Cytoscape.createNetworkView(cyNetwork);
- Rectangle2D rect = new Rectangle2D.Double(-20.0, -20.0, 40.0, 40.0);
-
- Paint paint = null;
-
- try {
- paint = new java.awt.TexturePaint(javax.imageio.ImageIO
- .read(new File(pieLocation)), rect);
-
- // new java.net.URL("http://cytoscape.org/people_photos/nerius.jpg")
-
- } catch (Exception exc) {
- paint = java.awt.Color.black;
- }
-
- giny.view.NodeView nv;
- // Obtain an instance of NodeView using documented Cytoscape API.....
- nv = (DNodeView) Cytoscape.getCurrentNetworkView().getNodeView(node);
-
- ding.view.DNodeView dnv = (ding.view.DNodeView) nv;
- dnv.addCustomGraphic(rect, paint, (byte)0);
- }
-}
+// PathVisio,
+// a tool for data visualization and analysis using Biological Pathways
+// Copyright 2006-2011 BiGCaT Bioinformatics
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package org.pathvisio.cytoscape.superpathways;
+
+import giny.model.Node;
+
+import java.awt.Paint;
+import java.awt.Shape;
+import java.awt.geom.Rectangle2D;
+import java.io.File;
+
+import cytoscape.CyNetwork;
+import cytoscape.Cytoscape;
+import ding.view.DNodeView;
+
+public class CustomNodeGenerator {
+
+ String pieLocation;
+ Node node;
+
+
+ public CustomNodeGenerator(String loc, Node n) {
+ pieLocation = new String(loc);
+ node = n;
+ }
+
+ // to create custom node graphics
+ public void createCustomNode(CyNetwork cyNetwork) {
+ Cytoscape.createNetworkView(cyNetwork);
+ Rectangle2D rect = new Rectangle2D.Double(-20.0, -20.0, 40.0, 40.0);
+
+ Paint paint = null;
+
+ try {
+ paint = new java.awt.TexturePaint(javax.imageio.ImageIO
+ .read(new File(pieLocation)), rect);
+
+ // new java.net.URL("http://cytoscape.org/people_photos/nerius.jpg")
+
+ } catch (Exception exc) {
+ paint = java.awt.Color.black;
+ }
+
+ giny.view.NodeView nv;
+ // Obtain an instance of NodeView using documented Cytoscape API.....
+ nv = (DNodeView) Cytoscape.getCurrentNetworkView().getNodeView(node);
+
+ ding.view.DNodeView dnv = (ding.view.DNodeView) nv;
+ dnv.addCustomGraphic(rect, paint, (byte)0);
+ }
+}
diff --git a/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/FindRelatedPwsDialog.java b/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/FindRelatedPwsDialog.java
index ac69fd73..7e2c69b7 100644
--- a/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/FindRelatedPwsDialog.java
+++ b/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/FindRelatedPwsDialog.java
@@ -1,791 +1,791 @@
-// PathVisio,
-// a tool for data visualization and analysis using Biological Pathways
-// Copyright 2006-2011 BiGCaT Bioinformatics
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-package org.pathvisio.cytoscape.superpathways;
-
-import java.awt.Cursor;
-import java.rmi.RemoteException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.swing.JDialog;
-import javax.swing.JOptionPane;
-import javax.swing.ListSelectionModel;
-import javax.swing.table.DefaultTableModel;
-import javax.swing.table.TableColumn;
-
-import org.pathvisio.core.debug.Logger;
-import org.pathvisio.core.model.ConverterException;
-import org.pathvisio.core.model.ObjectType;
-import org.pathvisio.core.model.Pathway;
-import org.pathvisio.core.model.PathwayElement;
-import org.pathvisio.cytoscape.superpathways.SuperpathwaysGui.ResultRow;
-import org.pathvisio.wikipathways.webservice.WSPathway;
-import org.pathvisio.wikipathways.webservice.WSSearchResult;
-import org.wikipathways.client.WikiPathwaysClient;
-
-import cytoscape.task.Task;
-import cytoscape.task.TaskMonitor;
-import cytoscape.task.ui.JTaskConfig;
-import cytoscape.task.util.TaskManager;
-
-public class FindRelatedPwsDialog extends JDialog {
-
- SuperpathwaysClient mClient;
-
- private List mCandidatePw;
-
- String anchorPwNameID;
-
- int mNoGeneNode;
-
- private Map mNodeIdToPwsSharingNode = new HashMap();
-
- List selectedPws;
-
- public FindRelatedPwsDialog(SuperpathwaysClient client, String s,
- String anchorPw) {
- super(client.getPlugin().mWindow, s);
- mClient = client;
- setSize(250, 300);
- setModal(true);
- initComponents(anchorPw);
- setModal(false);
-
- }
-
- private void initComponents(String anchorPw) {
-
- anchorPwNameID = anchorPw;
- // the following items are in helpPanel Dialog
- helpPanel = new javax.swing.JPanel();
- anchorPathwayLabel = new javax.swing.JLabel();
- sharingNodeNoLabel = new javax.swing.JLabel();
- // anchorPathwayComboBox = new javax.swing.JComboBox();
- anchorPathwayNameIDLabel = new javax.swing.JLabel();
-
- lowerBoundSharingNodeNoComboBox = new javax.swing.JComboBox();
- candidatePathwaysSharingNodesScrollPane = new javax.swing.JScrollPane();
- candidatePathwaysSharingNodesTable = new javax.swing.JTable();
-
- explainHelpLabel1 = new javax.swing.JLabel();
- addHelpButton = new javax.swing.JButton();
- lowerBoundLabel = new javax.swing.JLabel();
- upperBoundLabel = new javax.swing.JLabel();
- upperBoundSharingNodeNoComboBox = new javax.swing.JComboBox();
- explainHelpLabel2 = new javax.swing.JLabel();
- // backToSearchButton = new javax.swing.JButton();
- searchHelpButton = new javax.swing.JButton();
- lastLabel = new javax.swing.JLabel();
-
- // the follwoing code is for Search Help tab
- anchorPathwayLabel.setForeground(new java.awt.Color(0, 0, 255));
- anchorPathwayLabel.setText("Selected Pathway: ");
-
- anchorPathwayNameIDLabel.setForeground(new java.awt.Color(0, 0, 255));
- anchorPathwayNameIDLabel.setText(anchorPw);
-
- sharingNodeNoLabel.setForeground(new java.awt.Color(0, 0, 255));
- sharingNodeNoLabel.setText("Sharing");
-
- // anchorPathwayComboBox.setModel(new
- // DefaultComboBoxModel(mAvailablePathwaysNameIDList.toArray()));
-
- lowerBoundSharingNodeNoComboBox
- .setModel(new javax.swing.DefaultComboBoxModel(new String[] {
- "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }));
-
- // candidatePathwaysSharingNodesTable.setModel();
-
- explainHelpLabel1.setFont(new java.awt.Font("Dialog", 1, 11)); // NOI18N
- explainHelpLabel1.setForeground(new java.awt.Color(102, 0, 0));
- explainHelpLabel1
- .setText("Set the range of sharing nodes number for the selected pathway, a list of candidate");
-
- explainHelpLabel2.setFont(new java.awt.Font("Dialog", 1, 11)); // NOI18N
- explainHelpLabel2.setForeground(new java.awt.Color(102, 0, 0));
- explainHelpLabel2
- .setText("pathways with sharing nodes would be returned after clicking Search button.");
-
- addHelpButton.setText("Add");
- addHelpButton
- .setToolTipText("add the selected pathways to the 'Available Pathways' list");
-
- addHelpButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- addHelpButtonActionPerformed(evt);
- }
- });
-
- lowerBoundLabel.setForeground(new java.awt.Color(0, 0, 255));
- lowerBoundLabel.setText("Minimum");
-
- upperBoundLabel.setForeground(new java.awt.Color(0, 0, 255));
- upperBoundLabel.setText("Maximum");
-
- // set the numbers for according to the selected pathway
- int index1 = anchorPw.lastIndexOf("(");
- int index2 = anchorPw.lastIndexOf(")");
- String anchorPwID = anchorPw.substring(index1 + 1, index2);
-
- // Create a client to the WikiPathways web service
- WikiPathwaysClient client = mClient.getStub();
- WSPathway anchorPathway = new WSPathway();
-
- try {
- anchorPathway = client.getPathway(anchorPwID);
-
- } catch (RemoteException e) {
- Logger.log.error(
- "Unable to get the pathway due to the RemoteException", e);
- } catch (ConverterException e) {
- Logger.log.error(
- "Unable to get the pathway due to the ConverterException",
- e);
- }
- // Create the corresponding pathway objects
- Pathway mAnchorPw = new Pathway();
-
- try {
- mAnchorPw = WikiPathwaysClient.toPathway(anchorPathway);
- } catch (ConverterException e) {
- Logger.log.error(
- "Unable to get the pathway due to the RemoteException", e);
- }
-
- mNoGeneNode = 0;
- for (PathwayElement pwElm : mAnchorPw.getDataObjects()) {
- if (pwElm.getObjectType() == ObjectType.DATANODE) {
- mNoGeneNode = mNoGeneNode + 1;
-
- }
- }
- String[] temp = new String[mNoGeneNode];
- for (int i = 1; i <= mNoGeneNode; i++) {
- temp[i - 1] = String.valueOf(i);
- }
- upperBoundSharingNodeNoComboBox
- .setModel(new javax.swing.DefaultComboBoxModel(temp));
-
- lastLabel.setForeground(new java.awt.Color(0, 0, 255));
- lastLabel.setText("Nodes");
-
- searchHelpButton.setText("Search");
- searchHelpButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- searchHelpButtonActionPerformed(evt);
- }
- });
-
- candidatePathwaysSharingNodesTableModel.addColumn("Pathway Name");
- candidatePathwaysSharingNodesTableModel.addColumn("ID");
- candidatePathwaysSharingNodesTableModel.addColumn("No. Shared Nodes");
-
- candidatePathwaysSharingNodesTable
- .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
- candidatePathwaysSharingNodesScrollPane
- .setViewportView(candidatePathwaysSharingNodesTable);
- candidatePathwaysSharingNodesTable
- .setModel(candidatePathwaysSharingNodesTableModel);
-
- TableColumn column = null;
- for (int i = 0; i < 3; i++) {
- column = candidatePathwaysSharingNodesTable.getColumnModel()
- .getColumn(i);
- if (i == 0) {
- column.setPreferredWidth(150);
- } else if (i == 1) {
- column.setPreferredWidth(40);
- } else {
- column.setPreferredWidth(60);
- }
-
- }
-
- org.jdesktop.layout.GroupLayout helpPanelLayout = new org.jdesktop.layout.GroupLayout(
- helpPanel);
- helpPanel.setLayout(helpPanelLayout);
- helpPanelLayout
- .setHorizontalGroup(helpPanelLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.LEADING)
- .add(
- helpPanelLayout
- .createSequentialGroup()
- .add(
- helpPanelLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.LEADING)
- .add(
- helpPanelLayout
- .createSequentialGroup()
- .addContainerGap()
- .add(
- explainHelpLabel1))
- .add(
- helpPanelLayout
- .createSequentialGroup()
- .addContainerGap()
- .add(
- explainHelpLabel2))
- .add(
- helpPanelLayout
- .createSequentialGroup()
- .add(
- 19,
- 19,
- 19)
- .add(
- helpPanelLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.LEADING)
- .add(
- anchorPathwayLabel)
- .add(
- sharingNodeNoLabel))
- .add(
- 6,
- 6,
- 6)
- .add(
- helpPanelLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.LEADING,
- false)
- .add(
- helpPanelLayout
- .createSequentialGroup()
- .add(
- lowerBoundLabel)
- .add(
- 18,
- 18,
- 18)
- .add(
- lowerBoundSharingNodeNoComboBox,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(
- 18,
- 18,
- 18)
- .add(
- upperBoundLabel)
- .add(
- 18,
- 18,
- 18)
- .add(
- upperBoundSharingNodeNoComboBox,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .add(
- helpPanelLayout
- .createSequentialGroup()
- .add(
- 23,
- 23,
- 23)
- .add(
- anchorPathwayNameIDLabel,
- 0,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- Short.MAX_VALUE)))
- .add(
- 18,
- 18,
- 18)
- .add(
- lastLabel)
- .add(
- 18,
- 18,
- 18)
- .add(
- searchHelpButton)))
- .addContainerGap(24, Short.MAX_VALUE))
- .add(
- org.jdesktop.layout.GroupLayout.TRAILING,
- helpPanelLayout
- .createSequentialGroup()
- .addContainerGap(190, Short.MAX_VALUE)
- // .add(backToSearchButton)
- .addPreferredGap(
- org.jdesktop.layout.LayoutStyle.RELATED)
- .add(addHelpButton).add(26, 26, 26))
- .add(
- helpPanelLayout
- .createSequentialGroup()
- .addContainerGap()
- .add(
- candidatePathwaysSharingNodesScrollPane,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- 402, Short.MAX_VALUE).add(16,
- 16, 16)));
-
- /*
- * helpPanelLayout.linkSize(new java.awt.Component[] { addHelpButton,
- * backToSearchButton }, org.jdesktop.layout.GroupLayout.HORIZONTAL);
- */
-
- helpPanelLayout
- .setVerticalGroup(helpPanelLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.LEADING)
- .add(
- helpPanelLayout
- .createSequentialGroup()
- .add(33, 33, 33)
- .add(explainHelpLabel1)
- .addPreferredGap(
- org.jdesktop.layout.LayoutStyle.UNRELATED)
- .add(explainHelpLabel2)
- .add(44, 44, 44)
- .add(
- helpPanelLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.BASELINE)
- .add(anchorPathwayLabel)
- .add(
- anchorPathwayNameIDLabel,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .add(23, 23, 23)
- .add(
- helpPanelLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.BASELINE)
- .add(lowerBoundLabel)
- .add(
- lowerBoundSharingNodeNoComboBox,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(upperBoundLabel)
- .add(
- upperBoundSharingNodeNoComboBox,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(lastLabel)
- .add(searchHelpButton)
- .add(sharingNodeNoLabel))
- .add(53, 53, 53)
- .add(
- candidatePathwaysSharingNodesScrollPane,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- 251, Short.MAX_VALUE)
- .add(29, 29, 29)
- .add(
- helpPanelLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.BASELINE)
- // .add(backToSearchButton)
- .add(addHelpButton))
- .addContainerGap(131, Short.MAX_VALUE)));
-
- /*
- * helpPanelLayout.linkSize(new java.awt.Component[] { addHelpButton,
- * backToSearchButton }, org.jdesktop.layout.GroupLayout.VERTICAL);
- */
-
- helpPanelLayout.linkSize(new java.awt.Component[] { lastLabel,
- lowerBoundLabel, lowerBoundSharingNodeNoComboBox,
- searchHelpButton, sharingNodeNoLabel, upperBoundLabel,
- upperBoundSharingNodeNoComboBox },
- org.jdesktop.layout.GroupLayout.VERTICAL);
-
- // setLayout(helpPanelLayout);
- setContentPane(helpPanel);
- pack();
-
- }
-
- private void searchHelpButtonActionPerformed(java.awt.event.ActionEvent evt) {
-
- // clean the table
- int num = candidatePathwaysSharingNodesTableModel.getRowCount();
- for (int t = 0; t < num; t++) {
- candidatePathwaysSharingNodesTableModel.removeRow(t);
- }
-
- candidatePathwaysSharingNodesTable
- .setModel(candidatePathwaysSharingNodesTableModel);
- setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
-
- // debugging
- /*
- * Class columnType =
- * candidatePathwaysSharingNodesTableModel.getColumnClass(2);
- * System.out.println("2. in searchHelpButtonActionPerformed, right
- * after adding column names"); System.out.println(columnType+"");
- */
-
- // String anchorPwNameAndId =
- // anchorPathwayComboBox.getSelectedItem().toString();
- int lowerBound = Integer.parseInt(lowerBoundSharingNodeNoComboBox
- .getSelectedItem().toString());
- int upperBound = Integer.parseInt(upperBoundSharingNodeNoComboBox
- .getSelectedItem().toString());
-
- // mCandidatePwList = findCandidatePwBySharingNodes(lowerBound,
- // upperBound);
-
- searchSharingNodePwsTask task = new searchSharingNodePwsTask(
- lowerBound, upperBound);
-
- JTaskConfig config = new JTaskConfig();
- config.displayCancelButton(true);
- // config.displayCloseButton(true);
- // config.displayStatus(true);
- config.setModal(true);
- TaskManager.executeTask(task, config);
- setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
-
- }
-
- private void addHelpButtonActionPerformed(java.awt.event.ActionEvent evt) {
-
- selectedPws = new ArrayList();
- int[] selectedRowIndices = candidatePathwaysSharingNodesTable
- .getSelectedRows();
-
- for (int i = 0; i < selectedRowIndices.length; i++) {
- int viewRow = selectedRowIndices[i];
- int modelRow = sorter.modelIndex(viewRow);
-
- String pwNameId = (String) candidatePathwaysSharingNodesTableModel
- .getValueAt(modelRow, 0)
- + "("
- + (String) candidatePathwaysSharingNodesTableModel
- .getValueAt(modelRow, 1) + ")";
- System.out
- .println("After clicking the Add button in the 'Search Help' panel!");
- System.out.println(pwNameId);
-
- selectedPws.add(pwNameId);
- SuperpathwaysGui spGUI = mClient.getGUI();
- if (!spGUI.selectedPathwaysListModel.contains(pwNameId)) {
- spGUI.selectedPathwaysListModel.addElement((Object) pwNameId);
- spGUI.selectedPathwaysList
- .setModel(spGUI.selectedPathwaysListModel);
-
- /*if (spGUI.availablePathwaysListModel.getSize() > 0) {
- spGUI.rightButton.setEnabled(true);
- }*/
- }
- }
- // superpathwayPanel.setSelectedIndex(0);
- setVisible(false);
-
- }
-
- // private javax.swing.JComboBox anchorPathwayComboBox;
-
- private TableSorter sorter;
-
- private javax.swing.JLabel anchorPathwayLabel;
-
- private javax.swing.JLabel anchorPathwayNameIDLabel;
-
- // private javax.swing.DefaultComboBoxModel anchorPathwayComboBoxModel;
-
- // private javax.swing.JButton backToSearchButton;
-
- private javax.swing.JScrollPane candidatePathwaysSharingNodesScrollPane;
-
- private javax.swing.JLabel lowerBoundLabel;
-
- private javax.swing.JLabel explainHelpLabel1;
-
- private javax.swing.JLabel explainHelpLabel2;
-
- private javax.swing.JPanel helpPanel;
-
- private javax.swing.JLabel upperBoundLabel;
-
- private javax.swing.JComboBox upperBoundSharingNodeNoComboBox;
-
- private javax.swing.JButton searchHelpButton;
-
- private javax.swing.JLabel lastLabel;
-
- private javax.swing.JTable candidatePathwaysSharingNodesTable;
-
- private javax.swing.JLabel sharingNodeNoLabel;
-
- private javax.swing.JButton addHelpButton;
-
- private javax.swing.JComboBox lowerBoundSharingNodeNoComboBox;
-
- private javax.swing.table.DefaultTableModel candidatePathwaysSharingNodesTableModel = new DefaultTableModel() {
- Class[] classes = { String.class, String.class, Integer.class };
-
- public Class getColumnClass(int column) {
- return classes[column];
- }
- };;
-
- public class searchSharingNodePwsTask implements Task {
-
- TaskMonitor monitor;
-
- int lowerBound;
-
- int upperBound;
-
- boolean cancelled;
-
- public searchSharingNodePwsTask(int lb, int ub) {
- lowerBound = lb;
- upperBound = ub;
- cancelled = false;
- }
-
- /**
- * Run the Task.
- */
- public void run() {
-
- try {
- mCandidatePw = new ArrayList();
- if (lowerBound > upperBound) {
- JOptionPane.showMessageDialog(helpPanel,
- "Please reset the range of sharing nodes number!");
- } else {
-
- Map sharingNodeNumberofPws = new HashMap();
- List geneIDList = new ArrayList();
- int percentComplete = 0;
- int t = 0;
-
- // Create a client to the WikiPathways web service
- WikiPathwaysClient client = mClient.getStub();
-
- int index1 = anchorPwNameID.lastIndexOf("(");
- int index2 = anchorPwNameID.lastIndexOf(")");
- String anchorPwID = anchorPwNameID.substring(index1 + 1,
- index2);
-
- WSPathway anchorPathway = new WSPathway();
-
- try {
- anchorPathway = client.getPathway(anchorPwID);
-
- } catch (RemoteException e) {
- Logger.log
- .error(
- "Unable to get the pathway due to the RemoteException",
- e);
- } catch (ConverterException e) {
- Logger.log
- .error(
- "Unable to get the pathway due to the ConverterException",
- e);
- }
- // Create two corresponding pathway objects
- Pathway mAnchorPw = new Pathway();
-
- try {
- mAnchorPw = WikiPathwaysClient.toPathway(anchorPathway);
- } catch (ConverterException e) {
- Logger.log
- .error(
- "Unable to get the pathway due to the RemoteException",
- e);
- }
-
- // the following code is get a map "mNodeIdToPwsSharingNode"
- // with key of GeneID and value of a list of pathways which
- // contain the GeneID
- for (PathwayElement pwElm : mAnchorPw.getDataObjects()) {
- // Only take elements with type DATANODE (genes,
- // proteins, metabolites)
- if (pwElm.getObjectType() == ObjectType.DATANODE) {
-
- if (!cancelled) {
- percentComplete = (int) (((double) t / mNoGeneNode) * 98);
-
- System.out.println(pwElm.getXref().toString());
- geneIDList.add(pwElm.getXref().toString());
-
- try {
- WSSearchResult[] PwsSharingNode = client
- .findPathwaysByXref(pwElm.getXref());
- // System.out.println("" +
- // PwsSharingNode.length);
- mNodeIdToPwsSharingNode.put(pwElm.getXref()
- .toString(), PwsSharingNode);
-
- if (monitor != null) {
- monitor
- .setPercentCompleted(percentComplete);
- }
-
- } catch (RemoteException e) {
- Logger.log
- .error(
- "Unable to find the candidate pathways due to the RemoteException",
- e);
- }
- }
- }
- t++;
-
- }
-
- // the following code is for converting the above map to
- // another map "sharingNodeNumberofPws" with key of
- // the name and id of a pathway, and value of the number of
- // shared node of this pathway and the anchor pathway
- for (int i = 0; i < mNoGeneNode; i++) {
- if (!cancelled) {
- WSSearchResult[] pwsArray = mNodeIdToPwsSharingNode
- .get(geneIDList.get(i));
-
- for (int j = 0; j < pwsArray.length; j++) {
- WSSearchResult pw = pwsArray[j];
- // pay attention to the following two code lines
- SuperpathwaysGui spGui = mClient.getGUI();
- ResultRow pwResultRow = spGui.new ResultRow(pw);
- String onePwNameAndId = pwResultRow
- .getProperty(ResultProperty.NAME)
- + "("
- + pwResultRow
- .getProperty(ResultProperty.ID)
- + ")";
-
- if (sharingNodeNumberofPws
- .containsKey(onePwNameAndId)) {
- Integer oldValue = sharingNodeNumberofPws
- .get(onePwNameAndId);
- Integer newValue = new Integer(oldValue + 1);
- sharingNodeNumberofPws.put(onePwNameAndId,
- newValue);
- } else {
- sharingNodeNumberofPws.put(onePwNameAndId,
- 1);
- }
- }
- }
- }
-
- // the following code is for displaying the result in the
- // table of "Search Help" panel
- if (!cancelled) {
- Set sharingNodePwsSet = sharingNodeNumberofPws
- .keySet();
- Iterator it = sharingNodePwsSet.iterator();
- while (it.hasNext()) {
- String temp = it.next();
- Integer value = sharingNodeNumberofPws.get(temp);
- if (value >= lowerBound && value <= upperBound) {
- mCandidatePw.add(temp
- + ", sharing node number: "
- + String.valueOf(value));
- }
- }
- }
-
- }
-
- // mCandidatePw is a list of string with elements in format
- // "Pathway
- // Name (pw id), sharing node number: a int"
- // System.out.println(mCandidatePw.size()+"");
- if (!cancelled) {
- Iterator it = mCandidatePw.iterator();
-
- while (it.hasNext()) {
- String temp = it.next();
- // candidatePathwaysSharingNodesListModel.addElement(temp);
-
- // System.out.println(temp);
- // parse the string into three parts: pathway name, id,
- // and
- // No.
- // Sharing Nodes
- int index1 = temp.lastIndexOf(",");
- String temp1 = temp.substring(0, index1);
-
- int index2 = temp1.lastIndexOf("(");
- int index3 = temp1.lastIndexOf(")");
- String pwName = temp1.substring(0, index2);
- // System.out.println(pwName);
- String pwId = temp1.substring(index2 + 1, index3);
- // System.out.println(pwId);
-
- // String temp2 = temp.substring(index1+1);
- int index4 = temp.lastIndexOf(":");
- String NoSharingNode = temp.substring(index4 + 2);
- Integer NoSharingNodeInteger = Integer
- .valueOf(NoSharingNode);
-
- Object[] row = new Object[3];
- row[0] = pwName;
- row[1] = pwId;
- row[2] = NoSharingNodeInteger;
- // row[2] = NoSharingNode;
- candidatePathwaysSharingNodesTableModel.addRow(row);
- }
-
- sorter = new TableSorter(
- candidatePathwaysSharingNodesTableModel);
- candidatePathwaysSharingNodesTable.setModel(sorter);
- sorter.setTableHeader(candidatePathwaysSharingNodesTable
- .getTableHeader());
-
- // candidatePathwaysSharingNodesList.setModel(candidatePathwaysSharingNodesListModel);
- setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
-
- if (monitor != null) {
- monitor.setPercentCompleted(100);
- }
- // System.out.println("We reach here 2!");
- }
- } catch (Exception e) {
- Logger.log.error("Error while searching candidate pathways", e);
- JOptionPane.showMessageDialog(mClient.getGUI(), "Error: "
- + e.getMessage() + ". See log for details", "Error",
- JOptionPane.ERROR_MESSAGE);
- }
-
- }
-
- public void halt() {
- cancelled = true;
- }
-
- public void setTaskMonitor(TaskMonitor m)
- throws IllegalThreadStateException {
- monitor = m;
- }
-
- public String getTitle() {
- return new String(
- "Searching candidate pathways with shared nodes...");
- }
- }
-
+// PathVisio,
+// a tool for data visualization and analysis using Biological Pathways
+// Copyright 2006-2011 BiGCaT Bioinformatics
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package org.pathvisio.cytoscape.superpathways;
+
+import java.awt.Cursor;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.swing.JDialog;
+import javax.swing.JOptionPane;
+import javax.swing.ListSelectionModel;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableColumn;
+
+import org.pathvisio.core.debug.Logger;
+import org.pathvisio.core.model.ConverterException;
+import org.pathvisio.core.model.ObjectType;
+import org.pathvisio.core.model.Pathway;
+import org.pathvisio.core.model.PathwayElement;
+import org.pathvisio.cytoscape.superpathways.SuperpathwaysGui.ResultRow;
+import org.pathvisio.wikipathways.webservice.WSPathway;
+import org.pathvisio.wikipathways.webservice.WSSearchResult;
+import org.wikipathways.client.WikiPathwaysClient;
+
+import cytoscape.task.Task;
+import cytoscape.task.TaskMonitor;
+import cytoscape.task.ui.JTaskConfig;
+import cytoscape.task.util.TaskManager;
+
+public class FindRelatedPwsDialog extends JDialog {
+
+ SuperpathwaysClient mClient;
+
+ private List mCandidatePw;
+
+ String anchorPwNameID;
+
+ int mNoGeneNode;
+
+ private Map mNodeIdToPwsSharingNode = new HashMap();
+
+ List selectedPws;
+
+ public FindRelatedPwsDialog(SuperpathwaysClient client, String s,
+ String anchorPw) {
+ super(client.getPlugin().mWindow, s);
+ mClient = client;
+ setSize(250, 300);
+ setModal(true);
+ initComponents(anchorPw);
+ setModal(false);
+
+ }
+
+ private void initComponents(String anchorPw) {
+
+ anchorPwNameID = anchorPw;
+ // the following items are in helpPanel Dialog
+ helpPanel = new javax.swing.JPanel();
+ anchorPathwayLabel = new javax.swing.JLabel();
+ sharingNodeNoLabel = new javax.swing.JLabel();
+ // anchorPathwayComboBox = new javax.swing.JComboBox();
+ anchorPathwayNameIDLabel = new javax.swing.JLabel();
+
+ lowerBoundSharingNodeNoComboBox = new javax.swing.JComboBox();
+ candidatePathwaysSharingNodesScrollPane = new javax.swing.JScrollPane();
+ candidatePathwaysSharingNodesTable = new javax.swing.JTable();
+
+ explainHelpLabel1 = new javax.swing.JLabel();
+ addHelpButton = new javax.swing.JButton();
+ lowerBoundLabel = new javax.swing.JLabel();
+ upperBoundLabel = new javax.swing.JLabel();
+ upperBoundSharingNodeNoComboBox = new javax.swing.JComboBox();
+ explainHelpLabel2 = new javax.swing.JLabel();
+ // backToSearchButton = new javax.swing.JButton();
+ searchHelpButton = new javax.swing.JButton();
+ lastLabel = new javax.swing.JLabel();
+
+ // the follwoing code is for Search Help tab
+ anchorPathwayLabel.setForeground(new java.awt.Color(0, 0, 255));
+ anchorPathwayLabel.setText("Selected Pathway: ");
+
+ anchorPathwayNameIDLabel.setForeground(new java.awt.Color(0, 0, 255));
+ anchorPathwayNameIDLabel.setText(anchorPw);
+
+ sharingNodeNoLabel.setForeground(new java.awt.Color(0, 0, 255));
+ sharingNodeNoLabel.setText("Sharing");
+
+ // anchorPathwayComboBox.setModel(new
+ // DefaultComboBoxModel(mAvailablePathwaysNameIDList.toArray()));
+
+ lowerBoundSharingNodeNoComboBox
+ .setModel(new javax.swing.DefaultComboBoxModel(new String[] {
+ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }));
+
+ // candidatePathwaysSharingNodesTable.setModel();
+
+ explainHelpLabel1.setFont(new java.awt.Font("Dialog", 1, 11)); // NOI18N
+ explainHelpLabel1.setForeground(new java.awt.Color(102, 0, 0));
+ explainHelpLabel1
+ .setText("Set the range of sharing nodes number for the selected pathway, a list of candidate");
+
+ explainHelpLabel2.setFont(new java.awt.Font("Dialog", 1, 11)); // NOI18N
+ explainHelpLabel2.setForeground(new java.awt.Color(102, 0, 0));
+ explainHelpLabel2
+ .setText("pathways with sharing nodes would be returned after clicking Search button.");
+
+ addHelpButton.setText("Add");
+ addHelpButton
+ .setToolTipText("add the selected pathways to the 'Available Pathways' list");
+
+ addHelpButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ addHelpButtonActionPerformed(evt);
+ }
+ });
+
+ lowerBoundLabel.setForeground(new java.awt.Color(0, 0, 255));
+ lowerBoundLabel.setText("Minimum");
+
+ upperBoundLabel.setForeground(new java.awt.Color(0, 0, 255));
+ upperBoundLabel.setText("Maximum");
+
+ // set the numbers for according to the selected pathway
+ int index1 = anchorPw.lastIndexOf("(");
+ int index2 = anchorPw.lastIndexOf(")");
+ String anchorPwID = anchorPw.substring(index1 + 1, index2);
+
+ // Create a client to the WikiPathways web service
+ WikiPathwaysClient client = mClient.getStub();
+ WSPathway anchorPathway = new WSPathway();
+
+ try {
+ anchorPathway = client.getPathway(anchorPwID);
+
+ } catch (RemoteException e) {
+ Logger.log.error(
+ "Unable to get the pathway due to the RemoteException", e);
+ } catch (ConverterException e) {
+ Logger.log.error(
+ "Unable to get the pathway due to the ConverterException",
+ e);
+ }
+ // Create the corresponding pathway objects
+ Pathway mAnchorPw = new Pathway();
+
+ try {
+ mAnchorPw = WikiPathwaysClient.toPathway(anchorPathway);
+ } catch (ConverterException e) {
+ Logger.log.error(
+ "Unable to get the pathway due to the RemoteException", e);
+ }
+
+ mNoGeneNode = 0;
+ for (PathwayElement pwElm : mAnchorPw.getDataObjects()) {
+ if (pwElm.getObjectType() == ObjectType.DATANODE) {
+ mNoGeneNode = mNoGeneNode + 1;
+
+ }
+ }
+ String[] temp = new String[mNoGeneNode];
+ for (int i = 1; i <= mNoGeneNode; i++) {
+ temp[i - 1] = String.valueOf(i);
+ }
+ upperBoundSharingNodeNoComboBox
+ .setModel(new javax.swing.DefaultComboBoxModel(temp));
+
+ lastLabel.setForeground(new java.awt.Color(0, 0, 255));
+ lastLabel.setText("Nodes");
+
+ searchHelpButton.setText("Search");
+ searchHelpButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ searchHelpButtonActionPerformed(evt);
+ }
+ });
+
+ candidatePathwaysSharingNodesTableModel.addColumn("Pathway Name");
+ candidatePathwaysSharingNodesTableModel.addColumn("ID");
+ candidatePathwaysSharingNodesTableModel.addColumn("No. Shared Nodes");
+
+ candidatePathwaysSharingNodesTable
+ .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+ candidatePathwaysSharingNodesScrollPane
+ .setViewportView(candidatePathwaysSharingNodesTable);
+ candidatePathwaysSharingNodesTable
+ .setModel(candidatePathwaysSharingNodesTableModel);
+
+ TableColumn column = null;
+ for (int i = 0; i < 3; i++) {
+ column = candidatePathwaysSharingNodesTable.getColumnModel()
+ .getColumn(i);
+ if (i == 0) {
+ column.setPreferredWidth(150);
+ } else if (i == 1) {
+ column.setPreferredWidth(40);
+ } else {
+ column.setPreferredWidth(60);
+ }
+
+ }
+
+ org.jdesktop.layout.GroupLayout helpPanelLayout = new org.jdesktop.layout.GroupLayout(
+ helpPanel);
+ helpPanel.setLayout(helpPanelLayout);
+ helpPanelLayout
+ .setHorizontalGroup(helpPanelLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING)
+ .add(
+ helpPanelLayout
+ .createSequentialGroup()
+ .add(
+ helpPanelLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING)
+ .add(
+ helpPanelLayout
+ .createSequentialGroup()
+ .addContainerGap()
+ .add(
+ explainHelpLabel1))
+ .add(
+ helpPanelLayout
+ .createSequentialGroup()
+ .addContainerGap()
+ .add(
+ explainHelpLabel2))
+ .add(
+ helpPanelLayout
+ .createSequentialGroup()
+ .add(
+ 19,
+ 19,
+ 19)
+ .add(
+ helpPanelLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING)
+ .add(
+ anchorPathwayLabel)
+ .add(
+ sharingNodeNoLabel))
+ .add(
+ 6,
+ 6,
+ 6)
+ .add(
+ helpPanelLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING,
+ false)
+ .add(
+ helpPanelLayout
+ .createSequentialGroup()
+ .add(
+ lowerBoundLabel)
+ .add(
+ 18,
+ 18,
+ 18)
+ .add(
+ lowerBoundSharingNodeNoComboBox,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(
+ 18,
+ 18,
+ 18)
+ .add(
+ upperBoundLabel)
+ .add(
+ 18,
+ 18,
+ 18)
+ .add(
+ upperBoundSharingNodeNoComboBox,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .add(
+ helpPanelLayout
+ .createSequentialGroup()
+ .add(
+ 23,
+ 23,
+ 23)
+ .add(
+ anchorPathwayNameIDLabel,
+ 0,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ Short.MAX_VALUE)))
+ .add(
+ 18,
+ 18,
+ 18)
+ .add(
+ lastLabel)
+ .add(
+ 18,
+ 18,
+ 18)
+ .add(
+ searchHelpButton)))
+ .addContainerGap(24, Short.MAX_VALUE))
+ .add(
+ org.jdesktop.layout.GroupLayout.TRAILING,
+ helpPanelLayout
+ .createSequentialGroup()
+ .addContainerGap(190, Short.MAX_VALUE)
+ // .add(backToSearchButton)
+ .addPreferredGap(
+ org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(addHelpButton).add(26, 26, 26))
+ .add(
+ helpPanelLayout
+ .createSequentialGroup()
+ .addContainerGap()
+ .add(
+ candidatePathwaysSharingNodesScrollPane,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ 402, Short.MAX_VALUE).add(16,
+ 16, 16)));
+
+ /*
+ * helpPanelLayout.linkSize(new java.awt.Component[] { addHelpButton,
+ * backToSearchButton }, org.jdesktop.layout.GroupLayout.HORIZONTAL);
+ */
+
+ helpPanelLayout
+ .setVerticalGroup(helpPanelLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING)
+ .add(
+ helpPanelLayout
+ .createSequentialGroup()
+ .add(33, 33, 33)
+ .add(explainHelpLabel1)
+ .addPreferredGap(
+ org.jdesktop.layout.LayoutStyle.UNRELATED)
+ .add(explainHelpLabel2)
+ .add(44, 44, 44)
+ .add(
+ helpPanelLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(anchorPathwayLabel)
+ .add(
+ anchorPathwayNameIDLabel,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .add(23, 23, 23)
+ .add(
+ helpPanelLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(lowerBoundLabel)
+ .add(
+ lowerBoundSharingNodeNoComboBox,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(upperBoundLabel)
+ .add(
+ upperBoundSharingNodeNoComboBox,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(lastLabel)
+ .add(searchHelpButton)
+ .add(sharingNodeNoLabel))
+ .add(53, 53, 53)
+ .add(
+ candidatePathwaysSharingNodesScrollPane,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ 251, Short.MAX_VALUE)
+ .add(29, 29, 29)
+ .add(
+ helpPanelLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.BASELINE)
+ // .add(backToSearchButton)
+ .add(addHelpButton))
+ .addContainerGap(131, Short.MAX_VALUE)));
+
+ /*
+ * helpPanelLayout.linkSize(new java.awt.Component[] { addHelpButton,
+ * backToSearchButton }, org.jdesktop.layout.GroupLayout.VERTICAL);
+ */
+
+ helpPanelLayout.linkSize(new java.awt.Component[] { lastLabel,
+ lowerBoundLabel, lowerBoundSharingNodeNoComboBox,
+ searchHelpButton, sharingNodeNoLabel, upperBoundLabel,
+ upperBoundSharingNodeNoComboBox },
+ org.jdesktop.layout.GroupLayout.VERTICAL);
+
+ // setLayout(helpPanelLayout);
+ setContentPane(helpPanel);
+ pack();
+
+ }
+
+ private void searchHelpButtonActionPerformed(java.awt.event.ActionEvent evt) {
+
+ // clean the table
+ int num = candidatePathwaysSharingNodesTableModel.getRowCount();
+ for (int t = 0; t < num; t++) {
+ candidatePathwaysSharingNodesTableModel.removeRow(t);
+ }
+
+ candidatePathwaysSharingNodesTable
+ .setModel(candidatePathwaysSharingNodesTableModel);
+ setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+ // debugging
+ /*
+ * Class columnType =
+ * candidatePathwaysSharingNodesTableModel.getColumnClass(2);
+ * System.out.println("2. in searchHelpButtonActionPerformed, right
+ * after adding column names"); System.out.println(columnType+"");
+ */
+
+ // String anchorPwNameAndId =
+ // anchorPathwayComboBox.getSelectedItem().toString();
+ int lowerBound = Integer.parseInt(lowerBoundSharingNodeNoComboBox
+ .getSelectedItem().toString());
+ int upperBound = Integer.parseInt(upperBoundSharingNodeNoComboBox
+ .getSelectedItem().toString());
+
+ // mCandidatePwList = findCandidatePwBySharingNodes(lowerBound,
+ // upperBound);
+
+ searchSharingNodePwsTask task = new searchSharingNodePwsTask(
+ lowerBound, upperBound);
+
+ JTaskConfig config = new JTaskConfig();
+ config.displayCancelButton(true);
+ // config.displayCloseButton(true);
+ // config.displayStatus(true);
+ config.setModal(true);
+ TaskManager.executeTask(task, config);
+ setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+
+ }
+
+ private void addHelpButtonActionPerformed(java.awt.event.ActionEvent evt) {
+
+ selectedPws = new ArrayList();
+ int[] selectedRowIndices = candidatePathwaysSharingNodesTable
+ .getSelectedRows();
+
+ for (int i = 0; i < selectedRowIndices.length; i++) {
+ int viewRow = selectedRowIndices[i];
+ int modelRow = sorter.modelIndex(viewRow);
+
+ String pwNameId = (String) candidatePathwaysSharingNodesTableModel
+ .getValueAt(modelRow, 0)
+ + "("
+ + (String) candidatePathwaysSharingNodesTableModel
+ .getValueAt(modelRow, 1) + ")";
+ System.out
+ .println("After clicking the Add button in the 'Search Help' panel!");
+ System.out.println(pwNameId);
+
+ selectedPws.add(pwNameId);
+ SuperpathwaysGui spGUI = mClient.getGUI();
+ if (!spGUI.selectedPathwaysListModel.contains(pwNameId)) {
+ spGUI.selectedPathwaysListModel.addElement((Object) pwNameId);
+ spGUI.selectedPathwaysList
+ .setModel(spGUI.selectedPathwaysListModel);
+
+ /*if (spGUI.availablePathwaysListModel.getSize() > 0) {
+ spGUI.rightButton.setEnabled(true);
+ }*/
+ }
+ }
+ // superpathwayPanel.setSelectedIndex(0);
+ setVisible(false);
+
+ }
+
+ // private javax.swing.JComboBox anchorPathwayComboBox;
+
+ private TableSorter sorter;
+
+ private javax.swing.JLabel anchorPathwayLabel;
+
+ private javax.swing.JLabel anchorPathwayNameIDLabel;
+
+ // private javax.swing.DefaultComboBoxModel anchorPathwayComboBoxModel;
+
+ // private javax.swing.JButton backToSearchButton;
+
+ private javax.swing.JScrollPane candidatePathwaysSharingNodesScrollPane;
+
+ private javax.swing.JLabel lowerBoundLabel;
+
+ private javax.swing.JLabel explainHelpLabel1;
+
+ private javax.swing.JLabel explainHelpLabel2;
+
+ private javax.swing.JPanel helpPanel;
+
+ private javax.swing.JLabel upperBoundLabel;
+
+ private javax.swing.JComboBox upperBoundSharingNodeNoComboBox;
+
+ private javax.swing.JButton searchHelpButton;
+
+ private javax.swing.JLabel lastLabel;
+
+ private javax.swing.JTable candidatePathwaysSharingNodesTable;
+
+ private javax.swing.JLabel sharingNodeNoLabel;
+
+ private javax.swing.JButton addHelpButton;
+
+ private javax.swing.JComboBox lowerBoundSharingNodeNoComboBox;
+
+ private javax.swing.table.DefaultTableModel candidatePathwaysSharingNodesTableModel = new DefaultTableModel() {
+ Class[] classes = { String.class, String.class, Integer.class };
+
+ public Class getColumnClass(int column) {
+ return classes[column];
+ }
+ };;
+
+ public class searchSharingNodePwsTask implements Task {
+
+ TaskMonitor monitor;
+
+ int lowerBound;
+
+ int upperBound;
+
+ boolean cancelled;
+
+ public searchSharingNodePwsTask(int lb, int ub) {
+ lowerBound = lb;
+ upperBound = ub;
+ cancelled = false;
+ }
+
+ /**
+ * Run the Task.
+ */
+ public void run() {
+
+ try {
+ mCandidatePw = new ArrayList();
+ if (lowerBound > upperBound) {
+ JOptionPane.showMessageDialog(helpPanel,
+ "Please reset the range of sharing nodes number!");
+ } else {
+
+ Map sharingNodeNumberofPws = new HashMap();
+ List geneIDList = new ArrayList();
+ int percentComplete = 0;
+ int t = 0;
+
+ // Create a client to the WikiPathways web service
+ WikiPathwaysClient client = mClient.getStub();
+
+ int index1 = anchorPwNameID.lastIndexOf("(");
+ int index2 = anchorPwNameID.lastIndexOf(")");
+ String anchorPwID = anchorPwNameID.substring(index1 + 1,
+ index2);
+
+ WSPathway anchorPathway = new WSPathway();
+
+ try {
+ anchorPathway = client.getPathway(anchorPwID);
+
+ } catch (RemoteException e) {
+ Logger.log
+ .error(
+ "Unable to get the pathway due to the RemoteException",
+ e);
+ } catch (ConverterException e) {
+ Logger.log
+ .error(
+ "Unable to get the pathway due to the ConverterException",
+ e);
+ }
+ // Create two corresponding pathway objects
+ Pathway mAnchorPw = new Pathway();
+
+ try {
+ mAnchorPw = WikiPathwaysClient.toPathway(anchorPathway);
+ } catch (ConverterException e) {
+ Logger.log
+ .error(
+ "Unable to get the pathway due to the RemoteException",
+ e);
+ }
+
+ // the following code is get a map "mNodeIdToPwsSharingNode"
+ // with key of GeneID and value of a list of pathways which
+ // contain the GeneID
+ for (PathwayElement pwElm : mAnchorPw.getDataObjects()) {
+ // Only take elements with type DATANODE (genes,
+ // proteins, metabolites)
+ if (pwElm.getObjectType() == ObjectType.DATANODE) {
+
+ if (!cancelled) {
+ percentComplete = (int) (((double) t / mNoGeneNode) * 98);
+
+ System.out.println(pwElm.getXref().toString());
+ geneIDList.add(pwElm.getXref().toString());
+
+ try {
+ WSSearchResult[] PwsSharingNode = client
+ .findPathwaysByXref(pwElm.getXref());
+ // System.out.println("" +
+ // PwsSharingNode.length);
+ mNodeIdToPwsSharingNode.put(pwElm.getXref()
+ .toString(), PwsSharingNode);
+
+ if (monitor != null) {
+ monitor
+ .setPercentCompleted(percentComplete);
+ }
+
+ } catch (RemoteException e) {
+ Logger.log
+ .error(
+ "Unable to find the candidate pathways due to the RemoteException",
+ e);
+ }
+ }
+ }
+ t++;
+
+ }
+
+ // the following code is for converting the above map to
+ // another map "sharingNodeNumberofPws" with key of
+ // the name and id of a pathway, and value of the number of
+ // shared node of this pathway and the anchor pathway
+ for (int i = 0; i < mNoGeneNode; i++) {
+ if (!cancelled) {
+ WSSearchResult[] pwsArray = mNodeIdToPwsSharingNode
+ .get(geneIDList.get(i));
+
+ for (int j = 0; j < pwsArray.length; j++) {
+ WSSearchResult pw = pwsArray[j];
+ // pay attention to the following two code lines
+ SuperpathwaysGui spGui = mClient.getGUI();
+ ResultRow pwResultRow = spGui.new ResultRow(pw);
+ String onePwNameAndId = pwResultRow
+ .getProperty(ResultProperty.NAME)
+ + "("
+ + pwResultRow
+ .getProperty(ResultProperty.ID)
+ + ")";
+
+ if (sharingNodeNumberofPws
+ .containsKey(onePwNameAndId)) {
+ Integer oldValue = sharingNodeNumberofPws
+ .get(onePwNameAndId);
+ Integer newValue = new Integer(oldValue + 1);
+ sharingNodeNumberofPws.put(onePwNameAndId,
+ newValue);
+ } else {
+ sharingNodeNumberofPws.put(onePwNameAndId,
+ 1);
+ }
+ }
+ }
+ }
+
+ // the following code is for displaying the result in the
+ // table of "Search Help" panel
+ if (!cancelled) {
+ Set sharingNodePwsSet = sharingNodeNumberofPws
+ .keySet();
+ Iterator it = sharingNodePwsSet.iterator();
+ while (it.hasNext()) {
+ String temp = it.next();
+ Integer value = sharingNodeNumberofPws.get(temp);
+ if (value >= lowerBound && value <= upperBound) {
+ mCandidatePw.add(temp
+ + ", sharing node number: "
+ + String.valueOf(value));
+ }
+ }
+ }
+
+ }
+
+ // mCandidatePw is a list of string with elements in format
+ // "Pathway
+ // Name (pw id), sharing node number: a int"
+ // System.out.println(mCandidatePw.size()+"");
+ if (!cancelled) {
+ Iterator it = mCandidatePw.iterator();
+
+ while (it.hasNext()) {
+ String temp = it.next();
+ // candidatePathwaysSharingNodesListModel.addElement(temp);
+
+ // System.out.println(temp);
+ // parse the string into three parts: pathway name, id,
+ // and
+ // No.
+ // Sharing Nodes
+ int index1 = temp.lastIndexOf(",");
+ String temp1 = temp.substring(0, index1);
+
+ int index2 = temp1.lastIndexOf("(");
+ int index3 = temp1.lastIndexOf(")");
+ String pwName = temp1.substring(0, index2);
+ // System.out.println(pwName);
+ String pwId = temp1.substring(index2 + 1, index3);
+ // System.out.println(pwId);
+
+ // String temp2 = temp.substring(index1+1);
+ int index4 = temp.lastIndexOf(":");
+ String NoSharingNode = temp.substring(index4 + 2);
+ Integer NoSharingNodeInteger = Integer
+ .valueOf(NoSharingNode);
+
+ Object[] row = new Object[3];
+ row[0] = pwName;
+ row[1] = pwId;
+ row[2] = NoSharingNodeInteger;
+ // row[2] = NoSharingNode;
+ candidatePathwaysSharingNodesTableModel.addRow(row);
+ }
+
+ sorter = new TableSorter(
+ candidatePathwaysSharingNodesTableModel);
+ candidatePathwaysSharingNodesTable.setModel(sorter);
+ sorter.setTableHeader(candidatePathwaysSharingNodesTable
+ .getTableHeader());
+
+ // candidatePathwaysSharingNodesList.setModel(candidatePathwaysSharingNodesListModel);
+ setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+
+ if (monitor != null) {
+ monitor.setPercentCompleted(100);
+ }
+ // System.out.println("We reach here 2!");
+ }
+ } catch (Exception e) {
+ Logger.log.error("Error while searching candidate pathways", e);
+ JOptionPane.showMessageDialog(mClient.getGUI(), "Error: "
+ + e.getMessage() + ". See log for details", "Error",
+ JOptionPane.ERROR_MESSAGE);
+ }
+
+ }
+
+ public void halt() {
+ cancelled = true;
+ }
+
+ public void setTaskMonitor(TaskMonitor m)
+ throws IllegalThreadStateException {
+ monitor = m;
+ }
+
+ public String getTitle() {
+ return new String(
+ "Searching candidate pathways with shared nodes...");
+ }
+ }
+
}
\ No newline at end of file
diff --git a/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/PieGenerator.java b/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/PieGenerator.java
index 970f8c1f..e229926b 100644
--- a/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/PieGenerator.java
+++ b/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/PieGenerator.java
@@ -1,110 +1,110 @@
-// PathVisio,
-// a tool for data visualization and analysis using Biological Pathways
-// Copyright 2006-2011 BiGCaT Bioinformatics
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-package org.pathvisio.cytoscape.superpathways;
-
-import java.awt.Color;
-import java.io.File;
-import java.util.List;
-
-import org.jfree.chart.ChartFactory;
-import org.jfree.chart.ChartPanel;
-import org.jfree.chart.ChartUtilities;
-import org.jfree.chart.JFreeChart;
-import org.jfree.chart.plot.PiePlot;
-import org.jfree.data.general.DefaultPieDataset;
-import org.jfree.ui.ApplicationFrame;
-import org.jfree.ui.RefineryUtilities;
-import org.pathvisio.core.preferences.GlobalPreference;
-
-public class PieGenerator{ // extends ApplicationFrame {
-
- Color[] colors;
- static String imageLocation = GlobalPreference.getApplicationDir() .toString()+ "/" ;
-
- public PieGenerator(Color[] c){ //(final String title) {
- colors=c;
- }
-
- public void generatePie(int number){
- // Defining the dataset
- DefaultPieDataset dataset = new DefaultPieDataset();
- for (int i=0; i keys = dataset.getKeys();
- int aInt;
-
- for (int i = 0; i < keys.size(); i++) {
- aInt = i % this.color.length;
- plot.setSectionPaint(keys.get(i), this.color[aInt]);
- }
- }
- }
-
+// PathVisio,
+// a tool for data visualization and analysis using Biological Pathways
+// Copyright 2006-2011 BiGCaT Bioinformatics
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package org.pathvisio.cytoscape.superpathways;
+
+import java.awt.Color;
+import java.io.File;
+import java.util.List;
+
+import org.jfree.chart.ChartFactory;
+import org.jfree.chart.ChartPanel;
+import org.jfree.chart.ChartUtilities;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.plot.PiePlot;
+import org.jfree.data.general.DefaultPieDataset;
+import org.jfree.ui.ApplicationFrame;
+import org.jfree.ui.RefineryUtilities;
+import org.pathvisio.core.preferences.GlobalPreference;
+
+public class PieGenerator{ // extends ApplicationFrame {
+
+ Color[] colors;
+ static String imageLocation = GlobalPreference.getApplicationDir() .toString()+ "/" ;
+
+ public PieGenerator(Color[] c){ //(final String title) {
+ colors=c;
+ }
+
+ public void generatePie(int number){
+ // Defining the dataset
+ DefaultPieDataset dataset = new DefaultPieDataset();
+ for (int i=0; i keys = dataset.getKeys();
+ int aInt;
+
+ for (int i = 0; i < keys.size(); i++) {
+ aInt = i % this.color.length;
+ plot.setSectionPaint(keys.get(i), this.color[aInt]);
+ }
+ }
+ }
+
}
\ No newline at end of file
diff --git a/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/SuperpathwaysClient.java b/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/SuperpathwaysClient.java
index f45f6687..975b16d8 100644
--- a/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/SuperpathwaysClient.java
+++ b/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/SuperpathwaysClient.java
@@ -1,282 +1,282 @@
-// PathVisio,
-// a tool for data visualization and analysis using Biological Pathways
-// Copyright 2006-2011 BiGCaT Bioinformatics
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-package org.pathvisio.cytoscape.superpathways;
-
-import static cytoscape.data.webservice.CyWebServiceEvent.WSEventType.IMPORT_NETWORK;
-import static cytoscape.data.webservice.CyWebServiceEvent.WSEventType.SEARCH_DATABASE;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.rmi.RemoteException;
-import java.util.Properties;
-
-import javax.swing.JOptionPane;
-import javax.swing.SwingUtilities;
-import javax.xml.rpc.ServiceException;
-
-import org.bridgedb.bio.Organism;
-import org.pathvisio.core.debug.Logger;
-import org.pathvisio.core.model.Pathway;
-import org.pathvisio.wikipathways.webservice.WSPathway;
-import org.pathvisio.wikipathways.webservice.WSSearchResult;
-import org.wikipathways.client.WikiPathwaysClient;
-
-import cytoscape.CyNetwork;
-import cytoscape.Cytoscape;
-import cytoscape.CytoscapeInit;
-import cytoscape.data.webservice.CyWebServiceEvent;
-import cytoscape.data.webservice.CyWebServiceEventListener;
-import cytoscape.data.webservice.CyWebServiceException;
-import cytoscape.data.webservice.NetworkImportWebServiceClient;
-import cytoscape.data.webservice.WebServiceClientImplWithGUI;
-import cytoscape.data.webservice.WebServiceClientManager;
-import cytoscape.data.webservice.WebServiceClientManager.ClientType;
-import cytoscape.task.Task;
-import cytoscape.task.TaskMonitor;
-import cytoscape.task.ui.JTaskConfig;
-import cytoscape.task.util.TaskManager;
-import cytoscape.util.ModulePropertiesImpl;
-import cytoscape.visual.VisualStyle;
-
-public class SuperpathwaysClient extends WebServiceClientImplWithGUI implements NetworkImportWebServiceClient {
- private static final String DISPLAY_NAME = "Superpathways Web Service Client";
- private static final String CLIENT_ID = "superpathways";
-
- //private static final String DISPLAY_NAME = "WikiPathways Web Service Client";
- //private static final String CLIENT_ID = "wikipathways";
-
- protected static final String WEBSERVICE_URL = "wikipathways.webservice.uri";
- public static final String ATTR_PATHWAY_URL = "wikipathways.url";
-
- private WikiPathwaysClient stub;
- private String prevURL = null;
-
- private SuperpathwaysPlugin spPlugin;
- //private GpmlPlugin gpmlPlugin;
-
- public SuperpathwaysClient(SuperpathwaysPlugin spPlugin) {
- super(CLIENT_ID, DISPLAY_NAME, new ClientType[] { ClientType.NETWORK }, null, null, null);
- Logger.log.setLogLevel(true, true, true, true, true, true);
- setProperties();
- getStub();
- this.spPlugin = spPlugin;
- setGUI(new SuperpathwaysGui(this));
- SuperpathwaysGui a=getGUI();
- }
-
- public SuperpathwaysPlugin getPlugin(){
- return spPlugin;
- }
-
-
- private void setProperties() {
- //Using global properties, but need to initialize moduleproperties anyway.
- props = new ModulePropertiesImpl(CLIENT_ID, "wsc");
-
- Properties p = CytoscapeInit.getProperties();
- if(p.get(WEBSERVICE_URL) == null) {
- p.put(
- WEBSERVICE_URL,
- "http://www.wikipathways.org/wpi/webservice/webservice.php"
- );
- }
- }
-
-
- public WikiPathwaysClient getStub() {
- String urlString = CytoscapeInit.getProperties().getProperty(WEBSERVICE_URL);
- if(stub == null || prevURL == null || !prevURL.equals(urlString)) {
- try {
- URL url = new URL(urlString);
- stub = new WikiPathwaysClient(url);
- setClientStub(stub);
- prevURL = urlString;
-
- if(gui != null) gui.resetOrganisms();
- } catch (ServiceException e) {
- Logger.log.error("Unable to create WikiPathways webservice", e);
- } catch (MalformedURLException ue) {
- Logger.log.error("Invalid url to wsdl", ue);
- }
- }
- return stub;
- }
-
-
-
-
- public void executeService(CyWebServiceEvent e)throws CyWebServiceException {
- //must implemented, since WebServiceClientImplWithGUI is subclass of WebServiceClientImpl, and executeService is an abstract method of WebServiceClientImpl
- if(CLIENT_ID.equals(e.getSource())) {
- switch(e.getEventType()) {
- case IMPORT_NETWORK:
- Logger.log.info("Importing " + e.getParameter());
- openPathway((GetPathwayParameters)e.getParameter());
- break;
- case SEARCH_DATABASE:
- Logger.log.info("Searching " + e.getParameter());
- search((FindPathwaysByTextParameters)e.getParameter());
- break;
- }
- }
- }
- protected void openPathway(GetPathwayParameters query) {
- OpenTask task = new OpenTask(query);
-
- JTaskConfig config = new JTaskConfig();
- config.displayCancelButton(false);
- config.setModal(true);
- TaskManager.executeTask(task, config);
- }
-
- private void search(FindPathwaysByTextParameters request) throws CyWebServiceException {
- SearchTask task = new SearchTask(request);
- JTaskConfig config = new JTaskConfig();
- config.displayCancelButton(true);
- config.setModal(false);
- TaskManager.executeTask(task, config);
- }
-
- protected String[] listOrganisms() throws RemoteException {
- return getStub().listOrganisms();
- }
-
- class OpenTask implements Task {
- TaskMonitor monitor;
- GetPathwayParameters query;
-
- public OpenTask(GetPathwayParameters query) {
- this.query = query;
- }
-
- public String getTitle() {
- return "Opening pathway...";
- }
-
- public void halt() {
- }
-
- public void run() {
- try {
- WSPathway r = getStub().getPathway(query.id, query.revision);
- Pathway pathway = WikiPathwaysClient.toPathway(r);
- CyNetwork network = spPlugin.load(pathway, true);
- if(network != null) {
- Cytoscape.getNetworkAttributes().setAttribute(
- network.getIdentifier(), ATTR_PATHWAY_URL, r.getUrl()
- );
- }
- } catch (Exception e) {
- Logger.log.error("Error while opening pathway", e);
- JOptionPane.showMessageDialog(
- gui, "Error: " + e.getMessage() + ". See log for details",
- "Error", JOptionPane.ERROR_MESSAGE
- );
- }
- }
-
- public void setTaskMonitor(TaskMonitor m)throws IllegalThreadStateException {
- monitor = m;
- }
-
- }
-
- class SearchTask implements Task, CyWebServiceEventListener {
-
- FindPathwaysByTextParameters query;
- TaskMonitor monitor;
-
- public SearchTask(FindPathwaysByTextParameters query) {
- this.query = query;
- WebServiceClientManager.getCyWebServiceEventSupport().addCyWebServiceEventListener(this);
- }
-
- public String getTitle() {
- return "Searching...";
- }
-
- public void run() {
- try {
- WSSearchResult[] result = getStub().findPathwaysByText(query.query, query.species);
- gui.setResults(result);
- System.out.println("Superpathways-run!");
- if(result == null || result.length == 0) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- JOptionPane.showMessageDialog(
- gui, "The search didn't return any results",
- "No results", JOptionPane.INFORMATION_MESSAGE
- );
- }
- });
-
- }
- } catch (final Exception e) {
- Logger.log.error("Error while searching", e);
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- JOptionPane.showMessageDialog(
- gui, "Error: " + e.getMessage() + ". See log for details",
- "Error", JOptionPane.ERROR_MESSAGE
- );
- }
- });
- }
- }
-
- public void halt() {
- //Not 2.6 compatible
- // WebServiceClientManager.getCyWebServiceEventSupport().fireCyWebServiceEvent(
- // new CyWebServiceEvent(CLIENT_ID, WSEventType.CANCEL, query)
- // );
- }
-
- public void setTaskMonitor(TaskMonitor m)
- throws IllegalThreadStateException {
- this.monitor = m;
- }
-
- public void executeService(CyWebServiceEvent event) throws CyWebServiceException {
- //Not 2.6 compatible
- // if (event.getEventType().equals(WSEventType.CANCEL)) {
- // throw new CyWebServiceException(CyWebServiceException.WSErrorCode.REMOTE_EXEC_FAILED);
- // }
- }
- }
-
-
-
-
- public VisualStyle getDefaultVisualStyle() {
- //must implemented here, since this class implement interface NetworkImportWebServiceClient
- return null; //TODO
- }
-
- public static class FindPathwaysByTextParameters {
- public String query;
- public Organism species = null;
- }
-
- public static class GetPathwayParameters {
- public String id;
- public int revision;
- }
-
-
-
-}
+// PathVisio,
+// a tool for data visualization and analysis using Biological Pathways
+// Copyright 2006-2011 BiGCaT Bioinformatics
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package org.pathvisio.cytoscape.superpathways;
+
+import static cytoscape.data.webservice.CyWebServiceEvent.WSEventType.IMPORT_NETWORK;
+import static cytoscape.data.webservice.CyWebServiceEvent.WSEventType.SEARCH_DATABASE;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.rmi.RemoteException;
+import java.util.Properties;
+
+import javax.swing.JOptionPane;
+import javax.swing.SwingUtilities;
+import javax.xml.rpc.ServiceException;
+
+import org.bridgedb.bio.Organism;
+import org.pathvisio.core.debug.Logger;
+import org.pathvisio.core.model.Pathway;
+import org.pathvisio.wikipathways.webservice.WSPathway;
+import org.pathvisio.wikipathways.webservice.WSSearchResult;
+import org.wikipathways.client.WikiPathwaysClient;
+
+import cytoscape.CyNetwork;
+import cytoscape.Cytoscape;
+import cytoscape.CytoscapeInit;
+import cytoscape.data.webservice.CyWebServiceEvent;
+import cytoscape.data.webservice.CyWebServiceEventListener;
+import cytoscape.data.webservice.CyWebServiceException;
+import cytoscape.data.webservice.NetworkImportWebServiceClient;
+import cytoscape.data.webservice.WebServiceClientImplWithGUI;
+import cytoscape.data.webservice.WebServiceClientManager;
+import cytoscape.data.webservice.WebServiceClientManager.ClientType;
+import cytoscape.task.Task;
+import cytoscape.task.TaskMonitor;
+import cytoscape.task.ui.JTaskConfig;
+import cytoscape.task.util.TaskManager;
+import cytoscape.util.ModulePropertiesImpl;
+import cytoscape.visual.VisualStyle;
+
+public class SuperpathwaysClient extends WebServiceClientImplWithGUI implements NetworkImportWebServiceClient {
+ private static final String DISPLAY_NAME = "Superpathways Web Service Client";
+ private static final String CLIENT_ID = "superpathways";
+
+ //private static final String DISPLAY_NAME = "WikiPathways Web Service Client";
+ //private static final String CLIENT_ID = "wikipathways";
+
+ protected static final String WEBSERVICE_URL = "wikipathways.webservice.uri";
+ public static final String ATTR_PATHWAY_URL = "wikipathways.url";
+
+ private WikiPathwaysClient stub;
+ private String prevURL = null;
+
+ private SuperpathwaysPlugin spPlugin;
+ //private GpmlPlugin gpmlPlugin;
+
+ public SuperpathwaysClient(SuperpathwaysPlugin spPlugin) {
+ super(CLIENT_ID, DISPLAY_NAME, new ClientType[] { ClientType.NETWORK }, null, null, null);
+ Logger.log.setLogLevel(true, true, true, true, true, true);
+ setProperties();
+ getStub();
+ this.spPlugin = spPlugin;
+ setGUI(new SuperpathwaysGui(this));
+ SuperpathwaysGui a=getGUI();
+ }
+
+ public SuperpathwaysPlugin getPlugin(){
+ return spPlugin;
+ }
+
+
+ private void setProperties() {
+ //Using global properties, but need to initialize moduleproperties anyway.
+ props = new ModulePropertiesImpl(CLIENT_ID, "wsc");
+
+ Properties p = CytoscapeInit.getProperties();
+ if(p.get(WEBSERVICE_URL) == null) {
+ p.put(
+ WEBSERVICE_URL,
+ "http://www.wikipathways.org/wpi/webservice/webservice.php"
+ );
+ }
+ }
+
+
+ public WikiPathwaysClient getStub() {
+ String urlString = CytoscapeInit.getProperties().getProperty(WEBSERVICE_URL);
+ if(stub == null || prevURL == null || !prevURL.equals(urlString)) {
+ try {
+ URL url = new URL(urlString);
+ stub = new WikiPathwaysClient(url);
+ setClientStub(stub);
+ prevURL = urlString;
+
+ if(gui != null) gui.resetOrganisms();
+ } catch (ServiceException e) {
+ Logger.log.error("Unable to create WikiPathways webservice", e);
+ } catch (MalformedURLException ue) {
+ Logger.log.error("Invalid url to wsdl", ue);
+ }
+ }
+ return stub;
+ }
+
+
+
+
+ public void executeService(CyWebServiceEvent e)throws CyWebServiceException {
+ //must implemented, since WebServiceClientImplWithGUI is subclass of WebServiceClientImpl, and executeService is an abstract method of WebServiceClientImpl
+ if(CLIENT_ID.equals(e.getSource())) {
+ switch(e.getEventType()) {
+ case IMPORT_NETWORK:
+ Logger.log.info("Importing " + e.getParameter());
+ openPathway((GetPathwayParameters)e.getParameter());
+ break;
+ case SEARCH_DATABASE:
+ Logger.log.info("Searching " + e.getParameter());
+ search((FindPathwaysByTextParameters)e.getParameter());
+ break;
+ }
+ }
+ }
+ protected void openPathway(GetPathwayParameters query) {
+ OpenTask task = new OpenTask(query);
+
+ JTaskConfig config = new JTaskConfig();
+ config.displayCancelButton(false);
+ config.setModal(true);
+ TaskManager.executeTask(task, config);
+ }
+
+ private void search(FindPathwaysByTextParameters request) throws CyWebServiceException {
+ SearchTask task = new SearchTask(request);
+ JTaskConfig config = new JTaskConfig();
+ config.displayCancelButton(true);
+ config.setModal(false);
+ TaskManager.executeTask(task, config);
+ }
+
+ protected String[] listOrganisms() throws RemoteException {
+ return getStub().listOrganisms();
+ }
+
+ class OpenTask implements Task {
+ TaskMonitor monitor;
+ GetPathwayParameters query;
+
+ public OpenTask(GetPathwayParameters query) {
+ this.query = query;
+ }
+
+ public String getTitle() {
+ return "Opening pathway...";
+ }
+
+ public void halt() {
+ }
+
+ public void run() {
+ try {
+ WSPathway r = getStub().getPathway(query.id, query.revision);
+ Pathway pathway = WikiPathwaysClient.toPathway(r);
+ CyNetwork network = spPlugin.load(pathway, true);
+ if(network != null) {
+ Cytoscape.getNetworkAttributes().setAttribute(
+ network.getIdentifier(), ATTR_PATHWAY_URL, r.getUrl()
+ );
+ }
+ } catch (Exception e) {
+ Logger.log.error("Error while opening pathway", e);
+ JOptionPane.showMessageDialog(
+ gui, "Error: " + e.getMessage() + ". See log for details",
+ "Error", JOptionPane.ERROR_MESSAGE
+ );
+ }
+ }
+
+ public void setTaskMonitor(TaskMonitor m)throws IllegalThreadStateException {
+ monitor = m;
+ }
+
+ }
+
+ class SearchTask implements Task, CyWebServiceEventListener {
+
+ FindPathwaysByTextParameters query;
+ TaskMonitor monitor;
+
+ public SearchTask(FindPathwaysByTextParameters query) {
+ this.query = query;
+ WebServiceClientManager.getCyWebServiceEventSupport().addCyWebServiceEventListener(this);
+ }
+
+ public String getTitle() {
+ return "Searching...";
+ }
+
+ public void run() {
+ try {
+ WSSearchResult[] result = getStub().findPathwaysByText(query.query, query.species);
+ gui.setResults(result);
+ System.out.println("Superpathways-run!");
+ if(result == null || result.length == 0) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ JOptionPane.showMessageDialog(
+ gui, "The search didn't return any results",
+ "No results", JOptionPane.INFORMATION_MESSAGE
+ );
+ }
+ });
+
+ }
+ } catch (final Exception e) {
+ Logger.log.error("Error while searching", e);
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ JOptionPane.showMessageDialog(
+ gui, "Error: " + e.getMessage() + ". See log for details",
+ "Error", JOptionPane.ERROR_MESSAGE
+ );
+ }
+ });
+ }
+ }
+
+ public void halt() {
+ //Not 2.6 compatible
+ // WebServiceClientManager.getCyWebServiceEventSupport().fireCyWebServiceEvent(
+ // new CyWebServiceEvent(CLIENT_ID, WSEventType.CANCEL, query)
+ // );
+ }
+
+ public void setTaskMonitor(TaskMonitor m)
+ throws IllegalThreadStateException {
+ this.monitor = m;
+ }
+
+ public void executeService(CyWebServiceEvent event) throws CyWebServiceException {
+ //Not 2.6 compatible
+ // if (event.getEventType().equals(WSEventType.CANCEL)) {
+ // throw new CyWebServiceException(CyWebServiceException.WSErrorCode.REMOTE_EXEC_FAILED);
+ // }
+ }
+ }
+
+
+
+
+ public VisualStyle getDefaultVisualStyle() {
+ //must implemented here, since this class implement interface NetworkImportWebServiceClient
+ return null; //TODO
+ }
+
+ public static class FindPathwaysByTextParameters {
+ public String query;
+ public Organism species = null;
+ }
+
+ public static class GetPathwayParameters {
+ public String id;
+ public int revision;
+ }
+
+
+
+}
diff --git a/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/SuperpathwaysGui.java b/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/SuperpathwaysGui.java
index a7a7ff23..b9f4b906 100644
--- a/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/SuperpathwaysGui.java
+++ b/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/SuperpathwaysGui.java
@@ -1,1866 +1,1866 @@
-// PathVisio,
-// a tool for data visualization and analysis using Biological Pathways
-// Copyright 2006-2011 BiGCaT Bioinformatics
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-package org.pathvisio.cytoscape.superpathways;
-
-import java.awt.Color;
-import java.awt.Cursor;
-import java.rmi.RemoteException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.DefaultListModel;
-import javax.swing.JList;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.ListSelectionModel;
-import javax.swing.table.TableColumn;
-
-import org.bridgedb.Xref;
-import org.bridgedb.bio.Organism;
-import org.pathvisio.core.debug.Logger;
-import org.pathvisio.core.model.ConverterException;
-import org.pathvisio.core.model.ObjectType;
-import org.pathvisio.core.model.Pathway;
-import org.pathvisio.core.model.PathwayElement;
-import org.pathvisio.cytoscape.GpmlHandler;
-import org.pathvisio.cytoscape.superpathways.SuperpathwaysClient.FindPathwaysByTextParameters;
-import org.pathvisio.cytoscape.superpathways.SuperpathwaysClient.GetPathwayParameters;
-import org.pathvisio.desktop.util.ListWithPropertiesTableModel;
-import org.pathvisio.desktop.util.RowWithProperties;
-import org.pathvisio.wikipathways.webservice.WSPathway;
-import org.pathvisio.wikipathways.webservice.WSSearchResult;
-import org.wikipathways.client.WikiPathwaysClient;
-
-import cytoscape.CyNetwork;
-import cytoscape.Cytoscape;
-import cytoscape.data.webservice.CyWebServiceEvent;
-import cytoscape.data.webservice.CyWebServiceException;
-import cytoscape.data.webservice.WebServiceClientManager;
-import cytoscape.data.webservice.CyWebServiceEvent.WSEventType;
-import cytoscape.ding.CyGraphAllLOD;
-import cytoscape.task.Task;
-import cytoscape.task.TaskMonitor;
-import cytoscape.task.ui.JTaskConfig;
-import cytoscape.task.util.TaskManager;
-import cytoscape.view.CyNetworkView;
-import cytoscape.visual.CalculatorCatalog;
-import cytoscape.visual.GlobalAppearanceCalculator;
-import cytoscape.visual.VisualMappingManager;
-import cytoscape.visual.VisualStyle;
-import ding.view.DGraphView;
-
-//public class SuperpathwaysGui extends JFrame implements ActionListener{
-public class SuperpathwaysGui extends JPanel {
-
- // private static String ACTION_SEARCH = "Search";
-
- private static String ORGANISM_ALL = "All organisms";
-
- final SuperpathwaysClient mClient;
-
- ResultRow mSelectedInHelpPanel;
-
- List mClickedPathwayNameID = new ArrayList();
-
- List mSelectedPathwayNameID = new ArrayList();
-
- // this mSelectedPathwaysID is used for pass the reference of Pws to the
- // method in CommonNodeView class
- // use the identifier directly, not the name/identifier combination.
- List mSelectedPathwaysID = new ArrayList();
-
- // String[] mSelectedPathwaysID = new String[20];
-
- String mSelectedPwInHelpPanel = "not defined";
-
- private Map mNodeIdToPwsSharingNode = new HashMap();
-
- private List mCandidatePw;
-
- int mNoGeneNode;
-
- Pathway mAnchorPw;
-
- CommonNodeView cnViewObject;
-
- PathwaysMerge pMerge;
-
- static int superpathwaysVisualStyleCounter;
-
- // List selectedPwsNameId;
-
- public SuperpathwaysGui(SuperpathwaysClient c) {
- mClient = c;
-
- initComponents();
-
- cnViewObject = null;
-
- superpathwaysVisualStyleCounter = 1;
-
- }
-
- // the following code is generated in Netbean IDE
- /**
- * This method is called from within the constructor to initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is always
- * regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- //
- private void initComponents() {
-
- jScrollPane2 = new javax.swing.JScrollPane();
-
- // superpathwayPanel = new javax.swing.JTabbedPane();
- searchPane = new javax.swing.JPanel();
- stepLabel1 = new javax.swing.JLabel();
- searchText = new javax.swing.JTextField();
- organismCombo = new javax.swing.JComboBox();
- searchBtn = new javax.swing.JButton();
- // helpButton = new javax.swing.JButton();
- hintLabel1 = new javax.swing.JLabel();
- resultScrolllPane1 = new javax.swing.JScrollPane();
- resultTable = new javax.swing.JTable();
- addBtn = new javax.swing.JButton();
- selectPanel = new javax.swing.JPanel();
-
- /*
- * availablePathwaysScrollPane = new javax.swing.JScrollPane();
- * availablePathwaysList = new javax.swing.JList();
- * availablePathwaysListModel = new DefaultListModel();
- * availablePathwaysLabel = new javax.swing.JLabel();
- */
- removeBtn = new javax.swing.JButton();
-
- selectedPathwaysLabel = new javax.swing.JLabel();
- selectedPathwaysScrollPane = new javax.swing.JScrollPane();
- selectedPathwaysList = new javax.swing.JList();
- selectedPathwaysListModel = new DefaultListModel();
-
- findRelatedPwsBtn = new javax.swing.JButton();
- // rightButton = new javax.swing.JButton();
- // leftButton = new javax.swing.JButton();
-
- ClearBtn = new javax.swing.JButton();
- CommonNodeViewBtn = new javax.swing.JButton();
- MergeBtn = new javax.swing.JButton();
-
- helpPanel = new javax.swing.JPanel();
- anchorPathwayLabel = new javax.swing.JLabel();
- sharingNodeNoLabel = new javax.swing.JLabel();
- anchorPathwayComboBox = new javax.swing.JComboBox();
- lowerBoundSharingNodeNoComboBox = new javax.swing.JComboBox();
- candidatePathwaysSharingNodesScrollPane = new javax.swing.JScrollPane();
-
- // candidatePathwaysSharingNodesList = new javax.swing.JList();
- // candidatePathwaysSharingNodesListModel = new DefaultListModel();
-
- candidatePathwaysSharingNodesTable = new javax.swing.JTable();
- candidatePathwaysSharingNodesTableModel = new javax.swing.table.DefaultTableModel();
-
- // candidatePathwaysSharingNodesTable.setAutoCreateRowSorter(true);
-
- explainHelpLabel1 = new javax.swing.JLabel();
- addHelpButton = new javax.swing.JButton();
- lowerBoundLabel = new javax.swing.JLabel();
- upperBoundLabel = new javax.swing.JLabel();
- upperBoundSharingNodeNoComboBox = new javax.swing.JComboBox();
- explainHelpLabel2 = new javax.swing.JLabel();
- backToSearchButton = new javax.swing.JButton();
- searchHelpButton = new javax.swing.JButton();
- lastLabel = new javax.swing.JLabel();
-
- // setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
- // setTitle("Superpathways");
- // setBackground(new java.awt.Color(255, 255, 255));
-
- /*
- * superpathwayPanel.setToolTipText("");
- * superpathwayPanel.setName("search_select_tab"); // NOI18N
- * superpathwayPanel.setPreferredSize(new java.awt.Dimension(440, 680));
- */
-
- searchPane.setToolTipText("");
-
- stepLabel1.setBackground(new java.awt.Color(204, 204, 255));
- stepLabel1.setFont(new java.awt.Font("Dialog", 1, 11)); // NOI18N
- stepLabel1.setForeground(new java.awt.Color(102, 0, 0));
- stepLabel1
- .setText("Search and select multiple pathways from WikiPathways");
-
- searchText.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- searchTextActionPerformed(evt);
- }
- });
-
- resetOrganisms();
-
- searchBtn.setText("Search");
- searchBtn.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- searchBtnActionPerformed(evt);
- }
- });
-
- hintLabel1.setFont(new java.awt.Font("Dialog", 1, 11)); // NOI18N
- hintLabel1
- .setText("You can search by: pathway name, gene/protein name, or any page content");
-
- resultTable
- .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
-
- resultScrolllPane1.setViewportView(resultTable);
-
- addBtn.setText("Add");
- addBtn
- .setToolTipText("add the selected pathway to the \"Available Pathways\" list");
- addBtn.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- addBtnActionPerformed(evt);
- }
- });
-
- /*
- * selectPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
- * javax.swing.BorderFactory .createTitledBorder("Please select pathways
- * to merge"), "",
- * javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
- * javax.swing.border.TitledBorder.DEFAULT_POSITION, new
- * java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 255))); //
- * NOI18N
- */
-
- selectPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
- null, "",
- javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
- javax.swing.border.TitledBorder.DEFAULT_POSITION,
- new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0,
- 255))); // NOI18N
- /*
- * availablePathwaysList
- * .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
- * availablePathwaysList.setLayoutOrientation(JList.VERTICAL);
- * availablePathwaysList.setVisibleRowCount(8);
- *
- * availablePathwaysScrollPane.setViewportView(availablePathwaysList);
- */
-
- selectedPathwaysList
- .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
- selectedPathwaysList.setLayoutOrientation(JList.VERTICAL);
- selectedPathwaysList.setVisibleRowCount(8);
- selectedPathwaysScrollPane.setViewportView(selectedPathwaysList);
-
- /*
- * availablePathwaysLabel.setFont(new java.awt.Font("Tahoma", 1, 11)); //
- * NOI18N availablePathwaysLabel.setForeground(new java.awt.Color(102,
- * 0, 0)); availablePathwaysLabel.setText("Available Pathways");
- */
- selectedPathwaysLabel.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
- selectedPathwaysLabel.setForeground(new java.awt.Color(102, 0, 0));
- selectedPathwaysLabel.setText("Selected Pathways");
-
- removeBtn.setText("Remove");
- removeBtn.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- removeBtnActionPerformed(evt);
- }
- });
-
- ClearBtn.setText("Clear");
- ClearBtn
- .setToolTipText("clear all the previously selected pathways");
- ClearBtn.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- ClearBtnActionPerformed(evt);
- }
- });
-
- org.jdesktop.layout.GroupLayout selectPanelLayout = new org.jdesktop.layout.GroupLayout(
- selectPanel);
- selectPanel.setLayout(selectPanelLayout);
- selectPanelLayout
- .setHorizontalGroup(selectPanelLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.LEADING)
- .add(
- selectPanelLayout
- .createSequentialGroup()
- .addContainerGap()
- .add(
- selectPanelLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.LEADING)
- .add(
- org.jdesktop.layout.GroupLayout.TRAILING,
- selectedPathwaysScrollPane,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- 371,
- Short.MAX_VALUE)
- .add(
- selectedPathwaysLabel)
- .add(
- org.jdesktop.layout.GroupLayout.TRAILING,
- selectPanelLayout
- .createSequentialGroup()
- .add(
- ClearBtn)
- .addPreferredGap(
- org.jdesktop.layout.LayoutStyle.RELATED)
- .add(
- removeBtn,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
- 71,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
- .addContainerGap()));
- selectPanelLayout
- .setVerticalGroup(selectPanelLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.LEADING)
- .add(
- selectPanelLayout
- .createSequentialGroup()
- .add(selectedPathwaysLabel)
- .addPreferredGap(
- org.jdesktop.layout.LayoutStyle.RELATED)
- .add(
- selectedPathwaysScrollPane,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
- 110,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(
- org.jdesktop.layout.LayoutStyle.RELATED,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- Short.MAX_VALUE)
- .add(
- selectPanelLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.BASELINE)
- .add(removeBtn).add(
- ClearBtn))));
-
- /*
- * org.jdesktop.layout.GroupLayout selectPanelLayout = new
- * org.jdesktop.layout.GroupLayout(selectPanel);
- * selectPanel.setLayout(selectPanelLayout);
- * selectPanelLayout.setHorizontalGroup(
- * selectPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- * .add(selectPanelLayout.createSequentialGroup() .addContainerGap()
- * .add(selectPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- * .add(org.jdesktop.layout.GroupLayout.TRAILING,
- * selectedPathwaysScrollPane,
- * org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
- * .add(selectedPathwaysLabel)
- * .add(org.jdesktop.layout.GroupLayout.TRAILING, removeBtn))
- * .addContainerGap()) ); selectPanelLayout.setVerticalGroup(
- * selectPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- * .add(selectPanelLayout.createSequentialGroup()
- * .add(selectedPathwaysLabel)
- * .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- * .add(selectedPathwaysScrollPane,
- * org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 110,
- * org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- * .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED,
- * org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- * .add(removeBtn)) );
- */
-
- findRelatedPwsBtn.setText("Find Related Pathways");
- findRelatedPwsBtn
- .setToolTipText("find the related pathways which share nodes with the one you select");
- findRelatedPwsBtn
- .addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- findRelatedPwsBtnActionPerformed(evt);
- }
- });
-
-
-
- CommonNodeViewBtn.setText("Common Node View");
- CommonNodeViewBtn
- .setToolTipText("generate a network view showing the number of shared nodes between every two selected pathways");
- CommonNodeViewBtn
- .addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- CommonNodeViewBtnActionPerformed(evt);
- }
- });
-
- /*
- * helpButton.setText("Help"); helpButton .setToolTipText("switch to
- * Search Help tab, where you're provided with help for finding
- * candidate pathways with shared nodes");
- * helpButton.addActionListener(new java.awt.event.ActionListener() {
- * public void actionPerformed(java.awt.event.ActionEvent evt) {
- * helpButtonActionPerformed(evt); } });
- */
-
- MergeBtn.setText("Merge");
- MergeBtn.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- MergeBtnActionPerformed(evt);
- }
- });
-
- org.jdesktop.layout.GroupLayout searchPaneLayout = new org.jdesktop.layout.GroupLayout(
- searchPane);
- searchPane.setLayout(searchPaneLayout);
- searchPaneLayout
- .setHorizontalGroup(searchPaneLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.LEADING)
- .add(
- searchPaneLayout
- .createSequentialGroup()
- .addContainerGap()
- .add(
- searchPaneLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.LEADING)
- .add(
- searchPaneLayout
- .createSequentialGroup()
- .add(
- stepLabel1)
- .addContainerGap(
- 79,
- Short.MAX_VALUE))
- .add(
- searchPaneLayout
- .createSequentialGroup()
- .add(
- hintLabel1,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
- 412,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(
- 18,
- Short.MAX_VALUE))
- .add(
- org.jdesktop.layout.GroupLayout.TRAILING,
- searchPaneLayout
- .createSequentialGroup()
- .add(
- searchPaneLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.TRAILING)
- .add(
- searchPaneLayout
- .createSequentialGroup()
-
- /*.add(
- ClearBtn)*/
- .addPreferredGap(
- org.jdesktop.layout.LayoutStyle.RELATED)
- .add(
- CommonNodeViewBtn)
- .addPreferredGap(
- org.jdesktop.layout.LayoutStyle.RELATED)
- .add(
- MergeBtn)
- .add(
- 6,
- 6,
- 6))
- .add(
- searchPaneLayout
- .createSequentialGroup()
- .add(
- findRelatedPwsBtn)
- .addPreferredGap(
- org.jdesktop.layout.LayoutStyle.UNRELATED)
- .add(
- addBtn,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
- 67,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .add(
- org.jdesktop.layout.GroupLayout.LEADING,
- selectPanel,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- Short.MAX_VALUE)
- .add(
- org.jdesktop.layout.GroupLayout.LEADING,
- resultScrolllPane1,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- 407,
- Short.MAX_VALUE)
- .add(
- org.jdesktop.layout.GroupLayout.LEADING,
- searchPaneLayout
- .createSequentialGroup()
- .add(
- searchText,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- 171,
- Short.MAX_VALUE)
- .addPreferredGap(
- org.jdesktop.layout.LayoutStyle.UNRELATED)
- .add(
- organismCombo,
- 0,
- 151,
- Short.MAX_VALUE)
- .addPreferredGap(
- org.jdesktop.layout.LayoutStyle.UNRELATED)
- .add(
- searchBtn)))
- .add(
- 23,
- 23,
- 23)))));
-
- /*
- * searchPaneLayout.linkSize(new java.awt.Component[] { ClearBtn,
- * helpButton }, org.jdesktop.layout.GroupLayout.HORIZONTAL);
- */
-
- searchPaneLayout
- .setVerticalGroup(searchPaneLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.LEADING)
- .add(
- searchPaneLayout
- .createSequentialGroup()
- .add(28, 28, 28)
- .add(stepLabel1)
- .add(18, 18, 18)
- .add(hintLabel1)
- .add(32, 32, 32)
- .add(
- searchPaneLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.BASELINE)
- .add(
- searchText,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- 23,
- Short.MAX_VALUE)
- .add(organismCombo)
- .add(searchBtn))
- .add(18, 18, 18)
- .add(
- resultScrolllPane1,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- 176, Short.MAX_VALUE)
- .add(18, 18, 18)
- .add(
- searchPaneLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.BASELINE)
- .add(findRelatedPwsBtn)
- .add(addBtn))
- .addPreferredGap(
- org.jdesktop.layout.LayoutStyle.RELATED)
- .add(
- selectPanel,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- Short.MAX_VALUE)
- .add(39, 39, 39)
- .add(
- searchPaneLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.BASELINE)
- .add(MergeBtn)
- .add(CommonNodeViewBtn)
- /*.add(ClearBtn)*/).add(43,
- 43, 43)));
-
- searchPaneLayout.linkSize(new java.awt.Component[] { addBtn,
- findRelatedPwsBtn }, org.jdesktop.layout.GroupLayout.VERTICAL);
-
- searchPaneLayout.linkSize(new java.awt.Component[] { searchBtn,
- searchText }, org.jdesktop.layout.GroupLayout.VERTICAL);
-
- /*searchPaneLayout.linkSize(new java.awt.Component[] { ClearBtn,
- CommonNodeViewBtn }, org.jdesktop.layout.GroupLayout.VERTICAL);*/
-
- // superpathwayPanel.addTab("Search/Select", searchPane);
-
- anchorPathwayLabel.setForeground(new java.awt.Color(0, 0, 255));
- anchorPathwayLabel.setText("Pathway");
-
- sharingNodeNoLabel.setForeground(new java.awt.Color(0, 0, 255));
- sharingNodeNoLabel.setText("Sharing");
-
- // anchorPathwayComboBox.setModel(new
- // DefaultComboBoxModel(mAvailablePathwaysNameIDList.toArray()));
-
- anchorPathwayComboBoxModel = new DefaultComboBoxModel();
- anchorPathwayComboBoxModel.addElement((Object) new String(
- "choose one pathway"));
- anchorPathwayComboBox.setModel(anchorPathwayComboBoxModel);
-
- anchorPathwayComboBox
- .addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- anchorPathwayComboBoxActionPerformed(evt);
- }
- });
-
- lowerBoundSharingNodeNoComboBox
- .setModel(new javax.swing.DefaultComboBoxModel(new String[] {
- "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }));
-
- // candidatePathwaysSharingNodesTable.setModel();
-
- explainHelpLabel1.setFont(new java.awt.Font("Dialog", 1, 11)); // NOI18N
- explainHelpLabel1.setForeground(new java.awt.Color(102, 0, 0));
- explainHelpLabel1
- .setText("Choose a pathway and set the range of sharing nodes number, a list of ");
-
- addHelpButton.setText("Add");
- addHelpButton
- .setToolTipText("add the selected pathways to the 'Available Pathways' list");
- /*
- * addHelpButton.addActionListener(new java.awt.event.ActionListener() {
- * public void actionPerformed(java.awt.event.ActionEvent evt) {
- * addHelpButtonActionPerformed(evt); } });
- */
-
- lowerBoundLabel.setForeground(new java.awt.Color(0, 0, 255));
- lowerBoundLabel.setText("Minimum");
-
- upperBoundLabel.setForeground(new java.awt.Color(0, 0, 255));
- upperBoundLabel.setText("Maximum");
-
- upperBoundSharingNodeNoComboBox
- .setModel(new javax.swing.DefaultComboBoxModel(new String[] {
- "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
- "11", "12", "13", "14", "15", "16", "17", "18", "19",
- "20" }));
-
- explainHelpLabel2.setFont(new java.awt.Font("Dialog", 1, 11)); // NOI18N
- explainHelpLabel2.setForeground(new java.awt.Color(102, 0, 0));
- explainHelpLabel2
- .setText("candidate pathways with sharing nodes would be returned.");
-
- lastLabel.setForeground(new java.awt.Color(0, 0, 255));
- lastLabel.setText("Nodes");
-
- backToSearchButton.setText("Back to Search");
- backToSearchButton
- .addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- backtoSearchButtonActionPerformed(evt);
- }
- });
-
- searchHelpButton.setText("Search");
- searchHelpButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- searchHelpButtonActionPerformed(evt);
- }
- });
-
- /*
- * candidatePathwaysSharingNodesList
- * .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
- * candidatePathwaysSharingNodesScrollPane
- * .setViewportView(candidatePathwaysSharingNodesList);
- */
-
- candidatePathwaysSharingNodesTableModel.addColumn("Pathway Name");
- candidatePathwaysSharingNodesTableModel.addColumn("ID");
- candidatePathwaysSharingNodesTableModel.addColumn("No. Shared Nodes");
-
- candidatePathwaysSharingNodesTable
- .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
- candidatePathwaysSharingNodesScrollPane
- .setViewportView(candidatePathwaysSharingNodesTable);
- candidatePathwaysSharingNodesTable
- .setModel(candidatePathwaysSharingNodesTableModel);
-
- TableColumn column = null;
- for (int i = 0; i < 3; i++) {
- column = candidatePathwaysSharingNodesTable.getColumnModel()
- .getColumn(i);
- if (i == 0) {
- column.setPreferredWidth(150); // third column is bigger
- } else if (i == 1) {
- column.setPreferredWidth(40);
- } else {
- column.setPreferredWidth(60);
- }
-
- }
-
- org.jdesktop.layout.GroupLayout helpPanelLayout = new org.jdesktop.layout.GroupLayout(
- helpPanel);
- helpPanel.setLayout(helpPanelLayout);
- helpPanelLayout
- .setHorizontalGroup(helpPanelLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.LEADING)
- .add(
- helpPanelLayout
- .createSequentialGroup()
- .add(
- helpPanelLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.LEADING)
- .add(
- helpPanelLayout
- .createSequentialGroup()
- .addContainerGap()
- .add(
- explainHelpLabel1))
- .add(
- helpPanelLayout
- .createSequentialGroup()
- .addContainerGap()
- .add(
- explainHelpLabel2))
- .add(
- helpPanelLayout
- .createSequentialGroup()
- .add(
- 19,
- 19,
- 19)
- .add(
- helpPanelLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.LEADING)
- .add(
- anchorPathwayLabel)
- .add(
- sharingNodeNoLabel))
- .add(
- 6,
- 6,
- 6)
- .add(
- helpPanelLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.LEADING,
- false)
- .add(
- helpPanelLayout
- .createSequentialGroup()
- .add(
- lowerBoundLabel)
- .add(
- 18,
- 18,
- 18)
- .add(
- lowerBoundSharingNodeNoComboBox,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(
- 18,
- 18,
- 18)
- .add(
- upperBoundLabel)
- .add(
- 18,
- 18,
- 18)
- .add(
- upperBoundSharingNodeNoComboBox,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .add(
- helpPanelLayout
- .createSequentialGroup()
- .add(
- 23,
- 23,
- 23)
- .add(
- anchorPathwayComboBox,
- 0,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- Short.MAX_VALUE)))
- .add(
- 18,
- 18,
- 18)
- .add(
- lastLabel)
- .add(
- 18,
- 18,
- 18)
- .add(
- searchHelpButton)))
- .addContainerGap(24, Short.MAX_VALUE))
- .add(
- org.jdesktop.layout.GroupLayout.TRAILING,
- helpPanelLayout
- .createSequentialGroup()
- .addContainerGap(190, Short.MAX_VALUE)
- .add(backToSearchButton)
- .addPreferredGap(
- org.jdesktop.layout.LayoutStyle.RELATED)
- .add(addHelpButton).add(26, 26, 26))
- .add(
- helpPanelLayout
- .createSequentialGroup()
- .addContainerGap()
- .add(
- candidatePathwaysSharingNodesScrollPane,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- 402, Short.MAX_VALUE).add(16,
- 16, 16)));
-
- helpPanelLayout.linkSize(new java.awt.Component[] { addHelpButton,
- backToSearchButton },
- org.jdesktop.layout.GroupLayout.HORIZONTAL);
-
- helpPanelLayout
- .setVerticalGroup(helpPanelLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.LEADING)
- .add(
- helpPanelLayout
- .createSequentialGroup()
- .add(33, 33, 33)
- .add(explainHelpLabel1)
- .addPreferredGap(
- org.jdesktop.layout.LayoutStyle.UNRELATED)
- .add(explainHelpLabel2)
- .add(44, 44, 44)
- .add(
- helpPanelLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.BASELINE)
- .add(anchorPathwayLabel)
- .add(
- anchorPathwayComboBox,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .add(23, 23, 23)
- .add(
- helpPanelLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.BASELINE)
- .add(lowerBoundLabel)
- .add(
- lowerBoundSharingNodeNoComboBox,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(upperBoundLabel)
- .add(
- upperBoundSharingNodeNoComboBox,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(lastLabel)
- .add(searchHelpButton)
- .add(sharingNodeNoLabel))
- .add(53, 53, 53)
- .add(
- candidatePathwaysSharingNodesScrollPane,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
- 251, Short.MAX_VALUE)
- .add(29, 29, 29)
- .add(
- helpPanelLayout
- .createParallelGroup(
- org.jdesktop.layout.GroupLayout.BASELINE)
- .add(backToSearchButton)
- .add(addHelpButton))
- .addContainerGap(131, Short.MAX_VALUE)));
-
- helpPanelLayout.linkSize(new java.awt.Component[] { addHelpButton,
- backToSearchButton }, org.jdesktop.layout.GroupLayout.VERTICAL);
-
- helpPanelLayout.linkSize(new java.awt.Component[] { lastLabel,
- lowerBoundLabel, lowerBoundSharingNodeNoComboBox,
- searchHelpButton, sharingNodeNoLabel, upperBoundLabel,
- upperBoundSharingNodeNoComboBox },
- org.jdesktop.layout.GroupLayout.VERTICAL);
-
- // remove the Search Help panel
- /*
- * superpathwayPanel .addTab("Search Help", null, helpPanel, "help is
- * provided for finding candidate pathways with shared nodes");
- */
- // jScrollPane2.setViewportView(superpathwayPanel);
- jScrollPane2.setViewportView(searchPane);
-
- org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
- this);
- setLayout(layout);
- layout.setHorizontalGroup(layout.createParallelGroup(
- org.jdesktop.layout.GroupLayout.LEADING).add(
- layout.createSequentialGroup().add(18, 18, 18).add(
- jScrollPane2,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 447,
- Short.MAX_VALUE).add(20, 20, 20)));
- layout.setVerticalGroup(layout.createParallelGroup(
- org.jdesktop.layout.GroupLayout.LEADING).add(
- layout.createSequentialGroup().add(20, 20, 20).add(
- jScrollPane2,
- org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 701,
- Short.MAX_VALUE).addContainerGap()));
-
- // pack();
- }//
-
- private void searchTextActionPerformed(java.awt.event.ActionEvent evt) {
- searchActionPerformed(evt);
- }
-
- private void searchBtnActionPerformed(java.awt.event.ActionEvent evt) {
- searchActionPerformed(evt);
- }
-
- private void addBtnActionPerformed(java.awt.event.ActionEvent evt) {
- // System.out.println(mClickedPathwayNameID.size() + "");
- mClickedPathwayNameID.clear();
-
- int[] rows = resultTable.getSelectedRows();
- for (int k = 0; k < rows.length; k++) {
- int viewRow = rows[k];
- int modelRow = sorter.modelIndex(viewRow);
-
- ResultRow t = tableModel.getRow(modelRow);
- String temp = t.getProperty(ResultProperty.NAME) + "("
- + t.getProperty(ResultProperty.ID) + ")";
-
- mClickedPathwayNameID.add(temp);
-
- }
- for (int i = 0; i < mClickedPathwayNameID.size(); i++) {
- System.out.println(mClickedPathwayNameID.get(i));
- if (!selectedPathwaysListModel.contains(mClickedPathwayNameID
- .get(i))) {
- selectedPathwaysListModel.addElement(mClickedPathwayNameID
- .get(i));
- selectedPathwaysList.setModel(selectedPathwaysListModel);
- /*
- * if (availablePathwaysListModel.getSize() > 0) {
- * rightButton.setEnabled(true); }
- */
-
- mSelectedPathwayNameID.add(mClickedPathwayNameID.get(i));
-
- // add the pathways IDs to the list mSelectedPathwaysID
- String t = mClickedPathwayNameID.get(i);
- int index1 = t.lastIndexOf("(");
- int index2 = t.lastIndexOf(")");
- String pwID = t.substring(index1 + 1, index2);
- mSelectedPathwaysID.add(pwID);
-
- /*
- * anchorPathwayComboBoxModel.addElement(mClickedPathwayNameID
- * .get(i));
- * anchorPathwayComboBox.setModel(anchorPathwayComboBoxModel);
- */
- }
- }
-
- }
-
- private void removeBtnActionPerformed(java.awt.event.ActionEvent evt) {
- Object[] temp = selectedPathwaysList.getSelectedValues();
- for (int i = 0; i < temp.length; i++) {
- mSelectedPathwayNameID.remove((String) temp[i]);
-
- // removed the selected item in the selected pathways list
- selectedPathwaysListModel.removeElement(temp[i]);
- String t = (String) temp[i];
- int index1 = t.lastIndexOf("(");
- int index2 = t.lastIndexOf(")");
- String pwID = t.substring(index1 + 1, index2);
- mSelectedPathwaysID.remove(pwID);
- }
- }
-
- private void findRelatedPwsBtnActionPerformed(java.awt.event.ActionEvent evt) {
- System.out.println("After clicking 'Find Related Pathways' button!");
- int[] rows = resultTable.getSelectedRows();
-
- if (rows.length > 1 || rows.length == 0) {
- JOptionPane
- .showMessageDialog(
- this,
- "Please select ONE pathway among the search result",
- "find related pathways...",
- JOptionPane.INFORMATION_MESSAGE);
- } else {
- int viewRow = rows[0];
- int modelRow = sorter.modelIndex(viewRow);
-
- ResultRow t = tableModel.getRow(modelRow);
- String temp = t.getProperty(ResultProperty.NAME) + "("
- + t.getProperty(ResultProperty.ID) + ")";
-
- FindRelatedPwsDialog relatedPwsDialog = new FindRelatedPwsDialog(
- mClient, "Find related pathways...", temp);
- relatedPwsDialog.setVisible(true);
-
- }
-
- }
-
- private void ClearBtnActionPerformed(java.awt.event.ActionEvent evt) {
- // SuperpathwaysPlugin spPlugin = SuperpathwaysPlugin.getInstance();
- // spPlugin.mWindow.setVisible(false);
- // spPlugin.mWindow.dispose();
- searchText.setText("");
- /*
- * availablePathwaysListModel.clear();
- * availablePathwaysList.setModel(availablePathwaysListModel);
- */
- selectedPathwaysListModel.clear();
- selectedPathwaysList.setModel(selectedPathwaysListModel);
- //anchorPathwayComboBox.setModel(new DefaultComboBoxModel());
- mSelectedPathwaysID.clear();
- mSelectedPathwayNameID.clear();
-
- }
-
- private void CommonNodeViewBtnActionPerformed(java.awt.event.ActionEvent evt) {
-
- System.out.println("Display the selected pws' id:");
- for (int k = 0; k < mSelectedPathwaysID.size(); k++) {
- System.out.println(mSelectedPathwaysID.get(k));
- }
-
- /*
- * Object[] selectedPwNameId = selectedPathwaysListModel.toArray();
- * selectedPwsNameId = new ArrayList(); for (int i = 0; i <
- * selectedPwNameId.length; i++) { selectedPwsNameId.add((String)
- * selectedPwNameId[i]); }
- */
-
- commonNodeViewTask task = new commonNodeViewTask(mClient);
- JTaskConfig config = new JTaskConfig();
- config.displayCancelButton(true);
- // config.setModal(true);
- config.setModal(false);
- TaskManager.executeTask(task, config);
- }
-
- private void searchHelpButtonActionPerformed(java.awt.event.ActionEvent evt) {
-
- candidatePathwaysSharingNodesTableModel = new javax.swing.table.DefaultTableModel();
- candidatePathwaysSharingNodesTableModel.addColumn("Pathway Name");
- candidatePathwaysSharingNodesTableModel.addColumn("ID");
- candidatePathwaysSharingNodesTableModel.addColumn("No. Shared Nodes");
-
- candidatePathwaysSharingNodesTable
- .setModel(candidatePathwaysSharingNodesTableModel);
- setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
-
- // String anchorPwNameAndId =
- // anchorPathwayComboBox.getSelectedItem().toString();
- int lowerBound = Integer.parseInt(lowerBoundSharingNodeNoComboBox
- .getSelectedItem().toString());
- int upperBound = Integer.parseInt(upperBoundSharingNodeNoComboBox
- .getSelectedItem().toString());
-
- // mCandidatePwList = findCandidatePwBySharingNodes(lowerBound,
- // upperBound);
-
- searchSharingNodePwsTask task = new searchSharingNodePwsTask(
- lowerBound, upperBound);
-
- JTaskConfig config = new JTaskConfig();
- config.displayCancelButton(true);
- // config.displayCloseButton(true);
- // config.displayStatus(true);
- config.setModal(true);
- TaskManager.executeTask(task, config);
-
- // mCandidatePw is a list of string with elements in format "Pathway
- // Name (pw id), sharing node number: a int"
-
- // System.out.println("We reach here 3!");
- // System.out.println(mCandidatePw.size()+"");
- Iterator it = mCandidatePw.iterator();
- while (it.hasNext()) {
- String temp = it.next();
- // candidatePathwaysSharingNodesListModel.addElement(temp);
-
- // System.out.println(temp);
- // parse the string into three parts: pathway name, id, and No.
- // Sharing Nodes
- int index1 = temp.indexOf(",");
- String temp1 = temp.substring(0, index1);
-
- int index2 = temp1.lastIndexOf("(");
- int index3 = temp1.lastIndexOf(")");
- String pwName = temp1.substring(0, index2);
- // System.out.println(pwName);
- String pwId = temp1.substring(index2 + 1, index3);
- // System.out.println(pwId);
-
- // String temp2 = temp.substring(index1+1);
- int index4 = temp.indexOf(":");
- String NoSharingNode = temp.substring(index4 + 2);
- // System.out.println(NoSharingNode);
-
- Object[] row = new Object[3];
- row[0] = (Object) pwName;
- row[1] = (Object) pwId;
- row[2] = (Object) NoSharingNode;
-
- candidatePathwaysSharingNodesTableModel.addRow(row);
-
- }
-
- sorter = new TableSorter(candidatePathwaysSharingNodesTableModel);
- candidatePathwaysSharingNodesTable.setModel(sorter);
- sorter.setTableHeader(candidatePathwaysSharingNodesTable
- .getTableHeader());
-
- // candidatePathwaysSharingNodesList.setModel(candidatePathwaysSharingNodesListModel);
- setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
-
- private void backtoSearchButtonActionPerformed(
- java.awt.event.ActionEvent evt) {
- // System.out.println("Clicking the back to search button!");
- // superpathwayPanel.setSelectedIndex(0);
- }
-
- private void anchorPathwayComboBoxActionPerformed(
- java.awt.event.ActionEvent evt) {
- String anchorPwNameId = anchorPathwayComboBox.getSelectedItem()
- .toString();
-
- if (anchorPwNameId.equalsIgnoreCase("choose one pathway")) {
-
- } else {
- int index1 = anchorPwNameId.lastIndexOf("(");
- int index2 = anchorPwNameId.lastIndexOf(")");
- String anchorPwID = anchorPwNameId.substring(index1 + 1, index2);
-
- // Create a client to the WikiPathways web service
- WikiPathwaysClient client = mClient.getStub();
-
- // Download these two pathways from WikiPathways by passing their id
- WSPathway anchorPathway = new WSPathway();
-
- try {
- anchorPathway = client.getPathway(anchorPwID);
-
- } catch (RemoteException e) {
- Logger.log.error(
- "Unable to get the pathway due to the RemoteException",
- e);
- } catch (ConverterException e) {
- Logger.log
- .error(
- "Unable to get the pathway due to the ConverterException",
- e);
- }
- // Create two corresponding pathway objects
- mAnchorPw = new Pathway();
-
- try {
- mAnchorPw = WikiPathwaysClient.toPathway(anchorPathway);
- } catch (ConverterException e) {
- Logger.log.error(
- "Unable to get the pathway due to the RemoteException",
- e);
- }
-
- mNoGeneNode = 0;
- for (PathwayElement pwElm : mAnchorPw.getDataObjects()) {
- if (pwElm.getObjectType() == ObjectType.DATANODE) {
- mNoGeneNode = mNoGeneNode + 1;
-
- }
- }
-
- String[] temp = new String[mNoGeneNode];
- for (int i = 1; i <= mNoGeneNode; i++) {
- temp[i - 1] = String.valueOf(i);
- }
-
- upperBoundSharingNodeNoComboBox
- .setModel(new javax.swing.DefaultComboBoxModel(temp));
-
- }
- }
-
- private void MergeBtnActionPerformed(java.awt.event.ActionEvent evt) {
- // SimpleCaseMergeTest test=new SimpleCaseMergeTest();
-
- WikiPathwaysClient client = mClient.getStub();
- SuperpathwaysPlugin spPlugin = SuperpathwaysPlugin.getInstance();
- MergeTask task = new MergeTask(spPlugin, client);
-
- // Configure JTask Dialog Pop-Up Box
- final JTaskConfig jTaskConfig = new JTaskConfig();
-
- jTaskConfig.displayCloseButton(true);
- jTaskConfig.displayCancelButton(true);
- jTaskConfig.displayStatus(true);
- jTaskConfig.displayTimeElapsed(true);
-
- jTaskConfig.setAutoDispose(false);
- // jTaskConfig.setModal(true);
- jTaskConfig.setModal(false);
-
- // Execute Task in New Thread; pop open JTask Dialog Box.
- TaskManager.executeTask(task, jTaskConfig);
- if (task.isCancelled())
- return;
-
- }
-
- // the code above is generated in Netbean IDE
-
- protected void resetOrganisms() {
- List organisms = new ArrayList();
- organisms.add(ORGANISM_ALL);
- try {
- organisms.addAll(Arrays.asList(mClient.listOrganisms()));
- } catch (Exception e) {
- Logger.log.error("Unable to get organisms for WikiPathways client",
- e);
- }
-
- organismCombo.setModel(new DefaultComboBoxModel(organisms.toArray()));
- }
-
- public void searchActionPerformed(java.awt.event.ActionEvent evt) {
- // String action = e.getActionCommand();
- // if(ACTION_SEARCH.equals(action)) {
- FindPathwaysByTextParameters request = new FindPathwaysByTextParameters();
- request.query = searchText.getText();
- String org = organismCombo.getSelectedItem().toString();
- if (!ORGANISM_ALL.equals(org)) {
- request.species = Organism.fromLatinName(org);
- }
- try {
- WebServiceClientManager
- .getCyWebServiceEventSupport()
- .fireCyWebServiceEvent(
- new CyWebServiceEvent(
- mClient.getClientID(),
- WSEventType.SEARCH_DATABASE, request));
-
- } catch (CyWebServiceException ex) {
- switch (ex.getErrorCode()) {
- case NO_RESULT:
- JOptionPane.showMessageDialog(this,
- "The search didn't return any results", "No results",
- JOptionPane.INFORMATION_MESSAGE);
- break;
- case OPERATION_NOT_SUPPORTED:
- case REMOTE_EXEC_FAILED:
- JOptionPane.showMessageDialog(this, "Error: "
- + ex.getErrorCode() + ". See log for details", "Error",
- JOptionPane.ERROR_MESSAGE);
- break;
- }
- ex.printStackTrace();
- }
- // }
- }
-
- private void openNetwork(ResultRow mSelected) {
- try {
- GetPathwayParameters request = new GetPathwayParameters();
- WSSearchResult result = mSelected.getResult();
- request.id = result.getId();
- request.revision = Integer.parseInt(result.getRevision());
- WebServiceClientManager.getCyWebServiceEventSupport()
- .fireCyWebServiceEvent(
- new CyWebServiceEvent(mClient.getClientID(),
- WSEventType.IMPORT_NETWORK, request));
- } catch (CyWebServiceException ex) {
- JOptionPane.showMessageDialog(SuperpathwaysGui.this, "Error: "
- + ex.getErrorCode() + ". See error log for details",
- "Error", JOptionPane.ERROR_MESSAGE);
- }
- }
-
- public void setResults(WSSearchResult[] results) {
-
- tableModel = new ListWithPropertiesTableModel();
- if (results != null) {
- tableModel.setColumns(new ResultProperty[] { ResultProperty.NAME,
- ResultProperty.ID, ResultProperty.ORGANISM, });
-
- resultTable.setModel(tableModel);
- for (WSSearchResult r : results) {
- tableModel.addRow(new ResultRow(r));
- }
- }
-
- sorter = new TableSorter(tableModel);
- resultTable.setModel(sorter);
- sorter.setTableHeader(resultTable.getTableHeader());
-
- // resultTable.setModel(tableModel);
- System.out.println("Superpathways!");
-
- }
-
- // private javax.swing.DefaultListModel availablePathwaysListModel;
- // javax.swing.DefaultListModel availablePathwaysListModel;
-
- // private javax.swing.DefaultListModel selectedPathwaysListModel;
- javax.swing.DefaultListModel selectedPathwaysListModel;
-
- private javax.swing.DefaultComboBoxModel anchorPathwayComboBoxModel;
-
- // private javax.swing.DefaultListModel
- // candidatePathwaysSharingNodesListModel;
-
- private javax.swing.table.DefaultTableModel candidatePathwaysSharingNodesTableModel;
-
- private TableSorter sorter;
-
- private javax.swing.JButton ClearBtn;
-
- private javax.swing.JButton CommonNodeViewBtn;
-
- private javax.swing.JButton addBtn;
-
- private javax.swing.JButton addHelpButton;
-
- private javax.swing.JComboBox anchorPathwayComboBox;
-
- private javax.swing.JLabel anchorPathwayLabel;
-
- // private javax.swing.JLabel availablePathwaysLabel;
-
- // private javax.swing.JList availablePathwaysList;
- // javax.swing.JList availablePathwaysList;
-
- // private javax.swing.JScrollPane availablePathwaysScrollPane;
-
- private javax.swing.JButton backToSearchButton;
-
- private javax.swing.JScrollPane candidatePathwaysSharingNodesScrollPane;
-
- // private javax.swing.JList candidatePathwaysSharingNodesList;
-
- private javax.swing.JLabel explainHelpLabel1;
-
- private javax.swing.JLabel explainHelpLabel2;
-
- private javax.swing.JPanel helpPanel;
-
- private javax.swing.JLabel hintLabel1;
-
- // private javax.swing.JButton leftButton;
-
- private javax.swing.JLabel lowerBoundLabel;
-
- private javax.swing.JComboBox lowerBoundSharingNodeNoComboBox;
-
- private javax.swing.JButton findRelatedPwsBtn;
-
- private javax.swing.JComboBox organismCombo;
-
- private javax.swing.JScrollPane resultScrolllPane1;
-
- private javax.swing.JTable resultTable;
-
- // private javax.swing.JButton rightButton;
- // javax.swing.JButton rightButton;
-
- private javax.swing.JButton searchBtn;
-
- private javax.swing.JPanel searchPane;
-
- private javax.swing.JTextField searchText;
-
- private javax.swing.JPanel selectPanel;
-
- private javax.swing.JLabel selectedPathwaysLabel;
-
- // private javax.swing.JList selectedPathwaysList;
- javax.swing.JList selectedPathwaysList;
-
- private javax.swing.JScrollPane selectedPathwaysScrollPane;
-
- private javax.swing.JLabel sharingNodeNoLabel;
-
- private javax.swing.JLabel stepLabel1;
-
- private javax.swing.JLabel stepLabel2;
-
- // private javax.swing.JTabbedPane superpathwayPanel;
-
- private javax.swing.JLabel upperBoundLabel;
-
- private javax.swing.JComboBox upperBoundSharingNodeNoComboBox;
-
- private javax.swing.JButton searchHelpButton;
-
- // private javax.swing.JButton helpButton;
-
- private javax.swing.JLabel lastLabel;
-
- private javax.swing.JTable candidatePathwaysSharingNodesTable;
-
- private javax.swing.JScrollPane jScrollPane2;
-
- private javax.swing.JButton MergeBtn;
-
- private javax.swing.JButton removeBtn;
-
- // private javax.swing.JList candidatePathwaysSharingNodesList;
-
- // End of variables declaration
- ListWithPropertiesTableModel tableModel;
-
- class ResultRow implements RowWithProperties {
- WSSearchResult result;
-
- public ResultRow(WSSearchResult result) {
- this.result = result;
- }
-
- public WSSearchResult getResult() {
- return result;
- }
-
- public String getProperty(ResultProperty prop) {
- switch (prop) {
- case NAME:
- return result.getName();
- case ORGANISM:
- return result.getSpecies();
- case SCORE:
- return Double.toString(result.getScore());
- case URL:
- return result.getUrl();
- // helen add
- case ID:
- return result.getId();
- }
- return null;
- }
- }
-
- public class searchSharingNodePwsTask implements Task {
-
- TaskMonitor monitor;
-
- int lowerBound;
-
- int upperBound;
-
- public searchSharingNodePwsTask(int lb, int ub) {
- lowerBound = lb;
- upperBound = ub;
- }
-
- /**
- * Run the Task.
- */
- public void run() {
-
- try {
- mCandidatePw = new ArrayList();
- if (lowerBound > upperBound) {
- JOptionPane.showMessageDialog(helpPanel,
- "Please reset the range of sharing nodes number!");
- } else {
-
- Map sharingNodeNumberofPws = new HashMap();
- List geneIDList = new ArrayList();
- int percentComplete = 0;
- int t = 0;
-
- // Create a client to the WikiPathways web service
- WikiPathwaysClient client = mClient.getStub();
-
- // the following code is get a map "mNodeIdToPwsSharingNode"
- // with key of GeneID and value of a list of pathways which
- // contain the GeneID
- for (PathwayElement pwElm : mAnchorPw.getDataObjects()) {
- // Only take elements with type DATANODE (genes,
- // proteins, metabolites)
- if (pwElm.getObjectType() == ObjectType.DATANODE) {
-
- percentComplete = (int) (((double) t / mNoGeneNode) * 98);
-
- // System.out.println(pwElm.getXref().toString());
- geneIDList.add(pwElm.getXref().toString());
-
- try {
-
- WSSearchResult[] PwsSharingNode = client
- .findPathwaysByXref(pwElm.getXref());
- // System.out.println("" +
- // PwsSharingNode.length);
- mNodeIdToPwsSharingNode.put(pwElm.getXref()
- .toString(), PwsSharingNode);
-
- if (monitor != null) {
- monitor
- .setPercentCompleted(percentComplete);
- }
-
- } catch (RemoteException e) {
- Logger.log
- .error(
- "Unable to find the candidate pathways due to the RemoteException",
- e);
- }
- }
- t++;
-
- }
-
- // the following code is for converting the above map to
- // another map "sharingNodeNumberofPws" with key of
- // the name and id of a pathway, and value of the number of
- // shared node of this pathway and the anchor pathway
- for (int i = 0; i < mNoGeneNode; i++) {
- WSSearchResult[] pwsArray = mNodeIdToPwsSharingNode
- .get(geneIDList.get(i));
-
- for (int j = 0; j < pwsArray.length; j++) {
- WSSearchResult pw = pwsArray[j];
- ResultRow pwResultRow = new ResultRow(pw);
- String onePwNameAndId = pwResultRow
- .getProperty(ResultProperty.NAME)
- + "("
- + pwResultRow
- .getProperty(ResultProperty.ID)
- + ")";
-
- if (sharingNodeNumberofPws
- .containsKey(onePwNameAndId)) {
- Integer oldValue = sharingNodeNumberofPws
- .get(onePwNameAndId);
- Integer newValue = new Integer(oldValue + 1);
- sharingNodeNumberofPws.put(onePwNameAndId,
- newValue);
- } else {
- sharingNodeNumberofPws.put(onePwNameAndId, 1);
- }
- }
- }
-
- // the following code is for displaying the result in the
- // table of
- // "Search Help" panel
- Set sharingNodePwsSet = sharingNodeNumberofPws
- .keySet();
- Iterator it = sharingNodePwsSet.iterator();
- while (it.hasNext()) {
- String temp = it.next();
- Integer value = sharingNodeNumberofPws.get(temp);
- if (value >= lowerBound && value <= upperBound) {
- mCandidatePw.add(temp + ", sharing node number: "
- + String.valueOf(value));
- }
- }
-
- }
-
- if (monitor != null) {
- monitor.setPercentCompleted(100);
- }
- // System.out.println("We reach here 2!");
- } catch (Exception e) {
- Logger.log.error("Error while searching candidate pathways", e);
- JOptionPane.showMessageDialog(mClient.getGUI(), "Error: "
- + e.getMessage() + ". See log for details", "Error",
- JOptionPane.ERROR_MESSAGE);
- }
-
- }
-
- public void halt() {
- }
-
- public void setTaskMonitor(TaskMonitor m)
- throws IllegalThreadStateException {
- monitor = m;
- }
-
- public String getTitle() {
- return new String(
- "Searching candidate pathways with shared nodes...");
- }
- }
-
- public class commonNodeViewTask implements Task {
-
- TaskMonitor monitor;
-
- boolean cancelled;
-
- // List selectedPwNameId;
- SuperpathwaysClient client;
-
- public commonNodeViewTask(SuperpathwaysClient b) {
- // selectedPwNameId=a;
- client = b;
- cancelled = false;
- }
-
- public void run() {
- try {
-
- cnViewObject = new CommonNodeView(mSelectedPathwaysID,
- mSelectedPathwayNameID, client);
- cnViewObject.drawCommonNodeView();
-
- // the following code is for printing out the matched node pair
- // by translation
- System.out
- .println("printing out the matched node pair by translation");
- Set s = cnViewObject.getNodePairByTranslation().keySet();
- Iterator it = s.iterator();
- while (it.hasNext()) {
- Xref x1 = it.next();
- Xref x2 = cnViewObject.getNodePairByTranslation().get(x1);
- System.out
- .println(x1.toString() + "======" + x2.toString());
- }
-
- } catch (Exception e) {
- Logger.log.error("Error while searching candidate pathways", e);
- JOptionPane.showMessageDialog(mClient.getGUI(), "Error: "
- + e.getMessage() + ". See log for details", "Error",
- JOptionPane.ERROR_MESSAGE);
- }
- }
-
- public void halt() {
- cancelled = true;
- cnViewObject.interrupt();
- }
-
- public void setTaskMonitor(TaskMonitor m)
- throws IllegalThreadStateException {
- monitor = m;
- }
-
- public String getTitle() {
- return new String("Generating common node view...");
- }
-
- }
-
- class MergeTask implements Task {
-
- TaskMonitor monitor;
-
- boolean cancelled;
-
- // PathwaysMerge pMerge;
- SuperpathwaysPlugin spPlugin;
-
- WikiPathwaysClient client;
-
- /**
- * Constructor.
- *
- */
- public MergeTask(SuperpathwaysPlugin sp, WikiPathwaysClient c) {
- cancelled = false;
- spPlugin = sp;
- client = c;
- }
-
- public boolean isCancelled() {
- return cancelled;
- }
-
- public void run() {
-
- // if (cnViewObject==null){
- // here we need to re-run the CommonNodeView to get the correct
- // NodePairByTranslation, and colorPool
-
- cnViewObject = new CommonNodeView(mSelectedPathwaysID,
- mSelectedPathwayNameID, mClient);
-
- pMerge = new PathwaysMerge(null, cnViewObject
- .getNodePairByTranslation(), null);
- // here we call the method drawCommonNodeView(), because we want to
- // make the correspondance of the color between the common node view
- // and the merged network
-
- Map pwNameToColor = null;
- if (!isCancelled()) {
- try {
- pwNameToColor = cnViewObject.drawCommonNodeView();
- } catch (Exception e) {
- Logger.log.error("Unable to draw common node view", e);
- }
-
- WSPathway wsPathway = new WSPathway();
- Pathway pathway = new Pathway();
- List listOfNetworks = new ArrayList();
-
- for (int i = 0; i < selectedPathwaysListModel.getSize(); i++) {
-
- System.out.println("in for loop: " + i + "");
- String selectedOnePwNameID = (String) selectedPathwaysListModel
- .get(i);
- System.out.println(selectedOnePwNameID);
- int index1 = selectedOnePwNameID.lastIndexOf("(");
- int index2 = selectedOnePwNameID.lastIndexOf(")");
- String pwID = selectedOnePwNameID.substring(index1 + 1,
- index2);
- String pwName = selectedOnePwNameID.substring(0, index1);
- // System.out.println(pwID);
- // System.out.println(pwName);
-
- try {
- wsPathway = client.getPathway(pwID);
- pathway = WikiPathwaysClient.toPathway(wsPathway);
- } catch (RemoteException e) {
- Logger.log
- .error(
- "Unable to get the pathway due to the RemoteException",
- e);
- } catch (ConverterException e) {
- Logger.log
- .error(
- "Unable to get the pathway due to the ConverterException",
- e);
- }
-
- CyNetwork net = spPlugin.load(pathway, true);
-
- // the following code is for coloring the nodes by default
- if(pwNameToColor != null) applyGpmlVisualStyle(mClient.getPlugin().mGpmlHandler,
- pwNameToColor, pwName, true,
- superpathwaysVisualStyleCounter);
-
- listOfNetworks.add(net);
- }
-
- // convert the array of type Color to an array of type String
- String[] temp = new String[cnViewObject.getColorPool().size()];
- Object[] colors = cnViewObject.getColorPool().toArray();
- for (int s = 0; s < temp.length; s++) {
- temp[s] = (String) colors[s];
- }
- System.out.println("Problem is here2!");
- pMerge = new PathwaysMerge(listOfNetworks, cnViewObject
- .getNodePairByTranslation(), temp);
-
- try {
- pMerge.setTaskMonitor(monitor);
-
- CyNetwork mergedNetwork = pMerge.mergeNetwork(
- "Merged Network", cnViewObject
- .getNodePairByTranslation());
- CyNetworkView view = Cytoscape
- .createNetworkView(mergedNetwork);
-
- superpathwaysVisualStyle vs = new superpathwaysVisualStyle(
- "Merged Network", pwNameToColor,
- superpathwaysVisualStyleCounter);
- superpathwaysVisualStyleCounter++;
-
- } catch (Exception e) {
- monitor.setException(e, "Network Merge Failed!");
- e.printStackTrace();
- }
-
- // the following code is for forcing detail rendering at any
- // level of
- // zoom
- CyNetworkView currView = Cytoscape.getCurrentNetworkView();
- ding.view.DGraphView nv;
- nv = (DGraphView) currView;
- nv.setGraphLOD(new CyGraphAllLOD());
- }
-
- }
-
- public void halt() {
- cancelled = true;
- cnViewObject.interrupt();
- pMerge.interrupt();
- }
-
- public void setTaskMonitor(TaskMonitor taskMonitor)
- throws IllegalThreadStateException {
- this.monitor = taskMonitor;
- }
-
- public String getTitle() {
- return "Merging pathways";
- }
- }
-
- public void applyGpmlVisualStyle(GpmlHandler gpmlHandler,
- Map pwNameToColor, String t,
- boolean coloringNodeInGpml, int version) {
-
- if (coloringNodeInGpml == true) {
- VisualMappingManager vmm = Cytoscape.getVisualMappingManager();
- CalculatorCatalog catalog = vmm.getCalculatorCatalog();
- // the next code line is used for fix the bug (when doing several
- // merges)
- // catalog.removeVisualStyle(gpmlExtendVisualStyle.NAME);
-
- String styleName = gpmlExtendVisualStyle.NAME + "-"
- + String.valueOf(version);
- System.out.println("GPML-extention style name: " + styleName);
-
- VisualStyle gpmlExtensionStyle = catalog.getVisualStyle(styleName);
-
- if (gpmlExtensionStyle == null) { // Create the GPML visual style
- Logger.log.trace("VisualStyle: creating GPML-extension style");
- System.out.println(pwNameToColor.size() + "");
- gpmlExtensionStyle = new gpmlExtendVisualStyle(gpmlHandler,
- pwNameToColor, t, version);
-
- // set the background color
- GlobalAppearanceCalculator gCalc = gpmlExtensionStyle
- .getGlobalAppearanceCalculator();
- gCalc.setDefaultBackgroundColor(new Color(200, 200, 255));
- vmm.applyGlobalAppearances();
-
- catalog.addVisualStyle(gpmlExtensionStyle);
- } else {
- System.out.println("gpml-extension style is not null!");
- Logger.log.trace("VisualStyle: reusing GPML-extension style");
- }
- System.out.println("Problem is here1!");
- cytoscape.view.CyNetworkView networkView = Cytoscape
- .getNetworkView(t);
- networkView.setVisualStyle(gpmlExtensionStyle.getName());
-
- // actually apply the visual style
- vmm.setVisualStyle(gpmlExtensionStyle);
- networkView.redrawGraph(true, true);
- }
- }
+// PathVisio,
+// a tool for data visualization and analysis using Biological Pathways
+// Copyright 2006-2011 BiGCaT Bioinformatics
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package org.pathvisio.cytoscape.superpathways;
+
+import java.awt.Color;
+import java.awt.Cursor;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.DefaultListModel;
+import javax.swing.JList;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.ListSelectionModel;
+import javax.swing.table.TableColumn;
+
+import org.bridgedb.Xref;
+import org.bridgedb.bio.Organism;
+import org.pathvisio.core.debug.Logger;
+import org.pathvisio.core.model.ConverterException;
+import org.pathvisio.core.model.ObjectType;
+import org.pathvisio.core.model.Pathway;
+import org.pathvisio.core.model.PathwayElement;
+import org.pathvisio.cytoscape.GpmlHandler;
+import org.pathvisio.cytoscape.superpathways.SuperpathwaysClient.FindPathwaysByTextParameters;
+import org.pathvisio.cytoscape.superpathways.SuperpathwaysClient.GetPathwayParameters;
+import org.pathvisio.desktop.util.ListWithPropertiesTableModel;
+import org.pathvisio.desktop.util.RowWithProperties;
+import org.pathvisio.wikipathways.webservice.WSPathway;
+import org.pathvisio.wikipathways.webservice.WSSearchResult;
+import org.wikipathways.client.WikiPathwaysClient;
+
+import cytoscape.CyNetwork;
+import cytoscape.Cytoscape;
+import cytoscape.data.webservice.CyWebServiceEvent;
+import cytoscape.data.webservice.CyWebServiceException;
+import cytoscape.data.webservice.WebServiceClientManager;
+import cytoscape.data.webservice.CyWebServiceEvent.WSEventType;
+import cytoscape.ding.CyGraphAllLOD;
+import cytoscape.task.Task;
+import cytoscape.task.TaskMonitor;
+import cytoscape.task.ui.JTaskConfig;
+import cytoscape.task.util.TaskManager;
+import cytoscape.view.CyNetworkView;
+import cytoscape.visual.CalculatorCatalog;
+import cytoscape.visual.GlobalAppearanceCalculator;
+import cytoscape.visual.VisualMappingManager;
+import cytoscape.visual.VisualStyle;
+import ding.view.DGraphView;
+
+//public class SuperpathwaysGui extends JFrame implements ActionListener{
+public class SuperpathwaysGui extends JPanel {
+
+ // private static String ACTION_SEARCH = "Search";
+
+ private static String ORGANISM_ALL = "All organisms";
+
+ final SuperpathwaysClient mClient;
+
+ ResultRow mSelectedInHelpPanel;
+
+ List mClickedPathwayNameID = new ArrayList();
+
+ List mSelectedPathwayNameID = new ArrayList();
+
+ // this mSelectedPathwaysID is used for pass the reference of Pws to the
+ // method in CommonNodeView class
+ // use the identifier directly, not the name/identifier combination.
+ List mSelectedPathwaysID = new ArrayList();
+
+ // String[] mSelectedPathwaysID = new String[20];
+
+ String mSelectedPwInHelpPanel = "not defined";
+
+ private Map mNodeIdToPwsSharingNode = new HashMap();
+
+ private List mCandidatePw;
+
+ int mNoGeneNode;
+
+ Pathway mAnchorPw;
+
+ CommonNodeView cnViewObject;
+
+ PathwaysMerge pMerge;
+
+ static int superpathwaysVisualStyleCounter;
+
+ // List selectedPwsNameId;
+
+ public SuperpathwaysGui(SuperpathwaysClient c) {
+ mClient = c;
+
+ initComponents();
+
+ cnViewObject = null;
+
+ superpathwaysVisualStyleCounter = 1;
+
+ }
+
+ // the following code is generated in Netbean IDE
+ /**
+ * This method is called from within the constructor to initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is always
+ * regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ //
+ private void initComponents() {
+
+ jScrollPane2 = new javax.swing.JScrollPane();
+
+ // superpathwayPanel = new javax.swing.JTabbedPane();
+ searchPane = new javax.swing.JPanel();
+ stepLabel1 = new javax.swing.JLabel();
+ searchText = new javax.swing.JTextField();
+ organismCombo = new javax.swing.JComboBox();
+ searchBtn = new javax.swing.JButton();
+ // helpButton = new javax.swing.JButton();
+ hintLabel1 = new javax.swing.JLabel();
+ resultScrolllPane1 = new javax.swing.JScrollPane();
+ resultTable = new javax.swing.JTable();
+ addBtn = new javax.swing.JButton();
+ selectPanel = new javax.swing.JPanel();
+
+ /*
+ * availablePathwaysScrollPane = new javax.swing.JScrollPane();
+ * availablePathwaysList = new javax.swing.JList();
+ * availablePathwaysListModel = new DefaultListModel();
+ * availablePathwaysLabel = new javax.swing.JLabel();
+ */
+ removeBtn = new javax.swing.JButton();
+
+ selectedPathwaysLabel = new javax.swing.JLabel();
+ selectedPathwaysScrollPane = new javax.swing.JScrollPane();
+ selectedPathwaysList = new javax.swing.JList();
+ selectedPathwaysListModel = new DefaultListModel();
+
+ findRelatedPwsBtn = new javax.swing.JButton();
+ // rightButton = new javax.swing.JButton();
+ // leftButton = new javax.swing.JButton();
+
+ ClearBtn = new javax.swing.JButton();
+ CommonNodeViewBtn = new javax.swing.JButton();
+ MergeBtn = new javax.swing.JButton();
+
+ helpPanel = new javax.swing.JPanel();
+ anchorPathwayLabel = new javax.swing.JLabel();
+ sharingNodeNoLabel = new javax.swing.JLabel();
+ anchorPathwayComboBox = new javax.swing.JComboBox();
+ lowerBoundSharingNodeNoComboBox = new javax.swing.JComboBox();
+ candidatePathwaysSharingNodesScrollPane = new javax.swing.JScrollPane();
+
+ // candidatePathwaysSharingNodesList = new javax.swing.JList();
+ // candidatePathwaysSharingNodesListModel = new DefaultListModel();
+
+ candidatePathwaysSharingNodesTable = new javax.swing.JTable();
+ candidatePathwaysSharingNodesTableModel = new javax.swing.table.DefaultTableModel();
+
+ // candidatePathwaysSharingNodesTable.setAutoCreateRowSorter(true);
+
+ explainHelpLabel1 = new javax.swing.JLabel();
+ addHelpButton = new javax.swing.JButton();
+ lowerBoundLabel = new javax.swing.JLabel();
+ upperBoundLabel = new javax.swing.JLabel();
+ upperBoundSharingNodeNoComboBox = new javax.swing.JComboBox();
+ explainHelpLabel2 = new javax.swing.JLabel();
+ backToSearchButton = new javax.swing.JButton();
+ searchHelpButton = new javax.swing.JButton();
+ lastLabel = new javax.swing.JLabel();
+
+ // setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+ // setTitle("Superpathways");
+ // setBackground(new java.awt.Color(255, 255, 255));
+
+ /*
+ * superpathwayPanel.setToolTipText("");
+ * superpathwayPanel.setName("search_select_tab"); // NOI18N
+ * superpathwayPanel.setPreferredSize(new java.awt.Dimension(440, 680));
+ */
+
+ searchPane.setToolTipText("");
+
+ stepLabel1.setBackground(new java.awt.Color(204, 204, 255));
+ stepLabel1.setFont(new java.awt.Font("Dialog", 1, 11)); // NOI18N
+ stepLabel1.setForeground(new java.awt.Color(102, 0, 0));
+ stepLabel1
+ .setText("Search and select multiple pathways from WikiPathways");
+
+ searchText.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ searchTextActionPerformed(evt);
+ }
+ });
+
+ resetOrganisms();
+
+ searchBtn.setText("Search");
+ searchBtn.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ searchBtnActionPerformed(evt);
+ }
+ });
+
+ hintLabel1.setFont(new java.awt.Font("Dialog", 1, 11)); // NOI18N
+ hintLabel1
+ .setText("You can search by: pathway name, gene/protein name, or any page content");
+
+ resultTable
+ .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+
+ resultScrolllPane1.setViewportView(resultTable);
+
+ addBtn.setText("Add");
+ addBtn
+ .setToolTipText("add the selected pathway to the \"Available Pathways\" list");
+ addBtn.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ addBtnActionPerformed(evt);
+ }
+ });
+
+ /*
+ * selectPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
+ * javax.swing.BorderFactory .createTitledBorder("Please select pathways
+ * to merge"), "",
+ * javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
+ * javax.swing.border.TitledBorder.DEFAULT_POSITION, new
+ * java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 255))); //
+ * NOI18N
+ */
+
+ selectPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
+ null, "",
+ javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
+ javax.swing.border.TitledBorder.DEFAULT_POSITION,
+ new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0,
+ 255))); // NOI18N
+ /*
+ * availablePathwaysList
+ * .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+ * availablePathwaysList.setLayoutOrientation(JList.VERTICAL);
+ * availablePathwaysList.setVisibleRowCount(8);
+ *
+ * availablePathwaysScrollPane.setViewportView(availablePathwaysList);
+ */
+
+ selectedPathwaysList
+ .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+ selectedPathwaysList.setLayoutOrientation(JList.VERTICAL);
+ selectedPathwaysList.setVisibleRowCount(8);
+ selectedPathwaysScrollPane.setViewportView(selectedPathwaysList);
+
+ /*
+ * availablePathwaysLabel.setFont(new java.awt.Font("Tahoma", 1, 11)); //
+ * NOI18N availablePathwaysLabel.setForeground(new java.awt.Color(102,
+ * 0, 0)); availablePathwaysLabel.setText("Available Pathways");
+ */
+ selectedPathwaysLabel.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
+ selectedPathwaysLabel.setForeground(new java.awt.Color(102, 0, 0));
+ selectedPathwaysLabel.setText("Selected Pathways");
+
+ removeBtn.setText("Remove");
+ removeBtn.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ removeBtnActionPerformed(evt);
+ }
+ });
+
+ ClearBtn.setText("Clear");
+ ClearBtn
+ .setToolTipText("clear all the previously selected pathways");
+ ClearBtn.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ ClearBtnActionPerformed(evt);
+ }
+ });
+
+ org.jdesktop.layout.GroupLayout selectPanelLayout = new org.jdesktop.layout.GroupLayout(
+ selectPanel);
+ selectPanel.setLayout(selectPanelLayout);
+ selectPanelLayout
+ .setHorizontalGroup(selectPanelLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING)
+ .add(
+ selectPanelLayout
+ .createSequentialGroup()
+ .addContainerGap()
+ .add(
+ selectPanelLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING)
+ .add(
+ org.jdesktop.layout.GroupLayout.TRAILING,
+ selectedPathwaysScrollPane,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ 371,
+ Short.MAX_VALUE)
+ .add(
+ selectedPathwaysLabel)
+ .add(
+ org.jdesktop.layout.GroupLayout.TRAILING,
+ selectPanelLayout
+ .createSequentialGroup()
+ .add(
+ ClearBtn)
+ .addPreferredGap(
+ org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(
+ removeBtn,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+ 71,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
+ .addContainerGap()));
+ selectPanelLayout
+ .setVerticalGroup(selectPanelLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING)
+ .add(
+ selectPanelLayout
+ .createSequentialGroup()
+ .add(selectedPathwaysLabel)
+ .addPreferredGap(
+ org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(
+ selectedPathwaysScrollPane,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+ 110,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(
+ org.jdesktop.layout.LayoutStyle.RELATED,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ Short.MAX_VALUE)
+ .add(
+ selectPanelLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(removeBtn).add(
+ ClearBtn))));
+
+ /*
+ * org.jdesktop.layout.GroupLayout selectPanelLayout = new
+ * org.jdesktop.layout.GroupLayout(selectPanel);
+ * selectPanel.setLayout(selectPanelLayout);
+ * selectPanelLayout.setHorizontalGroup(
+ * selectPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ * .add(selectPanelLayout.createSequentialGroup() .addContainerGap()
+ * .add(selectPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ * .add(org.jdesktop.layout.GroupLayout.TRAILING,
+ * selectedPathwaysScrollPane,
+ * org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
+ * .add(selectedPathwaysLabel)
+ * .add(org.jdesktop.layout.GroupLayout.TRAILING, removeBtn))
+ * .addContainerGap()) ); selectPanelLayout.setVerticalGroup(
+ * selectPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ * .add(selectPanelLayout.createSequentialGroup()
+ * .add(selectedPathwaysLabel)
+ * .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ * .add(selectedPathwaysScrollPane,
+ * org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 110,
+ * org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ * .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED,
+ * org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ * .add(removeBtn)) );
+ */
+
+ findRelatedPwsBtn.setText("Find Related Pathways");
+ findRelatedPwsBtn
+ .setToolTipText("find the related pathways which share nodes with the one you select");
+ findRelatedPwsBtn
+ .addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ findRelatedPwsBtnActionPerformed(evt);
+ }
+ });
+
+
+
+ CommonNodeViewBtn.setText("Common Node View");
+ CommonNodeViewBtn
+ .setToolTipText("generate a network view showing the number of shared nodes between every two selected pathways");
+ CommonNodeViewBtn
+ .addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ CommonNodeViewBtnActionPerformed(evt);
+ }
+ });
+
+ /*
+ * helpButton.setText("Help"); helpButton .setToolTipText("switch to
+ * Search Help tab, where you're provided with help for finding
+ * candidate pathways with shared nodes");
+ * helpButton.addActionListener(new java.awt.event.ActionListener() {
+ * public void actionPerformed(java.awt.event.ActionEvent evt) {
+ * helpButtonActionPerformed(evt); } });
+ */
+
+ MergeBtn.setText("Merge");
+ MergeBtn.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ MergeBtnActionPerformed(evt);
+ }
+ });
+
+ org.jdesktop.layout.GroupLayout searchPaneLayout = new org.jdesktop.layout.GroupLayout(
+ searchPane);
+ searchPane.setLayout(searchPaneLayout);
+ searchPaneLayout
+ .setHorizontalGroup(searchPaneLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING)
+ .add(
+ searchPaneLayout
+ .createSequentialGroup()
+ .addContainerGap()
+ .add(
+ searchPaneLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING)
+ .add(
+ searchPaneLayout
+ .createSequentialGroup()
+ .add(
+ stepLabel1)
+ .addContainerGap(
+ 79,
+ Short.MAX_VALUE))
+ .add(
+ searchPaneLayout
+ .createSequentialGroup()
+ .add(
+ hintLabel1,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+ 412,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(
+ 18,
+ Short.MAX_VALUE))
+ .add(
+ org.jdesktop.layout.GroupLayout.TRAILING,
+ searchPaneLayout
+ .createSequentialGroup()
+ .add(
+ searchPaneLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(
+ searchPaneLayout
+ .createSequentialGroup()
+
+ /*.add(
+ ClearBtn)*/
+ .addPreferredGap(
+ org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(
+ CommonNodeViewBtn)
+ .addPreferredGap(
+ org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(
+ MergeBtn)
+ .add(
+ 6,
+ 6,
+ 6))
+ .add(
+ searchPaneLayout
+ .createSequentialGroup()
+ .add(
+ findRelatedPwsBtn)
+ .addPreferredGap(
+ org.jdesktop.layout.LayoutStyle.UNRELATED)
+ .add(
+ addBtn,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+ 67,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .add(
+ org.jdesktop.layout.GroupLayout.LEADING,
+ selectPanel,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ Short.MAX_VALUE)
+ .add(
+ org.jdesktop.layout.GroupLayout.LEADING,
+ resultScrolllPane1,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ 407,
+ Short.MAX_VALUE)
+ .add(
+ org.jdesktop.layout.GroupLayout.LEADING,
+ searchPaneLayout
+ .createSequentialGroup()
+ .add(
+ searchText,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ 171,
+ Short.MAX_VALUE)
+ .addPreferredGap(
+ org.jdesktop.layout.LayoutStyle.UNRELATED)
+ .add(
+ organismCombo,
+ 0,
+ 151,
+ Short.MAX_VALUE)
+ .addPreferredGap(
+ org.jdesktop.layout.LayoutStyle.UNRELATED)
+ .add(
+ searchBtn)))
+ .add(
+ 23,
+ 23,
+ 23)))));
+
+ /*
+ * searchPaneLayout.linkSize(new java.awt.Component[] { ClearBtn,
+ * helpButton }, org.jdesktop.layout.GroupLayout.HORIZONTAL);
+ */
+
+ searchPaneLayout
+ .setVerticalGroup(searchPaneLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING)
+ .add(
+ searchPaneLayout
+ .createSequentialGroup()
+ .add(28, 28, 28)
+ .add(stepLabel1)
+ .add(18, 18, 18)
+ .add(hintLabel1)
+ .add(32, 32, 32)
+ .add(
+ searchPaneLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(
+ searchText,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ 23,
+ Short.MAX_VALUE)
+ .add(organismCombo)
+ .add(searchBtn))
+ .add(18, 18, 18)
+ .add(
+ resultScrolllPane1,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ 176, Short.MAX_VALUE)
+ .add(18, 18, 18)
+ .add(
+ searchPaneLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(findRelatedPwsBtn)
+ .add(addBtn))
+ .addPreferredGap(
+ org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(
+ selectPanel,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ Short.MAX_VALUE)
+ .add(39, 39, 39)
+ .add(
+ searchPaneLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(MergeBtn)
+ .add(CommonNodeViewBtn)
+ /*.add(ClearBtn)*/).add(43,
+ 43, 43)));
+
+ searchPaneLayout.linkSize(new java.awt.Component[] { addBtn,
+ findRelatedPwsBtn }, org.jdesktop.layout.GroupLayout.VERTICAL);
+
+ searchPaneLayout.linkSize(new java.awt.Component[] { searchBtn,
+ searchText }, org.jdesktop.layout.GroupLayout.VERTICAL);
+
+ /*searchPaneLayout.linkSize(new java.awt.Component[] { ClearBtn,
+ CommonNodeViewBtn }, org.jdesktop.layout.GroupLayout.VERTICAL);*/
+
+ // superpathwayPanel.addTab("Search/Select", searchPane);
+
+ anchorPathwayLabel.setForeground(new java.awt.Color(0, 0, 255));
+ anchorPathwayLabel.setText("Pathway");
+
+ sharingNodeNoLabel.setForeground(new java.awt.Color(0, 0, 255));
+ sharingNodeNoLabel.setText("Sharing");
+
+ // anchorPathwayComboBox.setModel(new
+ // DefaultComboBoxModel(mAvailablePathwaysNameIDList.toArray()));
+
+ anchorPathwayComboBoxModel = new DefaultComboBoxModel();
+ anchorPathwayComboBoxModel.addElement((Object) new String(
+ "choose one pathway"));
+ anchorPathwayComboBox.setModel(anchorPathwayComboBoxModel);
+
+ anchorPathwayComboBox
+ .addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ anchorPathwayComboBoxActionPerformed(evt);
+ }
+ });
+
+ lowerBoundSharingNodeNoComboBox
+ .setModel(new javax.swing.DefaultComboBoxModel(new String[] {
+ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }));
+
+ // candidatePathwaysSharingNodesTable.setModel();
+
+ explainHelpLabel1.setFont(new java.awt.Font("Dialog", 1, 11)); // NOI18N
+ explainHelpLabel1.setForeground(new java.awt.Color(102, 0, 0));
+ explainHelpLabel1
+ .setText("Choose a pathway and set the range of sharing nodes number, a list of ");
+
+ addHelpButton.setText("Add");
+ addHelpButton
+ .setToolTipText("add the selected pathways to the 'Available Pathways' list");
+ /*
+ * addHelpButton.addActionListener(new java.awt.event.ActionListener() {
+ * public void actionPerformed(java.awt.event.ActionEvent evt) {
+ * addHelpButtonActionPerformed(evt); } });
+ */
+
+ lowerBoundLabel.setForeground(new java.awt.Color(0, 0, 255));
+ lowerBoundLabel.setText("Minimum");
+
+ upperBoundLabel.setForeground(new java.awt.Color(0, 0, 255));
+ upperBoundLabel.setText("Maximum");
+
+ upperBoundSharingNodeNoComboBox
+ .setModel(new javax.swing.DefaultComboBoxModel(new String[] {
+ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
+ "11", "12", "13", "14", "15", "16", "17", "18", "19",
+ "20" }));
+
+ explainHelpLabel2.setFont(new java.awt.Font("Dialog", 1, 11)); // NOI18N
+ explainHelpLabel2.setForeground(new java.awt.Color(102, 0, 0));
+ explainHelpLabel2
+ .setText("candidate pathways with sharing nodes would be returned.");
+
+ lastLabel.setForeground(new java.awt.Color(0, 0, 255));
+ lastLabel.setText("Nodes");
+
+ backToSearchButton.setText("Back to Search");
+ backToSearchButton
+ .addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ backtoSearchButtonActionPerformed(evt);
+ }
+ });
+
+ searchHelpButton.setText("Search");
+ searchHelpButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ searchHelpButtonActionPerformed(evt);
+ }
+ });
+
+ /*
+ * candidatePathwaysSharingNodesList
+ * .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+ * candidatePathwaysSharingNodesScrollPane
+ * .setViewportView(candidatePathwaysSharingNodesList);
+ */
+
+ candidatePathwaysSharingNodesTableModel.addColumn("Pathway Name");
+ candidatePathwaysSharingNodesTableModel.addColumn("ID");
+ candidatePathwaysSharingNodesTableModel.addColumn("No. Shared Nodes");
+
+ candidatePathwaysSharingNodesTable
+ .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+ candidatePathwaysSharingNodesScrollPane
+ .setViewportView(candidatePathwaysSharingNodesTable);
+ candidatePathwaysSharingNodesTable
+ .setModel(candidatePathwaysSharingNodesTableModel);
+
+ TableColumn column = null;
+ for (int i = 0; i < 3; i++) {
+ column = candidatePathwaysSharingNodesTable.getColumnModel()
+ .getColumn(i);
+ if (i == 0) {
+ column.setPreferredWidth(150); // third column is bigger
+ } else if (i == 1) {
+ column.setPreferredWidth(40);
+ } else {
+ column.setPreferredWidth(60);
+ }
+
+ }
+
+ org.jdesktop.layout.GroupLayout helpPanelLayout = new org.jdesktop.layout.GroupLayout(
+ helpPanel);
+ helpPanel.setLayout(helpPanelLayout);
+ helpPanelLayout
+ .setHorizontalGroup(helpPanelLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING)
+ .add(
+ helpPanelLayout
+ .createSequentialGroup()
+ .add(
+ helpPanelLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING)
+ .add(
+ helpPanelLayout
+ .createSequentialGroup()
+ .addContainerGap()
+ .add(
+ explainHelpLabel1))
+ .add(
+ helpPanelLayout
+ .createSequentialGroup()
+ .addContainerGap()
+ .add(
+ explainHelpLabel2))
+ .add(
+ helpPanelLayout
+ .createSequentialGroup()
+ .add(
+ 19,
+ 19,
+ 19)
+ .add(
+ helpPanelLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING)
+ .add(
+ anchorPathwayLabel)
+ .add(
+ sharingNodeNoLabel))
+ .add(
+ 6,
+ 6,
+ 6)
+ .add(
+ helpPanelLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING,
+ false)
+ .add(
+ helpPanelLayout
+ .createSequentialGroup()
+ .add(
+ lowerBoundLabel)
+ .add(
+ 18,
+ 18,
+ 18)
+ .add(
+ lowerBoundSharingNodeNoComboBox,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(
+ 18,
+ 18,
+ 18)
+ .add(
+ upperBoundLabel)
+ .add(
+ 18,
+ 18,
+ 18)
+ .add(
+ upperBoundSharingNodeNoComboBox,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .add(
+ helpPanelLayout
+ .createSequentialGroup()
+ .add(
+ 23,
+ 23,
+ 23)
+ .add(
+ anchorPathwayComboBox,
+ 0,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ Short.MAX_VALUE)))
+ .add(
+ 18,
+ 18,
+ 18)
+ .add(
+ lastLabel)
+ .add(
+ 18,
+ 18,
+ 18)
+ .add(
+ searchHelpButton)))
+ .addContainerGap(24, Short.MAX_VALUE))
+ .add(
+ org.jdesktop.layout.GroupLayout.TRAILING,
+ helpPanelLayout
+ .createSequentialGroup()
+ .addContainerGap(190, Short.MAX_VALUE)
+ .add(backToSearchButton)
+ .addPreferredGap(
+ org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(addHelpButton).add(26, 26, 26))
+ .add(
+ helpPanelLayout
+ .createSequentialGroup()
+ .addContainerGap()
+ .add(
+ candidatePathwaysSharingNodesScrollPane,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ 402, Short.MAX_VALUE).add(16,
+ 16, 16)));
+
+ helpPanelLayout.linkSize(new java.awt.Component[] { addHelpButton,
+ backToSearchButton },
+ org.jdesktop.layout.GroupLayout.HORIZONTAL);
+
+ helpPanelLayout
+ .setVerticalGroup(helpPanelLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING)
+ .add(
+ helpPanelLayout
+ .createSequentialGroup()
+ .add(33, 33, 33)
+ .add(explainHelpLabel1)
+ .addPreferredGap(
+ org.jdesktop.layout.LayoutStyle.UNRELATED)
+ .add(explainHelpLabel2)
+ .add(44, 44, 44)
+ .add(
+ helpPanelLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(anchorPathwayLabel)
+ .add(
+ anchorPathwayComboBox,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .add(23, 23, 23)
+ .add(
+ helpPanelLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(lowerBoundLabel)
+ .add(
+ lowerBoundSharingNodeNoComboBox,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(upperBoundLabel)
+ .add(
+ upperBoundSharingNodeNoComboBox,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(lastLabel)
+ .add(searchHelpButton)
+ .add(sharingNodeNoLabel))
+ .add(53, 53, 53)
+ .add(
+ candidatePathwaysSharingNodesScrollPane,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ 251, Short.MAX_VALUE)
+ .add(29, 29, 29)
+ .add(
+ helpPanelLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(backToSearchButton)
+ .add(addHelpButton))
+ .addContainerGap(131, Short.MAX_VALUE)));
+
+ helpPanelLayout.linkSize(new java.awt.Component[] { addHelpButton,
+ backToSearchButton }, org.jdesktop.layout.GroupLayout.VERTICAL);
+
+ helpPanelLayout.linkSize(new java.awt.Component[] { lastLabel,
+ lowerBoundLabel, lowerBoundSharingNodeNoComboBox,
+ searchHelpButton, sharingNodeNoLabel, upperBoundLabel,
+ upperBoundSharingNodeNoComboBox },
+ org.jdesktop.layout.GroupLayout.VERTICAL);
+
+ // remove the Search Help panel
+ /*
+ * superpathwayPanel .addTab("Search Help", null, helpPanel, "help is
+ * provided for finding candidate pathways with shared nodes");
+ */
+ // jScrollPane2.setViewportView(superpathwayPanel);
+ jScrollPane2.setViewportView(searchPane);
+
+ org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
+ this);
+ setLayout(layout);
+ layout.setHorizontalGroup(layout.createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING).add(
+ layout.createSequentialGroup().add(18, 18, 18).add(
+ jScrollPane2,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 447,
+ Short.MAX_VALUE).add(20, 20, 20)));
+ layout.setVerticalGroup(layout.createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING).add(
+ layout.createSequentialGroup().add(20, 20, 20).add(
+ jScrollPane2,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 701,
+ Short.MAX_VALUE).addContainerGap()));
+
+ // pack();
+ }//
+
+ private void searchTextActionPerformed(java.awt.event.ActionEvent evt) {
+ searchActionPerformed(evt);
+ }
+
+ private void searchBtnActionPerformed(java.awt.event.ActionEvent evt) {
+ searchActionPerformed(evt);
+ }
+
+ private void addBtnActionPerformed(java.awt.event.ActionEvent evt) {
+ // System.out.println(mClickedPathwayNameID.size() + "");
+ mClickedPathwayNameID.clear();
+
+ int[] rows = resultTable.getSelectedRows();
+ for (int k = 0; k < rows.length; k++) {
+ int viewRow = rows[k];
+ int modelRow = sorter.modelIndex(viewRow);
+
+ ResultRow t = tableModel.getRow(modelRow);
+ String temp = t.getProperty(ResultProperty.NAME) + "("
+ + t.getProperty(ResultProperty.ID) + ")";
+
+ mClickedPathwayNameID.add(temp);
+
+ }
+ for (int i = 0; i < mClickedPathwayNameID.size(); i++) {
+ System.out.println(mClickedPathwayNameID.get(i));
+ if (!selectedPathwaysListModel.contains(mClickedPathwayNameID
+ .get(i))) {
+ selectedPathwaysListModel.addElement(mClickedPathwayNameID
+ .get(i));
+ selectedPathwaysList.setModel(selectedPathwaysListModel);
+ /*
+ * if (availablePathwaysListModel.getSize() > 0) {
+ * rightButton.setEnabled(true); }
+ */
+
+ mSelectedPathwayNameID.add(mClickedPathwayNameID.get(i));
+
+ // add the pathways IDs to the list mSelectedPathwaysID
+ String t = mClickedPathwayNameID.get(i);
+ int index1 = t.lastIndexOf("(");
+ int index2 = t.lastIndexOf(")");
+ String pwID = t.substring(index1 + 1, index2);
+ mSelectedPathwaysID.add(pwID);
+
+ /*
+ * anchorPathwayComboBoxModel.addElement(mClickedPathwayNameID
+ * .get(i));
+ * anchorPathwayComboBox.setModel(anchorPathwayComboBoxModel);
+ */
+ }
+ }
+
+ }
+
+ private void removeBtnActionPerformed(java.awt.event.ActionEvent evt) {
+ Object[] temp = selectedPathwaysList.getSelectedValues();
+ for (int i = 0; i < temp.length; i++) {
+ mSelectedPathwayNameID.remove((String) temp[i]);
+
+ // removed the selected item in the selected pathways list
+ selectedPathwaysListModel.removeElement(temp[i]);
+ String t = (String) temp[i];
+ int index1 = t.lastIndexOf("(");
+ int index2 = t.lastIndexOf(")");
+ String pwID = t.substring(index1 + 1, index2);
+ mSelectedPathwaysID.remove(pwID);
+ }
+ }
+
+ private void findRelatedPwsBtnActionPerformed(java.awt.event.ActionEvent evt) {
+ System.out.println("After clicking 'Find Related Pathways' button!");
+ int[] rows = resultTable.getSelectedRows();
+
+ if (rows.length > 1 || rows.length == 0) {
+ JOptionPane
+ .showMessageDialog(
+ this,
+ "Please select ONE pathway among the search result",
+ "find related pathways...",
+ JOptionPane.INFORMATION_MESSAGE);
+ } else {
+ int viewRow = rows[0];
+ int modelRow = sorter.modelIndex(viewRow);
+
+ ResultRow t = tableModel.getRow(modelRow);
+ String temp = t.getProperty(ResultProperty.NAME) + "("
+ + t.getProperty(ResultProperty.ID) + ")";
+
+ FindRelatedPwsDialog relatedPwsDialog = new FindRelatedPwsDialog(
+ mClient, "Find related pathways...", temp);
+ relatedPwsDialog.setVisible(true);
+
+ }
+
+ }
+
+ private void ClearBtnActionPerformed(java.awt.event.ActionEvent evt) {
+ // SuperpathwaysPlugin spPlugin = SuperpathwaysPlugin.getInstance();
+ // spPlugin.mWindow.setVisible(false);
+ // spPlugin.mWindow.dispose();
+ searchText.setText("");
+ /*
+ * availablePathwaysListModel.clear();
+ * availablePathwaysList.setModel(availablePathwaysListModel);
+ */
+ selectedPathwaysListModel.clear();
+ selectedPathwaysList.setModel(selectedPathwaysListModel);
+ //anchorPathwayComboBox.setModel(new DefaultComboBoxModel());
+ mSelectedPathwaysID.clear();
+ mSelectedPathwayNameID.clear();
+
+ }
+
+ private void CommonNodeViewBtnActionPerformed(java.awt.event.ActionEvent evt) {
+
+ System.out.println("Display the selected pws' id:");
+ for (int k = 0; k < mSelectedPathwaysID.size(); k++) {
+ System.out.println(mSelectedPathwaysID.get(k));
+ }
+
+ /*
+ * Object[] selectedPwNameId = selectedPathwaysListModel.toArray();
+ * selectedPwsNameId = new ArrayList(); for (int i = 0; i <
+ * selectedPwNameId.length; i++) { selectedPwsNameId.add((String)
+ * selectedPwNameId[i]); }
+ */
+
+ commonNodeViewTask task = new commonNodeViewTask(mClient);
+ JTaskConfig config = new JTaskConfig();
+ config.displayCancelButton(true);
+ // config.setModal(true);
+ config.setModal(false);
+ TaskManager.executeTask(task, config);
+ }
+
+ private void searchHelpButtonActionPerformed(java.awt.event.ActionEvent evt) {
+
+ candidatePathwaysSharingNodesTableModel = new javax.swing.table.DefaultTableModel();
+ candidatePathwaysSharingNodesTableModel.addColumn("Pathway Name");
+ candidatePathwaysSharingNodesTableModel.addColumn("ID");
+ candidatePathwaysSharingNodesTableModel.addColumn("No. Shared Nodes");
+
+ candidatePathwaysSharingNodesTable
+ .setModel(candidatePathwaysSharingNodesTableModel);
+ setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+ // String anchorPwNameAndId =
+ // anchorPathwayComboBox.getSelectedItem().toString();
+ int lowerBound = Integer.parseInt(lowerBoundSharingNodeNoComboBox
+ .getSelectedItem().toString());
+ int upperBound = Integer.parseInt(upperBoundSharingNodeNoComboBox
+ .getSelectedItem().toString());
+
+ // mCandidatePwList = findCandidatePwBySharingNodes(lowerBound,
+ // upperBound);
+
+ searchSharingNodePwsTask task = new searchSharingNodePwsTask(
+ lowerBound, upperBound);
+
+ JTaskConfig config = new JTaskConfig();
+ config.displayCancelButton(true);
+ // config.displayCloseButton(true);
+ // config.displayStatus(true);
+ config.setModal(true);
+ TaskManager.executeTask(task, config);
+
+ // mCandidatePw is a list of string with elements in format "Pathway
+ // Name (pw id), sharing node number: a int"
+
+ // System.out.println("We reach here 3!");
+ // System.out.println(mCandidatePw.size()+"");
+ Iterator it = mCandidatePw.iterator();
+ while (it.hasNext()) {
+ String temp = it.next();
+ // candidatePathwaysSharingNodesListModel.addElement(temp);
+
+ // System.out.println(temp);
+ // parse the string into three parts: pathway name, id, and No.
+ // Sharing Nodes
+ int index1 = temp.indexOf(",");
+ String temp1 = temp.substring(0, index1);
+
+ int index2 = temp1.lastIndexOf("(");
+ int index3 = temp1.lastIndexOf(")");
+ String pwName = temp1.substring(0, index2);
+ // System.out.println(pwName);
+ String pwId = temp1.substring(index2 + 1, index3);
+ // System.out.println(pwId);
+
+ // String temp2 = temp.substring(index1+1);
+ int index4 = temp.indexOf(":");
+ String NoSharingNode = temp.substring(index4 + 2);
+ // System.out.println(NoSharingNode);
+
+ Object[] row = new Object[3];
+ row[0] = (Object) pwName;
+ row[1] = (Object) pwId;
+ row[2] = (Object) NoSharingNode;
+
+ candidatePathwaysSharingNodesTableModel.addRow(row);
+
+ }
+
+ sorter = new TableSorter(candidatePathwaysSharingNodesTableModel);
+ candidatePathwaysSharingNodesTable.setModel(sorter);
+ sorter.setTableHeader(candidatePathwaysSharingNodesTable
+ .getTableHeader());
+
+ // candidatePathwaysSharingNodesList.setModel(candidatePathwaysSharingNodesListModel);
+ setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+
+ private void backtoSearchButtonActionPerformed(
+ java.awt.event.ActionEvent evt) {
+ // System.out.println("Clicking the back to search button!");
+ // superpathwayPanel.setSelectedIndex(0);
+ }
+
+ private void anchorPathwayComboBoxActionPerformed(
+ java.awt.event.ActionEvent evt) {
+ String anchorPwNameId = anchorPathwayComboBox.getSelectedItem()
+ .toString();
+
+ if (anchorPwNameId.equalsIgnoreCase("choose one pathway")) {
+
+ } else {
+ int index1 = anchorPwNameId.lastIndexOf("(");
+ int index2 = anchorPwNameId.lastIndexOf(")");
+ String anchorPwID = anchorPwNameId.substring(index1 + 1, index2);
+
+ // Create a client to the WikiPathways web service
+ WikiPathwaysClient client = mClient.getStub();
+
+ // Download these two pathways from WikiPathways by passing their id
+ WSPathway anchorPathway = new WSPathway();
+
+ try {
+ anchorPathway = client.getPathway(anchorPwID);
+
+ } catch (RemoteException e) {
+ Logger.log.error(
+ "Unable to get the pathway due to the RemoteException",
+ e);
+ } catch (ConverterException e) {
+ Logger.log
+ .error(
+ "Unable to get the pathway due to the ConverterException",
+ e);
+ }
+ // Create two corresponding pathway objects
+ mAnchorPw = new Pathway();
+
+ try {
+ mAnchorPw = WikiPathwaysClient.toPathway(anchorPathway);
+ } catch (ConverterException e) {
+ Logger.log.error(
+ "Unable to get the pathway due to the RemoteException",
+ e);
+ }
+
+ mNoGeneNode = 0;
+ for (PathwayElement pwElm : mAnchorPw.getDataObjects()) {
+ if (pwElm.getObjectType() == ObjectType.DATANODE) {
+ mNoGeneNode = mNoGeneNode + 1;
+
+ }
+ }
+
+ String[] temp = new String[mNoGeneNode];
+ for (int i = 1; i <= mNoGeneNode; i++) {
+ temp[i - 1] = String.valueOf(i);
+ }
+
+ upperBoundSharingNodeNoComboBox
+ .setModel(new javax.swing.DefaultComboBoxModel(temp));
+
+ }
+ }
+
+ private void MergeBtnActionPerformed(java.awt.event.ActionEvent evt) {
+ // SimpleCaseMergeTest test=new SimpleCaseMergeTest();
+
+ WikiPathwaysClient client = mClient.getStub();
+ SuperpathwaysPlugin spPlugin = SuperpathwaysPlugin.getInstance();
+ MergeTask task = new MergeTask(spPlugin, client);
+
+ // Configure JTask Dialog Pop-Up Box
+ final JTaskConfig jTaskConfig = new JTaskConfig();
+
+ jTaskConfig.displayCloseButton(true);
+ jTaskConfig.displayCancelButton(true);
+ jTaskConfig.displayStatus(true);
+ jTaskConfig.displayTimeElapsed(true);
+
+ jTaskConfig.setAutoDispose(false);
+ // jTaskConfig.setModal(true);
+ jTaskConfig.setModal(false);
+
+ // Execute Task in New Thread; pop open JTask Dialog Box.
+ TaskManager.executeTask(task, jTaskConfig);
+ if (task.isCancelled())
+ return;
+
+ }
+
+ // the code above is generated in Netbean IDE
+
+ protected void resetOrganisms() {
+ List organisms = new ArrayList();
+ organisms.add(ORGANISM_ALL);
+ try {
+ organisms.addAll(Arrays.asList(mClient.listOrganisms()));
+ } catch (Exception e) {
+ Logger.log.error("Unable to get organisms for WikiPathways client",
+ e);
+ }
+
+ organismCombo.setModel(new DefaultComboBoxModel(organisms.toArray()));
+ }
+
+ public void searchActionPerformed(java.awt.event.ActionEvent evt) {
+ // String action = e.getActionCommand();
+ // if(ACTION_SEARCH.equals(action)) {
+ FindPathwaysByTextParameters request = new FindPathwaysByTextParameters();
+ request.query = searchText.getText();
+ String org = organismCombo.getSelectedItem().toString();
+ if (!ORGANISM_ALL.equals(org)) {
+ request.species = Organism.fromLatinName(org);
+ }
+ try {
+ WebServiceClientManager
+ .getCyWebServiceEventSupport()
+ .fireCyWebServiceEvent(
+ new CyWebServiceEvent(
+ mClient.getClientID(),
+ WSEventType.SEARCH_DATABASE, request));
+
+ } catch (CyWebServiceException ex) {
+ switch (ex.getErrorCode()) {
+ case NO_RESULT:
+ JOptionPane.showMessageDialog(this,
+ "The search didn't return any results", "No results",
+ JOptionPane.INFORMATION_MESSAGE);
+ break;
+ case OPERATION_NOT_SUPPORTED:
+ case REMOTE_EXEC_FAILED:
+ JOptionPane.showMessageDialog(this, "Error: "
+ + ex.getErrorCode() + ". See log for details", "Error",
+ JOptionPane.ERROR_MESSAGE);
+ break;
+ }
+ ex.printStackTrace();
+ }
+ // }
+ }
+
+ private void openNetwork(ResultRow mSelected) {
+ try {
+ GetPathwayParameters request = new GetPathwayParameters();
+ WSSearchResult result = mSelected.getResult();
+ request.id = result.getId();
+ request.revision = Integer.parseInt(result.getRevision());
+ WebServiceClientManager.getCyWebServiceEventSupport()
+ .fireCyWebServiceEvent(
+ new CyWebServiceEvent(mClient.getClientID(),
+ WSEventType.IMPORT_NETWORK, request));
+ } catch (CyWebServiceException ex) {
+ JOptionPane.showMessageDialog(SuperpathwaysGui.this, "Error: "
+ + ex.getErrorCode() + ". See error log for details",
+ "Error", JOptionPane.ERROR_MESSAGE);
+ }
+ }
+
+ public void setResults(WSSearchResult[] results) {
+
+ tableModel = new ListWithPropertiesTableModel();
+ if (results != null) {
+ tableModel.setColumns(new ResultProperty[] { ResultProperty.NAME,
+ ResultProperty.ID, ResultProperty.ORGANISM, });
+
+ resultTable.setModel(tableModel);
+ for (WSSearchResult r : results) {
+ tableModel.addRow(new ResultRow(r));
+ }
+ }
+
+ sorter = new TableSorter(tableModel);
+ resultTable.setModel(sorter);
+ sorter.setTableHeader(resultTable.getTableHeader());
+
+ // resultTable.setModel(tableModel);
+ System.out.println("Superpathways!");
+
+ }
+
+ // private javax.swing.DefaultListModel availablePathwaysListModel;
+ // javax.swing.DefaultListModel availablePathwaysListModel;
+
+ // private javax.swing.DefaultListModel selectedPathwaysListModel;
+ javax.swing.DefaultListModel selectedPathwaysListModel;
+
+ private javax.swing.DefaultComboBoxModel anchorPathwayComboBoxModel;
+
+ // private javax.swing.DefaultListModel
+ // candidatePathwaysSharingNodesListModel;
+
+ private javax.swing.table.DefaultTableModel candidatePathwaysSharingNodesTableModel;
+
+ private TableSorter sorter;
+
+ private javax.swing.JButton ClearBtn;
+
+ private javax.swing.JButton CommonNodeViewBtn;
+
+ private javax.swing.JButton addBtn;
+
+ private javax.swing.JButton addHelpButton;
+
+ private javax.swing.JComboBox anchorPathwayComboBox;
+
+ private javax.swing.JLabel anchorPathwayLabel;
+
+ // private javax.swing.JLabel availablePathwaysLabel;
+
+ // private javax.swing.JList availablePathwaysList;
+ // javax.swing.JList availablePathwaysList;
+
+ // private javax.swing.JScrollPane availablePathwaysScrollPane;
+
+ private javax.swing.JButton backToSearchButton;
+
+ private javax.swing.JScrollPane candidatePathwaysSharingNodesScrollPane;
+
+ // private javax.swing.JList candidatePathwaysSharingNodesList;
+
+ private javax.swing.JLabel explainHelpLabel1;
+
+ private javax.swing.JLabel explainHelpLabel2;
+
+ private javax.swing.JPanel helpPanel;
+
+ private javax.swing.JLabel hintLabel1;
+
+ // private javax.swing.JButton leftButton;
+
+ private javax.swing.JLabel lowerBoundLabel;
+
+ private javax.swing.JComboBox lowerBoundSharingNodeNoComboBox;
+
+ private javax.swing.JButton findRelatedPwsBtn;
+
+ private javax.swing.JComboBox organismCombo;
+
+ private javax.swing.JScrollPane resultScrolllPane1;
+
+ private javax.swing.JTable resultTable;
+
+ // private javax.swing.JButton rightButton;
+ // javax.swing.JButton rightButton;
+
+ private javax.swing.JButton searchBtn;
+
+ private javax.swing.JPanel searchPane;
+
+ private javax.swing.JTextField searchText;
+
+ private javax.swing.JPanel selectPanel;
+
+ private javax.swing.JLabel selectedPathwaysLabel;
+
+ // private javax.swing.JList selectedPathwaysList;
+ javax.swing.JList selectedPathwaysList;
+
+ private javax.swing.JScrollPane selectedPathwaysScrollPane;
+
+ private javax.swing.JLabel sharingNodeNoLabel;
+
+ private javax.swing.JLabel stepLabel1;
+
+ private javax.swing.JLabel stepLabel2;
+
+ // private javax.swing.JTabbedPane superpathwayPanel;
+
+ private javax.swing.JLabel upperBoundLabel;
+
+ private javax.swing.JComboBox upperBoundSharingNodeNoComboBox;
+
+ private javax.swing.JButton searchHelpButton;
+
+ // private javax.swing.JButton helpButton;
+
+ private javax.swing.JLabel lastLabel;
+
+ private javax.swing.JTable candidatePathwaysSharingNodesTable;
+
+ private javax.swing.JScrollPane jScrollPane2;
+
+ private javax.swing.JButton MergeBtn;
+
+ private javax.swing.JButton removeBtn;
+
+ // private javax.swing.JList candidatePathwaysSharingNodesList;
+
+ // End of variables declaration
+ ListWithPropertiesTableModel tableModel;
+
+ class ResultRow implements RowWithProperties {
+ WSSearchResult result;
+
+ public ResultRow(WSSearchResult result) {
+ this.result = result;
+ }
+
+ public WSSearchResult getResult() {
+ return result;
+ }
+
+ public String getProperty(ResultProperty prop) {
+ switch (prop) {
+ case NAME:
+ return result.getName();
+ case ORGANISM:
+ return result.getSpecies();
+ case SCORE:
+ return Double.toString(result.getScore());
+ case URL:
+ return result.getUrl();
+ // helen add
+ case ID:
+ return result.getId();
+ }
+ return null;
+ }
+ }
+
+ public class searchSharingNodePwsTask implements Task {
+
+ TaskMonitor monitor;
+
+ int lowerBound;
+
+ int upperBound;
+
+ public searchSharingNodePwsTask(int lb, int ub) {
+ lowerBound = lb;
+ upperBound = ub;
+ }
+
+ /**
+ * Run the Task.
+ */
+ public void run() {
+
+ try {
+ mCandidatePw = new ArrayList();
+ if (lowerBound > upperBound) {
+ JOptionPane.showMessageDialog(helpPanel,
+ "Please reset the range of sharing nodes number!");
+ } else {
+
+ Map sharingNodeNumberofPws = new HashMap();
+ List geneIDList = new ArrayList();
+ int percentComplete = 0;
+ int t = 0;
+
+ // Create a client to the WikiPathways web service
+ WikiPathwaysClient client = mClient.getStub();
+
+ // the following code is get a map "mNodeIdToPwsSharingNode"
+ // with key of GeneID and value of a list of pathways which
+ // contain the GeneID
+ for (PathwayElement pwElm : mAnchorPw.getDataObjects()) {
+ // Only take elements with type DATANODE (genes,
+ // proteins, metabolites)
+ if (pwElm.getObjectType() == ObjectType.DATANODE) {
+
+ percentComplete = (int) (((double) t / mNoGeneNode) * 98);
+
+ // System.out.println(pwElm.getXref().toString());
+ geneIDList.add(pwElm.getXref().toString());
+
+ try {
+
+ WSSearchResult[] PwsSharingNode = client
+ .findPathwaysByXref(pwElm.getXref());
+ // System.out.println("" +
+ // PwsSharingNode.length);
+ mNodeIdToPwsSharingNode.put(pwElm.getXref()
+ .toString(), PwsSharingNode);
+
+ if (monitor != null) {
+ monitor
+ .setPercentCompleted(percentComplete);
+ }
+
+ } catch (RemoteException e) {
+ Logger.log
+ .error(
+ "Unable to find the candidate pathways due to the RemoteException",
+ e);
+ }
+ }
+ t++;
+
+ }
+
+ // the following code is for converting the above map to
+ // another map "sharingNodeNumberofPws" with key of
+ // the name and id of a pathway, and value of the number of
+ // shared node of this pathway and the anchor pathway
+ for (int i = 0; i < mNoGeneNode; i++) {
+ WSSearchResult[] pwsArray = mNodeIdToPwsSharingNode
+ .get(geneIDList.get(i));
+
+ for (int j = 0; j < pwsArray.length; j++) {
+ WSSearchResult pw = pwsArray[j];
+ ResultRow pwResultRow = new ResultRow(pw);
+ String onePwNameAndId = pwResultRow
+ .getProperty(ResultProperty.NAME)
+ + "("
+ + pwResultRow
+ .getProperty(ResultProperty.ID)
+ + ")";
+
+ if (sharingNodeNumberofPws
+ .containsKey(onePwNameAndId)) {
+ Integer oldValue = sharingNodeNumberofPws
+ .get(onePwNameAndId);
+ Integer newValue = new Integer(oldValue + 1);
+ sharingNodeNumberofPws.put(onePwNameAndId,
+ newValue);
+ } else {
+ sharingNodeNumberofPws.put(onePwNameAndId, 1);
+ }
+ }
+ }
+
+ // the following code is for displaying the result in the
+ // table of
+ // "Search Help" panel
+ Set sharingNodePwsSet = sharingNodeNumberofPws
+ .keySet();
+ Iterator it = sharingNodePwsSet.iterator();
+ while (it.hasNext()) {
+ String temp = it.next();
+ Integer value = sharingNodeNumberofPws.get(temp);
+ if (value >= lowerBound && value <= upperBound) {
+ mCandidatePw.add(temp + ", sharing node number: "
+ + String.valueOf(value));
+ }
+ }
+
+ }
+
+ if (monitor != null) {
+ monitor.setPercentCompleted(100);
+ }
+ // System.out.println("We reach here 2!");
+ } catch (Exception e) {
+ Logger.log.error("Error while searching candidate pathways", e);
+ JOptionPane.showMessageDialog(mClient.getGUI(), "Error: "
+ + e.getMessage() + ". See log for details", "Error",
+ JOptionPane.ERROR_MESSAGE);
+ }
+
+ }
+
+ public void halt() {
+ }
+
+ public void setTaskMonitor(TaskMonitor m)
+ throws IllegalThreadStateException {
+ monitor = m;
+ }
+
+ public String getTitle() {
+ return new String(
+ "Searching candidate pathways with shared nodes...");
+ }
+ }
+
+ public class commonNodeViewTask implements Task {
+
+ TaskMonitor monitor;
+
+ boolean cancelled;
+
+ // List selectedPwNameId;
+ SuperpathwaysClient client;
+
+ public commonNodeViewTask(SuperpathwaysClient b) {
+ // selectedPwNameId=a;
+ client = b;
+ cancelled = false;
+ }
+
+ public void run() {
+ try {
+
+ cnViewObject = new CommonNodeView(mSelectedPathwaysID,
+ mSelectedPathwayNameID, client);
+ cnViewObject.drawCommonNodeView();
+
+ // the following code is for printing out the matched node pair
+ // by translation
+ System.out
+ .println("printing out the matched node pair by translation");
+ Set s = cnViewObject.getNodePairByTranslation().keySet();
+ Iterator it = s.iterator();
+ while (it.hasNext()) {
+ Xref x1 = it.next();
+ Xref x2 = cnViewObject.getNodePairByTranslation().get(x1);
+ System.out
+ .println(x1.toString() + "======" + x2.toString());
+ }
+
+ } catch (Exception e) {
+ Logger.log.error("Error while searching candidate pathways", e);
+ JOptionPane.showMessageDialog(mClient.getGUI(), "Error: "
+ + e.getMessage() + ". See log for details", "Error",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+
+ public void halt() {
+ cancelled = true;
+ cnViewObject.interrupt();
+ }
+
+ public void setTaskMonitor(TaskMonitor m)
+ throws IllegalThreadStateException {
+ monitor = m;
+ }
+
+ public String getTitle() {
+ return new String("Generating common node view...");
+ }
+
+ }
+
+ class MergeTask implements Task {
+
+ TaskMonitor monitor;
+
+ boolean cancelled;
+
+ // PathwaysMerge pMerge;
+ SuperpathwaysPlugin spPlugin;
+
+ WikiPathwaysClient client;
+
+ /**
+ * Constructor.
+ *
+ */
+ public MergeTask(SuperpathwaysPlugin sp, WikiPathwaysClient c) {
+ cancelled = false;
+ spPlugin = sp;
+ client = c;
+ }
+
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ public void run() {
+
+ // if (cnViewObject==null){
+ // here we need to re-run the CommonNodeView to get the correct
+ // NodePairByTranslation, and colorPool
+
+ cnViewObject = new CommonNodeView(mSelectedPathwaysID,
+ mSelectedPathwayNameID, mClient);
+
+ pMerge = new PathwaysMerge(null, cnViewObject
+ .getNodePairByTranslation(), null);
+ // here we call the method drawCommonNodeView(), because we want to
+ // make the correspondance of the color between the common node view
+ // and the merged network
+
+ Map pwNameToColor = null;
+ if (!isCancelled()) {
+ try {
+ pwNameToColor = cnViewObject.drawCommonNodeView();
+ } catch (Exception e) {
+ Logger.log.error("Unable to draw common node view", e);
+ }
+
+ WSPathway wsPathway = new WSPathway();
+ Pathway pathway = new Pathway();
+ List listOfNetworks = new ArrayList();
+
+ for (int i = 0; i < selectedPathwaysListModel.getSize(); i++) {
+
+ System.out.println("in for loop: " + i + "");
+ String selectedOnePwNameID = (String) selectedPathwaysListModel
+ .get(i);
+ System.out.println(selectedOnePwNameID);
+ int index1 = selectedOnePwNameID.lastIndexOf("(");
+ int index2 = selectedOnePwNameID.lastIndexOf(")");
+ String pwID = selectedOnePwNameID.substring(index1 + 1,
+ index2);
+ String pwName = selectedOnePwNameID.substring(0, index1);
+ // System.out.println(pwID);
+ // System.out.println(pwName);
+
+ try {
+ wsPathway = client.getPathway(pwID);
+ pathway = WikiPathwaysClient.toPathway(wsPathway);
+ } catch (RemoteException e) {
+ Logger.log
+ .error(
+ "Unable to get the pathway due to the RemoteException",
+ e);
+ } catch (ConverterException e) {
+ Logger.log
+ .error(
+ "Unable to get the pathway due to the ConverterException",
+ e);
+ }
+
+ CyNetwork net = spPlugin.load(pathway, true);
+
+ // the following code is for coloring the nodes by default
+ if(pwNameToColor != null) applyGpmlVisualStyle(mClient.getPlugin().mGpmlHandler,
+ pwNameToColor, pwName, true,
+ superpathwaysVisualStyleCounter);
+
+ listOfNetworks.add(net);
+ }
+
+ // convert the array of type Color to an array of type String
+ String[] temp = new String[cnViewObject.getColorPool().size()];
+ Object[] colors = cnViewObject.getColorPool().toArray();
+ for (int s = 0; s < temp.length; s++) {
+ temp[s] = (String) colors[s];
+ }
+ System.out.println("Problem is here2!");
+ pMerge = new PathwaysMerge(listOfNetworks, cnViewObject
+ .getNodePairByTranslation(), temp);
+
+ try {
+ pMerge.setTaskMonitor(monitor);
+
+ CyNetwork mergedNetwork = pMerge.mergeNetwork(
+ "Merged Network", cnViewObject
+ .getNodePairByTranslation());
+ CyNetworkView view = Cytoscape
+ .createNetworkView(mergedNetwork);
+
+ superpathwaysVisualStyle vs = new superpathwaysVisualStyle(
+ "Merged Network", pwNameToColor,
+ superpathwaysVisualStyleCounter);
+ superpathwaysVisualStyleCounter++;
+
+ } catch (Exception e) {
+ monitor.setException(e, "Network Merge Failed!");
+ e.printStackTrace();
+ }
+
+ // the following code is for forcing detail rendering at any
+ // level of
+ // zoom
+ CyNetworkView currView = Cytoscape.getCurrentNetworkView();
+ ding.view.DGraphView nv;
+ nv = (DGraphView) currView;
+ nv.setGraphLOD(new CyGraphAllLOD());
+ }
+
+ }
+
+ public void halt() {
+ cancelled = true;
+ cnViewObject.interrupt();
+ pMerge.interrupt();
+ }
+
+ public void setTaskMonitor(TaskMonitor taskMonitor)
+ throws IllegalThreadStateException {
+ this.monitor = taskMonitor;
+ }
+
+ public String getTitle() {
+ return "Merging pathways";
+ }
+ }
+
+ public void applyGpmlVisualStyle(GpmlHandler gpmlHandler,
+ Map pwNameToColor, String t,
+ boolean coloringNodeInGpml, int version) {
+
+ if (coloringNodeInGpml == true) {
+ VisualMappingManager vmm = Cytoscape.getVisualMappingManager();
+ CalculatorCatalog catalog = vmm.getCalculatorCatalog();
+ // the next code line is used for fix the bug (when doing several
+ // merges)
+ // catalog.removeVisualStyle(gpmlExtendVisualStyle.NAME);
+
+ String styleName = gpmlExtendVisualStyle.NAME + "-"
+ + String.valueOf(version);
+ System.out.println("GPML-extention style name: " + styleName);
+
+ VisualStyle gpmlExtensionStyle = catalog.getVisualStyle(styleName);
+
+ if (gpmlExtensionStyle == null) { // Create the GPML visual style
+ Logger.log.trace("VisualStyle: creating GPML-extension style");
+ System.out.println(pwNameToColor.size() + "");
+ gpmlExtensionStyle = new gpmlExtendVisualStyle(gpmlHandler,
+ pwNameToColor, t, version);
+
+ // set the background color
+ GlobalAppearanceCalculator gCalc = gpmlExtensionStyle
+ .getGlobalAppearanceCalculator();
+ gCalc.setDefaultBackgroundColor(new Color(200, 200, 255));
+ vmm.applyGlobalAppearances();
+
+ catalog.addVisualStyle(gpmlExtensionStyle);
+ } else {
+ System.out.println("gpml-extension style is not null!");
+ Logger.log.trace("VisualStyle: reusing GPML-extension style");
+ }
+ System.out.println("Problem is here1!");
+ cytoscape.view.CyNetworkView networkView = Cytoscape
+ .getNetworkView(t);
+ networkView.setVisualStyle(gpmlExtensionStyle.getName());
+
+ // actually apply the visual style
+ vmm.setVisualStyle(gpmlExtensionStyle);
+ networkView.redrawGraph(true, true);
+ }
+ }
}
\ No newline at end of file
diff --git a/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/SuperpathwaysPlugin.java b/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/SuperpathwaysPlugin.java
index 67622d11..2171f862 100644
--- a/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/SuperpathwaysPlugin.java
+++ b/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/SuperpathwaysPlugin.java
@@ -1,245 +1,245 @@
-// PathVisio,
-// a tool for data visualization and analysis using Biological Pathways
-// Copyright 2006-2011 BiGCaT Bioinformatics
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-package org.pathvisio.cytoscape.superpathways;
-
-import java.awt.Component;
-import java.awt.event.ActionEvent;
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.swing.JFileChooser;
-import javax.swing.JFrame;
-import javax.swing.JOptionPane;
-import javax.swing.WindowConstants;
-
-import org.bridgedb.BridgeDb;
-import org.bridgedb.IDMapper;
-import org.bridgedb.IDMapperException;
-import org.bridgedb.IDMapperStack;
-import org.bridgedb.bio.BioDataSource;
-import org.bridgedb.bio.Organism;
-import org.pathvisio.core.debug.Logger;
-import org.pathvisio.core.model.Pathway;
-import org.pathvisio.core.preferences.GlobalPreference;
-import org.pathvisio.cytoscape.GpmlConverter;
-import org.pathvisio.cytoscape.GpmlHandler;
-
-import cytoscape.CyNetwork;
-import cytoscape.Cytoscape;
-import cytoscape.data.webservice.WebServiceClientManager;
-import cytoscape.plugin.CytoscapePlugin;
-import cytoscape.util.CytoscapeAction;
-import cytoscape.view.CyMenus;
-import cytoscape.view.CyNetworkView;
-import cytoscape.view.CytoscapeDesktop;
-
-public class SuperpathwaysPlugin extends CytoscapePlugin {
- //private static final int WINDOW_WIDTH = 400;
- //private static final int WINDOW_HEIGHT = 500;
-
- GpmlHandler mGpmlHandler;
- JFrame mWindow;
- private static SuperpathwaysPlugin mInstance;
- SuperpathwaysGui mSpGui;
-
- private String idmLocation = GlobalPreference.getDataDir().toString()
- + "/gene databases/";
- private Map idMappers = new HashMap();
-
- public static SuperpathwaysPlugin getInstance() {
- return mInstance;
- }
-
- public SuperpathwaysPlugin() {
- BioDataSource.init();
-
- if (mInstance != null) {
- throw new RuntimeException(
- "SuperpathwaysPlugin is already instantiated! Use static"
- + " method getInstance instead!");
- }
-
- mInstance = this;
- Logger.log.setLogLevel(true, false, true, true, true, true);
- mGpmlHandler = new GpmlHandler();
-
-
-
- SuperpathwaysPlugin spPlugin = SuperpathwaysPlugin.getInstance();
- SuperpathwaysClient spClient = new SuperpathwaysClient(spPlugin);
- WebServiceClientManager.registerClient(spClient);
- mSpGui = spClient.getGUI();
- //mSpGui.setLocationRelativeTo(Cytoscape.getDesktop());
-
- mWindow = new JFrame("Superpathways Plugin");
- //mWindow.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
- mWindow.add(mSpGui);
- mWindow.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
-
- SuperpathwaysAction action = new SuperpathwaysAction();
- action.setPreferredMenu("Plugins");
-
- CytoscapeDesktop desktop = Cytoscape.getDesktop();
- CyMenus menu = desktop.getCyMenus();
- menu.addAction(action);
-
-
- }
-
- public IDMapper getIDMapper(Organism organism) throws ClassNotFoundException, IDMapperException {
- Class.forName ("org.bridgedb.rdb.IDMapperRdb");
-
- IDMapper idm = idMappers.get(organism);
- if(idm == null) {
- IDMapperStack idms = new IDMapperStack();
- idm = idms;
- idMappers.put(organism, idm);
-
- //Try to find the available bridgedb databases, ask for location if necessary
- File[] idmFiles = new File(idmLocation).listFiles();
- boolean speciesFound = false;
-
- if(idmFiles != null) for(int i = 0; i < idmFiles.length; i++) {
- File file = idmFiles[i];
- if (file.isDirectory()) continue; // skip directories
- String fileName = file.getName();
- int index = fileName.indexOf("_");
- if (index < 0) continue; // Skip this file, not the pgdb naming scheme
- String prefix = fileName.substring(0, index);
- // System.out.println(speciesOrMetabolite);
- if (prefix.equals(organism.code())) {
- Logger.log.info("Connecting to idmapper " + file);
- idms.addIDMapper("idmapper-pgdb:" + file);
- speciesFound = true;
- } else if("metabolites".equals(prefix)) {
- Logger.log.info("Connecting to idmapper " + file);
- idms.addIDMapper("idmapper-pgdb:" + file);
- }
- }
-
- if (!speciesFound) {
- JOptionPane
- .showMessageDialog(
- mWindow,
- "Could not find bridgedb database for " + organism.latinName() + " in " + idmFiles + ". " +
- "\nPlease download the database from http://bridgedb.org and " +
- "point me to its location.");
-
- JFileChooser chooser = new JFileChooser();
- chooser.setCurrentDirectory(new java.io.File("."));
- chooser
- .setDialogTitle("Choose the bridgedb database for " + organism.latinName());
- chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
- if (chooser.showOpenDialog(mWindow) == JFileChooser.APPROVE_OPTION) {
- File file = chooser.getSelectedFile();
- if(file != null) {
- Logger.log.info("Connecting to idmapper " + file);
- idms.addIDMapper("idmapper-pgdb:" + file);
- idmLocation = file.getParent();
- }
- }
- }
- }
- return idm;
- }
-
- /*
- * public GpmlHandler getGpmlHandler() { return mGpmlHandler; }
- */
-
- public CyNetwork load(Pathway p, boolean newNetwork) {
- try {
- GpmlConverter converter = new GpmlConverter(mGpmlHandler, p);
-
- // Get the nodes/edges indexes
- int[] nodes = converter.getNodeIndicesArray();
- //System.out.println("There are " + nodes.length + " nodes in the pathway!");
- int[] edges = converter.getEdgeIndicesArray();
- //System.out.println("There are " + edges.length + " edges in the pathway!");
-
-
- // Get the current network, or create a new one, if none is
- // available
- CyNetwork network = Cytoscape.getCurrentNetwork();
- if (newNetwork || network == Cytoscape.getNullNetwork()) {
- String title = converter.getPathway().getMappInfo()
- .getMapInfoName();
- network = Cytoscape.createNetwork(title == null ? "new network"
- : title, false);
- }
-
- // Add all nodes and edges to the network
- for (int nd : nodes) {
- network.addNode(nd);
- }
- for (int ed : edges)
- network.addEdge(ed);
-
- CyNetworkView view = Cytoscape.getNetworkView(network
- .getIdentifier());
- if (view == Cytoscape.getNullNetworkView()) {
- view = Cytoscape.createNetworkView(network);
- Cytoscape.firePropertyChange(
- CytoscapeDesktop.NETWORK_VIEW_FOCUS, null, view
- .getIdentifier());
- } else {
- view = Cytoscape.getCurrentNetworkView();
- }
- converter.layout(view);
- view.redrawGraph(true, false);
-
- return network;
- } catch (Exception ex) {
- Logger.log.error("Error while importing GPML", ex);
- JOptionPane.showMessageDialog(Cytoscape.getDesktop(),
- "Error while importing GPML: " + ex.getMessage(), "Error",
- JOptionPane.ERROR_MESSAGE);
- }
- return null;
- }
-
- public static double mToV(double m) {
- return m;
- }
-
- public static double vToM(double v) {
- return v;
- }
-
- /**
- * This class gets attached to the menu item.
- */
- public class SuperpathwaysAction extends CytoscapeAction {
-
- public SuperpathwaysAction() {
- super("Superpathways");
- }
-
- public void actionPerformed(ActionEvent arg0) {
- mWindow.add(mSpGui);
- mWindow.setLocationRelativeTo(Cytoscape.getDesktop());
- mWindow.setVisible(true);
- mWindow.pack();
-
-
- }
-
- }
-
-}
+// PathVisio,
+// a tool for data visualization and analysis using Biological Pathways
+// Copyright 2006-2011 BiGCaT Bioinformatics
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package org.pathvisio.cytoscape.superpathways;
+
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JOptionPane;
+import javax.swing.WindowConstants;
+
+import org.bridgedb.BridgeDb;
+import org.bridgedb.IDMapper;
+import org.bridgedb.IDMapperException;
+import org.bridgedb.IDMapperStack;
+import org.bridgedb.bio.BioDataSource;
+import org.bridgedb.bio.Organism;
+import org.pathvisio.core.debug.Logger;
+import org.pathvisio.core.model.Pathway;
+import org.pathvisio.core.preferences.GlobalPreference;
+import org.pathvisio.cytoscape.GpmlConverter;
+import org.pathvisio.cytoscape.GpmlHandler;
+
+import cytoscape.CyNetwork;
+import cytoscape.Cytoscape;
+import cytoscape.data.webservice.WebServiceClientManager;
+import cytoscape.plugin.CytoscapePlugin;
+import cytoscape.util.CytoscapeAction;
+import cytoscape.view.CyMenus;
+import cytoscape.view.CyNetworkView;
+import cytoscape.view.CytoscapeDesktop;
+
+public class SuperpathwaysPlugin extends CytoscapePlugin {
+ //private static final int WINDOW_WIDTH = 400;
+ //private static final int WINDOW_HEIGHT = 500;
+
+ GpmlHandler mGpmlHandler;
+ JFrame mWindow;
+ private static SuperpathwaysPlugin mInstance;
+ SuperpathwaysGui mSpGui;
+
+ private String idmLocation = GlobalPreference.getDataDir().toString()
+ + "/gene databases/";
+ private Map idMappers = new HashMap();
+
+ public static SuperpathwaysPlugin getInstance() {
+ return mInstance;
+ }
+
+ public SuperpathwaysPlugin() {
+ BioDataSource.init();
+
+ if (mInstance != null) {
+ throw new RuntimeException(
+ "SuperpathwaysPlugin is already instantiated! Use static"
+ + " method getInstance instead!");
+ }
+
+ mInstance = this;
+ Logger.log.setLogLevel(true, false, true, true, true, true);
+ mGpmlHandler = new GpmlHandler();
+
+
+
+ SuperpathwaysPlugin spPlugin = SuperpathwaysPlugin.getInstance();
+ SuperpathwaysClient spClient = new SuperpathwaysClient(spPlugin);
+ WebServiceClientManager.registerClient(spClient);
+ mSpGui = spClient.getGUI();
+ //mSpGui.setLocationRelativeTo(Cytoscape.getDesktop());
+
+ mWindow = new JFrame("Superpathways Plugin");
+ //mWindow.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
+ mWindow.add(mSpGui);
+ mWindow.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+
+ SuperpathwaysAction action = new SuperpathwaysAction();
+ action.setPreferredMenu("Plugins");
+
+ CytoscapeDesktop desktop = Cytoscape.getDesktop();
+ CyMenus menu = desktop.getCyMenus();
+ menu.addAction(action);
+
+
+ }
+
+ public IDMapper getIDMapper(Organism organism) throws ClassNotFoundException, IDMapperException {
+ Class.forName ("org.bridgedb.rdb.IDMapperRdb");
+
+ IDMapper idm = idMappers.get(organism);
+ if(idm == null) {
+ IDMapperStack idms = new IDMapperStack();
+ idm = idms;
+ idMappers.put(organism, idm);
+
+ //Try to find the available bridgedb databases, ask for location if necessary
+ File[] idmFiles = new File(idmLocation).listFiles();
+ boolean speciesFound = false;
+
+ if(idmFiles != null) for(int i = 0; i < idmFiles.length; i++) {
+ File file = idmFiles[i];
+ if (file.isDirectory()) continue; // skip directories
+ String fileName = file.getName();
+ int index = fileName.indexOf("_");
+ if (index < 0) continue; // Skip this file, not the pgdb naming scheme
+ String prefix = fileName.substring(0, index);
+ // System.out.println(speciesOrMetabolite);
+ if (prefix.equals(organism.code())) {
+ Logger.log.info("Connecting to idmapper " + file);
+ idms.addIDMapper("idmapper-pgdb:" + file);
+ speciesFound = true;
+ } else if("metabolites".equals(prefix)) {
+ Logger.log.info("Connecting to idmapper " + file);
+ idms.addIDMapper("idmapper-pgdb:" + file);
+ }
+ }
+
+ if (!speciesFound) {
+ JOptionPane
+ .showMessageDialog(
+ mWindow,
+ "Could not find bridgedb database for " + organism.latinName() + " in " + idmFiles + ". " +
+ "\nPlease download the database from http://bridgedb.org and " +
+ "point me to its location.");
+
+ JFileChooser chooser = new JFileChooser();
+ chooser.setCurrentDirectory(new java.io.File("."));
+ chooser
+ .setDialogTitle("Choose the bridgedb database for " + organism.latinName());
+ chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ if (chooser.showOpenDialog(mWindow) == JFileChooser.APPROVE_OPTION) {
+ File file = chooser.getSelectedFile();
+ if(file != null) {
+ Logger.log.info("Connecting to idmapper " + file);
+ idms.addIDMapper("idmapper-pgdb:" + file);
+ idmLocation = file.getParent();
+ }
+ }
+ }
+ }
+ return idm;
+ }
+
+ /*
+ * public GpmlHandler getGpmlHandler() { return mGpmlHandler; }
+ */
+
+ public CyNetwork load(Pathway p, boolean newNetwork) {
+ try {
+ GpmlConverter converter = new GpmlConverter(mGpmlHandler, p);
+
+ // Get the nodes/edges indexes
+ int[] nodes = converter.getNodeIndicesArray();
+ //System.out.println("There are " + nodes.length + " nodes in the pathway!");
+ int[] edges = converter.getEdgeIndicesArray();
+ //System.out.println("There are " + edges.length + " edges in the pathway!");
+
+
+ // Get the current network, or create a new one, if none is
+ // available
+ CyNetwork network = Cytoscape.getCurrentNetwork();
+ if (newNetwork || network == Cytoscape.getNullNetwork()) {
+ String title = converter.getPathway().getMappInfo()
+ .getMapInfoName();
+ network = Cytoscape.createNetwork(title == null ? "new network"
+ : title, false);
+ }
+
+ // Add all nodes and edges to the network
+ for (int nd : nodes) {
+ network.addNode(nd);
+ }
+ for (int ed : edges)
+ network.addEdge(ed);
+
+ CyNetworkView view = Cytoscape.getNetworkView(network
+ .getIdentifier());
+ if (view == Cytoscape.getNullNetworkView()) {
+ view = Cytoscape.createNetworkView(network);
+ Cytoscape.firePropertyChange(
+ CytoscapeDesktop.NETWORK_VIEW_FOCUS, null, view
+ .getIdentifier());
+ } else {
+ view = Cytoscape.getCurrentNetworkView();
+ }
+ converter.layout(view);
+ view.redrawGraph(true, false);
+
+ return network;
+ } catch (Exception ex) {
+ Logger.log.error("Error while importing GPML", ex);
+ JOptionPane.showMessageDialog(Cytoscape.getDesktop(),
+ "Error while importing GPML: " + ex.getMessage(), "Error",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ return null;
+ }
+
+ public static double mToV(double m) {
+ return m;
+ }
+
+ public static double vToM(double v) {
+ return v;
+ }
+
+ /**
+ * This class gets attached to the menu item.
+ */
+ public class SuperpathwaysAction extends CytoscapeAction {
+
+ public SuperpathwaysAction() {
+ super("Superpathways");
+ }
+
+ public void actionPerformed(ActionEvent arg0) {
+ mWindow.add(mSpGui);
+ mWindow.setLocationRelativeTo(Cytoscape.getDesktop());
+ mWindow.setVisible(true);
+ mWindow.pack();
+
+
+ }
+
+ }
+
+}
diff --git a/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/TableSorter.java b/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/TableSorter.java
index 54be38db..9b09dd0f 100644
--- a/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/TableSorter.java
+++ b/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/TableSorter.java
@@ -1,502 +1,502 @@
-// PathVisio,
-// a tool for data visualization and analysis using Biological Pathways
-// Copyright 2006-2011 BiGCaT Bioinformatics
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-package org.pathvisio.cytoscape.superpathways;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.util.*;
-import java.util.List;
-
-import javax.swing.*;
-import javax.swing.event.TableModelEvent;
-import javax.swing.event.TableModelListener;
-import javax.swing.table.*;
-
-/**
-# * TableSorter is a decorator for TableModels; adding sorting
-# * functionality to a supplied TableModel. TableSorter does
-# * not store or copy the data in its TableModel; instead it maintains
-# * a map from the row indexes of the view to the row indexes of the
-# * model. As requests are made of the sorter (like getValueAt(row, col))
-# * they are passed to the underlying model after the row numbers
-# * have been translated via the internal mapping array. This way,
-# * the TableSorter appears to hold another copy of the table
-# * with the rows in a different order.
-# *
-# * TableSorter registers itself as a listener to the underlying model,
-# * just as the JTable itself would. Events recieved from the model
-# * are examined, sometimes manipulated (typically widened), and then
-# * passed on to the TableSorter's listeners (typically the JTable).
-# * If a change to the model has invalidated the order of TableSorter's
-# * rows, a note of this is made and the sorter will resort the
-# * rows the next time a value is requested.
-# *
-# * When the tableHeader property is set, either by using the
-# * setTableHeader() method or the two argument constructor, the
-# * table header may be used as a complete UI for TableSorter.
-# * The default renderer of the tableHeader is decorated with a renderer
-# * that indicates the sorting status of each column. In addition,
-# * a mouse listener is installed with the following behavior:
-# *
-# * -
-# * Mouse-click: Clears the sorting status of all other columns
-# * and advances the sorting status of that column through three
-# * values: {NOT_SORTED, ASCENDING, DESCENDING} (then back to
-# * NOT_SORTED again).
-# *
-
-# * SHIFT-mouse-click: Clears the sorting status of all other columns
-# * and cycles the sorting status of the column through the same
-# * three values, in the opposite order: {NOT_SORTED, DESCENDING, ASCENDING}.
-# *
-
-# * CONTROL-mouse-click and CONTROL-SHIFT-mouse-click: as above except
-# * that the changes to the column do not cancel the statuses of columns
-# * that are already sorting - giving a way to initiate a compound
-# * sort.
-# *
-# *
-# * This is a long overdue rewrite of a class of the same name that
-# * first appeared in the swing table demos in 1997.
-# *
-# * @author Philip Milne
-# * @author Brendon McLean
-# * @author Dan van Enckevort
-# * @author Parwinder Sekhon
-# * @version 2.0 02/27/04
-# */
-
-public class TableSorter extends AbstractTableModel {
- protected TableModel tableModel;
-
- public static final int DESCENDING = -1;
- public static final int NOT_SORTED = 0;
- public static final int ASCENDING = 1;
-
- private static Directive EMPTY_DIRECTIVE = new Directive(-1, NOT_SORTED);
-
- public static final Comparator COMPARABLE_COMAPRATOR = new Comparator() {
- public int compare(Object o1, Object o2) {
- return ((Comparable) o1).compareTo(o2);
- }
- };
- public static final Comparator LEXICAL_COMPARATOR = new Comparator() {
- public int compare(Object o1, Object o2) {
- return o1.toString().compareTo(o2.toString());
- }
- };
-
- private Row[] viewToModel;
- private int[] modelToView;
-
- private JTableHeader tableHeader;
- private MouseListener mouseListener;
- private TableModelListener tableModelListener;
- private Map columnComparators = new HashMap();
- private List sortingColumns = new ArrayList();
-
- public TableSorter() {
- this.mouseListener = new MouseHandler();
- this.tableModelListener = new TableModelHandler();
- }
-
- public TableSorter(TableModel tableModel) {
- this();
- setTableModel(tableModel);
- }
-
- public TableSorter(TableModel tableModel, JTableHeader tableHeader) {
- this();
- setTableHeader(tableHeader);
- setTableModel(tableModel);
- }
-
- private void clearSortingState() {
- viewToModel = null;
- modelToView = null;
- }
-
- public TableModel getTableModel() {
- return tableModel;
- }
-
- public void setTableModel(TableModel tableModel) {
- if (this.tableModel != null) {
- this.tableModel.removeTableModelListener(tableModelListener);
- }
-
- this.tableModel = tableModel;
- if (this.tableModel != null) {
- this.tableModel.addTableModelListener(tableModelListener);
- }
-
- clearSortingState();
- fireTableStructureChanged();
- }
-
- public JTableHeader getTableHeader() {
- return tableHeader;
- }
-
- public void setTableHeader(JTableHeader tableHeader) {
- if (this.tableHeader != null) {
- this.tableHeader.removeMouseListener(mouseListener);
- TableCellRenderer defaultRenderer = this.tableHeader.getDefaultRenderer();
- if (defaultRenderer instanceof SortableHeaderRenderer) {
- this.tableHeader.setDefaultRenderer(((SortableHeaderRenderer) defaultRenderer).tableCellRenderer);
- }
- }
- this.tableHeader = tableHeader;
- if (this.tableHeader != null) {
- this.tableHeader.addMouseListener(mouseListener);
- this.tableHeader.setDefaultRenderer(
- new SortableHeaderRenderer(this.tableHeader.getDefaultRenderer()));
- }
- }
-
- public boolean isSorting() {
- return sortingColumns.size() != 0;
- }
-
- private Directive getDirective(int column) {
- for (int i = 0; i < sortingColumns.size(); i++) {
- Directive directive = (Directive)sortingColumns.get(i);
- if (directive.column == column) {
- return directive;
- }
- }
- return EMPTY_DIRECTIVE;
- }
-
- public int getSortingStatus(int column) {
- return getDirective(column).direction;
- }
-
- private void sortingStatusChanged() {
- clearSortingState();
- fireTableDataChanged();
- if (tableHeader != null) {
- tableHeader.repaint();
- }
- }
-
- public void setSortingStatus(int column, int status) {
- Directive directive = getDirective(column);
- if (directive != EMPTY_DIRECTIVE) {
- sortingColumns.remove(directive);
- }
- if (status != NOT_SORTED) {
- sortingColumns.add(new Directive(column, status));
- }
- sortingStatusChanged();
- }
-
- protected Icon getHeaderRendererIcon(int column, int size) {
- Directive directive = getDirective(column);
- if (directive == EMPTY_DIRECTIVE) {
- return null;
- }
- return new Arrow(directive.direction == DESCENDING, size, sortingColumns.indexOf(directive));
- }
-
- private void cancelSorting() {
- sortingColumns.clear();
- sortingStatusChanged();
- }
-
- public void setColumnComparator(Class type, Comparator comparator) {
- if (comparator == null) {
- columnComparators.remove(type);
- } else {
- columnComparators.put(type, comparator);
- }
- }
-
- protected Comparator getComparator(int column) {
- //System.out.println(column+"");
- Class columnType = tableModel.getColumnClass(column);
- //System.out.println(columnType+"");
- Comparator comparator = (Comparator) columnComparators.get(columnType);
- if (comparator != null) {
- return comparator;
- }
- if (Comparable.class.isAssignableFrom(columnType)) {
- return COMPARABLE_COMAPRATOR;
- }
- return LEXICAL_COMPARATOR;
- }
-
- private Row[] getViewToModel() {
- if (viewToModel == null) {
- int tableModelRowCount = tableModel.getRowCount();
- viewToModel = new Row[tableModelRowCount];
- for (int row = 0; row < tableModelRowCount; row++) {
- viewToModel[row] = new Row(row);
- }
-
- if (isSorting()) {
- Arrays.sort(viewToModel);
- }
- }
- return viewToModel;
- }
-
- public int modelIndex(int viewIndex) {
- return getViewToModel()[viewIndex].modelIndex;
- }
-
- private int[] getModelToView() {
- if (modelToView == null) {
- int n = getViewToModel().length;
- modelToView = new int[n];
- for (int i = 0; i < n; i++) {
- modelToView[modelIndex(i)] = i;
- }
- }
- return modelToView;
- }
-
- // TableModel interface methods
-
- public int getRowCount() {
- return (tableModel == null) ? 0 : tableModel.getRowCount();
- }
-
- public int getColumnCount() {
- return (tableModel == null) ? 0 : tableModel.getColumnCount();
- }
-
- public String getColumnName(int column) {
- return tableModel.getColumnName(column);
- }
-
- public Class getColumnClass(int column) {
- return tableModel.getColumnClass(column);
- }
-
- public boolean isCellEditable(int row, int column) {
- return tableModel.isCellEditable(modelIndex(row), column);
- }
-
- public Object getValueAt(int row, int column) {
- return tableModel.getValueAt(modelIndex(row), column);
- }
-
- public void setValueAt(Object aValue, int row, int column) {
- tableModel.setValueAt(aValue, modelIndex(row), column);
- }
-
- // Helper classes
-
- private class Row implements Comparable {
- private int modelIndex;
-
- public Row(int index) {
- this.modelIndex = index;
- }
-
- public int compareTo(Object o) {
- int row1 = modelIndex;
- int row2 = ((Row) o).modelIndex;
-
- for (Iterator it = sortingColumns.iterator(); it.hasNext();) {
- Directive directive = (Directive) it.next();
- int column = directive.column;
- Object o1 = tableModel.getValueAt(row1, column);
- Object o2 = tableModel.getValueAt(row2, column);
-
- int comparison = 0;
- // Define null less than everything, except null.
- if (o1 == null && o2 == null) {
- comparison = 0;
- } else if (o1 == null) {
- comparison = -1;
- } else if (o2 == null) {
- comparison = 1;
- } else {
- comparison = getComparator(column).compare(o1, o2);
- }
- if (comparison != 0) {
- return directive.direction == DESCENDING ? -comparison : comparison;
- }
- }
- return 0;
- }
- }
-
- private class TableModelHandler implements TableModelListener {
- public void tableChanged(TableModelEvent e) {
- // If we're not sorting by anything, just pass the event along.
- if (!isSorting()) {
- clearSortingState();
- fireTableChanged(e);
- return;
- }
-
- // If the table structure has changed, cancel the sorting; the
- // sorting columns may have been either moved or deleted from
- // the model.
- if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
- cancelSorting();
- fireTableChanged(e);
- return;
- }
-
- // We can map a cell event through to the view without widening
- // when the following conditions apply:
- //
- // a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and,
- // b) all the changes are in one column (column != TableModelEvent.ALL_COLUMNS) and,
- // c) we are not sorting on that column (getSortingStatus(column) == NOT_SORTED) and,
- // d) a reverse lookup will not trigger a sort (modelToView != null)
- //
- // Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS.
- //
- // The last check, for (modelToView != null) is to see if modelToView
- // is already allocated. If we don't do this check; sorting can become
- // a performance bottleneck for applications where cells
- // change rapidly in different parts of the table. If cells
- // change alternately in the sorting column and then outside of
- // it this class can end up re-sorting on alternate cell updates -
- // which can be a performance problem for large tables. The last
- // clause avoids this problem.
- int column = e.getColumn();
- if (e.getFirstRow() == e.getLastRow()
- && column != TableModelEvent.ALL_COLUMNS
- && getSortingStatus(column) == NOT_SORTED
- && modelToView != null) {
- int viewIndex = getModelToView()[e.getFirstRow()];
- fireTableChanged(new TableModelEvent(TableSorter.this,
- viewIndex, viewIndex,
- column, e.getType()));
- return;
- }
-
- // Something has happened to the data that may have invalidated the row order.
- clearSortingState();
- fireTableDataChanged();
- return;
- }
- }
-
- private class MouseHandler extends MouseAdapter {
- public void mouseClicked(MouseEvent e) {
- JTableHeader h = (JTableHeader) e.getSource();
- TableColumnModel columnModel = h.getColumnModel();
- int viewColumn = columnModel.getColumnIndexAtX(e.getX());
- int column = columnModel.getColumn(viewColumn).getModelIndex();
- if (column != -1) {
- int status = getSortingStatus(column);
- if (!e.isControlDown()) {
- cancelSorting();
- }
- // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or
- // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed.
- status = status + (e.isShiftDown() ? -1 : 1);
- status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1}
- setSortingStatus(column, status);
- }
- }
- }
-
- private static class Arrow implements Icon {
- private boolean descending;
- private int size;
- private int priority;
-
- public Arrow(boolean descending, int size, int priority) {
- this.descending = descending;
- this.size = size;
- this.priority = priority;
- }
-
- public void paintIcon(Component c, Graphics g, int x, int y) {
- Color color = c == null ? Color.GRAY : c.getBackground();
- // In a compound sort, make each succesive triangle 20%
- // smaller than the previous one.
- int dx = (int)(size/2*Math.pow(0.8, priority));
- int dy = descending ? dx : -dx;
- // Align icon (roughly) with font baseline.
- y = y + 5*size/6 + (descending ? -dy : 0);
- int shift = descending ? 1 : -1;
- g.translate(x, y);
-
- // Right diagonal.
- g.setColor(color.darker());
- g.drawLine(dx / 2, dy, 0, 0);
- g.drawLine(dx / 2, dy + shift, 0, shift);
-
- // Left diagonal.
- g.setColor(color.brighter());
- g.drawLine(dx / 2, dy, dx, 0);
- g.drawLine(dx / 2, dy + shift, dx, shift);
-
- // Horizontal line.
- if (descending) {
- g.setColor(color.darker().darker());
- } else {
- g.setColor(color.brighter().brighter());
- }
- g.drawLine(dx, 0, 0, 0);
-
- g.setColor(color);
- g.translate(-x, -y);
- }
-
- public int getIconWidth() {
- return size;
- }
-
- public int getIconHeight() {
- return size;
- }
- }
-
- private class SortableHeaderRenderer implements TableCellRenderer {
- private TableCellRenderer tableCellRenderer;
-
- public SortableHeaderRenderer(TableCellRenderer tableCellRenderer) {
- this.tableCellRenderer = tableCellRenderer;
- }
-
- public Component getTableCellRendererComponent(JTable table,
- Object value,
- boolean isSelected,
- boolean hasFocus,
- int row,
- int column) {
- Component c = tableCellRenderer.getTableCellRendererComponent(table,
- value, isSelected, hasFocus, row, column);
- if (c instanceof JLabel) {
- JLabel l = (JLabel) c;
- l.setHorizontalTextPosition(JLabel.LEFT);
- int modelColumn = table.convertColumnIndexToModel(column);
- l.setIcon(getHeaderRendererIcon(modelColumn, l.getFont().getSize()));
- }
- return c;
- }
- }
-
- private static class Directive {
- private int column;
- private int direction;
-
- public Directive(int column, int direction) {
- this.column = column;
- this.direction = direction;
- }
- }
+// PathVisio,
+// a tool for data visualization and analysis using Biological Pathways
+// Copyright 2006-2011 BiGCaT Bioinformatics
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package org.pathvisio.cytoscape.superpathways;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.*;
+import java.util.List;
+
+import javax.swing.*;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+import javax.swing.table.*;
+
+/**
+# * TableSorter is a decorator for TableModels; adding sorting
+# * functionality to a supplied TableModel. TableSorter does
+# * not store or copy the data in its TableModel; instead it maintains
+# * a map from the row indexes of the view to the row indexes of the
+# * model. As requests are made of the sorter (like getValueAt(row, col))
+# * they are passed to the underlying model after the row numbers
+# * have been translated via the internal mapping array. This way,
+# * the TableSorter appears to hold another copy of the table
+# * with the rows in a different order.
+# *
+# * TableSorter registers itself as a listener to the underlying model,
+# * just as the JTable itself would. Events recieved from the model
+# * are examined, sometimes manipulated (typically widened), and then
+# * passed on to the TableSorter's listeners (typically the JTable).
+# * If a change to the model has invalidated the order of TableSorter's
+# * rows, a note of this is made and the sorter will resort the
+# * rows the next time a value is requested.
+# *
+# * When the tableHeader property is set, either by using the
+# * setTableHeader() method or the two argument constructor, the
+# * table header may be used as a complete UI for TableSorter.
+# * The default renderer of the tableHeader is decorated with a renderer
+# * that indicates the sorting status of each column. In addition,
+# * a mouse listener is installed with the following behavior:
+# *
+# * -
+# * Mouse-click: Clears the sorting status of all other columns
+# * and advances the sorting status of that column through three
+# * values: {NOT_SORTED, ASCENDING, DESCENDING} (then back to
+# * NOT_SORTED again).
+# *
-
+# * SHIFT-mouse-click: Clears the sorting status of all other columns
+# * and cycles the sorting status of the column through the same
+# * three values, in the opposite order: {NOT_SORTED, DESCENDING, ASCENDING}.
+# *
-
+# * CONTROL-mouse-click and CONTROL-SHIFT-mouse-click: as above except
+# * that the changes to the column do not cancel the statuses of columns
+# * that are already sorting - giving a way to initiate a compound
+# * sort.
+# *
+# *
+# * This is a long overdue rewrite of a class of the same name that
+# * first appeared in the swing table demos in 1997.
+# *
+# * @author Philip Milne
+# * @author Brendon McLean
+# * @author Dan van Enckevort
+# * @author Parwinder Sekhon
+# * @version 2.0 02/27/04
+# */
+
+public class TableSorter extends AbstractTableModel {
+ protected TableModel tableModel;
+
+ public static final int DESCENDING = -1;
+ public static final int NOT_SORTED = 0;
+ public static final int ASCENDING = 1;
+
+ private static Directive EMPTY_DIRECTIVE = new Directive(-1, NOT_SORTED);
+
+ public static final Comparator COMPARABLE_COMAPRATOR = new Comparator() {
+ public int compare(Object o1, Object o2) {
+ return ((Comparable) o1).compareTo(o2);
+ }
+ };
+ public static final Comparator LEXICAL_COMPARATOR = new Comparator() {
+ public int compare(Object o1, Object o2) {
+ return o1.toString().compareTo(o2.toString());
+ }
+ };
+
+ private Row[] viewToModel;
+ private int[] modelToView;
+
+ private JTableHeader tableHeader;
+ private MouseListener mouseListener;
+ private TableModelListener tableModelListener;
+ private Map columnComparators = new HashMap();
+ private List sortingColumns = new ArrayList();
+
+ public TableSorter() {
+ this.mouseListener = new MouseHandler();
+ this.tableModelListener = new TableModelHandler();
+ }
+
+ public TableSorter(TableModel tableModel) {
+ this();
+ setTableModel(tableModel);
+ }
+
+ public TableSorter(TableModel tableModel, JTableHeader tableHeader) {
+ this();
+ setTableHeader(tableHeader);
+ setTableModel(tableModel);
+ }
+
+ private void clearSortingState() {
+ viewToModel = null;
+ modelToView = null;
+ }
+
+ public TableModel getTableModel() {
+ return tableModel;
+ }
+
+ public void setTableModel(TableModel tableModel) {
+ if (this.tableModel != null) {
+ this.tableModel.removeTableModelListener(tableModelListener);
+ }
+
+ this.tableModel = tableModel;
+ if (this.tableModel != null) {
+ this.tableModel.addTableModelListener(tableModelListener);
+ }
+
+ clearSortingState();
+ fireTableStructureChanged();
+ }
+
+ public JTableHeader getTableHeader() {
+ return tableHeader;
+ }
+
+ public void setTableHeader(JTableHeader tableHeader) {
+ if (this.tableHeader != null) {
+ this.tableHeader.removeMouseListener(mouseListener);
+ TableCellRenderer defaultRenderer = this.tableHeader.getDefaultRenderer();
+ if (defaultRenderer instanceof SortableHeaderRenderer) {
+ this.tableHeader.setDefaultRenderer(((SortableHeaderRenderer) defaultRenderer).tableCellRenderer);
+ }
+ }
+ this.tableHeader = tableHeader;
+ if (this.tableHeader != null) {
+ this.tableHeader.addMouseListener(mouseListener);
+ this.tableHeader.setDefaultRenderer(
+ new SortableHeaderRenderer(this.tableHeader.getDefaultRenderer()));
+ }
+ }
+
+ public boolean isSorting() {
+ return sortingColumns.size() != 0;
+ }
+
+ private Directive getDirective(int column) {
+ for (int i = 0; i < sortingColumns.size(); i++) {
+ Directive directive = (Directive)sortingColumns.get(i);
+ if (directive.column == column) {
+ return directive;
+ }
+ }
+ return EMPTY_DIRECTIVE;
+ }
+
+ public int getSortingStatus(int column) {
+ return getDirective(column).direction;
+ }
+
+ private void sortingStatusChanged() {
+ clearSortingState();
+ fireTableDataChanged();
+ if (tableHeader != null) {
+ tableHeader.repaint();
+ }
+ }
+
+ public void setSortingStatus(int column, int status) {
+ Directive directive = getDirective(column);
+ if (directive != EMPTY_DIRECTIVE) {
+ sortingColumns.remove(directive);
+ }
+ if (status != NOT_SORTED) {
+ sortingColumns.add(new Directive(column, status));
+ }
+ sortingStatusChanged();
+ }
+
+ protected Icon getHeaderRendererIcon(int column, int size) {
+ Directive directive = getDirective(column);
+ if (directive == EMPTY_DIRECTIVE) {
+ return null;
+ }
+ return new Arrow(directive.direction == DESCENDING, size, sortingColumns.indexOf(directive));
+ }
+
+ private void cancelSorting() {
+ sortingColumns.clear();
+ sortingStatusChanged();
+ }
+
+ public void setColumnComparator(Class type, Comparator comparator) {
+ if (comparator == null) {
+ columnComparators.remove(type);
+ } else {
+ columnComparators.put(type, comparator);
+ }
+ }
+
+ protected Comparator getComparator(int column) {
+ //System.out.println(column+"");
+ Class columnType = tableModel.getColumnClass(column);
+ //System.out.println(columnType+"");
+ Comparator comparator = (Comparator) columnComparators.get(columnType);
+ if (comparator != null) {
+ return comparator;
+ }
+ if (Comparable.class.isAssignableFrom(columnType)) {
+ return COMPARABLE_COMAPRATOR;
+ }
+ return LEXICAL_COMPARATOR;
+ }
+
+ private Row[] getViewToModel() {
+ if (viewToModel == null) {
+ int tableModelRowCount = tableModel.getRowCount();
+ viewToModel = new Row[tableModelRowCount];
+ for (int row = 0; row < tableModelRowCount; row++) {
+ viewToModel[row] = new Row(row);
+ }
+
+ if (isSorting()) {
+ Arrays.sort(viewToModel);
+ }
+ }
+ return viewToModel;
+ }
+
+ public int modelIndex(int viewIndex) {
+ return getViewToModel()[viewIndex].modelIndex;
+ }
+
+ private int[] getModelToView() {
+ if (modelToView == null) {
+ int n = getViewToModel().length;
+ modelToView = new int[n];
+ for (int i = 0; i < n; i++) {
+ modelToView[modelIndex(i)] = i;
+ }
+ }
+ return modelToView;
+ }
+
+ // TableModel interface methods
+
+ public int getRowCount() {
+ return (tableModel == null) ? 0 : tableModel.getRowCount();
+ }
+
+ public int getColumnCount() {
+ return (tableModel == null) ? 0 : tableModel.getColumnCount();
+ }
+
+ public String getColumnName(int column) {
+ return tableModel.getColumnName(column);
+ }
+
+ public Class getColumnClass(int column) {
+ return tableModel.getColumnClass(column);
+ }
+
+ public boolean isCellEditable(int row, int column) {
+ return tableModel.isCellEditable(modelIndex(row), column);
+ }
+
+ public Object getValueAt(int row, int column) {
+ return tableModel.getValueAt(modelIndex(row), column);
+ }
+
+ public void setValueAt(Object aValue, int row, int column) {
+ tableModel.setValueAt(aValue, modelIndex(row), column);
+ }
+
+ // Helper classes
+
+ private class Row implements Comparable {
+ private int modelIndex;
+
+ public Row(int index) {
+ this.modelIndex = index;
+ }
+
+ public int compareTo(Object o) {
+ int row1 = modelIndex;
+ int row2 = ((Row) o).modelIndex;
+
+ for (Iterator it = sortingColumns.iterator(); it.hasNext();) {
+ Directive directive = (Directive) it.next();
+ int column = directive.column;
+ Object o1 = tableModel.getValueAt(row1, column);
+ Object o2 = tableModel.getValueAt(row2, column);
+
+ int comparison = 0;
+ // Define null less than everything, except null.
+ if (o1 == null && o2 == null) {
+ comparison = 0;
+ } else if (o1 == null) {
+ comparison = -1;
+ } else if (o2 == null) {
+ comparison = 1;
+ } else {
+ comparison = getComparator(column).compare(o1, o2);
+ }
+ if (comparison != 0) {
+ return directive.direction == DESCENDING ? -comparison : comparison;
+ }
+ }
+ return 0;
+ }
+ }
+
+ private class TableModelHandler implements TableModelListener {
+ public void tableChanged(TableModelEvent e) {
+ // If we're not sorting by anything, just pass the event along.
+ if (!isSorting()) {
+ clearSortingState();
+ fireTableChanged(e);
+ return;
+ }
+
+ // If the table structure has changed, cancel the sorting; the
+ // sorting columns may have been either moved or deleted from
+ // the model.
+ if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
+ cancelSorting();
+ fireTableChanged(e);
+ return;
+ }
+
+ // We can map a cell event through to the view without widening
+ // when the following conditions apply:
+ //
+ // a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and,
+ // b) all the changes are in one column (column != TableModelEvent.ALL_COLUMNS) and,
+ // c) we are not sorting on that column (getSortingStatus(column) == NOT_SORTED) and,
+ // d) a reverse lookup will not trigger a sort (modelToView != null)
+ //
+ // Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS.
+ //
+ // The last check, for (modelToView != null) is to see if modelToView
+ // is already allocated. If we don't do this check; sorting can become
+ // a performance bottleneck for applications where cells
+ // change rapidly in different parts of the table. If cells
+ // change alternately in the sorting column and then outside of
+ // it this class can end up re-sorting on alternate cell updates -
+ // which can be a performance problem for large tables. The last
+ // clause avoids this problem.
+ int column = e.getColumn();
+ if (e.getFirstRow() == e.getLastRow()
+ && column != TableModelEvent.ALL_COLUMNS
+ && getSortingStatus(column) == NOT_SORTED
+ && modelToView != null) {
+ int viewIndex = getModelToView()[e.getFirstRow()];
+ fireTableChanged(new TableModelEvent(TableSorter.this,
+ viewIndex, viewIndex,
+ column, e.getType()));
+ return;
+ }
+
+ // Something has happened to the data that may have invalidated the row order.
+ clearSortingState();
+ fireTableDataChanged();
+ return;
+ }
+ }
+
+ private class MouseHandler extends MouseAdapter {
+ public void mouseClicked(MouseEvent e) {
+ JTableHeader h = (JTableHeader) e.getSource();
+ TableColumnModel columnModel = h.getColumnModel();
+ int viewColumn = columnModel.getColumnIndexAtX(e.getX());
+ int column = columnModel.getColumn(viewColumn).getModelIndex();
+ if (column != -1) {
+ int status = getSortingStatus(column);
+ if (!e.isControlDown()) {
+ cancelSorting();
+ }
+ // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or
+ // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed.
+ status = status + (e.isShiftDown() ? -1 : 1);
+ status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1}
+ setSortingStatus(column, status);
+ }
+ }
+ }
+
+ private static class Arrow implements Icon {
+ private boolean descending;
+ private int size;
+ private int priority;
+
+ public Arrow(boolean descending, int size, int priority) {
+ this.descending = descending;
+ this.size = size;
+ this.priority = priority;
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ Color color = c == null ? Color.GRAY : c.getBackground();
+ // In a compound sort, make each succesive triangle 20%
+ // smaller than the previous one.
+ int dx = (int)(size/2*Math.pow(0.8, priority));
+ int dy = descending ? dx : -dx;
+ // Align icon (roughly) with font baseline.
+ y = y + 5*size/6 + (descending ? -dy : 0);
+ int shift = descending ? 1 : -1;
+ g.translate(x, y);
+
+ // Right diagonal.
+ g.setColor(color.darker());
+ g.drawLine(dx / 2, dy, 0, 0);
+ g.drawLine(dx / 2, dy + shift, 0, shift);
+
+ // Left diagonal.
+ g.setColor(color.brighter());
+ g.drawLine(dx / 2, dy, dx, 0);
+ g.drawLine(dx / 2, dy + shift, dx, shift);
+
+ // Horizontal line.
+ if (descending) {
+ g.setColor(color.darker().darker());
+ } else {
+ g.setColor(color.brighter().brighter());
+ }
+ g.drawLine(dx, 0, 0, 0);
+
+ g.setColor(color);
+ g.translate(-x, -y);
+ }
+
+ public int getIconWidth() {
+ return size;
+ }
+
+ public int getIconHeight() {
+ return size;
+ }
+ }
+
+ private class SortableHeaderRenderer implements TableCellRenderer {
+ private TableCellRenderer tableCellRenderer;
+
+ public SortableHeaderRenderer(TableCellRenderer tableCellRenderer) {
+ this.tableCellRenderer = tableCellRenderer;
+ }
+
+ public Component getTableCellRendererComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ boolean hasFocus,
+ int row,
+ int column) {
+ Component c = tableCellRenderer.getTableCellRendererComponent(table,
+ value, isSelected, hasFocus, row, column);
+ if (c instanceof JLabel) {
+ JLabel l = (JLabel) c;
+ l.setHorizontalTextPosition(JLabel.LEFT);
+ int modelColumn = table.convertColumnIndexToModel(column);
+ l.setIcon(getHeaderRendererIcon(modelColumn, l.getFont().getSize()));
+ }
+ return c;
+ }
+ }
+
+ private static class Directive {
+ private int column;
+ private int direction;
+
+ public Directive(int column, int direction) {
+ this.column = column;
+ this.direction = direction;
+ }
+ }
}
\ No newline at end of file
diff --git a/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/gpmlExtendVisualStyle.java b/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/gpmlExtendVisualStyle.java
index 6191b61a..edd13692 100644
--- a/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/gpmlExtendVisualStyle.java
+++ b/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/gpmlExtendVisualStyle.java
@@ -1,322 +1,322 @@
-// PathVisio,
-// a tool for data visualization and analysis using Biological Pathways
-// Copyright 2006-2011 BiGCaT Bioinformatics
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-package org.pathvisio.cytoscape.superpathways;
-
-import java.awt.Color;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.pathvisio.core.model.LineStyle;
-import org.pathvisio.core.model.LineType;
-import org.pathvisio.core.model.ObjectType;
-import org.pathvisio.core.model.StaticProperty;
-import org.pathvisio.cytoscape.AttributeMapper;
-import org.pathvisio.cytoscape.GpmlAnchorNode;
-import org.pathvisio.cytoscape.GpmlHandler;
-import org.pathvisio.cytoscape.GpmlNetworkElement;
-import org.pathvisio.cytoscape.visualmapping.GpmlColorMapper;
-
-import cytoscape.CyNetwork;
-import cytoscape.Cytoscape;
-import cytoscape.visual.ArrowShape;
-import cytoscape.visual.EdgeAppearanceCalculator;
-import cytoscape.visual.GlobalAppearanceCalculator;
-import cytoscape.visual.NodeAppearance;
-import cytoscape.visual.NodeAppearanceCalculator;
-import cytoscape.visual.NodeShape;
-import cytoscape.visual.VisualMappingManager;
-import cytoscape.visual.VisualPropertyType;
-import cytoscape.visual.VisualStyle;
-import cytoscape.visual.calculators.BasicCalculator;
-import cytoscape.visual.calculators.Calculator;
-import cytoscape.visual.mappings.DiscreteMapping;
-import cytoscape.visual.mappings.ObjectMapping;
-import cytoscape.visual.mappings.PassThroughMapping;
-
-public class gpmlExtendVisualStyle extends VisualStyle {
- public static final String NAME = "GPML-extension";
-
- GpmlHandler gpmlHandler;
- AttributeMapper attrMapper;
-
- NodeAppearanceCalculator nac;
- EdgeAppearanceCalculator eac;
-
- Map pwNameToColor;
- String title;
-
-
- public gpmlExtendVisualStyle(GpmlHandler gpmlHandler, VisualStyle toCopy, Map map, String t) {
- super(toCopy);
- setName(NAME);
- init(gpmlHandler);
- pwNameToColor=map;
- title=t;
- }
-
- public gpmlExtendVisualStyle(GpmlHandler gpmlHandler, Map map, String t, int version) {
- super(NAME+"-"+String.valueOf(version));
- pwNameToColor=map;
- title=t;
-
- init(gpmlHandler);
-
- }
-
- private void init(GpmlHandler gh) {
- this.gpmlHandler = gh;
- attrMapper = gpmlHandler.getAttributeMapper();
-
- nac = getNodeAppearanceCalculator();
- eac = getEdgeAppearanceCalculator();
-
- VisualMappingManager vm = Cytoscape.getVisualMappingManager();
- VisualStyle currentStyle = vm.getVisualStyle();
-
- if(nac == null) {
- nac = new NodeAppearanceCalculator(currentStyle.getNodeAppearanceCalculator());
- setNodeAppearanceCalculator(nac);
- }
- if(eac == null) {
- eac = new EdgeAppearanceCalculator(currentStyle.getEdgeAppearanceCalculator());
- setEdgeAppearanceCalculator(eac);
- }
-
-
- setColorMapping();
- setLabelMapping();
- setTypeMapping();
- setArrowMapping();
- setLineTypeMapping();
- setNodeShapeMapping();
- setNodeColorMapping(title, pwNameToColor);
- }
-
- void setNodeShapeMapping() {
- getNodeAppearanceCalculator().setNodeSizeLocked(false);
- NodeAppearance nd = nac.getDefaultAppearance();
- nd.set(VisualPropertyType.NODE_SHAPE, NodeShape.RECT);
- nd.set(VisualPropertyType.NODE_WIDTH, 80);
- nd.set(VisualPropertyType.NODE_HEIGHT, 20);
-
- DiscreteMapping widthMapping = new DiscreteMapping(
- nac.getDefaultAppearance().get(VisualPropertyType.NODE_WIDTH),
- GpmlNetworkElement.ATTR_TYPE,
- ObjectMapping.NODE_MAPPING
- );
- widthMapping.putMapValue(ObjectType.GROUP.ordinal(), 5);
- widthMapping.putMapValue(GpmlAnchorNode.TYPE_ANCHOR, 5);
- DiscreteMapping heightMapping = new DiscreteMapping(
- nac.getDefaultAppearance().get(VisualPropertyType.NODE_HEIGHT),
- GpmlNetworkElement.ATTR_TYPE,
- ObjectMapping.NODE_MAPPING
- );
- heightMapping.putMapValue(ObjectType.GROUP.ordinal(), 5);
- heightMapping.putMapValue(GpmlAnchorNode.TYPE_ANCHOR, 5);
-
- nac.setCalculator(
- new BasicCalculator("Node width", widthMapping, VisualPropertyType.NODE_WIDTH)
- );
- nac.setCalculator(
- new BasicCalculator("Node height", heightMapping, VisualPropertyType.NODE_HEIGHT)
- );
- }
-
- void setLineTypeMapping() {
- DiscreteMapping styleMapping = new DiscreteMapping(
- nac.getDefaultAppearance().get(VisualPropertyType.EDGE_LINE_STYLE),
- attrMapper.getMapping(StaticProperty.LINESTYLE),
- ObjectMapping.EDGE_MAPPING
- );
- styleMapping.putMapValue("" + LineStyle.SOLID, cytoscape.visual.LineStyle.SOLID);
- styleMapping.putMapValue("" + LineStyle.DASHED, cytoscape.visual.LineStyle.LONG_DASH);
- eac.setCalculator(
- new BasicCalculator("GPML edge style", styleMapping, VisualPropertyType.EDGE_LINE_STYLE)
- );
- }
-
- void setArrowMapping() {
- DiscreteMapping srcMapping = new DiscreteMapping(
- nac.getDefaultAppearance().get(VisualPropertyType.EDGE_SRCARROW_SHAPE),
- attrMapper.getMapping(StaticProperty.STARTLINETYPE),
- ObjectMapping.EDGE_MAPPING
- );
- setArrowMappings(srcMapping);
- eac.setCalculator(
- new BasicCalculator("GPML edge source shape", srcMapping, VisualPropertyType.EDGE_SRCARROW_SHAPE)
- );
-
- DiscreteMapping tgtMapping = new DiscreteMapping(
- nac.getDefaultAppearance().get(VisualPropertyType.EDGE_TGTARROW_SHAPE),
- attrMapper.getMapping(StaticProperty.ENDLINETYPE),
- ObjectMapping.EDGE_MAPPING
- );
- setArrowMappings(tgtMapping);
- eac.setCalculator(
- new BasicCalculator("GPML edge target shape", tgtMapping, VisualPropertyType.EDGE_TGTARROW_SHAPE)
- );
-
- String colAttr = attrMapper.getMapping(StaticProperty.COLOR);
- eac.setCalculator(
- new BasicCalculator(
- "GPML edge source color",
- new GpmlColorMapper(
- (Color)eac.getDefaultAppearance().get(VisualPropertyType.EDGE_SRCARROW_COLOR), colAttr
- ),
- VisualPropertyType.EDGE_SRCARROW_COLOR
- )
- );
- eac.setCalculator(
- new BasicCalculator(
- "GPML edge target color",
- new GpmlColorMapper(
- (Color)eac.getDefaultAppearance().get(VisualPropertyType.EDGE_TGTARROW_COLOR), colAttr
- ),
- VisualPropertyType.EDGE_TGTARROW_COLOR
- )
- );
- }
-
- private static Map attribute2arrow;
- private static Map arrow2attribute;
-
- public static Map getAttributeToArrow() {
- if(attribute2arrow == null) {
- attribute2arrow = new HashMap();
- attribute2arrow.put(LineType.LINE.getName(), ArrowShape.NONE);
- attribute2arrow.put(LineType.ARROW.getName(), ArrowShape.ARROW);
- attribute2arrow.put(LineType.LIGAND_ROUND.getName(), ArrowShape.CIRCLE);
- attribute2arrow.put(LineType.LIGAND_SQUARE.getName(), ArrowShape.DELTA);
- attribute2arrow.put(LineType.RECEPTOR.getName(), ArrowShape.DELTA);
- attribute2arrow.put(LineType.RECEPTOR_ROUND.getName(), ArrowShape.DELTA);
- attribute2arrow.put(LineType.RECEPTOR_SQUARE.getName(), ArrowShape.DELTA);
- attribute2arrow.put(LineType.TBAR.getName(), ArrowShape.T);
-
- attribute2arrow.put("mim-necessary-stimulation", ArrowShape.ARROW);
- attribute2arrow.put("mim-binding", ArrowShape.ARROW);
- attribute2arrow.put("mim-conversion", ArrowShape.ARROW);
- attribute2arrow.put("mim-stimulation", ArrowShape.ARROW);
- attribute2arrow.put("mim-catalysis", ArrowShape.ARROW);
- attribute2arrow.put("mim-inhibition", ArrowShape.ARROW);
- attribute2arrow.put("mim-cleavage", ArrowShape.ARROW);
- }
- return attribute2arrow;
- }
-
- public static Map getArrowToAttribute() {
- if(arrow2attribute == null) {
- arrow2attribute = new HashMap();
- Map attribute2arrow = getAttributeToArrow();
- for(String attribute : attribute2arrow.keySet()) {
- arrow2attribute.put(attribute2arrow.get(attribute), attribute);
- }
- }
- return arrow2attribute;
- }
-
- void setArrowMappings(DiscreteMapping mapping) {
- Map attribute2arrow = getAttributeToArrow();
- for(String attribute : attribute2arrow.keySet()) {
- mapping.putMapValue(attribute, attribute2arrow.get(attribute));
- }
- }
-
- void setTypeMapping() {
- DiscreteMapping typeMapping = new DiscreteMapping(
- nac.getDefaultAppearance().get(VisualPropertyType.NODE_SIZE),
- GpmlNetworkElement.ATTR_TYPE,
- ObjectMapping.NODE_MAPPING
- );
- typeMapping.putMapValue(ObjectType.GROUP.ordinal(), 5);
- typeMapping.putMapValue(GpmlAnchorNode.TYPE_ANCHOR, 5);
-
- nac.setCalculator(
- new BasicCalculator(
- GpmlNetworkElement.ATTR_TYPE,
- typeMapping,
- VisualPropertyType.NODE_SIZE
- )
- );
- }
-
- void setLabelMapping() {
- nac.setCalculator(
- new BasicCalculator(
- "canonicalName",
- new PassThroughMapping("", "canonicalName"),
- VisualPropertyType.NODE_LABEL
- )
- );
- }
-
- void setColorMapping() {
- //Default node color is white and semi-transparent
- nac.getDefaultAppearance().set(VisualPropertyType.NODE_FILL_COLOR, Color.WHITE);
- nac.getDefaultAppearance().set(VisualPropertyType.NODE_OPACITY, 220);
-
- String colAttr = attrMapper.getMapping(StaticProperty.COLOR);
- nac.setCalculator(
- new BasicCalculator(
- "GPML node border color",
- new GpmlColorMapper(
- (Color)nac.getDefaultAppearance().get(VisualPropertyType.NODE_BORDER_COLOR), colAttr
- ),
- VisualPropertyType.NODE_BORDER_COLOR
- )
- );
- eac.setCalculator(
- new BasicCalculator(
- "GPML edge color",
- new GpmlColorMapper(
- (Color)eac.getDefaultAppearance().get(VisualPropertyType.EDGE_COLOR), colAttr
- ),
- VisualPropertyType.EDGE_COLOR
- )
- );
-
- }
-
- void setNodeColorMapping(String title, Map pwNameToColor){
-
- CyNetwork network = Cytoscape.getNetwork(title);
-
-// Discrete Mapping - set node colors
- DiscreteMapping disMapping = new DiscreteMapping(Color.WHITE,
- ObjectMapping.NODE_MAPPING);
-
- disMapping
- .setControllingAttributeName("Source Pathway", network, false);
-
- Set pwNames = pwNameToColor.keySet();
- Iterator it = pwNames.iterator();
- while (it.hasNext()) {
- String name = it.next();
- disMapping.putMapValue(name, pwNameToColor.get(name));
-
- }
-
- Calculator nodeColorCalculator = new BasicCalculator(
- "Superpathways Node Color Calc", disMapping,
- VisualPropertyType.NODE_FILL_COLOR);
-
- nac.setCalculator(nodeColorCalculator);
-
- }
-
-}
+// PathVisio,
+// a tool for data visualization and analysis using Biological Pathways
+// Copyright 2006-2011 BiGCaT Bioinformatics
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+package org.pathvisio.cytoscape.superpathways;
+
+import java.awt.Color;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.pathvisio.core.model.LineStyle;
+import org.pathvisio.core.model.LineType;
+import org.pathvisio.core.model.ObjectType;
+import org.pathvisio.core.model.StaticProperty;
+import org.pathvisio.cytoscape.AttributeMapper;
+import org.pathvisio.cytoscape.GpmlAnchorNode;
+import org.pathvisio.cytoscape.GpmlHandler;
+import org.pathvisio.cytoscape.GpmlNetworkElement;
+import org.pathvisio.cytoscape.visualmapping.GpmlColorMapper;
+
+import cytoscape.CyNetwork;
+import cytoscape.Cytoscape;
+import cytoscape.visual.ArrowShape;
+import cytoscape.visual.EdgeAppearanceCalculator;
+import cytoscape.visual.GlobalAppearanceCalculator;
+import cytoscape.visual.NodeAppearance;
+import cytoscape.visual.NodeAppearanceCalculator;
+import cytoscape.visual.NodeShape;
+import cytoscape.visual.VisualMappingManager;
+import cytoscape.visual.VisualPropertyType;
+import cytoscape.visual.VisualStyle;
+import cytoscape.visual.calculators.BasicCalculator;
+import cytoscape.visual.calculators.Calculator;
+import cytoscape.visual.mappings.DiscreteMapping;
+import cytoscape.visual.mappings.ObjectMapping;
+import cytoscape.visual.mappings.PassThroughMapping;
+
+public class gpmlExtendVisualStyle extends VisualStyle {
+ public static final String NAME = "GPML-extension";
+
+ GpmlHandler gpmlHandler;
+ AttributeMapper attrMapper;
+
+ NodeAppearanceCalculator nac;
+ EdgeAppearanceCalculator eac;
+
+ Map pwNameToColor;
+ String title;
+
+
+ public gpmlExtendVisualStyle(GpmlHandler gpmlHandler, VisualStyle toCopy, Map map, String t) {
+ super(toCopy);
+ setName(NAME);
+ init(gpmlHandler);
+ pwNameToColor=map;
+ title=t;
+ }
+
+ public gpmlExtendVisualStyle(GpmlHandler gpmlHandler, Map map, String t, int version) {
+ super(NAME+"-"+String.valueOf(version));
+ pwNameToColor=map;
+ title=t;
+
+ init(gpmlHandler);
+
+ }
+
+ private void init(GpmlHandler gh) {
+ this.gpmlHandler = gh;
+ attrMapper = gpmlHandler.getAttributeMapper();
+
+ nac = getNodeAppearanceCalculator();
+ eac = getEdgeAppearanceCalculator();
+
+ VisualMappingManager vm = Cytoscape.getVisualMappingManager();
+ VisualStyle currentStyle = vm.getVisualStyle();
+
+ if(nac == null) {
+ nac = new NodeAppearanceCalculator(currentStyle.getNodeAppearanceCalculator());
+ setNodeAppearanceCalculator(nac);
+ }
+ if(eac == null) {
+ eac = new EdgeAppearanceCalculator(currentStyle.getEdgeAppearanceCalculator());
+ setEdgeAppearanceCalculator(eac);
+ }
+
+
+ setColorMapping();
+ setLabelMapping();
+ setTypeMapping();
+ setArrowMapping();
+ setLineTypeMapping();
+ setNodeShapeMapping();
+ setNodeColorMapping(title, pwNameToColor);
+ }
+
+ void setNodeShapeMapping() {
+ getNodeAppearanceCalculator().setNodeSizeLocked(false);
+ NodeAppearance nd = nac.getDefaultAppearance();
+ nd.set(VisualPropertyType.NODE_SHAPE, NodeShape.RECT);
+ nd.set(VisualPropertyType.NODE_WIDTH, 80);
+ nd.set(VisualPropertyType.NODE_HEIGHT, 20);
+
+ DiscreteMapping widthMapping = new DiscreteMapping(
+ nac.getDefaultAppearance().get(VisualPropertyType.NODE_WIDTH),
+ GpmlNetworkElement.ATTR_TYPE,
+ ObjectMapping.NODE_MAPPING
+ );
+ widthMapping.putMapValue(ObjectType.GROUP.ordinal(), 5);
+ widthMapping.putMapValue(GpmlAnchorNode.TYPE_ANCHOR, 5);
+ DiscreteMapping heightMapping = new DiscreteMapping(
+ nac.getDefaultAppearance().get(VisualPropertyType.NODE_HEIGHT),
+ GpmlNetworkElement.ATTR_TYPE,
+ ObjectMapping.NODE_MAPPING
+ );
+ heightMapping.putMapValue(ObjectType.GROUP.ordinal(), 5);
+ heightMapping.putMapValue(GpmlAnchorNode.TYPE_ANCHOR, 5);
+
+ nac.setCalculator(
+ new BasicCalculator("Node width", widthMapping, VisualPropertyType.NODE_WIDTH)
+ );
+ nac.setCalculator(
+ new BasicCalculator("Node height", heightMapping, VisualPropertyType.NODE_HEIGHT)
+ );
+ }
+
+ void setLineTypeMapping() {
+ DiscreteMapping styleMapping = new DiscreteMapping(
+ nac.getDefaultAppearance().get(VisualPropertyType.EDGE_LINE_STYLE),
+ attrMapper.getMapping(StaticProperty.LINESTYLE),
+ ObjectMapping.EDGE_MAPPING
+ );
+ styleMapping.putMapValue("" + LineStyle.SOLID, cytoscape.visual.LineStyle.SOLID);
+ styleMapping.putMapValue("" + LineStyle.DASHED, cytoscape.visual.LineStyle.LONG_DASH);
+ eac.setCalculator(
+ new BasicCalculator("GPML edge style", styleMapping, VisualPropertyType.EDGE_LINE_STYLE)
+ );
+ }
+
+ void setArrowMapping() {
+ DiscreteMapping srcMapping = new DiscreteMapping(
+ nac.getDefaultAppearance().get(VisualPropertyType.EDGE_SRCARROW_SHAPE),
+ attrMapper.getMapping(StaticProperty.STARTLINETYPE),
+ ObjectMapping.EDGE_MAPPING
+ );
+ setArrowMappings(srcMapping);
+ eac.setCalculator(
+ new BasicCalculator("GPML edge source shape", srcMapping, VisualPropertyType.EDGE_SRCARROW_SHAPE)
+ );
+
+ DiscreteMapping tgtMapping = new DiscreteMapping(
+ nac.getDefaultAppearance().get(VisualPropertyType.EDGE_TGTARROW_SHAPE),
+ attrMapper.getMapping(StaticProperty.ENDLINETYPE),
+ ObjectMapping.EDGE_MAPPING
+ );
+ setArrowMappings(tgtMapping);
+ eac.setCalculator(
+ new BasicCalculator("GPML edge target shape", tgtMapping, VisualPropertyType.EDGE_TGTARROW_SHAPE)
+ );
+
+ String colAttr = attrMapper.getMapping(StaticProperty.COLOR);
+ eac.setCalculator(
+ new BasicCalculator(
+ "GPML edge source color",
+ new GpmlColorMapper(
+ (Color)eac.getDefaultAppearance().get(VisualPropertyType.EDGE_SRCARROW_COLOR), colAttr
+ ),
+ VisualPropertyType.EDGE_SRCARROW_COLOR
+ )
+ );
+ eac.setCalculator(
+ new BasicCalculator(
+ "GPML edge target color",
+ new GpmlColorMapper(
+ (Color)eac.getDefaultAppearance().get(VisualPropertyType.EDGE_TGTARROW_COLOR), colAttr
+ ),
+ VisualPropertyType.EDGE_TGTARROW_COLOR
+ )
+ );
+ }
+
+ private static Map attribute2arrow;
+ private static Map arrow2attribute;
+
+ public static Map getAttributeToArrow() {
+ if(attribute2arrow == null) {
+ attribute2arrow = new HashMap();
+ attribute2arrow.put(LineType.LINE.getName(), ArrowShape.NONE);
+ attribute2arrow.put(LineType.ARROW.getName(), ArrowShape.ARROW);
+ attribute2arrow.put(LineType.LIGAND_ROUND.getName(), ArrowShape.CIRCLE);
+ attribute2arrow.put(LineType.LIGAND_SQUARE.getName(), ArrowShape.DELTA);
+ attribute2arrow.put(LineType.RECEPTOR.getName(), ArrowShape.DELTA);
+ attribute2arrow.put(LineType.RECEPTOR_ROUND.getName(), ArrowShape.DELTA);
+ attribute2arrow.put(LineType.RECEPTOR_SQUARE.getName(), ArrowShape.DELTA);
+ attribute2arrow.put(LineType.TBAR.getName(), ArrowShape.T);
+
+ attribute2arrow.put("mim-necessary-stimulation", ArrowShape.ARROW);
+ attribute2arrow.put("mim-binding", ArrowShape.ARROW);
+ attribute2arrow.put("mim-conversion", ArrowShape.ARROW);
+ attribute2arrow.put("mim-stimulation", ArrowShape.ARROW);
+ attribute2arrow.put("mim-catalysis", ArrowShape.ARROW);
+ attribute2arrow.put("mim-inhibition", ArrowShape.ARROW);
+ attribute2arrow.put("mim-cleavage", ArrowShape.ARROW);
+ }
+ return attribute2arrow;
+ }
+
+ public static Map getArrowToAttribute() {
+ if(arrow2attribute == null) {
+ arrow2attribute = new HashMap();
+ Map attribute2arrow = getAttributeToArrow();
+ for(String attribute : attribute2arrow.keySet()) {
+ arrow2attribute.put(attribute2arrow.get(attribute), attribute);
+ }
+ }
+ return arrow2attribute;
+ }
+
+ void setArrowMappings(DiscreteMapping mapping) {
+ Map attribute2arrow = getAttributeToArrow();
+ for(String attribute : attribute2arrow.keySet()) {
+ mapping.putMapValue(attribute, attribute2arrow.get(attribute));
+ }
+ }
+
+ void setTypeMapping() {
+ DiscreteMapping typeMapping = new DiscreteMapping(
+ nac.getDefaultAppearance().get(VisualPropertyType.NODE_SIZE),
+ GpmlNetworkElement.ATTR_TYPE,
+ ObjectMapping.NODE_MAPPING
+ );
+ typeMapping.putMapValue(ObjectType.GROUP.ordinal(), 5);
+ typeMapping.putMapValue(GpmlAnchorNode.TYPE_ANCHOR, 5);
+
+ nac.setCalculator(
+ new BasicCalculator(
+ GpmlNetworkElement.ATTR_TYPE,
+ typeMapping,
+ VisualPropertyType.NODE_SIZE
+ )
+ );
+ }
+
+ void setLabelMapping() {
+ nac.setCalculator(
+ new BasicCalculator(
+ "canonicalName",
+ new PassThroughMapping("", "canonicalName"),
+ VisualPropertyType.NODE_LABEL
+ )
+ );
+ }
+
+ void setColorMapping() {
+ //Default node color is white and semi-transparent
+ nac.getDefaultAppearance().set(VisualPropertyType.NODE_FILL_COLOR, Color.WHITE);
+ nac.getDefaultAppearance().set(VisualPropertyType.NODE_OPACITY, 220);
+
+ String colAttr = attrMapper.getMapping(StaticProperty.COLOR);
+ nac.setCalculator(
+ new BasicCalculator(
+ "GPML node border color",
+ new GpmlColorMapper(
+ (Color)nac.getDefaultAppearance().get(VisualPropertyType.NODE_BORDER_COLOR), colAttr
+ ),
+ VisualPropertyType.NODE_BORDER_COLOR
+ )
+ );
+ eac.setCalculator(
+ new BasicCalculator(
+ "GPML edge color",
+ new GpmlColorMapper(
+ (Color)eac.getDefaultAppearance().get(VisualPropertyType.EDGE_COLOR), colAttr
+ ),
+ VisualPropertyType.EDGE_COLOR
+ )
+ );
+
+ }
+
+ void setNodeColorMapping(String title, Map pwNameToColor){
+
+ CyNetwork network = Cytoscape.getNetwork(title);
+
+// Discrete Mapping - set node colors
+ DiscreteMapping disMapping = new DiscreteMapping(Color.WHITE,
+ ObjectMapping.NODE_MAPPING);
+
+ disMapping
+ .setControllingAttributeName("Source Pathway", network, false);
+
+ Set pwNames = pwNameToColor.keySet();
+ Iterator it = pwNames.iterator();
+ while (it.hasNext()) {
+ String name = it.next();
+ disMapping.putMapValue(name, pwNameToColor.get(name));
+
+ }
+
+ Calculator nodeColorCalculator = new BasicCalculator(
+ "Superpathways Node Color Calc", disMapping,
+ VisualPropertyType.NODE_FILL_COLOR);
+
+ nac.setCalculator(nodeColorCalculator);
+
+ }
+
+}
diff --git a/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/superpathwaysVisualStyle.java b/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/superpathwaysVisualStyle.java
index 0140f2e4..55159415 100644
--- a/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/superpathwaysVisualStyle.java
+++ b/tools/superpathways/src/org/pathvisio/cytoscape/superpathways/superpathwaysVisualStyle.java
@@ -1,135 +1,135 @@
-// PathVisio,
-// a tool for data visualization and analysis using Biological Pathways
-// Copyright 2006-2011 BiGCaT Bioinformatics
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-package org.pathvisio.cytoscape.superpathways;
-
-import java.awt.Color;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.pathvisio.core.model.PropertyType;
-import org.pathvisio.cytoscape.visualmapping.GpmlColorMapper;
-
-import cytoscape.CyNetwork;
-import cytoscape.Cytoscape;
-import cytoscape.visual.CalculatorCatalog;
-import cytoscape.visual.EdgeAppearance;
-import cytoscape.visual.EdgeAppearanceCalculator;
-import cytoscape.visual.GlobalAppearance;
-import cytoscape.visual.GlobalAppearanceCalculator;
-import cytoscape.visual.NodeAppearance;
-import cytoscape.visual.NodeAppearanceCalculator;
-import cytoscape.visual.NodeShape;
-import cytoscape.visual.VisualMappingManager;
-import cytoscape.visual.VisualPropertyType;
-import cytoscape.visual.VisualStyle;
-import cytoscape.visual.calculators.BasicCalculator;
-import cytoscape.visual.calculators.Calculator;
-import cytoscape.visual.mappings.DiscreteMapping;
-import cytoscape.visual.mappings.ObjectMapping;
-import cytoscape.visual.mappings.PassThroughMapping;
-
-public class superpathwaysVisualStyle {
-
- public static final String vsName = "Superpathways Visual Style";
-
- int styleCount;
-
- public superpathwaysVisualStyle(String title,
- Map pwNameToColor, int i) {
- // get the network view
- CyNetwork network = Cytoscape.getNetwork(title);
- cytoscape.view.CyNetworkView networkView = Cytoscape
- .getNetworkView(title);
-
- // get the VisualMappingManager and CalculatorCatalog
- VisualMappingManager manager = Cytoscape.getVisualMappingManager();
- CalculatorCatalog catalog = manager.getCalculatorCatalog();
-
- //the next code line is used for fix the bug (when doing several merges)
- //catalog.removeVisualStyle(vsName);
- styleCount=i;
- String styleName=vsName+"-"+String.valueOf(i);
- // check to see if a visual style with this name already exists
- VisualStyle vs = catalog.getVisualStyle(styleName);
-
- if (vs == null) {
- // if not, create it and add it to the catalog
- // vs = createVisualStyle(network, title, c);
- vs = createVisualStyle(network, pwNameToColor, styleName);
- catalog.addVisualStyle(vs);
- }else{
- System.out.println("Superpathway style is not null!");
- }
-
- networkView.setVisualStyle(vs.getName()); // not strictly necessary
-
- // actually apply the visual style
- manager.setVisualStyle(vs);
- networkView.redrawGraph(true, true);
- }
-
- VisualStyle createVisualStyle(CyNetwork network, Map pwNameToColor, String StyleName) {
-
- VisualMappingManager vm = Cytoscape.getVisualMappingManager();
- VisualStyle currentStyle = vm.getVisualStyle();
- NodeAppearanceCalculator nodeAppCalc = new NodeAppearanceCalculator(currentStyle.getNodeAppearanceCalculator());
- EdgeAppearanceCalculator edgeAppCalc = new EdgeAppearanceCalculator(currentStyle.getEdgeAppearanceCalculator());
- GlobalAppearanceCalculator globalAppCalc = new GlobalAppearanceCalculator();
-
- //set default value for the following property
- globalAppCalc.setDefaultBackgroundColor(new Color(200, 200, 255));
- nodeAppCalc.getDefaultAppearance().set(VisualPropertyType.NODE_SHAPE, NodeShape.ELLIPSE);
- edgeAppCalc.getDefaultAppearance().set(VisualPropertyType.EDGE_COLOR, new Color(0,0, 255));
- edgeAppCalc.getDefaultAppearance().set(VisualPropertyType.EDGE_LINE_WIDTH, 1.5);
-
- // Passthrough Mapping - set node label
- PassThroughMapping pm = new PassThroughMapping(new String(), "canonicalName");
- Calculator nlc = new BasicCalculator("Superpathways Node Label Calc",
- pm, VisualPropertyType.NODE_LABEL);
- nodeAppCalc.setCalculator(nlc);
-
-
- // Discrete Mapping - set node colors
- DiscreteMapping disMapping = new DiscreteMapping(Color.WHITE,
- ObjectMapping.NODE_MAPPING);
-
- disMapping
- .setControllingAttributeName("Source Pathway", network, false);
-
- Set pwNames = pwNameToColor.keySet();
- Iterator it = pwNames.iterator();
- while (it.hasNext()) {
- String name = it.next();
- disMapping.putMapValue(name, pwNameToColor.get(name));
-
- }
-
- Calculator nodeColorCalculator = new BasicCalculator(
- "Superpathways Node Color Calc", disMapping,
- VisualPropertyType.NODE_FILL_COLOR);
-
- nodeAppCalc.setCalculator(nodeColorCalculator);
-
- // Create the visual style
- VisualStyle visualStyle = new VisualStyle(StyleName, nodeAppCalc, edgeAppCalc,
- globalAppCalc);
-
- return visualStyle;
- }
-}
+// PathVisio,
+// a tool for data visualization and analysis using Biological Pathways
+// Copyright 2006-2011 BiGCaT Bioinformatics
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package org.pathvisio.cytoscape.superpathways;
+
+import java.awt.Color;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.pathvisio.core.model.PropertyType;
+import org.pathvisio.cytoscape.visualmapping.GpmlColorMapper;
+
+import cytoscape.CyNetwork;
+import cytoscape.Cytoscape;
+import cytoscape.visual.CalculatorCatalog;
+import cytoscape.visual.EdgeAppearance;
+import cytoscape.visual.EdgeAppearanceCalculator;
+import cytoscape.visual.GlobalAppearance;
+import cytoscape.visual.GlobalAppearanceCalculator;
+import cytoscape.visual.NodeAppearance;
+import cytoscape.visual.NodeAppearanceCalculator;
+import cytoscape.visual.NodeShape;
+import cytoscape.visual.VisualMappingManager;
+import cytoscape.visual.VisualPropertyType;
+import cytoscape.visual.VisualStyle;
+import cytoscape.visual.calculators.BasicCalculator;
+import cytoscape.visual.calculators.Calculator;
+import cytoscape.visual.mappings.DiscreteMapping;
+import cytoscape.visual.mappings.ObjectMapping;
+import cytoscape.visual.mappings.PassThroughMapping;
+
+public class superpathwaysVisualStyle {
+
+ public static final String vsName = "Superpathways Visual Style";
+
+ int styleCount;
+
+ public superpathwaysVisualStyle(String title,
+ Map pwNameToColor, int i) {
+ // get the network view
+ CyNetwork network = Cytoscape.getNetwork(title);
+ cytoscape.view.CyNetworkView networkView = Cytoscape
+ .getNetworkView(title);
+
+ // get the VisualMappingManager and CalculatorCatalog
+ VisualMappingManager manager = Cytoscape.getVisualMappingManager();
+ CalculatorCatalog catalog = manager.getCalculatorCatalog();
+
+ //the next code line is used for fix the bug (when doing several merges)
+ //catalog.removeVisualStyle(vsName);
+ styleCount=i;
+ String styleName=vsName+"-"+String.valueOf(i);
+ // check to see if a visual style with this name already exists
+ VisualStyle vs = catalog.getVisualStyle(styleName);
+
+ if (vs == null) {
+ // if not, create it and add it to the catalog
+ // vs = createVisualStyle(network, title, c);
+ vs = createVisualStyle(network, pwNameToColor, styleName);
+ catalog.addVisualStyle(vs);
+ }else{
+ System.out.println("Superpathway style is not null!");
+ }
+
+ networkView.setVisualStyle(vs.getName()); // not strictly necessary
+
+ // actually apply the visual style
+ manager.setVisualStyle(vs);
+ networkView.redrawGraph(true, true);
+ }
+
+ VisualStyle createVisualStyle(CyNetwork network, Map pwNameToColor, String StyleName) {
+
+ VisualMappingManager vm = Cytoscape.getVisualMappingManager();
+ VisualStyle currentStyle = vm.getVisualStyle();
+ NodeAppearanceCalculator nodeAppCalc = new NodeAppearanceCalculator(currentStyle.getNodeAppearanceCalculator());
+ EdgeAppearanceCalculator edgeAppCalc = new EdgeAppearanceCalculator(currentStyle.getEdgeAppearanceCalculator());
+ GlobalAppearanceCalculator globalAppCalc = new GlobalAppearanceCalculator();
+
+ //set default value for the following property
+ globalAppCalc.setDefaultBackgroundColor(new Color(200, 200, 255));
+ nodeAppCalc.getDefaultAppearance().set(VisualPropertyType.NODE_SHAPE, NodeShape.ELLIPSE);
+ edgeAppCalc.getDefaultAppearance().set(VisualPropertyType.EDGE_COLOR, new Color(0,0, 255));
+ edgeAppCalc.getDefaultAppearance().set(VisualPropertyType.EDGE_LINE_WIDTH, 1.5);
+
+ // Passthrough Mapping - set node label
+ PassThroughMapping pm = new PassThroughMapping(new String(), "canonicalName");
+ Calculator nlc = new BasicCalculator("Superpathways Node Label Calc",
+ pm, VisualPropertyType.NODE_LABEL);
+ nodeAppCalc.setCalculator(nlc);
+
+
+ // Discrete Mapping - set node colors
+ DiscreteMapping disMapping = new DiscreteMapping(Color.WHITE,
+ ObjectMapping.NODE_MAPPING);
+
+ disMapping
+ .setControllingAttributeName("Source Pathway", network, false);
+
+ Set pwNames = pwNameToColor.keySet();
+ Iterator it = pwNames.iterator();
+ while (it.hasNext()) {
+ String name = it.next();
+ disMapping.putMapValue(name, pwNameToColor.get(name));
+
+ }
+
+ Calculator nodeColorCalculator = new BasicCalculator(
+ "Superpathways Node Color Calc", disMapping,
+ VisualPropertyType.NODE_FILL_COLOR);
+
+ nodeAppCalc.setCalculator(nodeColorCalculator);
+
+ // Create the visual style
+ VisualStyle visualStyle = new VisualStyle(StyleName, nodeAppCalc, edgeAppCalc,
+ globalAppCalc);
+
+ return visualStyle;
+ }
+}
diff --git a/www/index.html b/www/index.html
index 3915c1f8..8a9f0594 100644
--- a/www/index.html
+++ b/www/index.html
@@ -1,11 +1,11 @@
-
-
-
-
-
-
-This page had moved. If your browser doesn't automatically redirect to its new location, click
-here.
-
-
+
+
+
+
+
+
+This page had moved. If your browser doesn't automatically redirect to its new location, click
+here.
+
+
\ No newline at end of file