Author: ghuck
Date: 2009-06-26 07:32:27 -0700 (Fri, 26 Jun 2009)
New Revision: 17107
Added:
csplugins/trunk/soc/ghuck/plugin/
csplugins/trunk/soc/ghuck/plugin/build.xml
csplugins/trunk/soc/ghuck/plugin/plugin.props
csplugins/trunk/soc/ghuck/plugin/src/
csplugins/trunk/soc/ghuck/plugin/src/GpuLayout.java
Log:
Created plugin/ folder.
Created plugin/src folder
Added plugin/src/GpuLayout.java
Added plugin/build.xml
Added plugin/plugin.props
Added: csplugins/trunk/soc/ghuck/plugin/build.xml
===================================================================
--- csplugins/trunk/soc/ghuck/plugin/build.xml (rev 0)
+++ csplugins/trunk/soc/ghuck/plugin/build.xml 2009-06-26 14:32:27 UTC (rev
17107)
@@ -0,0 +1,104 @@
+<!-- =================================================================== -->
+<!-- Plugin build file -->
+<!-- =================================================================== -->
+
+<project name="tutorial01" default="jar" basedir=".">
+
+ <!-- =================================================================== -->
+ <!-- Initialization target -->
+ <!-- =================================================================== -->
+ <target name="init">
+ <property name="plugin_name" value="GpuLayout"/>
+ <property name="plugin_class" value="GpuLayout"/>
+ <property name="project.jar" value="${plugin_name}.jar"/>
+ <property name="version" value="0.1"/>
+ <property name="year" value="2009"/>
+
+ <echo message="Building plugin ${plugin_name} version ${version}..."/>
+
+ <!-- Define the plugin directories -->
+ <property name="root.dir" value="."/>
+ <property name="src.dir" value="${root.dir}/src"/>
+ <property name="build.dir" value="${root.dir}/build"/>
+ <property name="images.dir" value="${root.dir}/images"/>
+ <property name="manifest.dir" value="${root.dir}/manifest"/>
+ <property name="lib.dir" value="${root.dir}/lib"/>
+
+ <!-- Define the Cytoscape directories -->
+ <property name="cytoscape.dir" value="/home/gerardo/Cytoscape_v2.6.2"/>
+ <property name="cytoscape.lib.dir" value="${cytoscape.dir}/lib"/>
+ <property name="cytoscape.plugin.dir" value="${cytoscape.dir}/plugins"/>
+
+ <!-- Inheritable properties -->
+ <property name="debug" value="on"/>
+ <property name="optimize" value="off"/>
+ <property name="deprecation" value="on"/>
+ <property name="nowarn" value="true"/>
+ <property name="fork" value="false"/>
+
+ <!-- Check the availability of some files -->
+ <available file="${cytoscape.dir}/cytoscape.jar"
property="cytoscape.present"/>
+ <available file="${root.dir}/plugin.props" property="plugin.prop.present"/>
+ <available file="${images.dir}" property="images.dir.present"/>
+
+ <!-- Define the java class path -->
+ <path id="project.class.path">
+ <pathelement location="${cytoscape.dir}/cytoscape.jar"/>
+ <pathelement path="${java.class.path}/"/>
+ </path>
+
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Compiles the project -->
+ <!-- =================================================================== -->
+ <target name="compile" depends="init" >
+
+ <echo message="COMPILE ${plugin_name} ..."/>
+
+ <mkdir dir="${build.dir}"/>
+ <javac srcdir="${src.dir}"
+ excludes="${excludes}"
+ classpathref="project.class.path"
+ destdir="${build.dir}"
+ debug="${debug}"
+ nowarn="${nowarn}"
+ deprecation="${deprecation}"
+ optimize="${optimize}"
+ fork="${fork}"/>
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Creates the plugin jar file
-->
+ <!-- =================================================================== -->
+ <target name="jar" depends="compile, copy_plugin_prop, copy_images" >
+
+ <jar destfile="${project.jar}">
+ <manifest> <attribute name="Cytoscape-Plugin" value="${plugin_class}"/>
</manifest>
+ <fileset dir="${build.dir}" includes="**"/>
+ </jar>
+
+ </target>
+
+ <!-- If plugin.prop exist, copy it to build directory -->
+ <target name="copy_plugin_prop" if="plugin.prop.present">
+ <copy todir="${build.dir}/cytoscape/tutorial01"
file="${root.dir}/plugin.props"/>
+ </target>
+
+ <!-- If there are any image files, copy them to build directory -->
+ <target name="copy_images" if="images.dir.present">
+ <copy todir="${build.dir}">
+ <fileset dir="${images.dir}"/>
+ </copy>
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Clean up, get back to original state -->
+ <!-- =================================================================== -->
+ <target name="clean" depends="init">
+ <delete dir="${build.dir}"/>
+ </target>
+
+</project>
+
+<!-- End of file -->
Added: csplugins/trunk/soc/ghuck/plugin/plugin.props
===================================================================
--- csplugins/trunk/soc/ghuck/plugin/plugin.props
(rev 0)
+++ csplugins/trunk/soc/ghuck/plugin/plugin.props 2009-06-26 14:32:27 UTC
(rev 17107)
@@ -0,0 +1,37 @@
+#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=GpuLayout
+
+# Description used to give users information about the plugin such as what it
does.
+# Html tags are encouraged for formatting purposes.
+pluginDescription=This plugin computes a graph force driven layout.<br>It uses
the GPU to accelerate the layout process (you must have a CUDA compatible
graphic card, with CUDA and CUDPP installed.<p>
+
+# Plugin version number, this must be two numbers separated by a decimal. Ex.
0.2, 14.03
+pluginVersion=0.01
+
+# Compatible Cytoscape version. If there are more than one version, seperate
by ",".
+cytoscapeVersion=3.0
+
+# Category, use one of the categories listed on the
http://cytoscape.org/plugins2.php site
+pluginCategory=Scripting/Communication
+
+# -- The following properties are OPTIONAL -- #
+
+# URL to a website that gives more information about your plugin, Ex.
http://my-lab-site.org
+projectURL=http://socrates2.cgl.ucsf.edu/GenMAPP/wiki/Google_Summer_of_Code_2009/Gerardo
+
+# 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=Gerardo Huck:Google Summer of Code 2009
+
+# Date this plugin/plugin version was released
+releaseDate=July 1, 2009
+
+# 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
Added: csplugins/trunk/soc/ghuck/plugin/src/GpuLayout.java
===================================================================
--- csplugins/trunk/soc/ghuck/plugin/src/GpuLayout.java
(rev 0)
+++ csplugins/trunk/soc/ghuck/plugin/src/GpuLayout.java 2009-06-26 14:32:27 UTC
(rev 17107)
@@ -0,0 +1,126 @@
+
+
+
+import java.util.*;
+import java.awt.event.ActionEvent;
+import javax.swing.JOptionPane;
+
+import giny.model.Node;
+import giny.view.NodeView;
+
+import cytoscape.plugin.CytoscapePlugin;
+import cytoscape.util.CytoscapeAction;
+import cytoscape.Cytoscape;
+import cytoscape.CyNetwork;
+import cytoscape.CyNode;
+import cytoscape.CyEdge;
+import cytoscape.view.CyNetworkView;
+import cytoscape.data.Semantics;
+
+/**
+
+
+ */
+
+
+public class GpuLayout extends CytoscapePlugin {
+
+ /**
+ * This constructor creates an action and adds it to the Plugins menu.
+ */
+ public GpuLayout() {
+ // Show message on screen
+ String message = "Hello World!";
+ //System.out.println(message);
+ // use the CytoscapeDesktop as parent for a Swing dialog
+ JOptionPane.showMessageDialog( Cytoscape.getDesktop(), message);
+
+ //create a new action to respond to menu activation
+ GpuLayoutAction action = new GpuLayoutAction();
+ //set the preferred menu
+ action.setPreferredMenu("Layouts");
+ //and add it to the menus
+ Cytoscape.getDesktop().getCyMenus().addAction(action);
+ }
+
+ /**
+ * Gives a description of this plugin.
+ */
+ public String describe() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("Bla Bla... ");
+ sb.append(" more Bla.. ");
+ return sb.toString();
+ }
+
+ /**
+ * This class gets attached to the menu item.
+ */
+ public class GpuLayoutAction extends CytoscapeAction {
+
+ /**
+ * The constructor sets the text that should appear on the menu item.
+ */
+ public GpuLayoutAction() {super("GPU Layout");}
+
+ /**
+ * This method is called when the user selects the menu item.
+ */
+ public void actionPerformed(ActionEvent ae) {
+ //get the network object; this contains the graph
+ CyNetwork network = Cytoscape.getCurrentNetwork();
+ //get the network view object
+ CyNetworkView view = Cytoscape.getCurrentNetworkView();
+ //can't continue if either of these is null
+ if (network == null || view == null) {return;}
+ //put up a dialog if there are no selected nodes
+ if (view.getSelectedNodes().size() == 0) {
+ JOptionPane.showMessageDialog(view.getComponent(),
+ "Please select one or more nodes.");
+ }
+
+ //a container to hold the objects we're going to select
+ Set nodeViewsToSelect = new HashSet();
+ //iterate over every node view
+ for (Iterator i = view.getSelectedNodes().iterator(); i.hasNext();
) {
+ NodeView nView = (NodeView)i.next();
+ //first get the corresponding node in the network
+ CyNode node = (CyNode)nView.getNode();
+ // get the neighbors of that node
+ List neighbors = network.neighborsList(node);
+ // and iterate over the neighbors
+ for (Iterator ni = neighbors.iterator(); ni.hasNext(); ) {
+ CyNode neighbor = (CyNode)ni.next();
+ // get the view on this neighbor
+ NodeView neighborView = view.getNodeView(neighbor);
+ //and add that view to our container of objects to select
+ nodeViewsToSelect.add(neighborView);
+ }
+ }
+ //now go through our container and select each view
+ for (Iterator i = nodeViewsToSelect.iterator(); i.hasNext(); ) {
+ NodeView nView = (NodeView)i.next();
+ nView.setSelected(true);
+ }
+ //tell the view to redraw since we've changed the selection
+ view.redrawGraph(false, true);
+ }
+
+ /**
+ * Gets the canonical name of the given node from the network object
+ * and returns a String holding just the last letter of that name.
+ *
+ * Returns null if a valid name cannot be obtained.
+ */
+ private String getLastLetter(CyNetwork network, CyNode node) {
+ String canonicalName = (String)network.getNodeAttributeValue(node,
Semantics.CANONICAL_NAME);
+ //return nothing if we can't get a valid name
+ if (canonicalName == null || canonicalName.length() == 0) {return
null;}
+ //extract the last letter
+ int length = canonicalName.length();
+ String lastLetter = canonicalName.substring(length-1);
+ return lastLetter;
+ }
+ }
+}
+
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---