Author: paperwing
Date: 2012-03-28 15:45:59 -0700 (Wed, 28 Mar 2012)
New Revision: 28686

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/cytoscape/processing/TableSelectionCytoscapeDataSubprocessor.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/WindNetworkView.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/CameraInputHandler.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/shapes/ScalableShapeDrawer.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/NetworkToolkit.java
Log:
Bird's eye view is now more responsive after changes from feature #826 to pause 
rendering unless the scene is being changed. Mouse listeners were added to the 
container in Graphics.java for the bird's eye view to trigger scene 
re-rendering.

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-03-28 22:22:52 UTC (rev 28685)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
 2012-03-28 22:45:59 UTC (rev 28686)
@@ -8,6 +8,10 @@
 package org.cytoscape.paperwing.internal;
 import java.awt.Component;
 import java.awt.Container;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionAdapter;
 import java.nio.FloatBuffer;
 import javax.media.opengl.GL;
 import javax.media.opengl.GL2;
@@ -140,6 +144,29 @@
                
                if (handler instanceof MainGraphicsHandler) {
                        ((WindNetworkView) 
graphicsData.getNetworkView()).setContainer(component);
+               } else if (handler instanceof BirdsEyeGraphicsHandler) {
+                       
+                       // Add mouse listeners to render the updated scene when 
the Bird's eye view
+                       // is clicked or encounters mouse drag movement
+                       component.addMouseListener(new MouseAdapter() {
+                               @Override
+                               public void mousePressed(MouseEvent e) {
+                                       if (coordinator != null 
+                                                       && 
coordinator.getMainAnimatorController() != null) {
+                                               
coordinator.getMainAnimatorController().startAnimator();
+                                       }
+                               }
+                       });
+                       
+                       component.addMouseMotionListener(new 
MouseMotionAdapter() {
+                               @Override
+                               public void mouseDragged(MouseEvent e) {
+                                       if (coordinator != null 
+                                                       && 
coordinator.getMainAnimatorController() != null) {
+                                               
coordinator.getMainAnimatorController().startAnimator();
+                                       }
+                               }
+                       });
                }
        }
        
@@ -208,7 +235,8 @@
                                graphicsData.getAnimatorControl().stop();
                        }
                } else if (handler instanceof BirdsEyeGraphicsHandler) {
-                       if (coordinator.getMainAnimatorController() != null && 
!coordinator.getMainAnimatorController().hasKeysDown()) {
+                       if (coordinator.getMainAnimatorController() != null 
+                                       && 
!coordinator.getMainAnimatorController().hasKeysDown()) {
                                graphicsData.getAnimatorControl().stop();
                        }
                }

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/TableSelectionCytoscapeDataSubprocessor.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/TableSelectionCytoscapeDataSubprocessor.java
     2012-03-28 22:22:52 UTC (rev 28685)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/TableSelectionCytoscapeDataSubprocessor.java
     2012-03-28 22:45:59 UTC (rev 28686)
@@ -24,6 +24,7 @@
        
        @Override
        public void processCytoscapeData(GraphicsData graphicsData) {
+               
        }
        
        /**

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/WindNetworkView.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/WindNetworkView.java
   2012-03-28 22:22:52 UTC (rev 28685)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/WindNetworkView.java
   2012-03-28 22:45:59 UTC (rev 28686)
@@ -144,14 +144,14 @@
         */
        @Override
        public void fitContent() {
-               if (networkCamera != null) {
-                       NetworkToolkit.fitInView(networkCamera, 
nodeViews.values(), 180.0, 1.9, 2.0);
-                       networkCentered = true;
-               }
+               fitNodesInView();
                
                if (animatorController != null) {
                        animatorController.startAnimator();
                }
+               
+               // Request focus for the network view to be ready for keyboard 
input
+               requestNetworkFocus();
        }
 
        @Override
@@ -172,6 +172,9 @@
                if (animatorController != null) {
                        animatorController.startAnimator();
                }
+               
+               // Request focus for the network view to be ready for keyboard 
input
+               requestNetworkFocus();
        }
 
        @Override
@@ -190,16 +193,14 @@
                        animatorController.startAnimator();
                }
                
