Author: pwang
Date: 2010-09-30 12:51:24 -0700 (Thu, 30 Sep 2010)
New Revision: 22105
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/StackedNodeLayoutTask.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-30 02:29:22 UTC (rev 22104)
+++
core3/layout-cytoscape-impl/trunk/src/main/java/csplugins/layout/algorithms/StackedNodeLayout.java
2010-09-30 19:51:24 UTC (rev 22105)
@@ -36,15 +36,9 @@
package csplugins.layout.algorithms;
-import java.util.Collection;
-import java.util.Iterator;
-
-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.Tunable;
import org.cytoscape.work.TunableValidator;
import org.cytoscape.work.undo.UndoSupport;
@@ -53,6 +47,17 @@
*
*/
public class StackedNodeLayout extends AbstractLayout implements
TunableValidator {
+
+ @Tunable(description="x_position")
+ public double x_position = 10.0;
+
+ @Tunable(description="y_start_position")
+ public double y_start_position = 10.0;
+
+ //@Tunable(description="nodes")
+ //public Collection nodes;
+
+
/**
* 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.
@@ -62,6 +67,7 @@
* @param y_start_position the y starting position for the stack
*/
+ // TODO
public boolean tunablesAreValid(final Appendable errMsg) {
return true;
}
@@ -76,14 +82,13 @@
*/
public StackedNodeLayout(UndoSupport undoSupport) {
super(undoSupport);
- //this.x_position = x_position;
- //this.y_start_position = y_start_position;
- //this.nodes = nodes;
}
public TaskIterator getTaskIterator() {
- return new TaskIterator(new StackedNodeLayoutTask(networkView,
getName(), selectedOnly, staticNodes));
+
+ return new TaskIterator(new StackedNodeLayoutTask(networkView,
getName(), selectedOnly, staticNodes,
+ x_position, y_start_position));
}
/**
Modified:
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
2010-09-30 02:29:22 UTC (rev 22104)
+++
core3/layout-cytoscape-impl/trunk/src/main/java/csplugins/layout/algorithms/StackedNodeLayoutTask.java
2010-09-30 19:51:24 UTC (rev 22105)
@@ -6,6 +6,7 @@
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNode;
+import org.cytoscape.model.CyTableUtil;
import org.cytoscape.view.layout.LayoutTask;
import org.cytoscape.view.model.CyNetworkView;
import org.cytoscape.view.model.View;
@@ -16,17 +17,34 @@
private double y_start_position;
private double x_position;
+ private Collection nodeViews;
private Collection nodes;
-
+ private boolean selectedOnly = false;
+
public StackedNodeLayoutTask(final CyNetworkView networkView, final
String name,
- final boolean selectedOnly, final Set<View<CyNode>>
staticNodes)
+ final boolean selectedOnly, final Set<View<CyNode>>
staticNodes,
+ double x_position, double y_start_position)
{
super(networkView, name, selectedOnly, staticNodes);
+
+ this.selectedOnly = selectedOnly;
+
+ this.x_position =x_position;
+ this.y_start_position=y_start_position;
+ this.nodeViews = staticNodes;
+
}
final protected void doLayout(final TaskMonitor taskMonitor, final
CyNetwork network) {
-
+
+ if (selectedOnly){
+ nodes =
CyTableUtil.getNodesInState(networkView.getModel(),"selected",true);
+ }
+ else {
+ // select all nodes from the view
+ nodes = network.getNodeList();
+ }
construct();
}
@@ -34,18 +52,20 @@
* DOCUMENT ME!
*/
public void construct() {
+ double yPosition = y_start_position;
+
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);
+
+ int y = new
Float((nodeView.getVisualProperty(TwoDVisualLexicon.NODE_Y_SIZE).toString())).intValue();
+
+ yPosition += y * 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.