Author: paperwing
Date: 2011-06-27 05:55:16 -0700 (Mon, 27 Jun 2011)
New Revision: 25948
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/.settings/org.eclipse.jdt.core.prefs
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Vector3.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindMapRenderingEngineFactory.java
Log:
straight edges implemented; updated node sizes
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/.settings/org.eclipse.jdt.core.prefs
2011-06-27 01:34:49 UTC (rev 25947)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/.settings/org.eclipse.jdt.core.prefs
2011-06-27 12:55:16 UTC (rev 25948)
@@ -1,3 +1,3 @@
-#Sun Jun 26 10:33:12 EDT 2011
+#Mon Jun 27 05:19:20 EDT 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
2011-06-27 01:34:49 UTC (rev 25947)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
2011-06-27 12:55:16 UTC (rev 25948)
@@ -18,6 +18,7 @@
import com.jogamp.opengl.util.gl2.GLUT;
import org.cytoscape.session.CyApplicationManager;
+import org.cytoscape.model.CyEdge;
import org.cytoscape.model.CyNetworkManager;
import org.cytoscape.model.CyNode;
import org.cytoscape.view.model.CyNetworkView;
@@ -30,12 +31,18 @@
public class Graphics implements GLEventListener {
private static final float LARGE_SPHERE_RADIUS = 1.0f; // 1.5f
- private static final float SMALL_SPHERE_RADIUS = 0.125f; // 0.015f
- private static final float EDGE_RADIUS = 0.008f;
-
+ private static final float SMALL_SPHERE_RADIUS = 0.102f; // 0.015f
+ private static final float EDGE_RADIUS = 0.018f;
+
+ /*
+ * This value controls distance scaling when converting from node
+ * coordinates to drawing coordinates
+ */
+ private static final float DISTANCE_SCALE = 178.0f;
+
private static final int NODE_SLICES_DETAIL = 24;
private static final int NODE_STACKS_DETAIL = 24;
- private static final int EDGE_SLICES_DETAIL = 3;
+ private static final int EDGE_SLICES_DETAIL = 12;
private static final int EDGE_STACKS_DETAIL = 1;
private class DrawnNode {
@@ -170,7 +177,7 @@
if (pressed.contains(KeyEvent.VK_SPACE)) {
endTime = System.nanoTime();
-
+
double duration = (endTime - startTime) /
Math.pow(10, 9);
double frameRate = framesElapsed / duration;
System.out.println("Average fps over " +
duration + " seconds: "
@@ -395,11 +402,13 @@
//
projection.addLocal(camera.getPosition().subtract(eye));
projection.addLocal(camera.getPosition());
- /*
- testNode.x = (float) projection.x();
- testNode.y = (float) projection.y();
- testNode.z = (float) projection.z();
- */
+ if
(mouse.getPressed().contains(MouseEvent.BUTTON1)) {
+ /*
+ testNode.x = (float) projection.x();
+ testNode.y = (float) projection.y();
+ testNode.z = (float) projection.z();
+ */
+ }
// testNode.x = (float) nearPosition.x();
// testNode.y = (float) nearPosition.y();
@@ -424,6 +433,8 @@
if
(mouse.getPressed().contains(MouseEvent.BUTTON1)) {
selected = result;
+
+ System.out.println("Selected: " +
selected);
}
}
@@ -475,7 +486,7 @@
gl.glPushName(-1);
drawNodes(gl);
- drawEdges(gl);
+ //drawEdges(gl);
//gl.glPopMatrix();
//draw end
@@ -493,7 +504,9 @@
// System.out.println("Number of hits: " + hits);
int selected;
- if (hits > 0) {
+ if (hits > 0) {
+ // The variable max helps keep track of the polygon
that is closest
+ // to the front of the screen
int max = buffer.get(2);
selected = buffer.get(3);
@@ -517,9 +530,9 @@
int index;
for (View<CyNode> nodeView : networkView.getNodeViews()) {
- x = ((Double)
nodeView.getVisualProperty(RichVisualLexicon.NODE_X_LOCATION)).floatValue() /
200.0f;
- y = ((Double)
nodeView.getVisualProperty(RichVisualLexicon.NODE_Y_LOCATION)).floatValue() /
200.0f;
- z = ((Double)
nodeView.getVisualProperty(RichVisualLexicon.NODE_Z_LOCATION)).floatValue() /
200.0f;
+ x =
nodeView.getVisualProperty(RichVisualLexicon.NODE_X_LOCATION).floatValue() /
DISTANCE_SCALE;
+ y =
nodeView.getVisualProperty(RichVisualLexicon.NODE_Y_LOCATION).floatValue() /
DISTANCE_SCALE;
+ z =
nodeView.getVisualProperty(RichVisualLexicon.NODE_Z_LOCATION).floatValue() /
DISTANCE_SCALE;
index = nodeView.getModel().getIndex();
gl.glLoadName(index);
@@ -547,11 +560,34 @@
// Draw the testNode
gl.glTranslatef(testNode.x, testNode.y, testNode.z);
// gl.glCallList(nodeListIndex);
+ GLUT glut = new GLUT();
+ glut.glutSolidCylinder(EDGE_RADIUS, 1,
+ EDGE_SLICES_DETAIL, EDGE_STACKS_DETAIL);
gl.glTranslatef(-testNode.x, -testNode.y, -testNode.z);
}
private void drawEdges(GL2 gl) {
+ View<CyNode> sourceView;
+ View<CyNode> targetView;
+
+ float x1, x2, y1, y2, z1, z2;
+
+ for (View<CyEdge> edgeView : networkView.getEdgeViews()) {
+ sourceView =
networkView.getNodeView(edgeView.getModel().getSource());
+ targetView =
networkView.getNodeView(edgeView.getModel().getTarget());
+
+ x1 =
sourceView.getVisualProperty(RichVisualLexicon.NODE_X_LOCATION).floatValue() /
DISTANCE_SCALE;
+ y1 =
sourceView.getVisualProperty(RichVisualLexicon.NODE_Y_LOCATION).floatValue() /
DISTANCE_SCALE;
+ z1 =
sourceView.getVisualProperty(RichVisualLexicon.NODE_Z_LOCATION).floatValue() /
DISTANCE_SCALE;
+
+ x2 =
targetView.getVisualProperty(RichVisualLexicon.NODE_X_LOCATION).floatValue() /
DISTANCE_SCALE;
+ y2 =
targetView.getVisualProperty(RichVisualLexicon.NODE_Y_LOCATION).floatValue() /
DISTANCE_SCALE;
+ z2 =
targetView.getVisualProperty(RichVisualLexicon.NODE_Z_LOCATION).floatValue() /
DISTANCE_SCALE;
+
+ drawSingleEdge(gl, x1, y1, z1, x2, y2, z2);
+ }
+
/*
// gl.glColor3f(0.9f, 0.1f, 0.1f);
for (int i = 0; i < EDGE_COUNT; i++) {
@@ -572,7 +608,28 @@
}
*/
}
+
+ private void drawSingleEdge(GL2 gl, float x1, float y1, float z1, float
x2,
+ float y2, float z2) {
+ gl.glPushMatrix();
+
+ gl.glTranslatef(x1, y1, z1);
+
+ Vector3 current = new Vector3(0, 0, 1);
+ Vector3 direction = new Vector3(x2 - x1, y2 - y1, z2 - z1);
+
+ Vector3 rotateAxis = current.cross(direction);
+ // TODO: Consider using a Vector3f object for just floats
+ gl.glRotated(Math.toDegrees(direction.angle(current)),
rotateAxis.x(), rotateAxis.y(),
+ rotateAxis.z());
+
+ gl.glScalef(1.0f, 1.0f, (float) direction.magnitude());
+ gl.glCallList(edgeListIndex);
+
+ gl.glPopMatrix();
+ }
+
private void drawNodesEdges(GL2 gl) {
gl.glCallList(edgeListIndex);
gl.glCallList(nodeListIndex);
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Vector3.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Vector3.java
2011-06-27 01:34:49 UTC (rev 25947)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Vector3.java
2011-06-27 12:55:16 UTC (rev 25948)
@@ -103,6 +103,10 @@
}
}
+ public double magnitude() {
+ return Math.sqrt(x * x + y * y + z * z);
+ }
+
public void normalizeLocal() {
double length = Math.sqrt(x * x + y * y + z * z);
if (length > Double.MIN_NORMAL) {
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindMapRenderingEngineFactory.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindMapRenderingEngineFactory.java
2011-06-27 01:34:49 UTC (rev 25947)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindMapRenderingEngineFactory.java
2011-06-27 12:55:16 UTC (rev 25948)
@@ -33,72 +33,15 @@
this.networkViewManager = networkViewManager;
this.renderingEngineManager = renderingEngineManager;
this.visualLexicon = lexicon;
+
+ // TestGraphics.initSingleton();
+ Graphics.initSingleton();
+ WindRenderingEngine.setNetworkViewManager(networkViewManager);
}
@Override
public RenderingEngine<CyNetwork> getInstance(
Object container, View<CyNetwork> viewModel) {
-
- if (container instanceof JComponent) {
- System.out.println("map getInstance called");
-
- JComponent component = (JComponent) container;
- // component.removeAll();
- // System.out.println("number of components in
container after remove: " + component.getComponents().length);
-
- // Use the system's default version of OpenGL
- GLProfile profile = GLProfile.getDefault();
-
- // TODO: changed true to false, check for performance
difference
- // GLProfile.initSingleton(false);
-
- GLCapabilities capabilities = new
GLCapabilities(profile);
-
- // TODO: check whether to use GLCanvas or GLJPanel
- // GLCanvas canvas = new GLCanvas(capabilities);
- GLJPanel canvas = new GLJPanel(capabilities);
- // canvas.setBorder(BorderFactory.createEmptyBorder(5,
5, 5, 5));
-
- TestGraphics graphics = new TestGraphics();
-
- canvas.addGLEventListener(graphics);
-
- if (container instanceof JInternalFrame) {
- JInternalFrame frame = (JInternalFrame)
container;
- Container pane = frame.getContentPane();
-
- graphics.trackInput(pane);
-
- /*
- JPanel panel = new JPanel();
- panel.setLayout(new BorderLayout());
- panel.add(canvas, BorderLayout.CENTER);
- component.add(panel, BorderLayout.CENTER);
- */
-
- pane.setLayout(new BorderLayout());
- pane.add(canvas, BorderLayout.CENTER);
-
- // TODO: check if this line needed
- pane.setVisible(true);
- } else {
- graphics.trackInput(component);
- // graphics.trackInput(canvas);
-
- component.setLayout(new BorderLayout());
- // component.add(canvas, BorderLayout.CENTER);
- }
-
- graphics.setManagers(null, null, networkViewManager,
renderingEngineManager);
-
- //FPSAnimator animator = new FPSAnimator(60);
- //animator.add(canvas);
- //animator.start();
-
- // Animator animator = new Animator(canvas);
- // animator.setRunAsFastAsPossible(true);
- // animator.start();
- }
/* For code below, seems that NetworkViewManager does not
contain references to all available NetworkViews
*/
@@ -117,21 +60,17 @@
System.out.println("current model: " + view.getModel());
System.out.println("current model suid: " +
view.getModel().getSUID());
System.out.println("current suid: " + view.getSUID());
-
-
+
}
- // viewModel.getModel().
-
- System.out.println("Returning networkView: " + networkView);
*/
//TODO: NetworkViewManager does not contain all instances of
CyNetworkView, so wait
- WindRenderingEngine engine = new
WindRenderingEngine(networkViewManager, viewModel, visualLexicon);
+ WindRenderingEngine engine = new WindRenderingEngine(container,
viewModel, visualLexicon);
System.out.println("map returning engine: " + engine);
renderingEngineManager.addRenderingEngine(engine);
+ System.out.println("map engine active?: " + engine.isActive());
- // TODO Auto-generated method stub
return engine;
}
--
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.