Author: paperwing
Date: 2012-01-24 13:23:20 -0800 (Tue, 24 Jan 2012)
New Revision: 28092

Added:
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/PositionCameraProcedure.java
Modified:
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/BirdsEyeGraphicsHandler.java
   
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/GraphicsHandler.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/MainGraphicsHandler.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
   
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/RenderNodesProcedure.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/ResetSceneProcedure.java
Log:
separated camera positioning from scene clearing, modified how rendering 
procedures are handled in the GraphicsHandlers to make it easier to add/remove 
rendering routines such as drawing node or edge labels

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/BirdsEyeGraphicsHandler.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/BirdsEyeGraphicsHandler.java
  2012-01-24 20:53:23 UTC (rev 28091)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/BirdsEyeGraphicsHandler.java
  2012-01-24 21:23:20 UTC (rev 28092)
@@ -1,6 +1,8 @@
 package org.cytoscape.paperwing.internal;
 
 import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
 import java.util.Map;
 
 import 
org.cytoscape.paperwing.internal.coordinator.BirdsEyeCoordinatorProcessor;
@@ -16,6 +18,7 @@
 import org.cytoscape.paperwing.internal.input.MainInputProcessor;
 import org.cytoscape.paperwing.internal.input.MouseMonitor;
 import org.cytoscape.paperwing.internal.picking.ShapePickingProcessor;
+import org.cytoscape.paperwing.internal.rendering.PositionCameraProcedure;
 import org.cytoscape.paperwing.internal.rendering.ReadOnlyGraphicsProcedure;
 import org.cytoscape.paperwing.internal.rendering.RenderArcEdgesProcedure;
 import org.cytoscape.paperwing.internal.rendering.RenderBoundingBoxProcedure;
@@ -28,16 +31,16 @@
 
 public class BirdsEyeGraphicsHandler implements GraphicsHandler {
 
-private Map<String, ReadOnlyGraphicsProcedure> renderProcedures;
+private List<ReadOnlyGraphicsProcedure> renderProcedures;
 
        public BirdsEyeGraphicsHandler() {
-               renderProcedures = new LinkedHashMap<String, 
ReadOnlyGraphicsProcedure>();
+               renderProcedures = new LinkedList<ReadOnlyGraphicsProcedure>();
                
-               renderProcedures.put("nodes", new RenderNodesProcedure());
-               renderProcedures.put("edges", new RenderArcEdgesProcedure());
-               renderProcedures.put("boundingBox", new 
RenderBoundingBoxProcedure());
-               
-               renderProcedures.put("resetScene", new ResetSceneProcedure());
+               renderProcedures.add(new ResetSceneProcedure());
+               renderProcedures.add(new PositionCameraProcedure());
+               renderProcedures.add(new RenderNodesProcedure());
+               renderProcedures.add(new RenderArcEdgesProcedure());
+               renderProcedures.add(new RenderBoundingBoxProcedure()); 
        }
        
        @Override
@@ -46,11 +49,6 @@
        }
 
        @Override
-       public void resetSceneForDrawing(GraphicsData graphicsData) {
-               renderProcedures.get("resetScene").execute(graphicsData);
-       }
-
-       @Override
        public void drawScene(GraphicsData graphicsData) {
                // TODO Auto-generated method stub
                
@@ -61,9 +59,9 @@
                // gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION,
                // FloatBuffer.wrap(lightPosition));
                
-               renderProcedures.get("edges").execute(graphicsData);
-               renderProcedures.get("nodes").execute(graphicsData);
-               renderProcedures.get("boundingBox").execute(graphicsData);
+               for (ReadOnlyGraphicsProcedure renderProcedure : 
renderProcedures) {
+                       renderProcedure.execute(graphicsData);
+               }
        }
 
        @Override