-               if (networkCamera != null && !networkCentered) {
-                       NetworkToolkit.fitInView(networkCamera, 
nodeViews.values(), 180.0, 1.9, 2.0);
-                       networkCentered = true;
+               // Center the network if it hasn't been centered yet
+               if (!networkCentered) {
+                       fitNodesInView();
                }
                
                // Request focus after the network has been updated, such as 
via clicking a toolbar button,
                // in order to be ready to receive keyboard and mouse input
-               if (container != null) {
-                       container.requestFocus();
-               }
+               requestNetworkFocus();
        }
        
        // Checks if there is a discrepancy between number of nodes and 
nodeViews, attempts
@@ -367,51 +368,24 @@
                return container;
        }
        
-//     @Override
-//     public void handleEvent(AboutToRemoveNodesEvent e) {
-//             if (e.getSource() == network) {
-//                     for (CyNode node : e.getNodes()) {
-//                             nodeViews.remove(node.getIndex());
-//                     }
-//             }
-//     }
-//     
-//     @Override
-//     public void handleEvent(AboutToRemoveEdgesEvent e) {
-//             if (e.getSource() == network) {
-//                     for (CyEdge edge : e.getEdges()) {
-//                             edgeViews.remove(edge.getIndex());
-//                     }
-//             }
-//     }
-//
-//     @Override
-//     public void handleEvent(AddedNodesEvent e) {
-//             if (e.getSource() == network) {
-//                     WindNodeView nodeView;
-//                     
-//                     for (CyNode node : e.getPayloadCollection()) {
-//                             nodeView = new WindNodeView(node, 
SUIDFactory.getNextSUID());
-//                             defaultValues.initializeNode(nodeView);
-//                             
-//                             nodeViews.put(node.getIndex(), nodeView);
-//                     }
-//             }
-//     }
-//
-//     @Override
-//     public void handleEvent(AddedEdgesEvent e) {
-//             if (e.getSource() == network) {
-//                     WindEdgeView edgeView;
-//                     
-//                     for (CyEdge edge : e.getPayloadCollection()) {
-//                             edgeView = new WindEdgeView(edge, 
SUIDFactory.getNextSUID());
-//                             defaultValues.initializeEdge(edgeView);
-//                             
-//                             edgeViews.put(edge.getIndex(), edgeView);
-//                     }
-//             }
-//     }
+       /**
+        * Attempts to adjust the view to show all nodes by using the network 
camera.
+        */
+       private void fitNodesInView() {
+               if (networkCamera != null) {
+                       NetworkToolkit.fitInView(networkCamera, 
nodeViews.values(), 180.0, 1.9, 2.0);
+                       networkCentered = true;
+               }
+       }
+       
+       /**
+        * Requests focus for this network view so that it is ready to accept 
mouse and keyboard input.
+        */
+       private void requestNetworkFocus() {
+               if (container != null) {
+                       container.requestFocus();
+               }
+       }
 
        
 

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/CameraInputHandler.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/CameraInputHandler.java
 2012-03-28 22:22:52 UTC (rev 28685)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/CameraInputHandler.java
 2012-03-28 22:45:59 UTC (rev 28686)
@@ -163,7 +163,7 @@
                // Reset camera
                if (held.contains(KeyEvent.VK_C)) {
                        graphicsData.getCamera().set(new SimpleCamera());
-                       graphicsData.getNetworkView().updateView();
+                       graphicsData.getNetworkView().fitContent();
                }
        }
        

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-28 22:22:52 UTC (rev 28685)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/layouts/SphericalLayoutAlgorithmTask.java
     2012-03-28 22:45:59 UTC (rev 28686)
@@ -61,10 +61,6 @@
                }
                
                arrangePartitions(partitions);
