Author: paperwing
Date: 2012-03-19 11:31:27 -0700 (Mon, 19 Mar 2012)
New Revision: 28576

Modified:
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindBirdsEyeRenderingEngine.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindMainRenderingEngine.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindRenderingEngine.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/cytoscape/edges/AugmentedEdgeContainer.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/edges/EdgeAnalyser.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/input/LightMovementInputHandler.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderLightsProcedure.java
Log:
refs #666 Bird's eye view no longer responds to SetCurrentRenderingEngineEvent 
(does not need to as it is recreated by Cytoscape), EdgeAnalyser correctly 
removes analyzed edge data for edges no longer in the network

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindBirdsEyeRenderingEngine.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindBirdsEyeRenderingEngine.java
      2012-03-19 18:14:19 UTC (rev 28575)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindBirdsEyeRenderingEngine.java
      2012-03-19 18:31:27 UTC (rev 28576)
@@ -17,6 +17,7 @@
 import javax.swing.JComponent;
 import javax.swing.JInternalFrame;
 
+import org.cytoscape.application.events.SetCurrentRenderingEngineListener;
 import org.cytoscape.model.CyNetwork;
 import org.cytoscape.model.events.NetworkAboutToBeDestroyedEvent;
 import org.cytoscape.model.events.NetworkAboutToBeDestroyedListener;
@@ -53,16 +54,12 @@
                
                return new Graphics(networkView, visualLexicon, new 
BirdsEyeGraphicsHandler());
        }
-       
-       @Override
-       protected void setUpAnimatorStarting(Container container, FPSAnimator 
animator) {
-               
-               animator.start();
-       }
 
        @Override
-       public void setProperties(String key, String value) {
-               // TODO Auto-generated method stub
+       protected SetCurrentRenderingEngineListener 
getSetCurrentRenderingEngineListener(
+                       FPSAnimator animator) {
                
+               // Cytoscape creates a new RenderingEngine instance every time 
the current RenderingEngine changes
+               return null;
        }
 }

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindMainRenderingEngine.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindMainRenderingEngine.java
  2012-03-19 18:14:19 UTC (rev 28575)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindMainRenderingEngine.java
  2012-03-19 18:31:27 UTC (rev 28576)
@@ -15,6 +15,8 @@
 import javax.swing.JComponent;
 import javax.swing.JInternalFrame;
 
+import org.cytoscape.application.events.SetCurrentRenderingEngineEvent;
+import org.cytoscape.application.events.SetCurrentRenderingEngineListener;
 import org.cytoscape.model.CyNetwork;
 import org.cytoscape.model.events.NetworkAboutToBeDestroyedEvent;
 import org.cytoscape.model.events.NetworkAboutToBeDestroyedListener;
@@ -51,43 +53,24 @@
                
                return new Graphics(networkView, visualLexicon, new 
MainGraphicsHandler());
        }
-       
-       
+
        @Override
-       protected void setUpAnimatorStarting(Container container, FPSAnimator 
animator) {
-               animator.start();
-               
-               // TODO: Disabled focus listener to let visual property changes 
appear
-               // 
container.addFocusListener(getContainerFocusListener(animator));
-       }
-       
-       private FocusListener getContainerFocusListener(final FPSAnimator 
animator) {
+       protected SetCurrentRenderingEngineListener 
getSetCurrentRenderingEngineListener(
+                       final FPSAnimator animator) {
+               final RenderingEngine<CyNetwork> renderingEngine = this;
 
-               return new FocusListener() {
+               return new SetCurrentRenderingEngineListener() {
                        
                        @Override
-                       public void focusGained(FocusEvent event) {
-                               if (!event.isTemporary()) {
-                                       //System.out.println("Animator started 
for: " + this);
+                       public void handleEvent(SetCurrentRenderingEngineEvent 
e) {
+                               if (e.getRenderingEngine() == renderingEngine) {
+                                       System.out.println("Current network 
view changed, starting animator for " + this + ".");
                                        animator.start();
-                               }
-                       }
-
-                       @Override
-                       public void focusLost(FocusEvent event) {
-                               if (!event.isTemporary()) {
-                                       //System.out.println("Animator stopped 
for: " + this);
+                               } else {
+                                       System.out.println("Current network 
view changed, stopping animator for " + this + ".");
                                        animator.stop();
                                }
                        }
                };
        }
-
-       @Override
-       public void setProperties(String key, String value) {
-               // TODO Auto-generated method stub
-               
-       }
-
-       
 }

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindRenderingEngine.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindRenderingEngine.java
      2012-03-19 18:14:19 UTC (rev 28575)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindRenderingEngine.java
      2012-03-19 18:31:27 UTC (rev 28576)
@@ -143,15 +143,11 @@
                                
                                animator = new FPSAnimator(60);
                                animator.add(panel);
+                               animator.start();
                                
                                addStopAnimatorListener(component);
                                
-                               // Setup animator start/stop, can be based on 
gaining/losing focus of the canvas
-                               setUpAnimatorStarting(focus, animator);
-                               
                                active = true;
-                               
-//                             System.out.println("placed in canvas");
                        }
                }
        }
@@ -181,10 +177,9 @@
                });
        }
        
