Author: ghuck
Date: 2009-07-28 08:31:35 -0700 (Tue, 28 Jul 2009)
New Revision: 17593
Modified:
csplugins/trunk/soc/ghuck/plugin/build.xml
csplugins/trunk/soc/ghuck/plugin/src/ForceDirected.java
csplugins/trunk/soc/ghuck/plugin/src/GpuLayout.java
csplugins/trunk/soc/ghuck/plugin/src/gpuGraphDrawing/common.h
Log:
The plugin automatically extracts static library when it is run for the first
time
Modified: csplugins/trunk/soc/ghuck/plugin/build.xml
===================================================================
--- csplugins/trunk/soc/ghuck/plugin/build.xml 2009-07-28 06:37:55 UTC (rev
17592)
+++ csplugins/trunk/soc/ghuck/plugin/build.xml 2009-07-28 15:31:35 UTC (rev
17593)
@@ -116,11 +116,10 @@
<!-- =================================================================== -->
- <!-- Copy jar file and library to Cytoscape plugin folder -->
+ <!-- Copy jar file to Cytoscape plugin folder -->
<!-- =================================================================== -->
<target name="copy_jar" depends="jar">
<copy todir="${cytoscape.plugin.dir}/" file="${root.dir}/${project.jar}"/>
- <copy todir="${cytoscape.plugin.dir}/" file="${root.dir}/libGpuLayout.so"/>
</target>
Modified: csplugins/trunk/soc/ghuck/plugin/src/ForceDirected.java
===================================================================
--- csplugins/trunk/soc/ghuck/plugin/src/ForceDirected.java 2009-07-28
06:37:55 UTC (rev 17592)
+++ csplugins/trunk/soc/ghuck/plugin/src/ForceDirected.java 2009-07-28
15:31:35 UTC (rev 17593)
@@ -41,6 +41,7 @@
import java.awt.Rectangle;
import java.util.Iterator;
import java.lang.reflect.Field;
+import java.lang.Math;
import java.util.*;
import cytoscape.CyNetwork;
@@ -59,9 +60,9 @@
public class ForceDirected extends AbstractGraphPartition
{
-
- private double H_SIZE = 5000.0;
- private double V_SIZE = 5000.0;
+ //private double UNIT_SIZE = 100.0;
+ private double H_SIZE = 1000.0;
+ private double V_SIZE = 1000.0;
private String GPU_LIBRARY = "GpuLayout";
private String CY_PLUGIN_PATH = "/home/gerardo/Cytoscape_v2.6.2/plugins";
private String CUDA_LIB = "/usr/local/cuda/lib";
@@ -91,11 +92,13 @@
initialize_properties();
}
+ /**
+ * This plugin supports laying out only selected nodes
+ */
public boolean supportsSelectedOnly() {
return false;
}
-
/**
* Adds tunable objects for adjusting plugin parameters
@@ -104,11 +107,11 @@
protected void initialize_properties() {
// Add new properties to layout
- layoutProperties.add(new Tunable("coarseGraphSize", "Coarse
Graph Size " , Tunable.INTEGER, new Integer(50) ));
- layoutProperties.add(new Tunable("interpolationIterations",
"Interpolation Iterations " , Tunable.INTEGER, new Integer(50) ));
- layoutProperties.add(new Tunable("levelConvergence", "Level
Convergence " , Tunable.INTEGER, new Integer(2) ));
- layoutProperties.add(new Tunable("edgeLen", "Ideal Edge
Length " , Tunable.INTEGER, new Integer(5) ));
- layoutProperties.add(new Tunable("initialNoIterations", "Initial
Number of Iterations ", Tunable.INTEGER, new Integer(300)));
+ layoutProperties.add(new Tunable("coarseGraphSize", "Coarse
Graph Size" , Tunable.INTEGER, new Integer(50) ));
+ layoutProperties.add(new Tunable("interpolationIterations",
"Interpolation Iterations" , Tunable.INTEGER, new Integer(50) ));
+ layoutProperties.add(new Tunable("levelConvergence", "Level
Convergence" , Tunable.INTEGER, new Integer(2) ));
+ layoutProperties.add(new Tunable("edgeLen", "Ideal Edge
Length" , Tunable.INTEGER, new Integer(5) ));
+ layoutProperties.add(new Tunable("initialNoIterations", "Initial
Number of Iterations", Tunable.INTEGER, new Integer(300)));
// Initialize layout properties
layoutProperties.initializeProperties();
@@ -219,7 +222,7 @@
// Show message on the task monitor
- taskMonitor.setStatus("Initializing, partition: " +
part.getPartitionNumber());
+ taskMonitor.setStatus("Initializing: Partition: " +
part.getPartitionNumber());
// The completed percentage is indeterminable
taskMonitor.setPercentCompleted(-1);
@@ -248,6 +251,10 @@
// Iterate over all nodes
while (it.hasNext()){
+ // Check whether it has been canceled by the user
+ if (canceled)
+ return;
+
// Get next node
LayoutNode node = (LayoutNode) it.next();
@@ -288,14 +295,14 @@
// Show message on screen with AdjMatIndex and AdjMatVals
- String message2 = "AdjMatIndex\n";
+ /*String message2 = "AdjMatIndex\n";
for (int i = 0; i < AdjMatIndex.length; i++)
message2 = message2 + " " +AdjMatIndex[i];
message2 = message2 + "\nAdhMatVals\n";
for (int i = 0; i < AdjMatVals.length; i++)
message2 = message2 + " " +AdjMatVals[i];
JOptionPane.showMessageDialog( Cytoscape.getDesktop(), message2);
-
+ */
// Check whether it has been canceled by the user
if (canceled)
@@ -345,12 +352,17 @@
JOptionPane.showMessageDialog(Cytoscape.getDesktop(), message4);
}
+ // Set H_SIZE and V_SIZE
+ //H_SIZE = 1000.0 + UNIT_SIZE * Math.log((double) numNodes);
+ //V_SIZE = 1000.0 + UNIT_SIZE * Math.log((double) numNodes);
+
+
// Check whether it has been canceled by the user
if (canceled)
- return;
-
+ return;
+
// Show message on the task monitor
- taskMonitor.setStatus("Calling native code... Partition: " +
part.getPartitionNumber());
+ taskMonitor.setStatus("Calling native code: Partition: " +
part.getPartitionNumber());
// Make native method call
float[][]node_positions = ComputeGpuLayout( AdjMatIndex,
Modified: csplugins/trunk/soc/ghuck/plugin/src/GpuLayout.java
===================================================================
--- csplugins/trunk/soc/ghuck/plugin/src/GpuLayout.java 2009-07-28 06:37:55 UTC
(rev 17592)
+++ csplugins/trunk/soc/ghuck/plugin/src/GpuLayout.java 2009-07-28 15:31:35 UTC
(rev 17593)
@@ -1,76 +1,115 @@
-/**************************************************************************************
-Copyright (C) Gerardo Huck, 2009
-
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program 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. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-**************************************************************************************/
-package GpuLayout;
-
-import java.awt.event.ActionEvent;
-
-import cytoscape.Cytoscape;
-import cytoscape.plugin.CytoscapePlugin;
-import cytoscape.util.CytoscapeAction;
-import cytoscape.layout.CyLayouts;
-import cytoscape.layout.CyLayoutAlgorithm;
-import cytoscape.layout.AbstractLayout;
-import cytoscape.layout.LayoutProperties;
-import cytoscape.layout.Tunable;
-import cytoscape.CyNode;
-
-import giny.model.GraphPerspective;
-import giny.model.Node;
-
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-
-import java.awt.GridLayout;
-import java.awt.Rectangle;
-import java.util.Iterator;
-import java.lang.reflect.Field;
-import GpuLayout.*;
-
-
-
-
-/**
- * This plugin provides a GPU assited graph layout utility by calling CUDA C++
code
- */
-public class GpuLayout extends CytoscapePlugin {
-
-
- /**
- * Adds a menu entry and creates an instance of ForceDirected
- */
- public GpuLayout() {
- // Add Layout to menu
+/**************************************************************************************
+Copyright (C) Gerardo Huck, 2009
+
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program 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. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+**************************************************************************************/
+package GpuLayout;
+
+import java.awt.event.ActionEvent;
+
+import cytoscape.Cytoscape;
+import cytoscape.plugin.CytoscapePlugin;
+import cytoscape.util.CytoscapeAction;
+import cytoscape.layout.CyLayouts;
+import cytoscape.layout.CyLayoutAlgorithm;
+import cytoscape.layout.AbstractLayout;
+import cytoscape.layout.LayoutProperties;
+import cytoscape.layout.Tunable;
+import cytoscape.CyNode;
+
+import giny.model.GraphPerspective;
+import giny.model.Node;
+import java.io.*;
+import java.util.jar.*;
+import java.util.zip.*;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+
+import java.awt.GridLayout;
+import java.awt.Rectangle;
+import java.util.Iterator;
+import java.lang.reflect.Field;
+import GpuLayout.*;
+
+
+
+
+
+/**
+ * This plugin provides a GPU assited graph layout utility by calling CUDA C++
code
+ */
+public class GpuLayout extends CytoscapePlugin {
+
+
+ /**
+ * Adds a menu entry and creates an instance of ForceDirected
+ */
+ public GpuLayout() {
+
+ // Check whether the static library is already extracted in the plugins
folder, if not, extract it
+ File staticLib = new File ("./plugins/libGpuLayout.so");
+ if (!staticLib.exists()){
+ // Extract it
+ try {
+ String home = getClass().getProtectionDomain().
+ getCodeSource().getLocation().toString().
+ substring(6);
+ JarFile jar = new JarFile("./plugins/GpuLayout.jar");
+ ZipEntry entry = jar.getEntry("libGpuLayout.so");
+ File efile = new File("./plugins/", entry.getName());
+
+ InputStream in =
+ new BufferedInputStream(jar.getInputStream(entry));
+ OutputStream out =
+ new BufferedOutputStream(new FileOutputStream(efile));
+ byte[] buffer = new byte[2048];
+ for (;;) {
+ int nBytes = in.read(buffer);
+ if (nBytes <= 0) break;
+ out.write(buffer, 0, nBytes);
+ }
+ out.flush();
+ out.close();
+ in.close();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ String message2 = "GpuLayout Plugin: Error While extracting
Static libraty from jar file:\n" + e.getMessage();
+ JOptionPane.showMessageDialog( Cytoscape.getDesktop(),
message2);
+ return;
+ }
+
+ String message = "First time use of GpuLayout Plugin\nExtracted
required library to plugins folder";
+ JOptionPane.showMessageDialog( Cytoscape.getDesktop(), message);
+ }
+
+
+ // Add Layout to menu
CyLayouts.addLayout(new ForceDirected(), "GPU Assisted Layout");
+
- //Show message on screen with AdjMatIndex and AdjMatVals
- //String message2 = "GpuLayout Plugin loaded!\n";
- //JOptionPane.showMessageDialog( Cytoscape.getDesktop(), message2);
-
- }
-
-
-}
-
-
-
-
-
-
-
-
+ }
+
+
+}
+
+
+
+
+
+
+
+
Modified: csplugins/trunk/soc/ghuck/plugin/src/gpuGraphDrawing/common.h
===================================================================
--- csplugins/trunk/soc/ghuck/plugin/src/gpuGraphDrawing/common.h
2009-07-28 06:37:55 UTC (rev 17592)
+++ csplugins/trunk/soc/ghuck/plugin/src/gpuGraphDrawing/common.h
2009-07-28 15:31:35 UTC (rev 17593)
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-See licence.h for more information.
+See license.h for more information.
**************************************************************************************/
#include "license.h"
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---