Author: kono
Date: 2012-06-19 15:17:30 -0700 (Tue, 19 Jun 2012)
New Revision: 29625
Modified:
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/graphPartition/DegreeSortedCircleLayoutTask.java
Log:
Degree should be integer, not Double.
Modified:
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/graphPartition/DegreeSortedCircleLayoutTask.java
===================================================================
---
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/graphPartition/DegreeSortedCircleLayoutTask.java
2012-06-19 22:08:08 UTC (rev 29624)
+++
core3/impl/trunk/layout-cytoscape-impl/src/main/java/csapps/layout/algorithms/graphPartition/DegreeSortedCircleLayoutTask.java
2012-06-19 22:17:30 UTC (rev 29625)
@@ -1,6 +1,5 @@
package csapps.layout.algorithms.graphPartition;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -18,63 +17,61 @@
import org.cytoscape.view.model.View;
import org.cytoscape.work.undo.UndoSupport;
-
public class DegreeSortedCircleLayoutTask extends AbstractPartitionLayoutTask {
- private String DEGREE_ATTR_NAME = "degree.layout";
- private CyNetwork network;
+
+ private static final String DEGREE_ATTR_NAME = "degree.layout";
+
+ private final CyNetwork network;
/**
* Creates a new GridNodeLayout object.
*/
- public DegreeSortedCircleLayoutTask(final String name, CyNetworkView
networkView, Set<View<CyNode>> nodesToLayOut, DegreeSortedCircleContext
context, String attrName, UndoSupport undo) {
+ public DegreeSortedCircleLayoutTask(final String name, CyNetworkView
networkView, Set<View<CyNode>> nodesToLayOut,
+ DegreeSortedCircleContext context, String attrName,
UndoSupport undo) {
super(name, context.singlePartition, networkView,
nodesToLayOut, attrName, undo);
this.network = networkView.getModel();
}
- /**
- * DOCUMENT ME!
- *
- * @param partition DOCUMENT ME!
- */
+ @Override
public void layoutPartion(LayoutPartition partition) {
// Create attribute
- CyTable table = network.getDefaultNodeTable();
+ final CyTable table = network.getDefaultNodeTable();
if (table.getColumn(DEGREE_ATTR_NAME) == null)
- table.createColumn(DEGREE_ATTR_NAME, Double.class,
false);
+ table.createColumn(DEGREE_ATTR_NAME, Integer.class,
false);
// just add the unlocked nodes
- List<LayoutNode> nodes = new ArrayList<LayoutNode>();
+ final List<LayoutNode> nodes = new ArrayList<LayoutNode>();
for (final LayoutNode ln : partition.getNodeList()) {
if (!ln.isLocked())
nodes.add(ln);
}
-
+
if (cancelled)
return;
// sort the Nodes based on the degree
- Collections.sort(nodes,
- new Comparator<LayoutNode>() {
- public int compare(LayoutNode o1, LayoutNode
o2) {
- final CyNode node1 = o1.getNode();
- final CyNode node2 = o2.getNode();
- // FIXME: should allow parametrization
of edge type? (expose as tunable)
- final int d1 =
network.getAdjacentEdgeList(node1, CyEdge.Type.ANY).size();
- final int d2 =
network.getAdjacentEdgeList(node2, CyEdge.Type.ANY).size();
-
- // Create Degree Attribute
- o1.getRow().set(DEGREE_ATTR_NAME,
(double)d1);
- o2.getRow().set(DEGREE_ATTR_NAME,
(double)d2);
-
- return (d2 - d1);
- }
+ Collections.sort(nodes, new Comparator<LayoutNode>() {
+ public int compare(LayoutNode o1, LayoutNode o2) {
+ final CyNode node1 = o1.getNode();
+ final CyNode node2 = o2.getNode();
+ // FIXME: should allow parametrization of edge
type? (expose as
+ // tunable)
+ final int d1 =
network.getAdjacentEdgeList(node1, CyEdge.Type.ANY).size();
+ final int d2 =
network.getAdjacentEdgeList(node2, CyEdge.Type.ANY).size();
- public boolean equals(Object o) {
- return false;
- }
- });
+ // Create Degree Attribute
+ o1.getRow().set(DEGREE_ATTR_NAME, (double) d1);
+ o2.getRow().set(DEGREE_ATTR_NAME, (double) d2);
+ return (d2 - d1);
+ }
+
+ public boolean equals(Object o) {
+ return false;
+ }
+ });
+
if (cancelled)
return;
@@ -90,9 +87,4 @@
partition.moveNodeToLocation(node);
}
}
-
- //public void construct() {
- // super.construct();
- //}
-
}
--
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.