Author: chinmoy
Date: 2009-06-26 12:35:41 -0700 (Fri, 26 Jun 2009)
New Revision: 17117
Added:
csplugins/trunk/soc/chinmoy/sample plugins/LayoutPlugin/LayoutPlugin.jar
csplugins/trunk/soc/chinmoy/sample plugins/LayoutPlugin/build.xml
csplugins/trunk/soc/chinmoy/sample plugins/LayoutPlugin/src/
csplugins/trunk/soc/chinmoy/sample plugins/LayoutPlugin/src/LayoutPlugin.java
Log:
Added: csplugins/trunk/soc/chinmoy/sample plugins/LayoutPlugin/LayoutPlugin.jar
===================================================================
(Binary files differ)
Property changes on: csplugins/trunk/soc/chinmoy/sample
plugins/LayoutPlugin/LayoutPlugin.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: csplugins/trunk/soc/chinmoy/sample plugins/LayoutPlugin/build.xml
===================================================================
--- csplugins/trunk/soc/chinmoy/sample plugins/LayoutPlugin/build.xml
(rev 0)
+++ csplugins/trunk/soc/chinmoy/sample plugins/LayoutPlugin/build.xml
2009-06-26 19:35:41 UTC (rev 17117)
@@ -0,0 +1,104 @@
+<!-- =================================================================== -->
+<!-- Plugin build file -->
+<!-- =================================================================== -->
+
+<project name="LayoutPlugin" default="jar" basedir=".">
+
+ <!-- =================================================================== -->
+ <!-- Initialization target -->
+ <!-- =================================================================== -->
+ <target name="init">
+ <property name="plugin_name" value="LayoutPlugin"/>
+ <property name="plugin_class" value="layout.LayoutPlugin"/>
+ <property name="project.jar" value="${plugin_name}.jar"/>
+ <property name="version" value="1.1"/>
+ <property name="year" value="2008"/>
+
+ <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="C:\Program Files\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/LayoutPlugin"
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/chinmoy/sample
plugins/LayoutPlugin/src/LayoutPlugin.java
===================================================================
--- csplugins/trunk/soc/chinmoy/sample
plugins/LayoutPlugin/src/LayoutPlugin.java (rev 0)
+++ csplugins/trunk/soc/chinmoy/sample
plugins/LayoutPlugin/src/LayoutPlugin.java 2009-06-26 19:35:41 UTC (rev
17117)
@@ -0,0 +1,168 @@
+package layout;
+
+
+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 giny.model.GraphPerspective;
+import giny.model.Node;
+import javax.swing.JPanel;
+
+import java.awt.GridLayout;
+import java.awt.Rectangle;
+
+import java.util.Iterator;
+/**
+ *
+ */
+public class LayoutPlugin extends CytoscapePlugin {
+
+ private int groupcount = 2;
+ private LayoutProperties layoutProperties;
+
+
+ /**
+ *
+ */
+ public LayoutPlugin() {
+ CyLayouts.addLayout(new MyLayout(), "My zLayouts");
+ }
+
+ class MyLayout extends AbstractLayout{
+ /**
+ * Creates a new layout object.
+ */
+ public MyLayout() {
+ super();
+ layoutProperties = new LayoutProperties(getName());
+ initialize_properties();
+ }
+
+ protected void initialize_properties() {
+ layoutProperties.add(new Tunable("groupcount",
+ "Number of random
groups ",
+ Tunable.INTEGER, new
Integer(2)));
+
+ layoutProperties.initializeProperties();
+
+ updateSettings(true);
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ public void updateSettings() {
+ updateSettings(false);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param force DOCUMENT ME!
+ */
+ public void updateSettings(boolean force) {
+ layoutProperties.updateValues();
+
+ Tunable t = layoutProperties.get("groupcount");
+
+ if ((t != null) && (t.valueChanged() || force))
+ groupcount = ((Integer)
t.getValue()).intValue();
+ }
+
+ /**
+ * Get the settings panel for this layout
+ */
+ public JPanel getSettingsPanel() {
+ JPanel panel = new JPanel(new GridLayout(0, 1));
+ panel.add(layoutProperties.getTunablePanel());
+
+ return panel;
+ }
+
+
+ /**
+ * DOCUMENT ME!
+ */
+ public void revertSettings() {
+ layoutProperties.revertProperties();
+ }
+
+ public LayoutProperties getSettings() {
+ return layoutProperties;
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ public void construct() {
+
+ taskMonitor.setStatus("Initializing");
+ initialize(); // Calls initialize_local
+
+
+ System.out.println("do layout here: groupcount = "+
groupcount);
+
+ if (groupcount <2) {
+ return;
+ }
+
+ // Get the group center X
+ double[] group_center_x = new double[groupcount];
+
+ for (int i=0; i<groupcount; i++) {
+ group_center_x[i] = i* maxwidth/(groupcount*2);
+ }
+
+ double group_width = (maxwidth/groupcount)*0.6/2;
+
+ Iterator<Node> it = network.nodesIterator();
+
+ int group_id = 0;
+
+ while (it.hasNext()) {
+ if (canceled)
+ return;
+
+ group_id = (int)
Math.round((groupcount-1)*Math.random());
+
+ double x = group_center_x[group_id] +
(Math.random()-0.5)*group_width;
+
+ Node node = (Node) it.next();
+
+ //System.out.println(group_id);
+
+ networkView.getNodeView(node).setYPosition(x);
+ }
+ }
+
+
+ private double maxwidth = 5000.0;
+
+ /**
+ * getName is used to construct property strings
+ * for this layout.
+ */
+ public String getName() {
+ return "My zLayout";
+ }
+
+ /**
+ * toString is used to get the user-visible name
+ * of the layout
+ */
+ public String toString(){
+ return "My first zLayout";
+ }
+ }
+}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---