Author: paperwing
Date: 2012-01-23 15:48:17 -0800 (Mon, 23 Jan 2012)
New Revision: 28078

Added:
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodeLabelsProcedure.java
Removed:
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderLabelsProcedure.java
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/MainGraphicsHandler.java
   
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/ViewingCoordinator.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/CoordinatorData.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/BoundsInputHandler.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderBoundingBoxProcedure.java
Log:
node label rendering with JOGL's TextRenderer class implemented, viewing volume 
drawing on the bird's eye view updated. vizmapper sometimes crashes when 
setting node labels. check if resizing window causes and viewing volume drawing 
errors (a perspective change such as changing the width:height ratio should 
cause the viewing volume to reshape)

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-23 23:15:19 UTC (rev 28077)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
 2012-01-23 23:48:17 UTC (rev 28078)
@@ -129,12 +129,12 @@
                // Perform picking
                shapePickingProcessor.processPicking(mouse, keys, graphicsData);
                
+               // Check input
+               inputProcessor.processInput(keys, mouse, graphicsData);
+               
                // Update data for bird's eye view camera movement
                coordinatorProcessor.extractData(coordinator, graphicsData);
                
-               // Check input
-               inputProcessor.processInput(keys, mouse, graphicsData);
-               
                // Process Cytoscape data
                cytoscapeDataProcessor.processCytoscapeData(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-23 23:15:19 UTC (rev 28077)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/MainGraphicsHandler.java
      2012-01-23 23:48:17 UTC (rev 28078)
@@ -16,7 +16,7 @@
 import org.cytoscape.paperwing.internal.rendering.ReadOnlyGraphicsProcedure;
 import org.cytoscape.paperwing.internal.rendering.RenderArcEdgesProcedure;
 import org.cytoscape.paperwing.internal.rendering.RenderEdgesProcedure;
-import org.cytoscape.paperwing.internal.rendering.RenderLabelsProcedure;
+import org.cytoscape.paperwing.internal.rendering.RenderNodeLabelsProcedure;
 import org.cytoscape.paperwing.internal.rendering.RenderNodesProcedure;
 import org.cytoscape.paperwing.internal.rendering.RenderSelectionBoxProcedure;
 import org.cytoscape.paperwing.internal.rendering.ResetSceneProcedure;
@@ -33,7 +33,7 @@
                renderProcedures.put("nodes", new RenderNodesProcedure());
                renderProcedures.put("edges", new RenderArcEdgesProcedure());
                renderProcedures.put("selectionBox", new 
RenderSelectionBoxProcedure());
-               renderProcedures.put("labels", new RenderLabelsProcedure());
+               renderProcedures.put("labels", new RenderNodeLabelsProcedure());
                
                renderProcedures.put("resetScene", new ResetSceneProcedure());
        }

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-01-23 23:15:19 UTC (rev 28077)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/coordinator/BirdsEyeCoordinatorProcessor.java
 2012-01-23 23:48:17 UTC (rev 28078)
@@ -27,12 +27,10 @@
                        if (coordinator.isInitialMainCameraInitialized()
                                        && 
!coordinator.isInitialBoundsMatched()) {
                                
-                               
coordinatorData.setBoundsTo(coordinator.getMainCameraBounds());
+                               
coordinatorData.setNearBoundsTo(coordinator.getMainCameraBounds());
+                               
coordinatorData.setFarBoundsTo(coordinator.calculateBackBounds());
                                coordinatorData.setInitialBoundsMatched(true);
                                coordinator.setInitialBoundsMatched(true);
-                               
-                               
coordinatorData.setLastReportedMainCameraPosition(
-                                               
coordinator.getUpdatedMainCameraPosition());
                        }
                        
                        // This is the regular case
