Author: paperwing
Date: 2012-02-02 14:20:09 -0800 (Thu, 02 Feb 2012)
New Revision: 28186

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/rendering/RenderNodesProcedure.java
Log:
A basic zoom-to-selection function was added to be used in accordance with the 
toolbar buttons, but the code is currently run inside the CyNetworkView 
interface as requested by the API. Should check if it is possible to relegate 
this call to the RenderingEngine object as it seems to be more appropriate for 
the renderer to adjust the networkView rather than have the networkView adjust 
itself. Also, support for the node visual properties for node width, height, 
and depth were added.

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-02-02 21:59:57 UTC (rev 28185)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/WindNetworkView.java
   2012-02-02 22:20:09 UTC (rev 28186)
@@ -5,6 +5,7 @@
 import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.Map;
+import java.util.Set;
 
 import org.cytoscape.model.CyEdge;
 import org.cytoscape.model.CyNetwork;
@@ -131,7 +132,26 @@
 
        @Override
        public void fitSelected() {
+               // Obtain selected nodes
+               Set<Integer> selectedNodeIndices = new HashSet<Integer>();
                
+               for (View<CyNode> nodeView : getNodeViews()) {
+                       if 
(nodeView.getVisualProperty(RichVisualLexicon.NODE_SELECTED)) {
+                               
selectedNodeIndices.add(nodeView.getModel().getIndex());
+                       }
+               }
+               
+               Vector3 selectionCenter = 
NetworkToolkit.findCenter(selectedNodeIndices, this, 1);
+       
+               // Shift the nodes to place the center of the network at the 
center of the selected group of nodes
+               for (View<CyNode> nodeView : getNodeViews()) {
+                       
nodeView.setVisualProperty(RichVisualLexicon.NODE_X_LOCATION, 
+                                       
nodeView.getVisualProperty(RichVisualLexicon.NODE_X_LOCATION) - 
selectionCenter.x());
+                       
nodeView.setVisualProperty(RichVisualLexicon.NODE_Y_LOCATION, 
+                                       
nodeView.getVisualProperty(RichVisualLexicon.NODE_Y_LOCATION) - 
selectionCenter.y());
+                       
nodeView.setVisualProperty(RichVisualLexicon.NODE_Z_LOCATION, 
+                                       
nodeView.getVisualProperty(RichVisualLexicon.NODE_Z_LOCATION) - 
selectionCenter.z());
+               }
        }
 
        @Override

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-02-02 21:59:57 UTC (rev 28185)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodesProcedure.java
   2012-02-02 22:20:09 UTC (rev 28186)
@@ -66,6 +66,7 @@
                int hoverNodeIndex = 
graphicsData.getSelectionData().getHoverNodeIndex();
 
                float x, y, z;
+               float width, height, depth;
                int index;
                ShapeType shapeType;
                
@@ -78,6 +79,13 @@
                        z = 
nodeView.getVisualProperty(RichVisualLexicon.NODE_Z_LOCATION)
                                        .floatValue() / distanceScale;
 
+                       width = 
nodeView.getVisualProperty(MinimalVisualLexicon.NODE_WIDTH)
+                                       .floatValue() / distanceScale;
+                       height = 
nodeView.getVisualProperty(MinimalVisualLexicon.NODE_HEIGHT)
+                                       .floatValue() / distanceScale;
+                       depth = 
nodeView.getVisualProperty(RichVisualLexicon.NODE_DEPTH)
+                                       .floatValue() / distanceScale;
+                       
                        index = nodeView.getModel().getIndex();
                        
                        // gl.glLoadName(33);
@@ -91,7 +99,9 @@
                                chooseColor(gl, nodeView, graphicsData);
                                //gl.glCallList(nodeListIndex);
                                
-                               gl.glScalef(NODE_SIZE_RADIUS, NODE_SIZE_RADIUS, 
NODE_SIZE_RADIUS);
+                               gl.glScalef(NODE_SIZE_RADIUS * width, 
+                                               NODE_SIZE_RADIUS * height,
+                                               NODE_SIZE_RADIUS * depth);
                                
                                shapeType = 
cytoscapeShapeMap.get(nodeView.getVisualProperty(RichVisualLexicon.NODE_SHAPE));
                                

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