-       protected abstract void setUpAnimatorStarting(Container container, 
FPSAnimator animator);
        
+       
        public void setUpListeners(CyServiceRegistrar serviceRegistrar) {
-       //public void setUpNetworkViewDestroyedListener(CyServiceRegistrar 
serviceRegistrar) {
                this.serviceRegistrar = serviceRegistrar;
                
                // NetworkViewDestroyedEvent listener
@@ -200,27 +195,16 @@
                if (setCurrentRenderingEngineListener == null) {
                        final RenderingEngine<CyNetwork> renderingEngine = 
this; 
                        
-                       setCurrentRenderingEngineListener = new 
SetCurrentRenderingEngineListener() {
-                               
-                               @Override
-                               public void 
handleEvent(SetCurrentRenderingEngineEvent e) {
-                                       if (e.getRenderingEngine() != 
renderingEngine) {
-                                               animator.stop();
-                                       } else {
-                                               animator.start();
-                                       }
-                               }
-                       };
-                       
-                       
serviceRegistrar.registerService(setCurrentRenderingEngineListener,
-                                       SetCurrentRenderingEngineListener.class,
-                                       new Properties());
+                       setCurrentRenderingEngineListener = 
getSetCurrentRenderingEngineListener(animator);
+                       if (setCurrentRenderingEngineListener != null) {
+                               
serviceRegistrar.registerService(setCurrentRenderingEngineListener,
+                                               
SetCurrentRenderingEngineListener.class,
+                                               new Properties());
+                       }
                }
        }
        
        
-       
-       
        /** Return a listener to listen to events regarding when the graphics
         * object is to be destroyed, and the animator stopped
         * 
@@ -242,12 +226,17 @@
                                        animator.stop();
                                        
                                        
serviceRegistrar.unregisterService(networkViewDestroyedListener, 
NetworkViewAboutToBeDestroyedListener.class);
-                                       
serviceRegistrar.unregisterService(setCurrentRenderingEngineListener, 
SetCurrentRenderingEngineListener.class);
+                                       
+                                       if (setCurrentRenderingEngineListener 
!= null) {
+                                               
serviceRegistrar.unregisterService(setCurrentRenderingEngineListener, 
SetCurrentRenderingEngineListener.class);
+                                       }
                                }
                        }
                };
        }
        
+       protected abstract SetCurrentRenderingEngineListener 
getSetCurrentRenderingEngineListener(FPSAnimator animator);
+       
        /** Return whether the rendering engine is active */
        public boolean isActive() {
                return active;
@@ -272,6 +261,11 @@
        }
 
        @Override
+       public void setProperties(String key, String value) {
+               // TODO Auto-generated method stub
+       }
+       
+       @Override
        public Printable createPrintable() {
                // TODO Auto-generated method stub
                return null;

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-03-19 18:14:19 UTC (rev 28575)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/coordinator/ViewingCoordinator.java
   2012-03-19 18:31:27 UTC (rev 28576)
@@ -4,6 +4,7 @@
 import java.util.Map;
 import java.util.jar.Manifest;
 
+import org.cytoscape.paperwing.internal.cytoscape.edges.EdgeAnalyser;
 import org.cytoscape.paperwing.internal.geometric.Quadrilateral;
 import org.cytoscape.paperwing.internal.geometric.Vector3;
 import org.cytoscape.paperwing.internal.tools.GeometryToolkit;
@@ -42,6 +43,8 @@
        private boolean initialBoundsMatched = false;
        private boolean suggestRecalculateBounds = false;
        
+       private EdgeAnalyser mainEdgeAnalyser = null;
+       
        // Claiming: Means whether a Graphics object has claimed ownership of 
this coordinator by obtaining a reference to it.
        // Linking: Whether or not that Graphics object wishes to retain the 
reference to the coordinator, useful for garbage collection
        
@@ -282,4 +285,12 @@
        public boolean isSuggestRecalculateBounds() {
                return suggestRecalculateBounds;
        }
+
+       public void setMainEdgeAnalyser(EdgeAnalyser mainEdgeAnalyser) {
+               this.mainEdgeAnalyser = mainEdgeAnalyser;
+       }
+
+       public EdgeAnalyser getMainEdgeAnalyser() {
+               return mainEdgeAnalyser;
+       }
 }

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/edges/AugmentedEdgeContainer.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/edges/AugmentedEdgeContainer.java
   2012-03-19 18:14:19 UTC (rev 28575)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/edges/AugmentedEdgeContainer.java
   2012-03-19 18:31:27 UTC (rev 28576)