@@ -42,24 +40,28 @@
                                if (coordinatorData.isBoundsManuallyChanged()) {
                                        
                                        // Transfer data to coordinator
-                                       
coordinator.setBirdsEyeBoundsCopy(coordinatorData.getBounds());
+                                       
coordinator.setBirdsEyeBoundsCopy(coordinatorData.getNearBounds());
                                        
+                                       // Use new information to recalculate 
far bounds
+                                       
coordinator.getMainCameraCopy().getPosition().set(
+                                                       
coordinator.calculateCameraPosition(
+                                                                       
coordinator.getMainCameraCopy().getDirection()));
+                                       
coordinatorData.setFarBoundsTo(coordinator.calculateBackBounds());
+                                       
                                        // Set flag
                                        
coordinator.setBirdsEyeBoundsMoved(true);
                                        
                                        // Unset internal flag
                                        
coordinatorData.setBoundsManuallyChanged(false);
                                        
+                                       
                                // User moved the main camera
                                } else if (coordinator.isMainCameraMoved()) {
                                        
                                        // Obtain data from coordinator
-                                       
coordinatorData.setBoundsTo(coordinator.calculateBounds());
+                                       
coordinatorData.setNearBoundsTo(coordinator.calculateBounds());
+                                       
coordinatorData.setFarBoundsTo(coordinator.calculateBackBounds());
                                        
-                                       // Store a copy of the main camera's 
position
-                                       
coordinatorData.setLastReportedMainCameraPosition(
-                                                       
coordinator.getUpdatedMainCameraPosition());
-                                       
                                        // Unset flag
                                        coordinator.setMainCameraMoved(false);
                                }
@@ -68,11 +70,9 @@
                                if (coordinator.isSuggestRecalculateBounds()) {
                                        
                                        // Obtain data from coordinator
-                                       
coordinatorData.setBoundsTo(coordinator.calculateBounds());
+                                       
coordinatorData.setNearBoundsTo(coordinator.calculateBounds());
+                                       
coordinatorData.setFarBoundsTo(coordinator.calculateBackBounds());
                                        
-                                       
coordinatorData.setLastReportedMainCameraPosition(
-                                                       
coordinator.getUpdatedMainCameraPosition());
-                                       
                                        // Unset flag
                                        
coordinator.setSuggestRecalculateBounds(false);
                                }

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/coordinator/ViewingCoordinator.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/coordinator/ViewingCoordinator.java
   2012-01-23 23:15:19 UTC (rev 28077)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/coordinator/ViewingCoordinator.java
   2012-01-23 23:48:17 UTC (rev 28078)
@@ -10,15 +10,26 @@
 import org.cytoscape.paperwing.internal.tools.SimpleCamera;
 import org.cytoscape.view.model.CyNetworkView;
 
+/**
+ * This class is responsible for allowing communication between the main
+ * and bird's eye rendering objects without introducing circular reference 
schemes,
+ * as well allowing for either of the main and bird's eye pair to be switched 
during
+ * runtime.
+ *
+ * @author yuedong
+ */
 public class ViewingCoordinator {
 
        // Distance between bounds and camera position
        // TODO: Make into member variable, with adjustable value
-       public static double BOUND_DISTANCE = 0.7;
+       public static final double NEAR_BOUNDS_DISTANCE = 0.9;
        
-       public static double BOUNDS_CHANGE_THRESHOLD = 5e-16;
-       public static double CAMERA_CHANGE_THRESHOLD = 5e-25;
+       // Distance between the back bounds and the camera
+       public static final double FAR_BOUNDS_DISTANCE = 1.1;
        
+       public static final double BOUNDS_CHANGE_THRESHOLD = 5e-16;
+       public static final double CAMERA_CHANGE_THRESHOLD = 5e-25;
+       
        private SimpleCamera mainCameraCopy;
        private Quadrilateral birdsEyeBoundsCopy;
        
@@ -64,7 +75,7 @@
                Quadrilateral bounds;
                
                bounds = 
GeometryToolkit.generateViewingBounds(mainCameraCopy.getPosition(), 
-                               mainCameraCopy.getDirection(), 
mainCameraCopy.getUp(), BOUND_DISTANCE, verticalFov, aspectRatio);
+                               mainCameraCopy.getDirection(), 
mainCameraCopy.getUp(), NEAR_BOUNDS_DISTANCE, verticalFov, aspectRatio);
                
                return bounds;
        }
@@ -113,15 +124,27 @@
                        return 
GeometryToolkit.generateViewingBounds(mainCameraCopy.getPosition(), 
                                        mainCameraCopy.getDirection(), 
                                        mainCameraCopy.getUp(),
-                                       BOUND_DISTANCE, verticalFov, 
aspectRatio);
+                                       NEAR_BOUNDS_DISTANCE, verticalFov, 
aspectRatio);
                }
        }
        
