Author: mes
Date: 2011-10-07 13:32:33 -0700 (Fri, 07 Oct 2011)
New Revision: 27084

Added:
   csplugins/trunk/ucsd/mes/gxp-reader/
   csplugins/trunk/ucsd/mes/gxp-reader/pom.xml
   csplugins/trunk/ucsd/mes/gxp-reader/src/
   csplugins/trunk/ucsd/mes/gxp-reader/src/main/
   csplugins/trunk/ucsd/mes/gxp-reader/src/main/assembly/
   csplugins/trunk/ucsd/mes/gxp-reader/src/main/assembly/src.xml
   csplugins/trunk/ucsd/mes/gxp-reader/src/main/java/
   csplugins/trunk/ucsd/mes/gxp-reader/src/main/java/cytoscape/
   csplugins/trunk/ucsd/mes/gxp-reader/src/main/java/cytoscape/gxp/
   
csplugins/trunk/ucsd/mes/gxp-reader/src/main/java/cytoscape/gxp/GXPFilter.java
   
csplugins/trunk/ucsd/mes/gxp-reader/src/main/java/cytoscape/gxp/GXPGraphReader.java
   
csplugins/trunk/ucsd/mes/gxp-reader/src/main/java/cytoscape/gxp/GXPReaderPlugin.java
   
csplugins/trunk/ucsd/mes/gxp-reader/src/main/java/cytoscape/gxp/SBMLVisualStyleFactory.java.hold
   csplugins/trunk/ucsd/mes/gxp-reader/src/main/resources/
   csplugins/trunk/ucsd/mes/gxp-reader/src/main/resources/cytoscape/
   csplugins/trunk/ucsd/mes/gxp-reader/src/main/resources/cytoscape/gxp/
   
csplugins/trunk/ucsd/mes/gxp-reader/src/main/resources/cytoscape/gxp/plugin.props
   csplugins/trunk/ucsd/mes/gxp-reader/src/main/resources/mime.types
Log:
initial shot at a GXP reader

Added: csplugins/trunk/ucsd/mes/gxp-reader/pom.xml
===================================================================
--- csplugins/trunk/ucsd/mes/gxp-reader/pom.xml                         (rev 0)
+++ csplugins/trunk/ucsd/mes/gxp-reader/pom.xml 2011-10-07 20:32:33 UTC (rev 
27084)
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>cytoscape</groupId>
+  <artifactId>gxp-reader</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+  <name>GXP Reader Plugin</name>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+               <version>2.3.2</version>
+        <configuration>
+          <source>1.6</source>
+          <target>1.6</target>
+          <optimize>true</optimize>
+          <showWarnings>true</showWarnings>
+          <showDeprecation>true</showDeprecation>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <version>2.2-beta-5</version>
+        <configuration>
+          <archive>
+            <manifestEntries>
+              
<Cytoscape-Plugin>cytoscape.gxp.GXPReaderPlugin</Cytoscape-Plugin>
+            </manifestEntries>
+          </archive>
+          <descriptors>
+            <descriptor>src/main/assembly/src.xml</descriptor>
+          </descriptors>
+        </configuration>
+        <executions>
+          <execution>
+            <id>make-assembly</id>
+            <phase>package</phase>
+            <goals>
+              <goal>single</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>cytoscape</groupId>
+      <artifactId>application</artifactId>
+      <version>2.8.3-SNAPSHOT</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+       <dependency>
+               <groupId>org.jdom</groupId>
+               <artifactId>jdom</artifactId>
+               <version>1.1</version>
+               <scope>provided</scope>
+       </dependency>
+  </dependencies>
+
+  <repositories>
+    <repository>
+      <id>cytoscape_snapshots</id>
+      <snapshots>
+        <enabled>true</enabled>
+      </snapshots>
+      <releases>
+        <enabled>false</enabled>
+      </releases>
+      <name>Cytoscape Snapshots</name>
+      
<url>http://cytoscape.wodaklab.org/nexus/content/repositories/snapshots/</url>
+    </repository>
+    <repository>
+      <id>cytoscape_releases</id>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+      <releases>
+        <enabled>true</enabled>
+      </releases>
+      <name>Cytoscape Releases</name>
+      
<url>http://cytoscape.wodaklab.org/nexus/content/repositories/releases/</url>
+    </repository>
+    <repository>
+      <id>cytoscape_thirdparty</id>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+      <releases>            
+        <enabled>true</enabled>
+      </releases>
+      <name>Cytoscape Third Party</name>
+      
<url>http://cytoscape.wodaklab.org/nexus/content/repositories/thirdparty/</url>
+    </repository>
+  </repositories>
+
+</project>