-               
-               if (networkView instanceof WindNetworkView) {
-                       ((WindNetworkView) 
networkView).getAnimatorController().startAnimator();
-               }
        }
        
        private void arrangePartitions(Collection<Collection<View<CyNode>>> 
partitions) {
@@ -136,6 +132,7 @@
        }
        
        private void arrangeAsBox(Collection<View<CyNode>> nodeViews) {
+               
        }
        
        private void arrangeAsSphere(Collection<View<CyNode>> nodeViews) {
@@ -159,30 +156,10 @@
                        // Perform a correction for small numbers of nodes
                        double phiLimit = 0.20 - Math.min((double) nodeCount / 
125, 1) * 0.15;
                        
-                       /*
-                       if (nodeCount < 25) {
-                               phiLimit = 0.15;
-                       } else {
-                               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 * (2 - 2 * thetaLimit));
                        double phi = Math.PI * phiLimit + (double) (current % 
nodesPerLevel) / (nodesPerLevel - 1) * Math.PI * (1 - 2 * phiLimit);
                        
-                       /*
-                       int numLevels = (int) Math.sqrt(nodeCount);
-                       
-                       int level = (current / numLevels) * numLevels;
-                       
-                       double thetaLimit = 0.1;
-                       double phiLimit = 0.1;
-                               
-                       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);
                        z = Math.cos(phi);

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/shapes/ScalableShapeDrawer.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/shapes/ScalableShapeDrawer.java
     2012-03-28 22:22:52 UTC (rev 28685)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/shapes/ScalableShapeDrawer.java
     2012-03-28 22:45:59 UTC (rev 28686)
@@ -10,6 +10,8 @@
 import org.cytoscape.paperwing.internal.geometric.Vector3;
 import org.cytoscape.paperwing.internal.tools.RenderToolkit;
 
+import com.jogamp.opengl.util.gl2.GLUT;
+
 public class ScalableShapeDrawer {
        
        private static final int SPHERE_SLICES_DETAIL = 12;
@@ -61,6 +63,7 @@
                int shapeListIndex = gl.glGenLists(1);
 
                GLU glu = GLU.createGLU(gl);
+               GLUT glut = new GLUT();
                
                GLUquadric quadric = glu.gluNewQuadric();
                glu.gluQuadricDrawStyle(quadric, GLU.GLU_FILL);
@@ -73,10 +76,14 @@
                
                gl.glPushMatrix();
                //gl.glScalef(halfLength, halfLength, halfLength);
-               gl.glTranslatef(0.0f, 0.0f, -0.5f);
+               //gl.glTranslatef(0.0f, 0.0f, -0.5f);
                
-               glu.gluCylinder(quadric, 1.0, 1.0, 1.0, 4, 1);
+               //glu.gluCylinder(quadric, 1.0, 1.0, 1.0, 4, 1);
                
+               glut.glutSolidCube(0.5f);
+               // gl.glColor3f(0.0f, 0.0f, 0.0f);
+               // glut.glutWireCube(0.5f);
+               
                gl.glPopMatrix();
                
                gl.glEndList();
@@ -145,7 +152,7 @@
                
                gl.glEndList();
                
-               shapeLists.put(ShapeType.SHAPE_CUBE, shapeListIndex);
+               shapeLists.put(ShapeType.SHAPE_CUBE_SLICED_CORNERS, 
shapeListIndex);
        }
        
        // Tetrahedron inscribed in circle with radius 0.5

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/NetworkToolkit.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/NetworkToolkit.java
     2012-03-28 22:22:52 UTC (rev 28685)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/NetworkToolkit.java
     2012-03-28 22:45:59 UTC (rev 28686)
@@ -26,11 +26,7 @@
         * @param distanceScale The distance scaling used to convert between 
Cytoscape and renderer coordinates.
         * @return The average position
         */
-       public static Vector3 findCenter(Set<Integer> nodeIndices, 
CyNetworkView networkView, double distanceScale) {
-               if (nodeIndices.isEmpty()) {
-                       return null;
-               }
-               
+       public static Vector3 findCenter(Set<Integer> nodeIndices, 
CyNetworkView networkView, double distanceScale) {           
                double x = 0, y = 0, z = 0;
                int visitedCount = 0;
                
@@ -48,8 +44,11 @@
                }
                
                Vector3 result = new Vector3(x, y, z);
-               result.divideLocal(distanceScale * visitedCount);
                
+               if (visitedCount != 0) { 
+                       result.divideLocal(distanceScale * visitedCount);
+               }
+               
                return result;
        }
        
@@ -105,7 +104,9 @@
                }
                
                Vector3 result = new Vector3(x, y, z);
-               result.divideLocal(distanceScale * visitedCount);
+               if (visitedCount != 0) { 
+                       result.divideLocal(distanceScale * visitedCount);
+               }
                
                return result;
        }
@@ -118,7 +119,7 @@
         * are divided by this scale to obtain renderer coordinates.
         * @return The average position
         */
-       public static Vector3 findNetworkCenter(CyNetworkView networkView, 
double distanceScale) {
+       public static Vector3 findNetworkCenter(CyNetworkView networkView, 
double distanceScale) {              
                double x = 0, y = 0, z = 0;
                int visitedCount = 0;
                

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