+       // Returns null if main camera not initialized
+       public Quadrilateral calculateBackBounds() {
+               if (!initialMainCameraInitialized) {
+                       return null;
+               } else {
+                       return 
GeometryToolkit.generateViewingBounds(mainCameraCopy.getPosition(), 
+                                       mainCameraCopy.getDirection(), 
+                                       mainCameraCopy.getUp(),
+                                       FAR_BOUNDS_DISTANCE, verticalFov, 
aspectRatio);
+               }
+       }
+       
        public Vector3 calculateCameraPosition(Vector3 cameraDirection) {
                if (!initialBoundsMatched) {
                        return null;
                } else {
-                       return 
GeometryToolkit.generateCameraPosition(birdsEyeBoundsCopy, cameraDirection, 
BOUND_DISTANCE);
+                       return 
GeometryToolkit.generateCameraPosition(birdsEyeBoundsCopy, cameraDirection, 
NEAR_BOUNDS_DISTANCE);
                }
        }
        

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/CoordinatorData.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/CoordinatorData.java
     2012-01-23 23:15:19 UTC (rev 28077)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/CoordinatorData.java
     2012-01-23 23:48:17 UTC (rev 28078)
@@ -4,32 +4,37 @@
 import org.cytoscape.paperwing.internal.geometric.Vector3;
 
 public class CoordinatorData {
-       private Quadrilateral bounds;
+       private Quadrilateral nearBounds;
+       private Quadrilateral farBounds;
        
-       
        private boolean boundsManuallyChanged;
        private boolean initialBoundsMatched;
-
-       public Vector3 lastReportedMainCameraPosition;
        
        // This class only works with copies of Vector3 objects
        public CoordinatorData() {
-               bounds = new Quadrilateral();
+               nearBounds = new Quadrilateral();
+               farBounds = new Quadrilateral();
                
                boundsManuallyChanged = false;
                initialBoundsMatched = false;
-               
-               lastReportedMainCameraPosition = new Vector3();
        }
 
-       public void setBoundsTo(Quadrilateral bounds) {
-               this.bounds.set(bounds);
+       public void setNearBoundsTo(Quadrilateral nearBounds) {
+               this.nearBounds.set(nearBounds);
        }
 
-       public Quadrilateral getBounds() {
-               return bounds;
+       public Quadrilateral getNearBounds() {
+               return nearBounds;
        }
 
+       public void setFarBoundsTo(Quadrilateral backBounds) {
+               this.farBounds.set(backBounds);
+       }
+
+       public Quadrilateral getFarBounds() {
+               return farBounds;
+       }
+       
        public void setBoundsManuallyChanged(boolean boundsManuallyChanged) {
                this.boundsManuallyChanged = boundsManuallyChanged;
        }
@@ -45,13 +50,4 @@
        public boolean isInitialBoundsMatched() {
                return initialBoundsMatched;
        }
-
-       public Vector3 getLastReportedMainCameraPosition() {
-               return lastReportedMainCameraPosition;
-       }
-
-       public void setLastReportedMainCameraPosition(
-                       Vector3 lastReportedMainCameraPosition) {
-               
this.lastReportedMainCameraPosition.set(lastReportedMainCameraPosition);
-       }
 }

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/BoundsInputHandler.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/BoundsInputHandler.java
 2012-01-23 23:15:19 UTC (rev 28077)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/BoundsInputHandler.java
 2012-01-23 23:48:17 UTC (rev 28078)
@@ -1,5 +1,6 @@
 package org.cytoscape.paperwing.internal.input;
 
+import org.cytoscape.paperwing.internal.coordinator.ViewingCoordinator;
 import org.cytoscape.paperwing.internal.data.CoordinatorData;
 import org.cytoscape.paperwing.internal.data.GraphicsData;
 import org.cytoscape.paperwing.internal.geometric.Quadrilateral;
@@ -18,52 +19,71 @@
                processMoveBounds(mouse, graphicsData);
        }
        
+       /**
+        * Move the rectangular boundaries on the bird's eye view based on where
+        * the mouse clicked
+        * 
+        * @param mouse
+        * @param graphicsData
+        */
        private void processMoveBounds(MouseMonitor mouse, GraphicsData 
graphicsData) {
                CoordinatorData coordinatorData = 
graphicsData.getCoordinatorData();
                SimpleCamera camera = graphicsData.getCamera();
                
                if (mouse.getHeld().contains(MouseEvent.BUTTON1)
                                && coordinatorData.isInitialBoundsMatched()) {
-                       Vector3 mousePosition = 
GeometryToolkit.convertMouseTo3d(mouse, graphicsData, camera.getDistance());
+                       Vector3 nearMousePosition = 
GeometryToolkit.convertMouseTo3d(
+                                       mouse, graphicsData, 
ViewingCoordinator.NEAR_BOUNDS_DISTANCE);
+                       Vector3 farMousePosition = 
GeometryToolkit.convertMouseTo3d(
+                                       mouse, graphicsData, 
ViewingCoordinator.FAR_BOUNDS_DISTANCE);
                        
                        // The y-coordinate needs to be inverted
                        // mousePosition.set(mousePosition.x(), 
-mousePosition.y(), mousePosition.z());
                        
-                       Quadrilateral oldBounds = coordinatorData.getBounds();
+                       Quadrilateral oldNearBounds = 
coordinatorData.getNearBounds();
                        
-                       // Line-plane intersection approach
-//                     Vector3 newCenterPoint = 
GeometryToolkit.findLinePlaneIntersection(camera.getPosition(), 
-//                                     
mousePosition.subtract(camera.getPosition()), oldBounds.getCenterPoint(), 
camera.getDirection());
-                       
-                       // Orthogonal anchor approach (not complete, 
approximate)
-//                     Vector3 newCenterPoint = 
GeometryToolkit.findNewOrthogonalAnchoredPosition(mousePosition, 
-//                                     oldBounds.getCenterPoint(), 
camera.getDirection());
-                       
-                       // Direct calculation approach
-                       double projectionOrthogonalDistance = 
GeometryToolkit.findOrthogonalDistance(camera.getPosition(), 
-                                       oldBounds.getCenterPoint(), 
camera.getDirection());
+                       oldNearBounds.moveTo(findClickedNewCenter(
+                                       camera.getPosition(), 
camera.getDirection(), oldNearBounds.getCenterPoint(), nearMousePosition));
 
-                       Vector3 mouseCameraOffset = 
mousePosition.subtract(camera.getPosition());
-                       double mouseCameraAngle = 
camera.getDirection().angle(mouseCameraOffset);
-                       
-                       // TODO: implement checks so mouseCameraAngle stays 
away from 90 degrees, but should be ok as
-                       // this means the mouse is at an unlikely 90 degrees 
from the direction vector
-                       double projectionDiagonalDistance = 
projectionOrthogonalDistance / Math.cos(mouseCameraAngle);
-                       
-                       Vector3 newCenterPoint = mouseCameraOffset.normalize();
-                       
newCenterPoint.multiplyLocal(projectionDiagonalDistance);
-                       newCenterPoint.addLocal(camera.getPosition());
-                       
-                       oldBounds.moveTo(newCenterPoint);
-                       
-                       // Debug useful
-//                     System.out.println("mouseX: " + mouse.x());
-//                     System.out.println("mouseY: " + mouse.y());
-//     
-//                     System.out.println("mousePosition: " + mousePosition);
-//                     System.out.println("newCenterPoint: " + newCenterPoint);
-                       
                        coordinatorData.setBoundsManuallyChanged(true);
                }
        }