Added: csplugins/trunk/ucsd/mes/gxp-reader/src/main/assembly/src.xml
===================================================================
--- csplugins/trunk/ucsd/mes/gxp-reader/src/main/assembly/src.xml               
                (rev 0)
+++ csplugins/trunk/ucsd/mes/gxp-reader/src/main/assembly/src.xml       
2011-10-07 20:32:33 UTC (rev 27084)
@@ -0,0 +1,18 @@
+<assembly 
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0";
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+    
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0
 http://maven.apache.org/xsd/assembly-1.1.0.xsd";>
+  <id>jar-with-dependencies</id>
+  <formats>
+    <format>jar</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <dependencySets>
+    <dependencySet>
+      <outputDirectory>/</outputDirectory>
+      <useProjectArtifact>true</useProjectArtifact>
+      <unpack>true</unpack>
+      <scope>runtime</scope>
+         <useTransitiveDependencies>false</useTransitiveDependencies>
+    </dependencySet>
+  </dependencySets>
+</assembly>

Added: 
csplugins/trunk/ucsd/mes/gxp-reader/src/main/java/cytoscape/gxp/GXPFilter.java
===================================================================
--- 
csplugins/trunk/ucsd/mes/gxp-reader/src/main/java/cytoscape/gxp/GXPFilter.java  
                            (rev 0)
+++ 
csplugins/trunk/ucsd/mes/gxp-reader/src/main/java/cytoscape/gxp/GXPFilter.java  
    2011-10-07 20:32:33 UTC (rev 27084)
@@ -0,0 +1,81 @@
+
+/*
+ Copyright (c) 2006, 2007, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications.  In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage.  See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+
+package cytoscape.gxp;
+
+import cytoscape.data.ImportHandler;
+
+import cytoscape.data.readers.GraphReader;
+
+import cytoscape.util.CyFileFilter;
+
+import java.io.File;
+import java.io.IOException;
+
+
+public class GXPFilter extends CyFileFilter {
+       /**
+        * GXP Files are Graphs.
+        */
+       private static String fileNature = ImportHandler.GRAPH_NATURE;
+
+       /**
+        * File Extensions.
+        */
+       private static String[] fileExtensions = { "gxp" };
+
+       /**
+        * Filter Description.
+        */
+       private static String description = "GXP files";
+
+       /**
+        * Constructor.
+        */
+       public GXPFilter() {
+               super(fileExtensions, description, fileNature);
+       }
+
+       /**
+        * Gets the appropirate GraphReader object.
+        *
+        * @param fileName File Name.
+        * @return GraphReader Object.
+        */
+       public GraphReader getReader(String fileName) {
+               return new GXPGraphReader(fileName);
+       }
+}

Added: 
csplugins/trunk/ucsd/mes/gxp-reader/src/main/java/cytoscape/gxp/GXPGraphReader.java
===================================================================
--- 
csplugins/trunk/ucsd/mes/gxp-reader/src/main/java/cytoscape/gxp/GXPGraphReader.java
                         (rev 0)
+++ 
csplugins/trunk/ucsd/mes/gxp-reader/src/main/java/cytoscape/gxp/GXPGraphReader.java
 2011-10-07 20:32:33 UTC (rev 27084)
