Author: paperwing
Date: 2012-03-21 16:15:00 -0700 (Wed, 21 Mar 2012)
New Revision: 28611
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/coordinator/BirdsEyeCoordinatorProcessor.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/GraphicsData.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/DebugInputHandler.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/layouts/SphericalLayoutAlgorithmTask.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodeLabelsProcedure.java
Log:
Pressing L now toggles between displaying all node labels or only labels of
selected or hovered nodes; Bird's eye view should now show entirety of network
(before, with circular layouts some nodes were cut off); Spherical layout
algorithm now distributes given nodes evenly across latitude and longitude, in
process of adding support for dividing partitioned graphs and graphs with
cliques (subgraphs where all nodes have edges to each other)
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/coordinator/BirdsEyeCoordinatorProcessor.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/coordinator/BirdsEyeCoordinatorProcessor.java
2012-03-21 23:01:52 UTC (rev 28610)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/coordinator/BirdsEyeCoordinatorProcessor.java
2012-03-21 23:15:00 UTC (rev 28611)
@@ -102,7 +102,7 @@
double newDistance = farthestNode.distance(networkCenter);
// Further increase the distance needed
- newDistance *= 2.5;
+ newDistance *= 3;
// newDistance = Math.max(newDistance,
coordinator.getCurrentMainCamera().getPosition().distance(networkCenter) * 2);
newDistance = Math.max(newDistance, 5);
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/GraphicsData.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/GraphicsData.java
2012-03-21 23:01:52 UTC (rev 28610)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/GraphicsData.java
2012-03-21 23:15:00 UTC (rev 28611)
@@ -80,6 +80,9 @@
/** Whether to display the current frames per second */
private boolean showFPS = false;
+ /** Whether to display all node labels */
+ private boolean showAllNodeLabels = true;
+
private Component container;
/** A framerate tracker used to calculate the current number of frames
per second. */
@@ -340,7 +343,15 @@
public boolean getShowFPS() {
return showFPS;
}
+
+ public void setShowAllNodeLabels(boolean showAllNodeLabels) {
+ this.showAllNodeLabels = showAllNodeLabels;
+ }
+ public boolean getShowAllNodeLabels() {
+ return showAllNodeLabels;
+ }
+
public FrameRateTracker getFrameRateTracker() {
return frameRateTracker;
}
@@ -352,5 +363,4 @@
public EdgeAnalyser getEdgeAnalyser() {
return edgeAnalyser;
}
-
}
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/DebugInputHandler.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/DebugInputHandler.java
2012-03-21 23:01:52 UTC (rev 28610)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/DebugInputHandler.java
2012-03-21 23:15:00 UTC (rev 28611)
@@ -25,6 +25,10 @@
if (pressed.contains(KeyEvent.VK_K)) {
graphicsData.setShowFPS(!graphicsData.getShowFPS());
}
+
+ if (pressed.contains(KeyEvent.VK_L)) {
+
graphicsData.setShowAllNodeLabels(!graphicsData.getShowAllNodeLabels());
+ }
}
}
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/layouts/SphericalLayoutAlgorithmTask.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/layouts/SphericalLayoutAlgorithmTask.java
2012-03-21 23:01:52 UTC (rev 28610)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/layouts/SphericalLayoutAlgorithmTask.java
2012-03-21 23:15:00 UTC (rev 28611)
@@ -1,10 +1,19 @@
package org.cytoscape.paperwing.internal.layouts;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Set;
import org.cytoscape.model.CyNode;
+import org.cytoscape.paperwing.internal.geometric.Vector3;
+import org.cytoscape.paperwing.internal.tools.NetworkToolkit;
import org.cytoscape.view.layout.AbstractBasicLayoutTask;
import org.cytoscape.view.layout.AbstractLayoutAlgorithmContext;
+import org.cytoscape.view.layout.LayoutNode;
+import org.cytoscape.view.layout.LayoutPartition;
+import org.cytoscape.view.layout.PartitionUtil;
import org.cytoscape.view.model.CyNetworkView;
import org.cytoscape.view.model.View;
import org.cytoscape.view.presentation.property.BasicVisualLexicon;
@@ -23,32 +32,65 @@
@Override
protected void doLayout(TaskMonitor taskMonitor) {
- taskMonitor.setProgress(0.2);
+ /*
- int nodeCount = networkView.getNodeViews().size();
+ // Break graph into partitions
+ List<LayoutPartition> partitions =
PartitionUtil.partition(networkView, false, null);
+ int numPartitions = partitions.size();
+ int count = 0;
+
+ System.out.println("Number of partitions: " + numPartitions);
+
+ double xOffsetAmount = 1000;
+ double yOffsetAmount = 1000;
+
+ Collection<View<CyNode>> partitionNodeViews;
+
+ for (LayoutPartition partition : partitions) {
+ partitionNodeViews = new HashSet<View<CyNode>>();
+
+ for (LayoutNode layoutNode : partition.getNodeList()) {
+ View<CyNode> nodeView =
layoutNode.getNodeView();
+ partitionNodeViews.add(nodeView);
+ }
+
+
+
+ partition.offset(count * xOffsetAmount, count *
yOffsetAmount);
+
+ count++;
+ }
+
+ */
+
+ arrangeAsSphere(networkView.getNodeViews());
+
+ }
+
+ private void arrangeAsSphere(Collection<View<CyNode>> nodeViews) {
+ int nodeCount = nodeViews.size();
int current = 0;
- double sphereRadius = 500 + Math.sqrt(nodeCount);
+ double sphereRadius = findSphereRadius(nodeCount);
double x, y, z;
- for (View<CyNode> nodeView : networkView.getNodeViews()) {
+ Vector3 sphereCenter = findCenter(nodeViews);
+
+ for (View<CyNode> nodeView : nodeViews) {
- /*
int nodesPerLevel = (int)
Math.max(Math.sqrt(nodeCount), 1);
// The fraction should range from 0 to 1
double levelFraction = Math.floor(current /
nodesPerLevel) * nodesPerLevel / nodeCount;
- double thetaLimit = 0.1;
- double phiLimit = 0.1;
+ double thetaLimit = 0.0;
+ double phiLimit = 0.05;
// double theta = Math.PI / 2 - (Math.PI * thetaLimit +
(double) level / numLevels * Math.PI * (1 - 2 * thetaLimit));
- double theta = Math.PI / 2 - (Math.PI * thetaLimit +
levelFraction * Math.PI * (1 - 2 * thetaLimit));
- double phi = Math.PI * phiLimit + (double) (current %
nodesPerLevel) / nodesPerLevel * Math.PI * (2 - 2 * phiLimit);
+ double theta = Math.PI / 2 - (Math.PI * thetaLimit +
levelFraction * Math.PI * (2 - 2 * thetaLimit));
+ double phi = Math.PI * phiLimit + (double) (current %
nodesPerLevel) / (nodesPerLevel - 1) * Math.PI * (1 - 2 * phiLimit);
- phi = 2;
- */
-
+ /*
int numLevels = (int) Math.sqrt(nodeCount);
int level = (current / numLevels) * numLevels;
@@ -58,6 +100,7 @@
double theta = Math.PI / 2 - (Math.PI * thetaLimit +
(double) level / nodeCount * Math.PI * (1 - 2 * thetaLimit));
double phi = Math.PI * phiLimit + (double) (current %
numLevels) / numLevels * Math.PI * (2 - 2 * phiLimit);
+ */
x = Math.cos(theta) * Math.sin(phi);
y = Math.sin(theta) * Math.sin(phi);
@@ -67,14 +110,53 @@
y *= sphereRadius;
z *= sphereRadius;
-
nodeView.setVisualProperty(BasicVisualLexicon.NODE_X_LOCATION, x);
-
nodeView.setVisualProperty(BasicVisualLexicon.NODE_Y_LOCATION, y);
-
nodeView.setVisualProperty(BasicVisualLexicon.NODE_Z_LOCATION, z);
+
nodeView.setVisualProperty(BasicVisualLexicon.NODE_X_LOCATION, x +
sphereCenter.x());
+
nodeView.setVisualProperty(BasicVisualLexicon.NODE_Y_LOCATION, y +
sphereCenter.y());
+
nodeView.setVisualProperty(BasicVisualLexicon.NODE_Z_LOCATION, z +
sphereCenter.z());
current++;
}
+ }
+
+ /**
+ * Find the average position of a given set of nodes
+ * @param nodeViews A set of nodes whose average position is to be found
+ * @return The average position, in coordinates directly obtained from
node visual properties
+ */
+ private Vector3 findCenter(Collection<View<CyNode>> nodeViews) {
+ double x = 0;
+ double y = 0;
+ double z = 0;
- taskMonitor.setProgress(0.8);
+ for (View<CyNode> nodeView : nodeViews) {
+ x +=
nodeView.getVisualProperty(BasicVisualLexicon.NODE_X_LOCATION);
+ y +=
nodeView.getVisualProperty(BasicVisualLexicon.NODE_Y_LOCATION);
+ z +=
nodeView.getVisualProperty(BasicVisualLexicon.NODE_Z_LOCATION);
+ }
+
+ Vector3 center = new Vector3(x, y, z);
+ center.divideLocal(nodeViews.size());
+
+ return center;
}
+
+ /**
+ * Find an appropriate sphere size given the number of nodes to arrange
+ */
+ private double findSphereRadius(int nodeCount) {
+ return 100 + nodeCount;
+ }
+ /**
+ * Return a list of all cliques in the given set of nodes, sorted in
order of decreasing size.
+ * A clique is a subgraph where there is an edge between any 2 nodes.
+ *
+ * @param nodeViews The set of node view objects that should be used to
find cliques.
+ * @return A list of cliques found, sorted in order of decreasing size.
+ */
+ private List<Collection<View<CyNode>>>
findCliques(Collection<View<CyNode>> nodeViews) {
+ List<Collection<View<CyNode>>> cliques = new
LinkedList<Collection<View<CyNode>>>();
+
+ return null;
+ }
}
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodeLabelsProcedure.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodeLabelsProcedure.java
2012-03-21 23:01:52 UTC (rev 28610)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodeLabelsProcedure.java
2012-03-21 23:15:00 UTC (rev 28611)
@@ -109,18 +109,13 @@
textColor =
TEXT_DEFAULT_COLOR;
}
- // Below to be used for JOGL
2.0-b45-20111219's new TextRenderer
-// gl.glColor3f((float)
textColor.getRed() / 255,
-// (float)
textColor.getGreen() / 255,
-// (float)
textColor.getBlue() / 255);
-
-
-// textRenderer.drawString3D(gl,
FontFactory.getDefault().getDefault(),
-// text, new
float[]{1.0f, 1.0f, 2.0f}, TEXT_FONT_SIZE, 1024);
-
-
textRenderer.setColor(textColor);
- textRenderer.draw(text, (int)
screenCoordinates.x() - findTextScreenWidth(text) / 2, (int)
screenCoordinates.y());
-
+ // If we are set to not draw
all node labels, only show labels for hovered and selected nodes
+ if
(graphicsData.getShowAllNodeLabels()
+ ||
graphicsData.getSelectionData().getHoverNodeIndex() ==
nodeView.getModel().getIndex()
+ ||
nodeView.getVisualProperty(BasicVisualLexicon.NODE_SELECTED)) {
+
textRenderer.setColor(textColor);
+ textRenderer.draw(text,
(int) screenCoordinates.x() - findTextScreenWidth(text) / 2, (int)
screenCoordinates.y());
+ }
}
}
}
@@ -132,7 +127,7 @@
textRenderer.draw("FPS: " + (int) frameRate, 1, 1);
}
- textRenderer.flush();
+ // textRenderer.flush();
textRenderer.endRendering();
gl.glPopMatrix();
--
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.