+       
+       /** 
+        * Moves a point from its previous position to align itself with the 
line formed between
+        * the camera and the projected mouse click position.
+        * 
+        * @param cameraPosition The position of the camera used to align with
+        * @param cameraDirection The direction vector of the camera used as 
the normal for orthogonal displacement
+        * @param oldPosition The old position, used to obtain orthogonal data
+        * @param projectedMousePosition The projected mouse position to align 
with
+        */
+       private Vector3 findClickedNewCenter(Vector3 cameraPosition, Vector3 
cameraDirection, Vector3 oldPosition, Vector3 projectedMousePosition) {
+               // Line-plane intersection approach
+//             Vector3 newCenterPoint = 
GeometryToolkit.findLinePlaneIntersection(camera.getPosition(), 
+//                             mousePosition.subtract(camera.getPosition()), 
oldBounds.getCenterPoint(), camera.getDirection());
+               
+               // Orthogonal anchor approach (not complete, approximate)
+//             Vector3 newCenterPoint = 
GeometryToolkit.findNewOrthogonalAnchoredPosition(mousePosition, 
+//                             oldBounds.getCenterPoint(), 
camera.getDirection());
+               
+               // Direct calculation approach
+               double projectionOrthogonalDistance = 
GeometryToolkit.findOrthogonalDistance(
+                               cameraPosition, 
+                               oldPosition,
+                               cameraDirection);
+
+               Vector3 mouseCameraOffset = 
projectedMousePosition.subtract(cameraPosition);
+               double mouseCameraAngle = 
cameraDirection.angle(mouseCameraOffset);
+               
+               // TODO: implement checks so mouseCameraAngle stays away from 
90 degrees, but should be ok as
+               // this means the mouse is at an unlikely 90 degrees from the 
direction vector
+               double projectionDiagonalDistance = 
projectionOrthogonalDistance / Math.cos(mouseCameraAngle);
+               
+               Vector3 newPosition = mouseCameraOffset.normalize();
+               newPosition.multiplyLocal(projectionDiagonalDistance);
+               newPosition.addLocal(cameraPosition);
+               
+               return newPosition;
+       }
 }

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderBoundingBoxProcedure.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderBoundingBoxProcedure.java
     2012-01-23 23:15:19 UTC (rev 28077)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderBoundingBoxProcedure.java
     2012-01-23 23:48:17 UTC (rev 28078)
