Author: clopes
Date: 2011-08-03 10:42:18 -0700 (Wed, 03 Aug 2011)
New Revision: 26365
Added:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/BoxPositions.as
Modified:
cytoscapeweb/trunk/cytoscapeweb/src-test/org/cytoscapeweb/model/converters/ExternalObjectConverterTest.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/controller/DrawGraphCommand.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/ConfigProxy.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/ConfigVO.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/ApplicationMediator.as
Log:
Implemented feature #2487: Add option for setting the pan-zoom control position
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/controller/DrawGraphCommand.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/controller/DrawGraphCommand.as
2011-08-03 17:40:53 UTC (rev 26364)
+++
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/controller/DrawGraphCommand.as
2011-08-03 17:42:18 UTC (rev 26365)
@@ -30,8 +30,8 @@
package org.cytoscapeweb.controller {
import org.cytoscapeweb.model.data.VisualStyleVO;
- import org.cytoscapeweb.model.error.CWError;
import org.cytoscapeweb.model.methods.error;
+ import org.cytoscapeweb.util.BoxPositions;
import org.cytoscapeweb.view.GraphMediator;
import org.cytoscapeweb.view.components.GraphView;
import org.cytoscapeweb.view.render.ImageCache;
@@ -46,6 +46,8 @@
try {
var options:Object = notification.getBody();
+ configProxy.panZoomControlPosition =
BoxPositions.parse(options.panZoomControlPosition);
+
if (options.visualStyle != null)
configProxy.visualStyle =
VisualStyleVO.fromObject(options.visualStyle);
if (options.layout != null)
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/ConfigProxy.as
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/ConfigProxy.as
2011-08-03 17:40:53 UTC (rev 26364)
+++ cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/ConfigProxy.as
2011-08-03 17:42:18 UTC (rev 26365)
@@ -76,6 +76,14 @@
config.panZoomControlVisible = visible;
}
+ public function get panZoomControlPosition():String {
+ return config.panZoomControlPosition;
+ }
+
+ public function set panZoomControlPosition(position:String):void {
+ config.panZoomControlPosition = position;
+ }
+
public function set grabToPanEnabled(enable:Boolean):void {
config.grabToPanEnabled = enable;
}
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/ConfigVO.as
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/ConfigVO.as
2011-08-03 17:40:53 UTC (rev 26364)
+++ cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/model/data/ConfigVO.as
2011-08-03 17:42:18 UTC (rev 26365)
@@ -29,6 +29,7 @@
*/
package org.cytoscapeweb.model.data {
+ import org.cytoscapeweb.util.BoxPositions;
import org.cytoscapeweb.util.Layouts;
@@ -43,6 +44,7 @@
// ========[ PUBLIC PROPERTIES
]============================================================
public var panZoomControlVisible:Boolean = true;
+ public var panZoomControlPosition:String = BoxPositions.BOTTOM_RIGHT;
public var grabToPanEnabled:Boolean;
public var edgesMerged:Boolean;
public var nodeLabelsVisible:Boolean = true;
Added: cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/BoxPositions.as
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/BoxPositions.as
(rev 0)
+++ cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/util/BoxPositions.as
2011-08-03 17:42:18 UTC (rev 26365)
@@ -0,0 +1,84 @@
+/*
+ This file is part of Cytoscape Web.
+ Copyright (c) 2009, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Agilent Technologies
+ - Institut Pasteur
+ - Institute for Systems Biology
+ - Memorial Sloan-Kettering Cancer Center
+ - National Center for Integrative Biomedical Informatics
+ - Unilever
+ - University of California San Diego
+ - University of California San Francisco
+ - University of Toronto
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+package org.cytoscapeweb.util {
+ import mx.utils.StringUtil;
+
+
+ /**
+ * Abstract utility class defining names of positions for boxes.
+ */
+ public class BoxPositions {
+
+ // ========[ CONSTANTS
]====================================================================
+
+ public static const TOP_LEFT:String = "topLeft";
+ public static const TOP_CENTER:String = "topCenter";
+ public static const TOP_RIGHT:String = "topRight";
+
+ public static const MIDDLE_LEFT:String = "middleLeft";
+ public static const MIDDLE_CENTER:String = "middleCenter";
+ public static const MIDDLE_RIGHT:String = "middleRight";
+
+ public static const BOTTOM_LEFT:String = "bottomLeft";
+ public static const BOTTOM_CENTER:String = "bottomCenter";
+ public static const BOTTOM_RIGHT:String = "bottomRight";
+
+ // ========[ CONSTRUCTOR
]==================================================================
+
+ /**
+ * This constructor will throw an error, as this is an abstract class.
+ */
+ public function BoxPositions() {
+ throw new Error("This is an abstract class.");
+ }
+
+ // ========[ PUBLIC METHODS
]===============================================================
+
+ public static function parse(s:String):String {
+ if (s != null) s = StringUtil.trim(s.toLowerCase());
+
+ switch (s) {
+ case TOP_LEFT.toLowerCase(): return TOP_LEFT;
+ case TOP_CENTER.toLowerCase(): return TOP_CENTER;
+ case TOP_RIGHT.toLowerCase(): return TOP_RIGHT;
+ case MIDDLE_LEFT.toLowerCase(): return MIDDLE_LEFT;
+ case MIDDLE_CENTER.toLowerCase(): return MIDDLE_CENTER;
+ case MIDDLE_RIGHT.toLowerCase(): return MIDDLE_RIGHT;
+ case BOTTOM_LEFT.toLowerCase(): return BOTTOM_LEFT;
+ case BOTTOM_CENTER.toLowerCase(): return BOTTOM_CENTER;
+ case BOTTOM_RIGHT.toLowerCase():
+ default: return BOTTOM_RIGHT;
+ }
+ }
+
+ // ========[ PRIVATE METHODS
]==============================================================
+
+ }
+}
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/ApplicationMediator.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/ApplicationMediator.as
2011-08-03 17:40:53 UTC (rev 26364)
+++
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/ApplicationMediator.as
2011-08-03 17:42:18 UTC (rev 26365)
@@ -53,6 +53,7 @@
import org.cytoscapeweb.model.converters.SVGExporter;
import org.cytoscapeweb.model.data.VisualStyleVO;
import org.cytoscapeweb.model.methods.$;
+ import org.cytoscapeweb.util.BoxPositions;
import org.cytoscapeweb.util.ExternalFunctions;
import org.cytoscapeweb.util.Utils;
import org.cytoscapeweb.util.VisualProperties;
@@ -180,6 +181,8 @@
sendNotification(ApplicationFacade.CALL_EXTERNAL_INTERFACE, { functionName:
ExternalFunctions.READY });
case ApplicationFacade.CONFIG_CHANGED:
panZoomBox.visible = configProxy.panZoomControlVisible;
+ panZoomBox.x = calculatePanZoomBoxX();
+ panZoomBox.y = calculatePanZoomBoxY();
break;
case ApplicationFacade.UPDATE_CURSOR:
_cursorOptions = n.getBody();
@@ -429,9 +432,29 @@
}
private function calculatePanZoomBoxX():Number {
- // Initially anchored on the right side of the canvas:
- var x:Number = application.width - panZoomBox.width - 6;
+ // Initially anchored on one edge of the canvas:
+ var x:Number;
+ const HPAD:int = 6;
+ var position:String = configProxy.panZoomControlPosition;
+ switch (position) {
+ case BoxPositions.TOP_LEFT:
+ case BoxPositions.MIDDLE_LEFT:
+ case BoxPositions.BOTTOM_LEFT:
+ x = HPAD;
+ break;
+ case BoxPositions.TOP_CENTER:
+ case BoxPositions.MIDDLE_CENTER:
+ case BoxPositions.BOTTOM_CENTER:
+ x = application.width/2 - panZoomBox.width/2;
+ break;
+ case BoxPositions.TOP_RIGHT:
+ case BoxPositions.MIDDLE_RIGHT:
+ case BoxPositions.BOTTOM_RIGHT:
+ default:
+ x = application.width - panZoomBox.width - HPAD;
+ }
+
if (_panZoomMoved) {
const MIN_DIST_TO_ANCHOR:Number = Math.min(20,
application.width/10);
@@ -459,8 +482,28 @@
}
private function calculatePanZoomBoxY():Number {
- // Initially anchored on the bottom side of the canvas:
- var y:Number = application.height - panZoomBox.height - 6;
+ // Initially anchored on one edge of the canvas:
+ var y:Number;
+ const VPAD:int = 6;
+ var position:String = configProxy.panZoomControlPosition;
+
+ switch (position) {
+ case BoxPositions.TOP_LEFT:
+ case BoxPositions.TOP_CENTER:
+ case BoxPositions.TOP_RIGHT:
+ y = VPAD;
+ break;
+ case BoxPositions.MIDDLE_LEFT:
+ case BoxPositions.MIDDLE_CENTER:
+ case BoxPositions.MIDDLE_RIGHT:
+ y = application.height/2 - panZoomBox.height/2;
+ break;
+ case BoxPositions.BOTTOM_LEFT:
+ case BoxPositions.BOTTOM_CENTER:
+ case BoxPositions.BOTTOM_RIGHT:
+ default:
+ y = application.height - panZoomBox.height - VPAD;
+ }
if (_panZoomMoved) {
const MIN_DIST_TO_ANCHOR:Number = Math.min(20,
application.height/10);
Modified:
cytoscapeweb/trunk/cytoscapeweb/src-test/org/cytoscapeweb/model/converters/ExternalObjectConverterTest.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src-test/org/cytoscapeweb/model/converters/ExternalObjectConverterTest.as
2011-08-03 17:40:53 UTC (rev 26364)
+++
cytoscapeweb/trunk/cytoscapeweb/src-test/org/cytoscapeweb/model/converters/ExternalObjectConverterTest.as
2011-08-03 17:42:18 UTC (rev 26365)
@@ -267,7 +267,7 @@
// NODES
var props:Array =
["data","shape","borderColor","borderWidth","opacity","visible","color",
- "x","y"/*, "degree", "indegree", "outdegree"*/];
+ "x","y","size","width","height"/*, "degree",
"indegree", "outdegree"*/];
var attrs:Array = ["id"];
for each (var n:NodeSprite in data.nodes) {
--
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.