@@ -13,7 +13,7 @@
        private View<CyEdge> edgeView;
        
        // Identifies the pair of nodes that the edge connects
-       private long pairIdentifier;
+       private Long pairIdentifier = null;
        
        // The index of this edge compared to all the other edges that connect 
the same pair
        // of nodes. If this is the first of 7 edges that connect the same pair 
of nodes, its
@@ -45,11 +45,11 @@
                this.edgeView = edgeView;
        }
 
-       public long getPairIdentifier() {
+       public Long getPairIdentifier() {
                return pairIdentifier;
        }
 
-       public void setPairIdentifier(long pairIdentifier) {
+       public void setPairIdentifier(Long pairIdentifier) {
                this.pairIdentifier = pairIdentifier;
        }
 

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/edges/EdgeAnalyser.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/edges/EdgeAnalyser.java
     2012-03-19 18:14:19 UTC (rev 28575)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/edges/EdgeAnalyser.java
     2012-03-19 18:31:27 UTC (rev 28576)
@@ -3,6 +3,7 @@
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Set;
 
@@ -46,8 +47,6 @@
        /** The frame number that the generated edge data is current for */
        private Long currentFrame;
        
-       private Long lastCalculatedTime = 0L;
-       
        public EdgeAnalyser() {
                edgeContainers = new HashMap<View<CyEdge>, 
AugmentedEdgeContainer>();
                currentFrame = 0L;
@@ -68,10 +67,24 @@
                        calculateEdgeProperties(networkView, distanceScale);
                        calculateEdgeCoordinates();
                        this.currentFrame = currentFrame;
-               } else {
-                       // System.out.println("Reusing edge data");
                }
                
+               // Prepare to remove edgeContainers for edges that are no 
longer in the network
+               Set<AugmentedEdgeContainer> edgeContainersToBeRemoved = new 
HashSet<AugmentedEdgeContainer>();
+               
+               for (AugmentedEdgeContainer edgeContainer : 
edgeContainers.values()) {
+                       // Check if this edge container holds an edge that is 
no longer in the network
+                       if 
(networkView.getModel().getEdge(edgeContainer.getEdgeView().getModel().getIndex())
 == null) {
+                               edgeContainersToBeRemoved.add(edgeContainer);
+                       }
+               }
+               
+               for (AugmentedEdgeContainer edgeContainer : 
edgeContainersToBeRemoved) {
+                       edgeContainers.remove(edgeContainer.getEdgeView());
+                       
+                       System.out.println("Removed edge " + 
edgeContainer.getEdgeView().getSUID());
+               }
+               
                return edgeContainers.values();         
        }       
        
@@ -87,11 +100,10 @@
                int nodeCount = networkView.getModel().getNodeCount();
                CyEdge edge;
                
-               AugmentedEdgeContainer edgeContainer;
-               
                for (View<CyEdge> edgeView : networkView.getEdgeViews()) {
-                       edgeContainer = edgeContainers.get(edgeView);
                        
+                       AugmentedEdgeContainer edgeContainer = 
edgeContainers.get(edgeView);
+                       
                        if (edgeContainer == null) {
                                edgeContainer = new AugmentedEdgeContainer();
                                edgeContainer.setEdgeView(edgeView);
@@ -140,23 +152,25 @@
                                edgeContainer.setSufficientLength(false);
                        }
                }
+
                
-               Collection<View<CyEdge>> edgeViews = networkView.getEdgeViews();
                
                // Update the value for the total number of edges between this 
pair of nodes
-               for (AugmentedEdgeContainer container : 
edgeContainers.values()) {
+               for (AugmentedEdgeContainer edgeContainer : 
edgeContainers.values()) {
                        
-                       
container.setTotalCoincidentEdges(pairCoincidenceCount.get(container.getPairIdentifier()));
+                       Long pairIdentifier = edgeContainer.getPairIdentifier();
+                       Integer totalCoincidentEdgesCount = 
pairCoincidenceCount.get(pairIdentifier);
+               
+                       if (totalCoincidentEdgesCount != null) {
+                               
+                       
edgeContainer.setTotalCoincidentEdges(totalCoincidentEdgesCount);
                        
-                       // If there was only 1 edge for that pair of nodes, 
make it a straight edge
-                       if (container.getTotalCoincidentEdges() == 1 && 
!container.isSelfEdge()) {
-                               container.setStraightEdge(true);
+                               // If there was only 1 edge for that pair of 
nodes, make it a straight edge
+                               if (edgeContainer.getTotalCoincidentEdges() == 
1 && !edgeContainer.isSelfEdge()) {
+                                       edgeContainer.setStraightEdge(true);
+                               }
+                       
                        }
-                       
-                       // Check if this edge container holds an edge that is 
no longer in the network
-//                     if (!edgeViews.contains(container.getEdgeView())) {
-//                             edgeContainers.remove(container.getEdgeView());
-//                     }
                }
        }
        

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-19 18:14:19 UTC (rev 28575)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/TableSelectionCytoscapeDataSubprocessor.java
     2012-03-19 18:31:27 UTC (rev 28576)
@@ -29,7 +29,7 @@
                // Update CyTable with the currently selected set of nodes and 
edges
                processSelectionData(graphicsData);
                
-               processUpdateSelected(graphicsData);
+               // processUpdateSelected(graphicsData);
        }
        
        // Performs selection in Cytoscape data objects, such as CyTable
@@ -69,13 +69,15 @@
                Set<Integer> selectedEdgeIndices = 
graphicsData.getSelectionData().getSelectedEdgeIndices();
                
                for (View<CyNode> nodeView : networkView.getNodeViews()) {
-                       if 
(nodeView.getVisualProperty(BasicVisualLexicon.NODE_SELECTED)) {
+                       if 
(NetworkToolkit.checkNodeSelected(nodeView.getModel().getIndex(), networkView)) 
{
+//                     if 
(nodeView.getVisualProperty(BasicVisualLexicon.NODE_SELECTED)) {
                                
selectedNodeIndices.add(nodeView.getModel().getIndex());
                        }
                }
                
                for (View<CyEdge> edgeView : networkView.getEdgeViews()) {
-                       if 
(edgeView.getVisualProperty(BasicVisualLexicon.EDGE_SELECTED)) {
+                       if 
(NetworkToolkit.checkNodeSelected(edgeView.getModel().getIndex(), networkView)) 
{
+//                     if 
(edgeView.getVisualProperty(BasicVisualLexicon.EDGE_SELECTED)) {
                                
selectedEdgeIndices.add(edgeView.getModel().getIndex());
                        }
                }

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/LightMovementInputHandler.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/LightMovementInputHandler.java
  2012-03-19 18:14:19 UTC (rev 28575)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/LightMovementInputHandler.java
  2012-03-19 18:31:27 UTC (rev 28576)
@@ -50,7 +50,7 @@
                float[] lightPosition = light.getPosition();
                Vector3 currentLightPosition = new Vector3(lightPosition[0], 
lightPosition[1], lightPosition[2]);
                
-               currentLightPosition.divideLocal(lightPosition[3]); // Since 
lightPosition contains homogenous coordinates, perform division
+               currentLightPosition.divideLocal(lightPosition[3]); // Since 
lightPosition contains homogenous coordinates, perform division by w
                
                double mouseProjectionDistance = 
GeometryToolkit.findOrthogonalDistance(
                                camera.getPosition(), currentLightPosition, 
camera.getDirection());

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderLightsProcedure.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderLightsProcedure.java
  2012-03-19 18:14:19 UTC (rev 28575)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderLightsProcedure.java
  2012-03-19 18:31:27 UTC (rev 28576)
@@ -14,6 +14,8 @@
  */
 public class RenderLightsProcedure implements ReadOnlyGraphicsProcedure {
 
+       public static final float LIGHT_RADIUS = 0.1f;
+       
        private ScalableShapeDrawer shapeDrawer;
        
        public RenderLightsProcedure() {
@@ -44,6 +46,7 @@
                        gl.glTranslatef(lightPosition[0], lightPosition[1], 
lightPosition[2]);
                        
                        gl.glColor3f(1.0f, 1.0f, 0.6f);
+                       gl.glScalef(LIGHT_RADIUS, LIGHT_RADIUS, LIGHT_RADIUS);
                        shapeDrawer.drawShape(gl, ShapeType.SHAPE_SPHERE);
                                        
                        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.

Reply via email to