@@ -35,7 +35,7 @@
        private void drawHalfBox(GraphicsData graphicsData) {
                GL2 gl = graphicsData.getGlContext();
                
-               Quadrilateral bounds = 
graphicsData.getCoordinatorData().getBounds();
+               Quadrilateral bounds = 
graphicsData.getCoordinatorData().getNearBounds();
                double fraction = 0.25;
                
                Vector3 topLeft = bounds.getTopLeft();
@@ -93,7 +93,7 @@
        private void drawFullBox(GraphicsData graphicsData) {
                GL2 gl = graphicsData.getGlContext();
        
-               Quadrilateral bounds = 
graphicsData.getCoordinatorData().getBounds();
+               Quadrilateral bounds = 
graphicsData.getCoordinatorData().getNearBounds();
 
                Vector3 topLeft = bounds.getTopLeft();
                Vector3 topRight = bounds.getTopRight();
@@ -123,19 +123,10 @@
        private void drawViewingVolumePortion(GraphicsData graphicsData) {
                
                GL2 gl = graphicsData.getGlContext();
-               Vector3 eyePosition = 
graphicsData.getCoordinatorData().getLastReportedMainCameraPosition();
-               Quadrilateral frontFace = 
graphicsData.getCoordinatorData().getBounds();
-               Quadrilateral backFace;
-
-               double backDistanceMultiplier = -1.2;
                
-               // Move the back face so it is twice the distance away from the 
depicted camera as the front face
-               backFace = new Quadrilateral(
-                               frontFace.getTopLeft().towards(eyePosition, 
backDistanceMultiplier),
-                               frontFace.getTopRight().towards(eyePosition, 
backDistanceMultiplier),
-                               frontFace.getBottomLeft().towards(eyePosition, 
backDistanceMultiplier),
-                               frontFace.getBottomRight().towards(eyePosition, 
backDistanceMultiplier));
-               
+               Quadrilateral frontFace = 
graphicsData.getCoordinatorData().getNearBounds();
+               Quadrilateral backFace = 
graphicsData.getCoordinatorData().getFarBounds();
+
                gl.glDisable(GL2.GL_LIGHTING);
                gl.glDisable(GL.GL_DEPTH_TEST);
                

Deleted: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderLabelsProcedure.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderLabelsProcedure.java
  2012-01-23 23:15:19 UTC (rev 28077)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderLabelsProcedure.java
  2012-01-23 23:48:17 UTC (rev 28078)
@@ -1,111 +0,0 @@
-package org.cytoscape.paperwing.internal.rendering;
-
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.font.FontRenderContext;
-import java.util.Set;
-
-import javax.media.opengl.GL2;
-
-import org.cytoscape.model.CyNode;
-import org.cytoscape.paperwing.internal.data.GraphicsData;
-import org.cytoscape.paperwing.internal.geometric.Vector3;
-import 
org.cytoscape.paperwing.internal.rendering.shapes.ScalableShapeDrawer.ShapeType;
-import org.cytoscape.paperwing.internal.rendering.text.StringRenderer;
-import org.cytoscape.paperwing.internal.tools.RenderColor;
-import org.cytoscape.view.model.CyNetworkView;
-import org.cytoscape.view.model.View;
-import org.cytoscape.view.presentation.property.MinimalVisualLexicon;
-import org.cytoscape.view.presentation.property.RichVisualLexicon;
-
-import com.jogamp.opengl.util.awt.TextRenderer;
-
-public class RenderLabelsProcedure implements ReadOnlyGraphicsProcedure {
-
-       private static final float TEXT_SCALE = 0.045f;
-       private static final Vector3 TEXT_OFFSET = new Vector3 (0, 0.04, 0);
-       
-       private TextRenderer textRenderer;
-       private Font defaultFont = new Font("Trebuchet MS", Font.PLAIN, 72);
-       
-       public RenderLabelsProcedure() {
-               textRenderer = new TextRenderer(defaultFont);
-       }
-       
-       @Override
-       public void initialize(GraphicsData graphicsData) {
-               GL2 gl = graphicsData.getGlContext();
-               
-               textRenderer.setSmoothing(false);
-       }
-
-       @Override
-       public void execute(GraphicsData graphicsData) {
-               GL2 gl = graphicsData.getGlContext();
-
-               CyNetworkView networkView = graphicsData.getNetworkView();
-               float distanceScale = graphicsData.getDistanceScale();
-               float x, y, z;
-
-               String text;
-               
-               textRenderer.setColor(Color.BLACK);
-               textRenderer.begin3DRendering();
-               
-               for (View<CyNode> nodeView : networkView.getNodeViews()) {
-                       x = 
nodeView.getVisualProperty(RichVisualLexicon.NODE_X_LOCATION)
-                                       .floatValue() / distanceScale;
-                       y = 
nodeView.getVisualProperty(RichVisualLexicon.NODE_Y_LOCATION)
-                                       .floatValue() / distanceScale;
-                       z = 
nodeView.getVisualProperty(RichVisualLexicon.NODE_Z_LOCATION)
-                                       .floatValue() / distanceScale;
-
-                       // 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);
-                               
-                               text = 
nodeView.getVisualProperty(MinimalVisualLexicon.NODE_LABEL);
-                               
-//                             gl.glTranslatef((float) TEXT_OFFSET.x(),
-//                                             (float) TEXT_OFFSET.y(),
-//                                             (float) TEXT_OFFSET.z());
-                               
-                               if (text != null) {
-                                       
-//                                     gl.glScalef(TEXT_SCALE, TEXT_SCALE, 
TEXT_SCALE);
-                                       // textRenderer.drawCenteredText(gl, 
text, TEXT_OFFSET);
-                                       // textRenderer.drawCenteredText(gl, 
"aac");
-                                       
-//                                     text = "test" + nodeView.getSUID();
-                                       textRenderer.draw3D(text, 
-                                                       x + (float) 
TEXT_OFFSET.x() - text.length() * 0.0085f, 
-                                                       y + (float) 
TEXT_OFFSET.y(), 
-                                                       z + (float) 
TEXT_OFFSET.z(), 
-                                                       0.0005f);
-                               }
-                               
-                               gl.glPopMatrix();
-                       }
-               }
-               
-               textRenderer.flush();
-               textRenderer.endRendering();
-               
-       }
-
-       private int getStringWidth(TextRenderer textRenderer, String string) {
-//             FontRenderContext renderContext = 
textRenderer.getFontRenderContext();
-               
-               int width = 0;
-               
-               for (int i = 0; i < string.length(); i++) {
-                       width += textRenderer.getCharWidth(string.charAt(i));
-                       
-               }
-               
-               return width;
-       }
-}