@@ -0,0 +1,268 @@
+
+/*
+ Copyright (c) 2006, 2007, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications.  In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage.  See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+
+package cytoscape.gxp;
+
+import cytoscape.CyEdge;
+import cytoscape.CyNetwork;
+import cytoscape.CyNode;
+import cytoscape.Cytoscape;
+
+import cytoscape.data.CyAttributes;
+import cytoscape.data.Semantics;
+
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+
+import org.jdom.input.SAXBuilder;
+
+
+import cytoscape.data.readers.AbstractGraphReader;
+import cytoscape.data.readers.GraphReader;
+
+import cytoscape.view.CyNetworkView;
+import cytoscape.view.CytoscapeDesktop;
+
+import cytoscape.visual.*;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import java.net.URL;
+
+import java.util.*;
+
+
+/**
+ * @author  Mike Smoot
+ */
+public class GXPGraphReader extends AbstractGraphReader implements GraphReader 
{
+       // node id from file -> node
+       private Map<String,CyNode> nodeIdMap; 
+
+       // module id from file -> list of nodes in module
+       private Map<String,List<CyNode>> moduleMap; 
+
+       // regulator id from file -> list of nodes in regulator
+       private Map<String,List<CyNode>> regulatorMap; 
+
+
+       private List<Integer> nodeIds;
+       private List<Integer> edgeIds;
+       private URL fileURL;
+
+       /**
+        * Creates a new SBMLGraphReader object.
+        *
+        * @param filename  DOCUMENT ME!
+        */
+       public GXPGraphReader(String filename) {
+               super(filename);
+               fileURL = null;
+       }
+
+       /**
+        * Creates a new SBMLGraphReader object.
+        *
+        * @param url  DOCUMENT ME!
+        */
+       public GXPGraphReader(URL url) {
+               super(null);
+               fileURL = url;
+               fileName = null;
+       }
+
+       /**
+        *  DOCUMENT ME!
+        *
+        * @throws IOException DOCUMENT ME!
+        */
+       public void read() throws IOException {
+               InputStream instream;
+
+               if ((fileURL == null) && (fileName != null))
+                       instream = new FileInputStream(fileName);
+               else if ((fileURL != null) && (fileName == null))
+                       instream = fileURL.openStream();
+               else
+                       throw new IOException("No file to open!");
+
+               nodeIds = new ArrayList<Integer>();
+               edgeIds = new ArrayList<Integer>();
+
+               nodeIdMap = new HashMap<String,CyNode>();
+               // module -> list of nodes in module
+               moduleMap = new HashMap<String,List<CyNode>>();
+               // regulator -> list of nodes in regulator
+               regulatorMap = new HashMap<String,List<CyNode>>();
+
+               try {
+
+                       // Actual work
+                       SAXBuilder builder = new SAXBuilder(false);
+                       Document doc = builder.build(instream);
+       
+                       createNodes( getTable(doc,"Genes") );
+                       createModules( getTable(doc,"Genes_Modules") );
+                       createRegulators( getTable(doc,"Regulators_Regulators") 
);
+                       createEdges( getTable(doc, "Modules_Regulator") );
+
+               } catch (JDOMException je) { 
+                       throw new IOException("JDOM failure parsing file.",je); 
+               }
+       }
+
+       private void createEdges(Element moduleRegulators) {
+               for ( Object o : 
moduleRegulators.getChildren("Module_Regulator") ) {
+                       Element moduleRegulator = (Element)o;
+                       String moduleId = 
moduleRegulator.getAttributeValue("Module_Id");
+                       String regId = 
moduleRegulator.getAttributeValue("Regulator_Id");
+                       if ( moduleId == null || regId == null || 
!moduleMap.containsKey(moduleId) || !regulatorMap.containsKey(regId) )
+                               continue;
+
+                       for ( CyNode na : regulatorMap.get(regId) ) {
+                               for (CyNode nb : moduleMap.get(moduleId) ) {
+                                       CyEdge e = 
Cytoscape.getCyEdge(na,nb,Semantics.INTERACTION,"regulates",true,true);
+                                       edgeIds.add( e.getRootGraphIndex() );
+                               }
+                       }
+               }
+       }
+
+       private void createRegulators(Element regulators) {
+               for ( Object o : regulators.getChildren("Regulator_Gene") ) {
+                       Element regulator = (Element) o;
+                       String regId = 
regulator.getAttributeValue("Regulator_Id");
+                       if ( !regulatorMap.containsKey(regId) )
+                               regulatorMap.put(regId,new ArrayList<CyNode>());
+                       CyNode node = nodeIdMap.get( 
regulator.getAttributeValue("Gene_Id") );
+                       if ( node == null ) {
+                               System.out.println("unable to createRegulator 
for gene_id " + regulator.getAttributeValue("Gene_Id"));
+                               continue;
+                       }
+                       regulatorMap.get(regId).add( node );
+                       
Cytoscape.getNodeAttributes().setAttribute(node.getIdentifier(),"GXP_Regulator_Id",regId);
+               }
+       }
+
+       private void createModules(Element geneModules) {
+               for ( Object o : geneModules.getChildren("Gene_Module") ) {
+                       Element geneModule = (Element) o;
+                       CyNode node = nodeIdMap.get( 
geneModule.getAttributeValue("Gene_Id") );
+                       if ( node != null ) {
+                               String moduleId = 
geneModule.getAttributeValue("Module_Id");
+                               
Cytoscape.getNodeAttributes().setAttribute(node.getIdentifier(),"GXP_Module_Id",moduleId);
+                               if ( !moduleMap.containsKey(moduleId) )
+                                       moduleMap.put(moduleId,new 
ArrayList<CyNode>());
+                               moduleMap.get(moduleId).add(node);
+                       }
+               }
+       }
+
+       private void createNodes(Element genes) {
+               for ( Object o : genes.getChildren("Gene") ) {
+                       Element gene = (Element) o;
+                       CyNode node = 
Cytoscape.getCyNode(gene.getAttributeValue("ORF"),true);
+                       String id = gene.getAttributeValue("Id");
+                       System.out.println("creating node: " + id + "  " + 
node.getIdentifier());
+                       nodeIdMap.put(id,node);
+                       nodeIds.add( node.getRootGraphIndex() );        
+               }
+       }
+
+       private Element getTable(Document doc, String tableName) {
+               for ( Object e : doc.getRootElement().getChildren("Table") )
+                       if ( 
tableName.equals(((Element)e).getAttributeValue("Type")) )
+                               return (Element)e;
+
+               return null;
+       }
+
+       /**
+        *  DOCUMENT ME!
+        *
+        * @param network DOCUMENT ME!
+        */
+       public void doPostProcessing(CyNetwork network) {
+       /*
+               // Set SBML specific visual style
+               VisualMappingManager manager = 
Cytoscape.getVisualMappingManager();
+               CalculatorCatalog catalog = manager.getCalculatorCatalog();
+
+               VisualStyle vs = 
catalog.getVisualStyle(SBMLVisualStyleFactory.SBMLReader_VS);
+
+               if (vs == null) {
+                       vs = SBMLVisualStyleFactory.createVisualStyle(network);
+                       catalog.addVisualStyle(vs);
+               }
+
+               manager.setVisualStyle(vs);
+               Cytoscape.getCurrentNetworkView().setVisualStyle(vs.getName());
+               Cytoscape.getCurrentNetworkView().applyVizmapper(vs);
+               */
+       }
+
+       /**
+        *  DOCUMENT ME!
+        *
+        * @return  DOCUMENT ME!
+        */
+       public int[] getNodeIndicesArray() {
+               int[] nodes = new int[nodeIds.size()];
+
+               for (int i = 0; i < nodes.length; i++)
+                       nodes[i] = nodeIds.get(i).intValue();
+
+               return nodes;
+       }
+
+       /**
+        *  DOCUMENT ME!
+        *
+        * @return  DOCUMENT ME!
+        */
+       public int[] getEdgeIndicesArray() {
+               int[] edges = new int[edgeIds.size()];
+
+               for (int i = 0; i < edges.length; i++)
+                       edges[i] = edgeIds.get(i).intValue();
+
+               return edges;
+       }
+}

Added: 
csplugins/trunk/ucsd/mes/gxp-reader/src/main/java/cytoscape/gxp/GXPReaderPlugin.java
===================================================================
--- 
csplugins/trunk/ucsd/mes/gxp-reader/src/main/java/cytoscape/gxp/GXPReaderPlugin.java
                                (rev 0)
+++ 
csplugins/trunk/ucsd/mes/gxp-reader/src/main/java/cytoscape/gxp/GXPReaderPlugin.java
        2011-10-07 20:32:33 UTC (rev 27084)
@@ -0,0 +1,23 @@
+package cytoscape.gxp;
+
+import cytoscape.Cytoscape;
+import cytoscape.data.ImportHandler;
+import cytoscape.plugin.CytoscapePlugin;
+
+
+/**
+ * This class is used to instantiate your plugin. Put whatever initialization 
code
+ * you need into the no argument constructor (the only one that will be 
called).
+ * The actual functionality of your plugin can be in this class, but should 
+ * probably be separated into separted classes that get instantiated here.
+ */
+public class GXPReaderPlugin extends CytoscapePlugin {
+
+       public GXPReaderPlugin() {
+               super();
+               ImportHandler ih = Cytoscape.getImportHandler();
+               ih.addFilter(new GXPFilter());
+       }
+}      
+
+

Added: 
csplugins/trunk/ucsd/mes/gxp-reader/src/main/java/cytoscape/gxp/SBMLVisualStyleFactory.java.hold
===================================================================
--- 
csplugins/trunk/ucsd/mes/gxp-reader/src/main/java/cytoscape/gxp/SBMLVisualStyleFactory.java.hold
                            (rev 0)
+++ 
csplugins/trunk/ucsd/mes/gxp-reader/src/main/java/cytoscape/gxp/SBMLVisualStyleFactory.java.hold
    2011-10-07 20:32:33 UTC (rev 27084)
@@ -0,0 +1,165 @@
+
+/*
+ Copyright (c) 2006, 2007, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications.  In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage.  See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+
+package sbmlreader;
+
+import cytoscape.*;
+
+import cytoscape.data.Semantics;
+
+import cytoscape.view.CytoscapeDesktop;
+
+import cytoscape.visual.*;
+
+import cytoscape.visual.calculators.*;
+
+import cytoscape.visual.mappings.*;
+
+import cytoscape.visual.ui.*;
+
+import giny.view.EdgeView;
+
+import java.awt.Color;
+
+
+/**
+ * VisualStyleFactory.java
+ * This class defines the visualstyle in Cytoscape for the SBMLReader plugin.
+ *
+ * @author W.P.A. Ligtenberg, Eindhoven University of Technology
+ */
+public class SBMLVisualStyleFactory {
+       /**
+        * 
+        */
+       public static final String SBMLReader_VS = "SBMLReader Style";
+
+       /**
+        * 
+        */
+       public static final String NODE_TYPE_ATT = "sbml type";
+
+       /**
+        * 
+        */
+       public static final String EDGE_TYPE_ATT = "interaction";
+
+       /**
+        *  DOCUMENT ME!
+        *
+        * @param network DOCUMENT ME!
+        *
+        * @return  DOCUMENT ME!
+        */
+       public static VisualStyle createVisualStyle(CyNetwork network) {
+               VisualMappingManager vmManager = 
Cytoscape.getVisualMappingManager();
+               NodeAppearanceCalculator nodeAppCalc = new 
NodeAppearanceCalculator();
+               EdgeAppearanceCalculator edgeAppCalc = new 
EdgeAppearanceCalculator();
+               CalculatorCatalog calculatorCatalog = 
vmManager.getCalculatorCatalog();
+
+               // ------------------------------ Set node shapes 
---------------------------//
+               DiscreteMapping disMapping = new DiscreteMapping(NodeShape.RECT,
+                                                                
ObjectMapping.NODE_MAPPING);
+               disMapping.setControllingAttributeName(NODE_TYPE_ATT, network, 
false);
+               disMapping.putMapValue("species", NodeShape.DIAMOND);
+               disMapping.putMapValue("reaction", NodeShape.ELLIPSE);
+
+               Calculator shapeCalculator = new BasicCalculator("SBMLReader 
Shape Calculator",
+                                                                           
disMapping,
+                                                                               
                                                        
VisualPropertyType.NODE_SHAPE);
+               nodeAppCalc.setCalculator(shapeCalculator);
+
+               // ------------------------------ Set the label 
------------------------------//
+               // Display the value for geneName as a label
+               String cName = "sbml name";
+               Calculator nlc = 
calculatorCatalog.getCalculator(VisualPropertyType.NODE_LABEL, cName);
+
+               if (nlc == null) {
+                       PassThroughMapping m = new PassThroughMapping(new 
String(), cName);
+                       nlc = new BasicCalculator(cName, m, 
VisualPropertyType.NODE_LABEL);
+               }
+
+               nodeAppCalc.setCalculator(nlc);
+
+               //--------------------- Set the size of the nodes 
--------------------------//
+               //Discrete mapping on nodeType
+               Double speciesNodeSize = new Double(30);
+               Double reactionNodeSize = new Double(30);
+               DiscreteMapping sizeMapping = new 
DiscreteMapping(reactionNodeSize,
+                                                                 
ObjectMapping.NODE_MAPPING);
+               sizeMapping.setControllingAttributeName(NODE_TYPE_ATT, network, 
false);
+               sizeMapping.putMapValue("species", speciesNodeSize);
+               sizeMapping.putMapValue("reaction", reactionNodeSize);
+
+               Calculator sizeCalculator = new BasicCalculator("SBMLReader 
Size Calculator",
+                                                                               
 sizeMapping,
+                                                                               
                                                                 
VisualPropertyType.NODE_SIZE);
+               nodeAppCalc.setCalculator(sizeCalculator);
+               nodeAppCalc.setNodeSizeLocked(true);
+
+               // ------------------------------ Set edge arrow shape 
---------------------------//
+               DiscreteMapping arrowMapping = new 
DiscreteMapping(ArrowShape.DELTA,
+                                                                  
ObjectMapping.NODE_MAPPING);
+               arrowMapping.setControllingAttributeName(EDGE_TYPE_ATT, 
network, false);
+               arrowMapping.putMapValue("reaction-product", ArrowShape.ARROW);
+               arrowMapping.putMapValue("reaction-reactant", ArrowShape.NONE);
+               arrowMapping.putMapValue("reaction-modifier", 
ArrowShape.CIRCLE);
+
+               Calculator edgeArrowCalculator = new 
BasicCalculator("SBMLReader Edge Arrow Calculator",
+                                                             arrowMapping,
+                                                                               
                                          
VisualPropertyType.EDGE_SRCARROW_SHAPE);
+               edgeAppCalc.setCalculator(edgeArrowCalculator);
+
+               // ------------------------------ Set edge colour 
---------------------------//
+               DiscreteMapping edgeColorMapping = new 
DiscreteMapping(Color.BLACK,
+                                                                      
ObjectMapping.NODE_MAPPING);
+               edgeColorMapping.setControllingAttributeName(EDGE_TYPE_ATT, 
network, false);
+               edgeColorMapping.putMapValue("reaction-product", Color.GREEN);
+               edgeColorMapping.putMapValue("reaction-reactant", Color.RED);
+               edgeColorMapping.putMapValue("reaction-modifier", Color.BLACK);
+
+               Calculator edgeColorCalculator = new 
BasicCalculator("SBMLReader Edge Color Calculator",
+                                                                               
edgeColorMapping,
+                                                                               
                                                                
VisualPropertyType.EDGE_COLOR);
+               edgeAppCalc.setCalculator(edgeColorCalculator);
+
+               //------------------------- Create a visual style 
-------------------------------//
+               GlobalAppearanceCalculator gac = 
vmManager.getVisualStyle().getGlobalAppearanceCalculator();
+               VisualStyle visualStyle = new VisualStyle(SBMLReader_VS, 
nodeAppCalc, edgeAppCalc, gac);
+
+               return visualStyle;
+       }
+}

Added: 
csplugins/trunk/ucsd/mes/gxp-reader/src/main/resources/cytoscape/gxp/plugin.props
===================================================================
--- 
csplugins/trunk/ucsd/mes/gxp-reader/src/main/resources/cytoscape/gxp/plugin.props
                           (rev 0)
+++ 
csplugins/trunk/ucsd/mes/gxp-reader/src/main/resources/cytoscape/gxp/plugin.props
   2011-10-07 20:32:33 UTC (rev 27084)
@@ -0,0 +1,26 @@
+# This props file would 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
+pluginName=GXPReaderPlugin
+
+# Description used to give users information about the plugin such as what it 
does.  
+# Html tags are encouraged for formatting purposes.
+pluginDescription=GXP Reader Plugin
+
+# Plugin version number, this must be two numbers separated by a decimlal.  
Ex. 0.2, 14.03
+pluginVersion=0.1
+
+# Compatible Cytoscape version
+cytoscapeVersion=2.8
+
+# Category, use one of the categories listed on the website or create your own
+pluginCategory=Network and Attribute I/O
+
+# 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)
+pluginAuthorsIntsitutions=Mike Smoot:UCSD
+

Added: csplugins/trunk/ucsd/mes/gxp-reader/src/main/resources/mime.types
===================================================================
--- csplugins/trunk/ucsd/mes/gxp-reader/src/main/resources/mime.types           
                (rev 0)
+++ csplugins/trunk/ucsd/mes/gxp-reader/src/main/resources/mime.types   
2011-10-07 20:32:33 UTC (rev 27084)
@@ -0,0 +1,26 @@
+#
+# A simple, old format, mime.types file
+#
+text/html              html htm HTML HTM
+text/plain             txt text TXT TEXT
+image/gif              gif GIF
+image/ief              ief
+image/jpeg             jpeg jpg jpe JPG
+image/tiff             tiff tif
+image/png              png PNG
+image/x-xwindowdump    xwd
+application/postscript ai eps ps
+application/rtf                rtf
+application/x-tex      tex
+application/x-texinfo  texinfo texi
+application/x-troff    t tr roff
+audio/basic            au
+audio/midi             midi mid
+audio/x-aifc           aifc
+audio/x-aiff            aif aiff
+audio/x-mpeg           mpeg mpg
+audio/x-wav             wav
+video/mpeg             mpeg mpg mpe
+video/quicktime                qt mov
+video/x-msvideo                avi
+application/json       json

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to