Author: pwang
Date: 2010-09-28 16:49:31 -0700 (Tue, 28 Sep 2010)
New Revision: 22099
Added:
core3/layout-cytoscape-impl/trunk/src/main/java/csplugins/layout/algorithms/StackedNodeLayoutTask.java
Modified:
core3/layout-cytoscape-impl/trunk/src/main/java/csplugins/layout/algorithms/StackedNodeLayout.java
Log:
Refactored
Modified:
core3/layout-cytoscape-impl/trunk/src/main/java/csplugins/layout/algorithms/StackedNodeLayout.java
===================================================================
---
core3/layout-cytoscape-impl/trunk/src/main/java/csplugins/layout/algorithms/StackedNodeLayout.java
2010-09-28 23:37:18 UTC (rev 22098)
+++
core3/layout-cytoscape-impl/trunk/src/main/java/csplugins/layout/algorithms/StackedNodeLayout.java
2010-09-28 23:49:31 UTC (rev 22099)
@@ -41,15 +41,18 @@
import org.cytoscape.model.CyNode;
import org.cytoscape.view.layout.AbstractLayout;
+import org.cytoscape.view.layout.internal.algorithms.GridNodeLayoutTask;
import org.cytoscape.view.model.View;
import org.cytoscape.view.presentation.property.TwoDVisualLexicon;
+import org.cytoscape.work.TaskIterator;
+import org.cytoscape.work.TunableValidator;
import org.cytoscape.work.undo.UndoSupport;
/**
*
*/
-public class StackedNodeLayout extends AbstractLayout {
+public class StackedNodeLayout extends AbstractLayout implements
TunableValidator {
/**
* Puts a collection of nodes into a "stack" layout. This means the
nodes are
* arranged in a line vertically, with each node overlapping with the
previous.
@@ -58,10 +61,12 @@
* @param x_position the x position for the nodes
* @param y_start_position the y starting position for the stack
*/
- private double y_start_position;
- private double x_position;
- private Collection nodes;
+ public boolean tunablesAreValid(final Appendable errMsg) {
+ return true;
+ }
+
+
/**
* Creates a new StackedNodeLayout object.
*
@@ -69,27 +74,16 @@
* @param y_start_position DOCUMENT ME!
* @param nodes DOCUMENT ME!
*/
- public StackedNodeLayout(UndoSupport undoSupport, double x_position,
double y_start_position, Collection nodes) {
+ public StackedNodeLayout(UndoSupport undoSupport) {
super(undoSupport);
- this.x_position = x_position;
- this.y_start_position = y_start_position;
- this.nodes = nodes;
+ //this.x_position = x_position;
+ //this.y_start_position = y_start_position;
+ //this.nodes = nodes;
}
-
- /**
- * DOCUMENT ME!
- */
- public void construct() {
- Iterator it = nodes.iterator();
- double yPosition = y_start_position;
-
- while (it.hasNext()) {
- CyNode node = (CyNode) it.next();
- View<CyNode> nodeView = networkView.getNodeView(node);
-
nodeView.setVisualProperty(TwoDVisualLexicon.NODE_X_LOCATION, x_position);
-
nodeView.setVisualProperty(TwoDVisualLexicon.NODE_Y_LOCATION, yPosition);
- yPosition +=
(nodeView.getVisualProperty(TwoDVisualLexicon.NODE_Y_SIZE) * 2);
- }
+
+
+ public TaskIterator getTaskIterator() {
+ return new TaskIterator(new StackedNodeLayoutTask(networkView,
getName(), selectedOnly, staticNodes));
}
/**
Added:
core3/layout-cytoscape-impl/trunk/src/main/java/csplugins/layout/algorithms/StackedNodeLayoutTask.java
===================================================================
---
core3/layout-cytoscape-impl/trunk/src/main/java/csplugins/layout/algorithms/StackedNodeLayoutTask.java
(rev 0)
+++
core3/layout-cytoscape-impl/trunk/src/main/java/csplugins/layout/algorithms/StackedNodeLayoutTask.java
2010-09-28 23:49:31 UTC (rev 22099)
@@ -0,0 +1,51 @@
+package csplugins.layout.algorithms;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNode;
+import org.cytoscape.view.layout.LayoutTask;
+import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.model.View;
+import org.cytoscape.view.presentation.property.TwoDVisualLexicon;
+import org.cytoscape.work.TaskMonitor;
+
+public class StackedNodeLayoutTask extends LayoutTask {
+
+ private double y_start_position;
+ private double x_position;
+ private Collection nodes;
+
+ public StackedNodeLayoutTask(final CyNetworkView networkView, final
String name,
+ final boolean selectedOnly, final Set<View<CyNode>>
staticNodes)
+
+ {
+ super(networkView, name, selectedOnly, staticNodes);
+ }
+
+ final protected void doLayout(final TaskMonitor taskMonitor, final
CyNetwork network) {
+
+ construct();
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ public void construct() {
+ Iterator it = nodes.iterator();
+ double yPosition = y_start_position;
+
+ while (it.hasNext()) {
+ CyNode node = (CyNode) it.next();
+ View<CyNode> nodeView = networkView.getNodeView(node);
+
nodeView.setVisualProperty(TwoDVisualLexicon.NODE_X_LOCATION, x_position);
+
nodeView.setVisualProperty(TwoDVisualLexicon.NODE_Y_LOCATION, yPosition);
+ yPosition +=
(nodeView.getVisualProperty(TwoDVisualLexicon.NODE_Y_SIZE) * 2);
+ }
+ }
+
+
+
+}
--
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.