Author: Christian Lopes
Date: 2010-02-01 15:01:01 -0800 (Mon, 01 Feb 2010)
New Revision: 19101

Modified:
   
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/ApplicationMediator.as
Log:
The function that export the graph to PNG does not crop the image anymore.

Modified: 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/ApplicationMediator.as
===================================================================
--- 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/ApplicationMediator.as
    2010-02-01 22:53:04 UTC (rev 19100)
+++ 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/ApplicationMediator.as
    2010-02-01 23:01:01 UTC (rev 19101)
@@ -31,6 +31,7 @@
        import flash.display.BitmapData;
        import flash.events.KeyboardEvent;
        import flash.events.MouseEvent;
+       import flash.geom.Matrix;
        import flash.geom.Rectangle;
        import flash.ui.Keyboard;
        import flash.ui.Mouse;
@@ -105,6 +106,10 @@
             return application.networkVisBox;
         }
         
+        private function get graphView():GraphView {
+            return networkVisBox.graphView;
+        }
+        
         private function get panZoomBox():PanZoomBox {
             return application.networkVisBox.panZoomBox;
         }
@@ -221,13 +226,17 @@
             var bytes:ByteArray;
 
             if (type === "png") {
+                var bounds:Rectangle = graphView.getRealBounds();
+                var scale:Number = graphProxy.zoom;
                 var color:uint = 
configProxy.config.visualStyle.getValue(VisualProperties.BACKGROUND_COLOR);
-                var source:BitmapData = new BitmapData(networkVisBox.width, 
networkVisBox.height, false, color);
                 
+                var source:BitmapData = new BitmapData(bounds.width, 
bounds.height, false, color);
+                
                 // Do not draw the pan-zoom copntrol:
                 if (panZoomBox.visible) panZoomBox.visible = false;
 
-                source.draw(networkVisBox);
+                var matrix:Matrix = new Matrix(1, 0, 0, 1, -bounds.x, 
-bounds.y);
+                source.draw(networkVisBox, matrix);
                 
                 if (configProxy.panZoomControlVisible) panZoomBox.visible = 
true;
 
@@ -235,7 +244,7 @@
                 bytes = encoder.encode(source);
             } else {
                 // PDF:
-                var pdfConv:PDFConverter = new 
PDFConverter(networkVisBox.graphView);
+                var pdfConv:PDFConverter = new PDFConverter(graphView);
                 bytes = pdfConv.convertToPDF(graphProxy.graphData,
                                              configProxy.visualStyle,
                                              configProxy.config,
@@ -270,14 +279,14 @@
                }
                  
                private function showWaitMessage():void {
-                       networkVisBox.graphView.visible = false;
+                       graphView.visible = false;
                    PopUpManager.addPopUp(waitMsgLabel, application, true);
                    PopUpManager.centerPopUp(waitMsgLabel);
                }
                  
                private function hideWaitMessage():void {
                    PopUpManager.removePopUp(waitMsgLabel);
-                   networkVisBox.graphView.visible = true;
+                   graphView.visible = true;
                }
                
         public function onKeyPressed(e:KeyboardEvent):void {
@@ -328,8 +337,8 @@
                     graphProxy.rolledOverEdge.dispatchEvent(new 
MouseEvent(MouseEvent.ROLL_OUT));
                 }
                 // To force the end of a drag-selection or graph panning:
-                if (networkVisBox.graphView != null && 
networkVisBox.graphView.graphContainer != null)
-                    networkVisBox.graphView.graphContainer.dispatchEvent(new 
MouseEvent(MouseEvent.MOUSE_UP));
+                if (graphView != null && graphView.graphContainer != null)
+                    graphView.graphContainer.dispatchEvent(new 
MouseEvent(MouseEvent.MOUSE_UP));
                 
                 // Another workaround: it seems that forcing roll-over 
node/edge can bubble it up
                 // to the application, causing a roll-over app. as well,

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