@@ -122,7 +120,7 @@
 
        @Override
        public void initializeGraphicsProcedures(GraphicsData graphicsData) {
-               for (ReadOnlyGraphicsProcedure renderProcedure : 
renderProcedures.values()) {
+               for (ReadOnlyGraphicsProcedure renderProcedure : 
renderProcedures) {
                        renderProcedure.initialize(graphicsData);
                }
        }

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
 2012-01-24 20:53:23 UTC (rev 28091)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
 2012-01-24 21:23:20 UTC (rev 28092)
@@ -84,7 +84,7 @@
                
                // TODO: add default constant speeds for camera movement
                graphicsData = new GraphicsData();
-               graphicsData.setCamera(new SimpleCamera(new Vector3(0, 0, 2), 
new Vector3(0, 0, 0),
+               graphicsData.setCamera(new SimpleCamera(new Vector3(0, 0, 3), 
new Vector3(0, 0, 0),
                                new Vector3(0, 1, 0), 0.04, 0.0033, 0.01, 0.01, 
0.4));
                
                graphicsData.setNetworkView(networkView);
@@ -138,9 +138,6 @@
                // Process Cytoscape data
                cytoscapeDataProcessor.processCytoscapeData(graphicsData);
                
-               // Reset the scene for drawing
-               handler.resetSceneForDrawing(graphicsData);
-               
                // Draw the scene
                handler.drawScene(graphicsData);
                

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/GraphicsHandler.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/GraphicsHandler.java
  2012-01-24 20:53:23 UTC (rev 28091)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/GraphicsHandler.java
  2012-01-24 21:23:20 UTC (rev 28092)
@@ -22,9 +22,6 @@
        // Call procedures' init methods
        public void initializeGraphicsProcedures(GraphicsData graphicsData);
        
-       // Clear the scene
-       public void resetSceneForDrawing(GraphicsData graphicsData);
-       
        // Draw the scene
        public void drawScene(GraphicsData graphicsData);
 

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/MainGraphicsHandler.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/MainGraphicsHandler.java
      2012-01-24 20:53:23 UTC (rev 28091)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/MainGraphicsHandler.java
      2012-01-24 21:23:20 UTC (rev 28092)
@@ -1,6 +1,8 @@
 package org.cytoscape.paperwing.internal;
 
 import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
 import java.util.Map;
 
 import org.cytoscape.paperwing.internal.coordinator.CoordinatorProcessor;
@@ -13,6 +15,7 @@
 import org.cytoscape.paperwing.internal.input.MainInputProcessor;
 import org.cytoscape.paperwing.internal.picking.DefaultShapePickingProcessor;
 import org.cytoscape.paperwing.internal.picking.ShapePickingProcessor;
+import org.cytoscape.paperwing.internal.rendering.PositionCameraProcedure;
 import org.cytoscape.paperwing.internal.rendering.ReadOnlyGraphicsProcedure;
 import org.cytoscape.paperwing.internal.rendering.RenderArcEdgesProcedure;
 import org.cytoscape.paperwing.internal.rendering.RenderEdgesProcedure;
@@ -25,17 +28,18 @@
 
 public class MainGraphicsHandler implements GraphicsHandler {
 
-       private Map<String, ReadOnlyGraphicsProcedure> renderProcedures;
+       private List<ReadOnlyGraphicsProcedure> renderProcedures;
        
        public MainGraphicsHandler() {
-               renderProcedures = new LinkedHashMap<String, 
ReadOnlyGraphicsProcedure>();
+               renderProcedures = new LinkedList<ReadOnlyGraphicsProcedure>();
                
-               renderProcedures.put("nodes", new RenderNodesProcedure());
-               renderProcedures.put("edges", new RenderArcEdgesProcedure());
-               renderProcedures.put("selectionBox", new 
RenderSelectionBoxProcedure());
-               renderProcedures.put("labels", new RenderNodeLabelsProcedure());
+               renderProcedures.add(new ResetSceneProcedure());
+               renderProcedures.add(new PositionCameraProcedure());
                
-               renderProcedures.put("resetScene", new ResetSceneProcedure());
+               renderProcedures.add(new RenderNodesProcedure());
+               renderProcedures.add(new RenderArcEdgesProcedure());
+               renderProcedures.add(new RenderSelectionBoxProcedure());
+               renderProcedures.add(new RenderNodeLabelsProcedure());
        }
        
        @Override
@@ -44,11 +48,6 @@
        }
 
        @Override
-       public void resetSceneForDrawing(GraphicsData graphicsData) {
-               renderProcedures.get("resetScene").execute(graphicsData);
-       }
-
-       @Override
        public void drawScene(GraphicsData graphicsData) {
                // TODO Auto-generated method stub
                
@@ -58,12 +57,11 @@
                // Code below toggles the light following the camera
                // gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION,
                // FloatBuffer.wrap(lightPosition));
+
+               for (ReadOnlyGraphicsProcedure renderProcedure : 
renderProcedures) {
+                       renderProcedure.execute(graphicsData);
+               }
                
-               renderProcedures.get("edges").execute(graphicsData);
-               renderProcedures.get("nodes").execute(graphicsData);
-               renderProcedures.get("selectionBox").execute(graphicsData);
-               renderProcedures.get("labels").execute(graphicsData);
-               
        }
 
        @Override
@@ -101,7 +99,7 @@
        
        @Override
        public void initializeGraphicsProcedures(GraphicsData graphicsData) {
-               for (ReadOnlyGraphicsProcedure renderProcedure : 
renderProcedures.values()) {
+               for (ReadOnlyGraphicsProcedure renderProcedure : 
renderProcedures) {
                        renderProcedure.initialize(graphicsData);
                }
        }

Added: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/PositionCameraProcedure.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/PositionCameraProcedure.java
                                (rev 0)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/PositionCameraProcedure.java
        2012-01-24 21:23:20 UTC (rev 28092)
@@ -0,0 +1,33 @@
+package org.cytoscape.paperwing.internal.rendering;
+
+import javax.media.opengl.GL2;
+import javax.media.opengl.glu.GLU;
+
+import org.cytoscape.paperwing.internal.data.GraphicsData;
+import org.cytoscape.paperwing.internal.geometric.Vector3;
+import org.cytoscape.paperwing.internal.tools.SimpleCamera;
+
+public class PositionCameraProcedure implements ReadOnlyGraphicsProcedure {
+
+       GLU glu;
+       
+       @Override
+       public void initialize(GraphicsData graphicsData) {
+               glu = GLU.createGLU(graphicsData.getGlContext());
+       }
+
+       @Override
+       public void execute(GraphicsData graphicsData) {
+               GL2 gl = graphicsData.getGlContext();
+               SimpleCamera camera = graphicsData.getCamera();
+               
+               Vector3 position = camera.getPosition();
+               Vector3 target = camera.getTarget();
+               Vector3 up = camera.getUp();
+               
+               glu.gluLookAt(
+                               position.x(), position.y(), position.z(), 
+                               target.x(), target.y(), target.z(), 
+                               up.x(), up.y(), up.z());
+       }
+}


Property changes on: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/PositionCameraProcedure.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
        2012-01-24 20:53:23 UTC (rev 28091)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
        2012-01-24 21:23:20 UTC (rev 28092)
@@ -25,7 +25,7 @@
 
 public class RenderArcEdgesProcedure implements ReadOnlyGraphicsProcedure {
 
-       private static final double SEGMENT_RADIUS = 0.007;
+       private static final double SEGMENT_RADIUS = 0.005; // 0.007 default
        private static final int SEGMENT_SLICES = 4;
        private static final int SEGMENT_STACKS = 1;
        

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-01-24 20:53:23 UTC (rev 28091)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodeLabelsProcedure.java
      2012-01-24 21:23:20 UTC (rev 28092)
@@ -54,6 +54,8 @@
                String text;
                
                textRenderer.setColor(Color.BLACK);
+               
+               gl.glPushMatrix();
                textRenderer.begin3DRendering();
                
                for (View<CyNode> nodeView : networkView.getNodeViews()) {
@@ -66,7 +68,7 @@
 
                        // Draw it only if the visual property says it is 
visible
                        if 
(nodeView.getVisualProperty(MinimalVisualLexicon.NODE_VISIBLE)) {
-                               gl.glPushMatrix();
+                               
 //                             gl.glTranslatef(x, y, z);
                                
                                gl.glColor3f(0.2f, 0.2f, 0.2f);
@@ -90,13 +92,13 @@
                                                        z + (float) 
TEXT_OFFSET.z(), 
                                                        TEXT_SCALE);
                                }
-                               
-                               gl.glPopMatrix();
                        }
                }
                
                textRenderer.flush();
                textRenderer.endRendering();
                
+               gl.glPopMatrix();
+               
        }
 }

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodesProcedure.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodesProcedure.java
   2012-01-24 20:53:23 UTC (rev 28091)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodesProcedure.java
   2012-01-24 21:23:20 UTC (rev 28092)
@@ -33,20 +33,10 @@
        private static final RenderColor DEFAULT_HOVER_COLOR = 
                new RenderColor(0.5, 0.5, 0.7);
        
-       
        /** The default radius of the spherical nodes */
-       private static final float SMALL_SPHERE_RADIUS = 0.102f; // 0.015f
+       private static final float NODE_SIZE_RADIUS = 0.102f; // 0.015f
 
-       /** The slices detail level to use for drawing spherical nodes */
-       // 10, 10, 4 // 24, 24, 12 used to be default values for
-       // slices/stacks/slices
-       private static int NODE_SLICES_DETAIL = 12;
-
-       /** The stacks detail level to use for drawing spherical nodes */
-       private static int NODE_STACKS_DETAIL = 12;
-
        private Map<NodeShape, ShapeType> cytoscapeShapeMap;
-       
        private ScalableShapeDrawer shapeDrawer;
        
        public RenderNodesProcedure() {
@@ -75,22 +65,6 @@
                                .getSelectedNodeIndices();
                int hoverNodeIndex = 
graphicsData.getSelectionData().getHoverNodeIndex();
 
-               // Currently supporting the following visual properties
-
-               // VisualProperty<Double> NODE_X_LOCATION
-               // VisualProperty<Double> NODE_Y_LOCATION
-               // VisualProperty<Double> NODE_Z_LOCATION
-               // VisualProperty<Paint> NODE_PAINT
-               // VisualProperty<Boolean> NODE_VISIBLE
-               // VisualProperty<Boolean> NODE_SELECTED
-               // VisualProperty<Double> NODE_WIDTH
-               // VisualProperty<Double> NODE_HEIGHT
-               // VisualProperty<Double> NODE_DEPTH
-
-               // Uncertain about the following visual properties
-
-               // VisualProperty<Paint> NODE_FILL_COLOR
-
                float x, y, z;
                int index;
                ShapeType shapeType;
@@ -117,7 +91,7 @@
                                chooseColor(gl, nodeView, graphicsData);
                                //gl.glCallList(nodeListIndex);
                                
-                               gl.glScalef(SMALL_SPHERE_RADIUS, 
SMALL_SPHERE_RADIUS, SMALL_SPHERE_RADIUS);
+                               gl.glScalef(NODE_SIZE_RADIUS, NODE_SIZE_RADIUS, 
NODE_SIZE_RADIUS);
                                
                                shapeType = 
cytoscapeShapeMap.get(nodeView.getVisualProperty(RichVisualLexicon.NODE_SHAPE));
                                

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/ResetSceneProcedure.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/ResetSceneProcedure.java
    2012-01-24 20:53:23 UTC (rev 28091)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/ResetSceneProcedure.java
    2012-01-24 21:23:20 UTC (rev 28092)
@@ -10,11 +10,8 @@
 
 public class ResetSceneProcedure implements ReadOnlyGraphicsProcedure {
 
-       GLU glu;
-       
        @Override
        public void initialize(GraphicsData graphicsData) {
-               glu = GLU.createGLU(graphicsData.getGlContext());
        }
 
        @Override
@@ -25,19 +22,6 @@
                // Reset scene
                gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
                gl.glLoadIdentity();
-
-               Vector3 position = camera.getPosition();
-               Vector3 target = camera.getTarget();
-               Vector3 up = camera.getUp();
-
-//             System.out.println(position);
-//             System.out.println(target);
-//             System.out.println(up);
-               
-               glu.gluLookAt(
-                               position.x(), position.y(), position.z(), 
-                               target.x(), target.y(), target.z(), 
-                               up.x(), up.y(), up.z());
        }
 
 }

-- 
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.

Reply via email to