Author: Christian Lopes
Date: 2010-02-04 11:42:18 -0800 (Thu, 04 Feb 2010)
New Revision: 19180

Modified:
   cytoscapeweb/trunk/cytoscapeweb/
   cytoscapeweb/trunk/cytoscapeweb/html-template/fixtures/bundle_test.properties
   cytoscapeweb/trunk/cytoscapeweb/html-template/js/cytoscapeweb.js
   cytoscapeweb/trunk/cytoscapeweb/html-template/js/tests.js
   cytoscapeweb/trunk/cytoscapeweb/html-template/tests.html
   cytoscapeweb/trunk/cytoscapeweb/src/assets/locale/en_US/bundle.properties
   
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/controller/ZoomGraphCommand.as
   
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/controller/ZoomGraphToFitCommand.as
   cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/ConfigProxy.as
   cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/GraphProxy.as
   cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/ConfigVO.as
   
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/ApplicationMediator.as
   cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/GraphMediator.as
   cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/PanZoomMediator.as
   
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/components/GraphView.as
   
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/components/PanZoomBox.mxml
Log:
Fixed Issues:
    - #2130: Circle layout doesn't "zoom to fit".
    - #2142: The pan control shortcut keys pan to the opposite direction.
    - #2144: The export to PNG feature should not crop the image.
    - #2150: Browser crashes with multiple node/edge selection.
Other Changes:
    - Added a default Passthrough Mapper for edge labels.
    - Removed the mouse-over tool tip from the Pan-Zoom Control.


Property changes on: cytoscapeweb/trunk/cytoscapeweb
___________________________________________________________________
Name: svn:ignore
   - .settings
.actionScriptProperties
.flexProperties
.project
build

   + .settings
.actionScriptProperties
.flexProperties
.project
build
local.properties
.externalToolBuilders


Modified: 
cytoscapeweb/trunk/cytoscapeweb/html-template/fixtures/bundle_test.properties
===================================================================
--- 
cytoscapeweb/trunk/cytoscapeweb/html-template/fixtures/bundle_test.properties   
    2010-02-04 18:51:45 UTC (rev 19179)
+++ 
cytoscapeweb/trunk/cytoscapeweb/html-template/fixtures/bundle_test.properties   
    2010-02-04 19:42:18 UTC (rev 19180)
@@ -10,4 +10,3 @@
 zoom.in.tooltip = Zoom in (+) [TEST]
 zoom.fit.tooltip = Fit to screen (*) [TEST]
 zoom.slider.tooltip = {0}% [TEST]
-zoom.slider.datatip = {0}% [TEST]

Modified: cytoscapeweb/trunk/cytoscapeweb/html-template/js/cytoscapeweb.js
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/html-template/js/cytoscapeweb.js    
2010-02-04 18:51:45 UTC (rev 19179)
+++ cytoscapeweb/trunk/cytoscapeweb/html-template/js/cytoscapeweb.js    
2010-02-04 19:42:18 UTC (rev 19180)
@@ -104,7 +104,6 @@
      * zoom.in.tooltip = Zoom in (+)
      * zoom.fit.tooltip = Fit to screen (*)
      * zoom.slider.tooltip = {0}%
-     * zoom.slider.datatip = {0}%
      * </pre></li>
      *                    <li><code>idToken</code>: A string used to create 
the embedded Flash video id
      *                                                               (usually 
an HTML <code>embed</code> or <code>object</code> tag).
@@ -1142,7 +1141,7 @@
                         "allowScriptAccess", "always",
                         "type", "application/x-shockwave-flash",
                         "pluginspage", 