Copied: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodeLabelsProcedure.java
 (from rev 28076, 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderLabelsProcedure.java)
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodeLabelsProcedure.java
                              (rev 0)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodeLabelsProcedure.java
      2012-01-23 23:48:17 UTC (rev 28078)
@@ -0,0 +1,102 @@
+package org.cytoscape.paperwing.internal.rendering;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.font.FontRenderContext;
+import java.util.Set;
+
+import javax.media.opengl.GL2;
+
+import org.cytoscape.model.CyNode;
+import org.cytoscape.paperwing.internal.data.GraphicsData;
+import org.cytoscape.paperwing.internal.geometric.Vector3;
+import 
org.cytoscape.paperwing.internal.rendering.shapes.ScalableShapeDrawer.ShapeType;
+import org.cytoscape.paperwing.internal.rendering.text.StringRenderer;
+import org.cytoscape.paperwing.internal.tools.RenderColor;
+import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.model.View;
+import org.cytoscape.view.presentation.property.MinimalVisualLexicon;
+import org.cytoscape.view.presentation.property.RichVisualLexicon;
+
+import com.jogamp.opengl.util.awt.TextRenderer;
+
+public class RenderNodeLabelsProcedure implements ReadOnlyGraphicsProcedure {
+
+       private static final float TEXT_SCALE = 0.0005f;
+       private static final Vector3 TEXT_OFFSET = new Vector3 (0, 0.04, 0);
+       
+       private static final float TEXT_CHARACTER_WIDTH = 0.612f;
+       private static final int TEXT_FONT_SIZE = 72;
+       
+       private TextRenderer textRenderer;
+       private Font defaultFont = new Font("Trebuchet MS", Font.PLAIN, 
TEXT_FONT_SIZE);
+       
+       public RenderNodeLabelsProcedure() {
+               textRenderer = new TextRenderer(defaultFont);
+       }
+       
+       @Override
+       public void initialize(GraphicsData graphicsData) {
+               GL2 gl = graphicsData.getGlContext();
+               
+               // Increase rendering efficiency; can set to true if desired
+               textRenderer.setSmoothing(false);
+       }
+
+       @Override
+       public void execute(GraphicsData graphicsData) {
+               GL2 gl = graphicsData.getGlContext();
+
+               CyNetworkView networkView = graphicsData.getNetworkView();
+               float distanceScale = graphicsData.getDistanceScale();
+               float x, y, z;
+
+               String text;
+               
+               textRenderer.setColor(Color.BLACK);
+               textRenderer.begin3DRendering();
+               
+               for (View<CyNode> nodeView : networkView.getNodeViews()) {
+                       x = 
nodeView.getVisualProperty(RichVisualLexicon.NODE_X_LOCATION)
+                                       .floatValue() / distanceScale;
+                       y = 
nodeView.getVisualProperty(RichVisualLexicon.NODE_Y_LOCATION)
+                                       .floatValue() / distanceScale;
+                       z = 
nodeView.getVisualProperty(RichVisualLexicon.NODE_Z_LOCATION)
+                                       .floatValue() / distanceScale;
+
+                       // 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);
+                               
+                               text = 
nodeView.getVisualProperty(MinimalVisualLexicon.NODE_LABEL);
+                               
+//                             gl.glTranslatef((float) TEXT_OFFSET.x(),
+//                                             (float) TEXT_OFFSET.y(),
+//                                             (float) TEXT_OFFSET.z());
+                               
+                               if (text != null) {
+                                       
+//                                     gl.glScalef(TEXT_SCALE, TEXT_SCALE, 
TEXT_SCALE);
+                                       // textRenderer.drawCenteredText(gl, 
text, TEXT_OFFSET);
+                                       // textRenderer.drawCenteredText(gl, 
"aac");
+                                       
+//                                     text = "test" + nodeView.getSUID();
+                                       textRenderer.draw3D(text, 
+                                                       x + (float) 
TEXT_OFFSET.x() - text.length() * (TEXT_CHARACTER_WIDTH / TEXT_FONT_SIZE), 
+                                                       y + (float) 
TEXT_OFFSET.y(), 
+                                                       z + (float) 
TEXT_OFFSET.z(), 
+                                                       TEXT_SCALE);
+                               }
+                               
+                               gl.glPopMatrix();
+                       }
+               }
+               
+               textRenderer.flush();
+               textRenderer.endRendering();
+               
+       }
+}


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

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