"http://www.adobe.com/go/getflashplayer";,
-                        "wmode", "transparent",
+                        "wmode", "opaque", // DO NOT set it to "transparent", 
because it may crash FireFox and IE on Windows!
                         "flashVars", flashVars
                 );
             } else { // flash is too old or we can't detect the plugin

Modified: cytoscapeweb/trunk/cytoscapeweb/html-template/js/tests.js
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/html-template/js/tests.js   2010-02-04 
18:51:45 UTC (rev 19179)
+++ cytoscapeweb/trunk/cytoscapeweb/html-template/js/tests.js   2010-02-04 
19:42:18 UTC (rev 19180)
@@ -165,23 +165,23 @@
         vis.panZoomControlVisible(true);
         ok(vis.panZoomControlVisible(), "Pan-zoom control should be visible");
 
-        vis.zoom(0.2);
-        same(vis.$callbacks.zoom, 0.2, "Zoom out");
-        same(Math.round(vis.zoom()*10), 2, "zoom() returns the correct value 
after zoom(0.2).");
-        vis.zoom(2);
-        same(vis.$callbacks.zoom, 2, "Zoom in");
-        same(vis.zoom(), 2, "zoom() returns the correct value after zoom(2).");
+        vis.zoom(0.02322);
+        same(Math.round(vis.$callbacks.zoom*100000)/100000, 0.02322, "Zoom 
out");
+        same(Math.round(vis.zoom()*100000)/100000, 0.02322, "zoom() returns 
the correct value after zoom out.");
+        vis.zoom(2.1);
+        same(Math.round(vis.$callbacks.zoom*100)/100, 2.1, "Zoom in");
+        same(Math.round(vis.zoom()*100)/100, 2.1, "zoom() returns the correct 
value after zoom in.");
 
         vis.panBy(100, 200);
         vis.zoomToFit();
         ok(vis.$callbacks.zoom <= 1, "Zoom to fit (value <= 1 ?):" + 
vis.$callbacks.zoom);
-        same(vis.$callbacks.zoom, vis.zoom(), "zoom() returns the correct 
value after zoomToFit().");
+        same(vis.zoom(), vis.$callbacks.zoom, "zoom() returns the correct 
value after zoomToFit().");
 
         var zoom = vis.$callbacks.zoom;
         vis.panBy(320, 160);
         vis.panToCenter();
         same(vis.$callbacks.zoom, zoom, "Zoom value should NOT change after 
panning");
-        same(zoom, vis.zoom(), "zoom() returns the correct value again.");
+        same(vis.zoom(), zoom, "zoom() returns the correct value again.");
     });
 
     test("Tooltips", function() {
@@ -630,9 +630,23 @@
                        stop();
                        
                        vis.removeListener("layout");
-                       
-                       // Visual test of node coordinates - align divs with 
nodes:
-                       // 
--------------------------------------------------------
+       });
+       
+       vis.layout('  TREE '); // It should trim and be case insensitive!
+    });
+    
+    test("PNG", function() {
+       vis.zoom(Math.random()*2);
+       vis.panBy(Math.random()*-1000, Math.random()*1000);
+       
+       var base64 = vis.png();
+       ok(typeof base64 === 'string', "PNG returned as string");
+       ok(base64.length > 0, "PNG string not empty");
+       $("#image_"+vis.containerId).html('<img 
src="data:image/png;base64,'+base64+'"/>');
+       
+               // Visual test of node coordinates - align divs with nodes:
+               // --------------------------------------------------------
+       vis.addListener("zoom", function(evt) {
                        var nodes = vis.nodes();
                        $.each(nodes, function(i, n) {
                                var pointer = $('<div class="pointer"></div>');
@@ -646,19 +660,12 @@
                                pointer.css('left', p.x - size/2).css('top', 
p.y - size/2);
                                pointer.css('width', size).css('height', size);
                        });
-                       // 
--------------------------------------------------------
        });
-       
-       vis.layout('  TREE '); // It should trim and be case insensitive!
+       vis.zoomToFit();
+       vis.removeListener("zoom");
+               // --------------------------------------------------------
     });
     
-    test("PNG", function() {
-       var base64 = vis.png();
-       ok(typeof base64 === 'string', "PNG returned as string");
-       ok(base64.length > 0, "PNG string not empty");
-       $("#image_"+vis.containerId).html('<img 
src="data:image/png;base64,'+base64+'"/>');
-    });
-    
     test("PDF", function() {
        var base64 = vis.pdf();
        ok(typeof base64 === 'string', "PDF returned as string");

Modified: cytoscapeweb/trunk/cytoscapeweb/html-template/tests.html
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/html-template/tests.html    2010-02-04 
18:51:45 UTC (rev 19179)
+++ cytoscapeweb/trunk/cytoscapeweb/html-template/tests.html    2010-02-04 
19:42:18 UTC (rev 19180)
@@ -45,7 +45,7 @@
 <style type="text/css">
     body { overflow-y: scroll; }
     #graphs { float: right; width: 44%; height: 100%; background-color: 
#ffffff; padding: 2px 4px 2px 2px; }
-    #graphs div { width: 100%; height: 160px; margin: 2px; border: 1px solid 
#D2E0E6; }
+    #graphs div { width: 100%; height: 160px; margin: 2px; border: 1px solid 
#D2E0E6; text-align: center; overflow: auto; }
     .pointer { position: absolute; width: 10px; height: 10px; 
background-color: rgba(0,255,100, 0.7); }
 </style>
 

Modified: 
cytoscapeweb/trunk/cytoscapeweb/src/assets/locale/en_US/bundle.properties
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/src/assets/locale/en_US/bundle.properties   
2010-02-04 18:51:45 UTC (rev 19179)
+++ cytoscapeweb/trunk/cytoscapeweb/src/assets/locale/en_US/bundle.properties   
2010-02-04 19:42:18 UTC (rev 19180)
@@ -11,4 +11,3 @@
 zoom.in.tooltip = Zoom in (+)
 zoom.fit.tooltip = Fit to screen (*)
 zoom.slider.tooltip = {0}%
-zoom.slider.datatip = {0}%

Modified: 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/controller/ZoomGraphCommand.as
===================================================================
--- 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/controller/ZoomGraphCommand.as
 2010-02-04 18:51:45 UTC (rev 19179)
+++ 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/controller/ZoomGraphCommand.as
 2010-02-04 19:42:18 UTC (rev 19180)
@@ -30,6 +30,7 @@
 package org.cytoscapeweb.controller {
     import org.cytoscapeweb.ApplicationFacade;
     import org.cytoscapeweb.model.ExternalInterfaceProxy;
+    import org.cytoscapeweb.model.GraphProxy;
     import org.cytoscapeweb.util.ExternalFunctions;
     import org.cytoscapeweb.view.GraphMediator;
     import org.puremvc.as3.interfaces.INotification;
@@ -45,16 +46,20 @@
         override public function execute(notification:INotification):void {
             var scale:Number = notification.getBody() as Number;
             var mediator:GraphMediator = 
facade.retrieveMediator(GraphMediator.NAME) as GraphMediator;
-                        
-            if (scale != mediator.scale) {
-                mediator.zoomGraph(scale);
+            var graphProxy:GraphProxy = facade.retrieveProxy(GraphProxy.NAME) 
as GraphProxy;
 
+            if (scale != graphProxy.zoom) {
+                mediator.zoomGraphTo(scale);
+
                 // Call external listener:
                 var extProxy:ExternalInterfaceProxy = 
facade.retrieveProxy(ExternalInterfaceProxy.NAME) as ExternalInterfaceProxy;
+                
 
                 if (extProxy.hasListener("zoom")) {
+                    var newScale:Number = graphProxy.zoom;
+                    
                     var body:Object = { functionName: 
ExternalFunctions.INVOKE_LISTENERS, 
-                                        argument: { type: "zoom", value: scale 
} };
+                                        argument: { type: "zoom", value: 
newScale } };
                     
                     
sendNotification(ApplicationFacade.CALL_EXTERNAL_INTERFACE, body);
                 }

Modified: 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/controller/ZoomGraphToFitCommand.as
===================================================================
--- 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/controller/ZoomGraphToFitCommand.as
    2010-02-04 18:51:45 UTC (rev 19179)
+++ 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/controller/ZoomGraphToFitCommand.as
    2010-02-04 19:42:18 UTC (rev 19180)
@@ -30,6 +30,7 @@
 package org.cytoscapeweb.controller {
     import org.cytoscapeweb.ApplicationFacade;
     import org.cytoscapeweb.model.ExternalInterfaceProxy;
+    import org.cytoscapeweb.model.GraphProxy;
     import org.cytoscapeweb.util.ExternalFunctions;
     import org.cytoscapeweb.view.GraphMediator;
     import org.puremvc.as3.interfaces.INotification;
@@ -42,16 +43,22 @@
     public class ZoomGraphToFitCommand extends SimpleCommand {
         
         override public function execute(notification:INotification):void {
+            var graphProxy:GraphProxy = facade.retrieveProxy(GraphProxy.NAME) 
as GraphProxy;
             var mediator:GraphMediator = 
facade.retrieveMediator(GraphMediator.NAME) as GraphMediator;
-            var scale:Number = mediator.scale;
+            
+            var scale:Number = graphProxy.zoom;
+            
             mediator.zoomGraphToFit();
-            var newScale:Number = mediator.scale;
+
+            var newScale:Number = graphProxy.zoom;
             
             if (newScale != scale) {
                 // Call external listener:
                 var extProxy:ExternalInterfaceProxy = 
facade.retrieveProxy(ExternalInterfaceProxy.NAME) as ExternalInterfaceProxy;
 
                 if (extProxy.hasListener("zoom")) {
+                    
+                    
                     var body:Object = { functionName: 
ExternalFunctions.INVOKE_LISTENERS, 
                                         argument: { type: "zoom", value: 
newScale } };
                     

Modified: 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/ConfigProxy.as
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/ConfigProxy.as   
2010-02-04 18:51:45 UTC (rev 19179)
+++ cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/ConfigProxy.as   
2010-02-04 19:42:18 UTC (rev 19180)
@@ -159,6 +159,22 @@
                 config.currentLayout = layout;
             }
         }
+        
+        public function get minZoom():Number {
+            return config.minZoom;
+        }
+        
+        public function set minZoom(value:Number):void {
+            config.minZoom = value;
+        }
+        
+        public function get maxZoom():Number {
+            return config.maxZoom;
+        }
+        
+        public function set maxZoom(value:Number):void {
+            config.maxZoom = value;
+        }
 
         // ========[ CONSTRUCTOR 
]==================================================================
 

Modified: 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/GraphProxy.as
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/GraphProxy.as    
2010-02-04 18:51:45 UTC (rev 19179)
+++ cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/GraphProxy.as    
2010-02-04 19:42:18 UTC (rev 19180)
@@ -82,6 +82,8 @@
         private var _filteredEdges:Array;
         private var _nodesMap:Object = {};
         private var _edgesMap:Object = {};
+        // Scale factor, between 0 and 1:
+        private var _zoom:Number = 1;
 
         private var _configProxy:ConfigProxy;
         
@@ -98,8 +100,6 @@
         // ========[ PUBLIC PROPERTIES 
]============================================================
         
         public var dataSet:DataSet;
-        // Scale factor, between 0 and 1:
-        public var zoom:Number = 1;
         
         public function get graphData():Data {
             return _graphData;
@@ -269,6 +269,14 @@
                 _rolledOverEdge = edge;
             }
         }
+        
+        public function get zoom():Number {
+            return _zoom;
+        }
+ 
+        public function set zoom(value:Number):void {
+            _zoom = value;
+        }
 
         // ========[ CONSTRUCTOR 
]==================================================================
 

Modified: 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/ConfigVO.as
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/ConfigVO.as 
2010-02-04 18:51:45 UTC (rev 19179)
+++ cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/ConfigVO.as 
2010-02-04 19:42:18 UTC (rev 19180)
@@ -51,6 +51,8 @@
         public var visualStyle:VisualStyleVO;
         public var layouts:Array = [Layouts.FORCE_DIRECTED, Layouts.CIRCLE, 
Layouts.CIRCLE_TREE, Layouts.RADIAL, Layouts.TREE];
         public var currentLayout:String = Layouts.FORCE_DIRECTED;
+        public var minZoom:Number = 0.008;
+        public var maxZoom:Number = 3;
         public var nodesPoints:/*nodeId->flash.geom.Point*/Object;
         
         // ========[ CONSTRUCTOR 
]==================================================================

Modified: 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/ApplicationMediator.as
===================================================================
--- 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/ApplicationMediator.as
    2010-02-04 18:51:45 UTC (rev 19179)
+++ 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/ApplicationMediator.as
    2010-02-04 19:42:18 UTC (rev 19180)
@@ -288,26 +288,26 @@
                    PopUpManager.removePopUp(waitMsgLabel);
                    graphView.visible = true;
                }
-               
-        public function onKeyPressed(e:KeyboardEvent):void {
+        
+        public function onKeyPressed(evt:KeyboardEvent):void {
             var panX:Number = 0; var panY:Number = 0;
             var amount:Number = 16;
 
-            if (e.keyCode == Keyboard.UP)
+            if (evt.keyCode == Keyboard.UP)
                 panY = -amount;
-            else if (e.keyCode == Keyboard.DOWN)
+            else if (evt.keyCode == Keyboard.DOWN)
                 panY = amount;
-            else if (e.keyCode == Keyboard.LEFT)
+            else if (evt.keyCode == Keyboard.LEFT)
                 panX = -amount;
-            else if (e.keyCode == Keyboard.RIGHT)
+            else if (evt.keyCode == Keyboard.RIGHT)
                 panX = amount;
-            else if (e.charCode == 43) // '+'
+            else if (evt.charCode == 43) // '+'
                 panZoomBox.zoomInButton.dispatchEvent(new 
MouseEvent(MouseEvent.CLICK));
-            else if (e.charCode == 45) // '-'
+            else if (evt.charCode == 45) // '-'
                 panZoomBox.zoomOutButton.dispatchEvent(new 
MouseEvent(MouseEvent.CLICK));
-            else if (e.charCode == 42) // '*'
+            else if (evt.charCode == 42) // '*'
                 panZoomBox.zoomFitButton.dispatchEvent(new 
MouseEvent(MouseEvent.CLICK));
-            else if (e.ctrlKey || e.shiftKey)
+            else if (evt.ctrlKey || evt.shiftKey)
                 updateCursor();
                 
             if (panX != 0 || panY != 0)

Modified: 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/GraphMediator.as
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/GraphMediator.as  
2010-02-04 18:51:45 UTC (rev 19179)
+++ cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/GraphMediator.as  
2010-02-04 19:42:18 UTC (rev 19180)
@@ -108,16 +108,16 @@
             
             return _selectionControl;
         }
+        
+        private function get _graphScale():Number {
+            return graphContainer.scaleX;
+        }
    
         // ========[ PUBLIC PROPERTIES 
]============================================================
    
         public function get graphView():GraphView {
             return viewComponent as GraphView;
         }
-        
-        public function get scale():Number {
-            return graphContainer.scaleX;
-        }
    
         // ========[ CONSTRUCTOR 
]==================================================================
    
@@ -240,7 +240,7 @@
             if (sg != null) sg.resetDataSprite(ds);
         }
         
-        public function zoomGraph(scale:Number):void {
+        public function zoomGraphTo(scale:Number):void {
             graphView.zoomTo(scale);
             if (graphProxy.rolledOverNode != null) {
                 // If zooming while mouse still over a node (e.g. using the 
keyboard to zoom),
@@ -465,7 +465,7 @@
             n.addEventListener(MouseEvent.ROLL_OUT, onRollOutNode, false, 0, 
true);
             
             // When zoom < 100%, increase the label size to make it readable:
-            if (scale < 1) rescaleNodeLabel(n);
+            if (_graphScale < 1) rescaleNodeLabel(n);
         }
         
         private function onRollOutNode(evt:MouseEvent):void {
@@ -654,8 +654,8 @@
                     var fsize:Number = 
configProxy.visualStyle.getValue(VisualProperties.NODE_LABEL_FONT_SIZE, n.data) 
as Number;
                     if (reset)
                         label.size = fsize;
-                    else if (scale < 1)
-                        label.size = fsize / scale;
+                    else if (_graphScale < 1)
+                        label.size = fsize / _graphScale;
                         
                     var sg:SubGraphView = graphView.getSubGraphOf(n);
                     sg.nodeLabeler.operate();

Modified: 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/PanZoomMediator.as
===================================================================
--- 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/PanZoomMediator.as    
    2010-02-04 18:51:45 UTC (rev 19179)
+++ 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/PanZoomMediator.as    
    2010-02-04 19:42:18 UTC (rev 19180)
@@ -70,6 +70,9 @@
         public function PanZoomMediator(viewComponent:Object) {
             super(NAME, viewComponent, this);
 
+            // Setup Zoom Slider:
+            panZoomBox.setZoomRange(configProxy.minZoom, configProxy.maxZoom);
+
             // Panning events:
             var panButtons:Array = [panZoomBox.panDownButton, 
panZoomBox.panLeftButton, 
                                     panZoomBox.panRightButton, 
panZoomBox.panUpButton];
@@ -88,12 +91,12 @@
             panZoomBox.zoomInButton.addEventListener(MouseEvent.CLICK, 
onZoomInClick, false, 0, true);
             panZoomBox.zoomOutButton.addEventListener(MouseEvent.CLICK, 
onZoomOutClick, false, 0, true);
             panZoomBox.zoomFitButton.addEventListener(MouseEvent.CLICK, 
onZoomFitClick, false, 0, true);
+            panZoomBox.zoomInButton.addEventListener(MouseEvent.MOUSE_DOWN, 
onMouseDown, false, 0, true);
+            panZoomBox.zoomOutButton.addEventListener(MouseEvent.MOUSE_DOWN, 
onMouseDown, false, 0, true);
+            panZoomBox.zoomFitButton.addEventListener(MouseEvent.MOUSE_DOWN, 
onMouseDown, false, 0, true);
             
             // To avoid dragging the panZoomBox while pressing its buttons or 
the slider:
             zoomSlider.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown, 
false, 0, true);
-            panZoomBox.zoomInButton.addEventListener(MouseEvent.MOUSE_DOWN, 
onMouseDown, false, 0, true);
-            panZoomBox.zoomOutButton.addEventListener(MouseEvent.MOUSE_DOWN, 
onMouseDown, false, 0, true);
-            panZoomBox.zoomFitButton.addEventListener(MouseEvent.MOUSE_DOWN, 
onMouseDown, false, 0, true);
         }
 
         // ========[ PUBLIC METHODS 
]===============================================================
@@ -112,7 +115,7 @@
                     // Avoid infinit loops:
                     zoomSlider.removeEventListener(SliderEvent.CHANGE, 
onZoomSliderChange);
                     var scale:Number = note.getBody() as Number;
-                    zoomSlider.value = Math.round(scale*100);
+                    panZoomBox.scale = scale;
                     zoomSlider.addEventListener(SliderEvent.CHANGE, 
onZoomSliderChange);
                     graphProxy.zoom = scale;
                     break;
@@ -160,11 +163,11 @@
            }
            
            private function onZoomSliderChange(e:SliderEvent):void {
-                sendNotification(ApplicationFacade.ZOOM_GRAPH, e.value/100);
+            sendNotification(ApplicationFacade.ZOOM_GRAPH, 
e.value/panZoomBox.ZOOM_FACTOR);
            }
            
            private function onZoomInClick(e:Event):void {
-               var zoomValue:Number = Math.round(graphProxy.zoom*10000)/100;
+               var zoomValue:Number = 
Math.round(graphProxy.zoom*panZoomBox.ZOOM_FACTOR*10)/10;
                
                if (zoomValue < zoomSlider.maximum) {
                 var tickValues:Array = zoomSlider.tickValues;
@@ -180,7 +183,7 @@
            }
            
            private function onZoomOutClick(e:Event):void {
-               var zoomValue:Number = Math.round(graphProxy.zoom*10000)/100;
+               var zoomValue:Number = 
Math.round(graphProxy.zoom*panZoomBox.ZOOM_FACTOR*10)/10;
                
                if (zoomValue > zoomSlider.minimum) {
                 var tickValues:Array = zoomSlider.tickValues;

Modified: 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/components/GraphView.as
===================================================================
--- 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/components/GraphView.as
   2010-02-04 18:51:45 UTC (rev 19179)
+++ 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/components/GraphView.as
   2010-02-04 19:42:18 UTC (rev 19180)
@@ -144,22 +144,18 @@
 
         /**
         * Zoom the "camera" until it reaches the required scale.
+        * @return The actual scale value after the zooming is executed.
         */
         public function zoomTo(scale:Number):void { trace("-> Zoom to: " + 
scale);
-                       zoomBy(scale / graphContainer.scaleX);
+                       if (scale < _config.minZoom)
+                scale = _config.minZoom;
+            else if (scale > _config.maxZoom)
+                scale = _config.maxZoom;
+                       
+                       var delta:Number = scale / graphContainer.scaleX;
+                       zoomBy(delta);
         }
         
-        /**
-        * Zoom the "camera" by the specified scale factor.
-        */
-        public function zoomBy(scale:Number):void { trace("-> Zoom by: " + 
scale);
-            if (scale > 0) {
-                Displays.zoomBy(graphContainer, scale, parent.width/2, 
parent.height/2);
-                // Let others know about the new scale:
-                dispatchEvent(new GraphViewEvent(GraphViewEvent.SCALE_CHANGE, 
graphContainer.scaleX));
-               }
-        }
-        
         public function zoomToFit():Number {
                    // Reset zoom first:
                if (graphContainer.scaleX != 1)
@@ -348,6 +344,17 @@
                
         // ========[ PRIVATE METHODS 
]==============================================================
                
+               /**
+         * Zoom the "camera" by the specified scale factor.
+         */
+        private function zoomBy(scale:Number):void { trace("-> Zoom by: " + 
scale);            
+            if (scale > 0) {
+                Displays.zoomBy(graphContainer, scale, parent.width/2, 
parent.height/2);
+                // Let others know about the new scale:
+                dispatchEvent(new GraphViewEvent(GraphViewEvent.SCALE_CHANGE, 
graphContainer.scaleX));
+            }
+        }
+               
                private function resize():void {
                    width = parent.width;
             height = parent.height;

Modified: 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/components/PanZoomBox.mxml
===================================================================
--- 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/components/PanZoomBox.mxml
        2010-02-04 18:51:45 UTC (rev 19179)
+++ 
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/components/PanZoomBox.mxml
        2010-02-04 19:42:18 UTC (rev 19180)
@@ -38,9 +38,51 @@
        import org.cytoscapeweb.view.components.slider.TrackSkin;
        import org.cytoscapeweb.view.components.slider.ThumbSkin;
        
-       private function toolTipFormat(value:Number, 
bundleKey:String='zoom.slider.datatip'):String {
-           return $(bundleKey, Math.round(value));
+       public const ZOOM_FACTOR:Number = 10000;
+       
+       private function toolTipFormat(value:Number):String {
+           var v:* = value < ZOOM_FACTOR ? Math.round(value*100)/ZOOM_FACTOR : 
Math.round(100*value/ZOOM_FACTOR);
+           return $('zoom.slider.tooltip', v);
        }
+       
+       public function get scale():Number {
+        return zoomSlider.value/ZOOM_FACTOR;
+    }
+    
+       public function set scale(value:Number):void {
+        zoomSlider.value = value*ZOOM_FACTOR;
+    }
+    
+       public function setZoomRange(min:Number, max:Number):void {
+           if (max < min) max = min;
+           min *= ZOOM_FACTOR;
+        max *= ZOOM_FACTOR;
+        
+        // Initial zoom value:
+        var value:Number = max > ZOOM_FACTOR ? ZOOM_FACTOR : max; // 100% 
unless max < 100%
+        
+        var tickValues:Array = [];
+        var t:Number = min;
+        
+        do {
+            tickValues.push(t);
+            t *= 2;
+        } while (t < value);
+        
+        t = value; // usually == 100%
+        
+        do {
+            tickValues.push(t);
+            t += (0.25 * ZOOM_FACTOR);
+        } while (t <= max);
+
+        trace("Zoom Slider | tickValues: " + tickValues);
+        
+        zoomSlider.minimum = min;
+        zoomSlider.maximum = max;
+        zoomSlider.tickValues = tickValues;
+        zoomSlider.value = value;
+    }
 ]]>
 </mx:Script>
 
@@ -88,16 +130,12 @@
         <mx:GridRow>
             <mx:GridItem colSpan="3">
                 <mx:HSlider id="zoomSlider" width="76"
-                            minimum="1" maximum="300"
-                            dataTipPrecision="2"
+                            dataTipPrecision="0"
                             snapInterval="1"
                             liveDragging="true"
-                            tickValues="{[1,10,25,50,75,100,125,150,200,300]}"
                             tickLength="0"
                             tickOffset="4"
-                            value="100"
-                            toolTip="{toolTipFormat(zoomSlider.value, 
'zoom.slider.tooltip')}"
-                            dataTipFormatFunction="{toolTipFormat}"
+                            dataTipFormatFunction="toolTipFormat"
                             trackSkin="{TrackSkin}"
                             thumbSkin="{ThumbSkin}"/>
             </mx:GridItem>

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