PageRenderTime 65ms CodeModel.GetById 31ms RepoModel.GetById 1ms app.codeStats 0ms

/geovis/src/org/un/cava/birdeye/geovis/controls/viewers/toolbars/MainViewToolbar.as

http://birdeye.googlecode.com/
ActionScript | 797 lines | 630 code | 102 blank | 65 comment | 37 complexity | bffca4f4da556030807d15aed45053a4 MD5 | raw file
  1. /*
  2. * The MIT License
  3. *
  4. * Copyright (c) 2008
  5. * United Nations Office at Geneva
  6. * Center for Advanced Visual Analytics
  7. * http://cava.unog.ch
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10. * of this software and associated documentation files (the "Software"), to deal
  11. * in the Software without restriction, including without limitation the rights
  12. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. * copies of the Software, and to permit persons to whom the Software is
  14. * furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be included in
  17. * all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. * THE SOFTWARE.
  26. */
  27. package org.un.cava.birdeye.geovis.controls.viewers.toolbars
  28. {
  29. import flash.display.Sprite;
  30. import flash.events.Event;
  31. import flash.events.MouseEvent;
  32. import flash.geom.Point;
  33. import mx.controls.CheckBox;
  34. import mx.core.Application;
  35. import mx.core.LayoutContainer;
  36. import org.un.cava.birdeye.geovis.controls.viewers.toolbars.icons.*;
  37. import org.un.cava.birdeye.geovis.core.GeoFrame;
  38. import org.un.cava.birdeye.geovis.core.Map;
  39. import org.un.cava.birdeye.geovis.events.MapEvent;
  40. public class MainViewToolbar extends LayoutContainer implements IMainViewToolbar
  41. {
  42. private var map:Map;
  43. // Keep the starting point position when dragging, if mouse goes out of the parents' view
  44. // than the toolbar will be repositioned to this point
  45. private var startDraggingPoint:Point;
  46. private var myRestoreHeight:int;
  47. private var isMinimized:Boolean = false;
  48. // Offset positions used when moving the toolbar on dragging/dropping
  49. private var offsetX:Number, offsetY:Number;
  50. private var isCenteringMap:CheckBox;
  51. private var zoomOut:CheckBox;
  52. private var zoomIn:CheckBox;
  53. private var wheelZoom:CheckBox;
  54. private var dragBox:CheckBox;
  55. private var wheelSkewVertically:CheckBox;
  56. private var wheelSkewHorizontally:CheckBox;
  57. private var zoomRect:CheckBox;
  58. private var resetMap:CheckBox;
  59. private var hawkEye:CheckBox;
  60. private var hkView:ZoomReticle;
  61. private var cursor:Sprite = new Sprite();
  62. static private const CENTER:String = "center";
  63. static private const ZOOM_OUT:String = "zoom out";
  64. static private const ZOOM_IN:String = "zoom in";
  65. static private const WHEEL_ZOOM:String = "wheel zoom";
  66. static private const DRAG_MAP:String = "drag map";
  67. static private const WHEEL_SKEW_VERTICALLY:String = "skew map V";
  68. static private const WHEEL_SKEW_HORIZONTALLY:String = "skew map H";
  69. static private const ZOOM_RECTANGLE:String = "zoom rectangle";
  70. static private const RESET_MAP:String = "reset map";
  71. static private const HAWK_EYE:String = "hawk view";
  72. public static const GREY:Number = 0x777777;
  73. public static const WHITE:Number = 0xffffff;
  74. public static const YELLOW:Number = 0xffd800;
  75. public static const RED:Number = 0xff0000;
  76. public static const BLUE:Number = 0x009cff;
  77. public static const GREEN:Number = 0x609677;
  78. public static const BLACK:Number = 0x000000;
  79. public static const size:Number = 15;
  80. public static const thick:Number = 2;
  81. private var _autosizeIcons:Boolean = false;
  82. private var _customCursor:Boolean = true;
  83. private var _upIconColor:Number = GREY;
  84. private var _overIconColor:Number = YELLOW;
  85. private var _downIconColor:Number = RED;
  86. private var _selectedUpIconColor:Number = GREEN;
  87. private var _selectedOverIconColor:Number = GREY;
  88. private var _selectedDownIconColor:Number = BLUE;
  89. private var _dragHawkView:Boolean = true;
  90. [Inspectable(enumeration="true,false")]
  91. public function set dragHawkView(val:Boolean):void
  92. {
  93. _dragHawkView = val;
  94. }
  95. public function get autosizeIcons():Boolean
  96. {
  97. return _autosizeIcons;
  98. }
  99. [Inspectable(enumeration="true,false")]
  100. public function set autosizeIcons(val:Boolean):void
  101. {
  102. _autosizeIcons = val;
  103. }
  104. public function get customCursor():Boolean
  105. {
  106. return _customCursor;
  107. }
  108. [Inspectable(enumeration="true,false")]
  109. public function set customCursor(val:Boolean):void
  110. {
  111. _customCursor = val;
  112. }
  113. public function get upIconColor():Number
  114. {
  115. return _upIconColor;
  116. }
  117. public function set upIconColor(val:Number):void
  118. {
  119. _upIconColor = val;
  120. }
  121. public function get overIconColor():Number
  122. {
  123. return _overIconColor;
  124. }
  125. public function set overIconColor(val:Number):void
  126. {
  127. _overIconColor = val;
  128. }
  129. public function get downIconColor():Number
  130. {
  131. return _downIconColor;
  132. }
  133. public function set downIconColor(val:Number):void
  134. {
  135. _downIconColor = val;
  136. }
  137. public function get selectedUpIconColor():Number
  138. {
  139. return _selectedUpIconColor;
  140. }
  141. public function set selectedUpIconColor(val:Number):void
  142. {
  143. _selectedUpIconColor = val;
  144. }
  145. public function get selectedOverIconColor():Number
  146. {
  147. return _selectedOverIconColor;
  148. }
  149. public function set selectedOverIconColor(val:Number):void
  150. {
  151. _selectedOverIconColor = val;
  152. }
  153. public function get selectedDownIconColor():Number
  154. {
  155. return _selectedDownIconColor;
  156. }
  157. public function set selectedDownIconColor(val:Number):void
  158. {
  159. _selectedDownIconColor = val;
  160. }
  161. private var _draggable:Boolean = false;
  162. [Inspectable(enumeration="true,false")]
  163. public function set draggable(val:Boolean):void
  164. {
  165. _draggable = val;
  166. }
  167. // Add the creationCOmplete event handler.
  168. public function MainViewToolbar()
  169. {
  170. super();
  171. isCenteringMap = new CheckBox();
  172. isCenteringMap.name = CENTER;
  173. isCenteringMap.setStyle("upIcon", CenteringMapIcon);
  174. isCenteringMap.setStyle("selectedUpIcon", CenteringMapIcon);
  175. isCenteringMap.setStyle("overIcon", CenteringMapIcon);
  176. isCenteringMap.setStyle("downIcon", CenteringMapIcon);
  177. isCenteringMap.setStyle("selectedOverIcon", CenteringMapIcon);
  178. isCenteringMap.setStyle("selectedDownIcon", CenteringMapIcon);
  179. // isCenteringMap.blendMode = BlendMode.ADD;
  180. isCenteringMap.addEventListener(Event.CHANGE, toolbarListenersHandler);
  181. isCenteringMap.addEventListener(MouseEvent.MOUSE_OVER, tooltipHandler);
  182. addChild(isCenteringMap);
  183. zoomOut = new CheckBox();
  184. zoomOut.name = ZOOM_OUT
  185. zoomOut.setStyle("upIcon", ZoomOutIcon);
  186. zoomOut.setStyle("selectedUpIcon", ZoomOutIcon);
  187. zoomOut.setStyle("overIcon", ZoomOutIcon);
  188. zoomOut.setStyle("downIcon", ZoomOutIcon);
  189. zoomOut.setStyle("selectedOverIcon", ZoomOutIcon);
  190. zoomOut.setStyle("selectedDownIcon", ZoomOutIcon);
  191. // zoomOut.blendMode = BlendMode.ADD;
  192. zoomOut.addEventListener(Event.CHANGE, toolbarListenersHandler);
  193. zoomOut.addEventListener(MouseEvent.MOUSE_OVER, tooltipHandler);
  194. addChild(zoomOut);
  195. zoomIn = new CheckBox();
  196. zoomIn.name = ZOOM_IN;
  197. zoomIn.setStyle("upIcon", ZoomInIcon);
  198. zoomIn.setStyle("selectedUpIcon", ZoomInIcon);
  199. zoomIn.setStyle("overIcon", ZoomInIcon);
  200. zoomIn.setStyle("downIcon", ZoomInIcon);
  201. zoomIn.setStyle("selectedOverIcon", ZoomInIcon);
  202. zoomIn.setStyle("selectedDownIcon", ZoomInIcon);
  203. // zoomIn.blendMode = BlendMode.ADD;
  204. zoomIn.addEventListener(Event.CHANGE, toolbarListenersHandler);
  205. zoomIn.addEventListener(MouseEvent.MOUSE_OVER, tooltipHandler);
  206. addChild(zoomIn);
  207. wheelZoom = new CheckBox();
  208. wheelZoom.name = WHEEL_ZOOM;
  209. wheelZoom.setStyle("upIcon", WheelZoomIcon);
  210. wheelZoom.setStyle("selectedUpIcon", WheelZoomIcon);
  211. wheelZoom.setStyle("overIcon", WheelZoomIcon);
  212. wheelZoom.setStyle("downIcon", WheelZoomIcon);
  213. wheelZoom.setStyle("selectedOverIcon", WheelZoomIcon);
  214. wheelZoom.setStyle("selectedDownIcon", WheelZoomIcon);
  215. // wheelZoom.blendMode = BlendMode.ADD;
  216. wheelZoom.addEventListener(Event.CHANGE, toolbarListenersHandler);
  217. wheelZoom.addEventListener(MouseEvent.MOUSE_OVER, tooltipHandler);
  218. addChild(wheelZoom);
  219. dragBox = new CheckBox();
  220. dragBox.name = DRAG_MAP;
  221. dragBox.setStyle("upIcon", DragBox);
  222. dragBox.setStyle("selectedUpIcon", DragBox);
  223. dragBox.setStyle("overIcon", DragBox);
  224. dragBox.setStyle("downIcon", DragBox);
  225. dragBox.setStyle("selectedOverIcon", DragBox);
  226. dragBox.setStyle("selectedDownIcon", DragBox);
  227. // dragBox.blendMode = BlendMode.ADD;
  228. dragBox.addEventListener(Event.CHANGE, toolbarListenersHandler);
  229. dragBox.addEventListener(MouseEvent.MOUSE_OVER, tooltipHandler);
  230. addChild(dragBox);
  231. wheelSkewVertically = new CheckBox();
  232. wheelSkewVertically.name = WHEEL_SKEW_VERTICALLY;
  233. wheelSkewVertically.setStyle("upIcon", WheelSkewVerticallyIcon);
  234. wheelSkewVertically.setStyle("selectedUpIcon", WheelSkewVerticallyIcon);
  235. wheelSkewVertically.setStyle("overIcon", WheelSkewVerticallyIcon);
  236. wheelSkewVertically.setStyle("downIcon", WheelSkewVerticallyIcon);
  237. wheelSkewVertically.setStyle("selectedOverIcon", WheelSkewVerticallyIcon);
  238. wheelSkewVertically.setStyle("selectedDownIcon", WheelSkewVerticallyIcon);
  239. // wheelSkewVertically.blendMode = BlendMode.ADD;
  240. /* wheelSkewVertically.addEventListener(Event.CHANGE, toolbarListenersHandler);
  241. wheelSkewVertically.addEventListener(MouseEvent.MOUSE_OVER, tooltipHandler);
  242. addChild(wheelSkewVertically);
  243. */
  244. wheelSkewHorizontally = new CheckBox();
  245. wheelSkewHorizontally.name = WHEEL_SKEW_HORIZONTALLY;
  246. wheelSkewHorizontally.setStyle("upIcon", WheelSkewHorizontallyIcon);
  247. wheelSkewHorizontally.setStyle("selectedUpIcon", WheelSkewHorizontallyIcon);
  248. wheelSkewHorizontally.setStyle("overIcon", WheelSkewHorizontallyIcon);
  249. wheelSkewHorizontally.setStyle("downIcon", WheelSkewHorizontallyIcon);
  250. wheelSkewHorizontally.setStyle("selectedOverIcon", WheelSkewHorizontallyIcon);
  251. wheelSkewHorizontally.setStyle("selectedDownIcon", WheelSkewHorizontallyIcon);
  252. // wheelSkewHorizontally.blendMode = BlendMode.ADD;
  253. /* wheelSkewHorizontally.addEventListener(Event.CHANGE, toolbarListenersHandler);
  254. wheelSkewHorizontally.addEventListener(MouseEvent.MOUSE_OVER, tooltipHandler);
  255. addChild(wheelSkewHorizontally);
  256. */
  257. zoomRect = new CheckBox();
  258. zoomRect.name = ZOOM_RECTANGLE;
  259. zoomRect.setStyle("upIcon", ZoomRectangle);
  260. zoomRect.setStyle("selectedUpIcon", ZoomRectangle);
  261. zoomRect.setStyle("overIcon", ZoomRectangle);
  262. zoomRect.setStyle("downIcon", ZoomRectangle);
  263. zoomRect.setStyle("selectedOverIcon", ZoomRectangle);
  264. zoomRect.setStyle("selectedDownIcon", ZoomRectangle);
  265. // zoomRect.blendMode = BlendMode.ADD;
  266. zoomRect.addEventListener(Event.CHANGE, toolbarListenersHandler);
  267. zoomRect.addEventListener(MouseEvent.MOUSE_OVER, tooltipHandler);
  268. addChild(zoomRect);
  269. resetMap = new CheckBox();
  270. resetMap.name = RESET_MAP;
  271. resetMap.setStyle("upIcon", ResetMap);
  272. resetMap.setStyle("selectedUpIcon", ResetMap);
  273. resetMap.setStyle("overIcon", ResetMap);
  274. resetMap.setStyle("downIcon", ResetMap);
  275. resetMap.setStyle("selectedOverIcon", ResetMap);
  276. resetMap.setStyle("selectedDownIcon", ResetMap);
  277. // resetMap.blendMode = BlendMode.ADD;
  278. resetMap.addEventListener(Event.CHANGE, toolbarListenersHandler);
  279. resetMap.addEventListener(MouseEvent.MOUSE_OVER, tooltipHandler);
  280. addChild(resetMap);
  281. hawkEye = new CheckBox();
  282. hawkEye.name = HAWK_EYE;
  283. hawkEye.setStyle("upIcon", HawkEye);
  284. hawkEye.setStyle("selectedUpIcon", HawkEye);
  285. hawkEye.setStyle("overIcon", HawkEye);
  286. hawkEye.setStyle("downIcon", HawkEye);
  287. hawkEye.setStyle("selectedOverIcon", HawkEye);
  288. hawkEye.setStyle("selectedDownIcon", HawkEye);
  289. // hawkEye.blendMode = BlendMode.ADD;
  290. hawkEye.addEventListener(Event.CHANGE, toolbarListenersHandler);
  291. hawkEye.addEventListener(MouseEvent.MOUSE_OVER, tooltipHandler);
  292. addChild(hawkEye);
  293. hkView = new ZoomReticle();
  294. hkView.eventType = ZoomReticle.ROLL_OVER;
  295. hkView.shape = ZoomReticle.CIRCLE;
  296. hkView.yOffsetFromMouse = 140;
  297. hkView.xOffsetFromMouse = 0;
  298. hkView.width = 150;
  299. hkView.height = 150;
  300. hkView.followMouse = false;
  301. hkView.draggable = _dragHawkView;
  302. hkView.zoom = 4;
  303. hkView.backgroundColor = IconsUtils.WHITE;
  304. hkView.backgroundAlpha = 0.8;
  305. Application.application.addEventListener(MapEvent.MAP_INSTANTIATED, init, true)
  306. }
  307. override protected function measure():void
  308. {
  309. if (layout == "horizontal")
  310. {
  311. minWidth = IconsUtils.size * numChildren;
  312. minHeight = IconsUtils.size + 10;
  313. } else {
  314. minHeight = IconsUtils.size * numChildren;
  315. minWidth = IconsUtils.size + 10;
  316. }
  317. }
  318. override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
  319. {
  320. super.updateDisplayList(unscaledWidth, unscaledHeight);
  321. var pos:Number = 0, size:Number = IconsUtils.size, space:Number = 4;
  322. if (autosizeIcons)
  323. {
  324. if (layout == "horizontal")
  325. size = Math.min(unscaledHeight,IconsUtils.size,unscaledWidth/numChildren - space);
  326. else
  327. size = Math.min(unscaledWidth,IconsUtils.size,unscaledHeight/numChildren - space);
  328. IconsUtils.size = size;
  329. }
  330. for (var i:Number = 0; i < numChildren; i++)
  331. {
  332. getChildAt(i).width = getChildAt(i).height = size;
  333. if (layout == "horizontal")
  334. {
  335. getChildAt(i).x = pos;
  336. getChildAt(i).y = 0;
  337. } else {
  338. getChildAt(i).y = pos;
  339. getChildAt(i).x = 0;
  340. }
  341. pos += size + space;
  342. }
  343. }
  344. private function init(event:Event):void
  345. {
  346. if (_customCursor)
  347. stage.addChild(cursor);
  348. // Add the resizing event handler.
  349. map = Map(event.target);
  350. this.doubleClickEnabled = true;
  351. //uncomment if Panel is used instead titleBar.addEventListener(MouseEvent.DOUBLE_CLICK, resizeToolbar);
  352. if (_draggable)
  353. addEventListener(MouseEvent.MOUSE_DOWN, moveToolbar);
  354. registerMapListeners();
  355. map.centeringMapSelected = isCenteringMap.selected = true;
  356. map.wheelZoomSelected = wheelZoom.selected = true;
  357. map.dragSelected = dragBox.selected = true;
  358. hawkEye.selected = true;
  359. map.parent.addChildAt(hkView,map.parent.numChildren-1);
  360. if (parent is GeoFrame)
  361. parent.setChildIndex(this, parent.numChildren-1);
  362. }
  363. private function getMap(e:MapEvent):void
  364. {
  365. map = Map(e.target);
  366. }
  367. private function resizeToolbar(e:Event):void
  368. {
  369. if (isMinimized)
  370. restorePanelSizeHandler(e);
  371. else
  372. minPanelSizeHandler(e);
  373. }
  374. // Minimize panel event handler.
  375. private function minPanelSizeHandler(event:Event):void
  376. {
  377. if (!isMinimized)
  378. {
  379. myRestoreHeight = height;
  380. //uncomment if Panel is used instead height = titleBar.height;
  381. isMinimized = true;
  382. }
  383. }
  384. // Restore panel event handler.
  385. private function restorePanelSizeHandler(event:Event):void
  386. {
  387. if (isMinimized)
  388. {
  389. height = myRestoreHeight;
  390. isMinimized = false;
  391. }
  392. }
  393. // Resize panel event handler.
  394. public function moveToolbar(event:MouseEvent):void
  395. {
  396. startMovingToolBar(event);
  397. stage.addEventListener(MouseEvent.MOUSE_UP, stopMovingToolBar);
  398. }
  399. // Start moving the toolbar
  400. private function startMovingToolBar(e:MouseEvent):void
  401. {
  402. this.parent.addEventListener(MouseEvent.ROLL_OUT, resetToolBarPosition);
  403. startDraggingPoint = new Point(this.x, this.y);
  404. offsetX = e.stageX - this.x;
  405. offsetY = e.stageY - this.y;
  406. stage.addEventListener(MouseEvent.MOUSE_MOVE, dragToolBar);
  407. }
  408. // Reset the toolbar position to the starting point
  409. private function resetToolBarPosition(e:MouseEvent):void
  410. {
  411. stopMovingToolBar(e);
  412. this.x = startDraggingPoint.x;
  413. this.y = startDraggingPoint.y;
  414. this.parent.removeEventListener(MouseEvent.ROLL_OUT, resetToolBarPosition);
  415. }
  416. // Stop moving the toolbar
  417. private function stopMovingToolBar(e:MouseEvent):void
  418. {
  419. stage.removeEventListener(MouseEvent.MOUSE_MOVE, dragToolBar)
  420. stage.removeEventListener(MouseEvent.MOUSE_UP, stopMovingToolBar);
  421. this.parent.removeEventListener(MouseEvent.ROLL_OUT, resetToolBarPosition);
  422. }
  423. // Moving the toolbar while MOUSE_MOVE event is on
  424. private function dragToolBar(e:MouseEvent):void
  425. {
  426. this.x = e.stageX - offsetX;
  427. this.y = e.stageY - offsetY;
  428. e.updateAfterEvent();
  429. // dispatch moved toolbar event
  430. }
  431. private function toolbarListenersHandler(e:Event):void
  432. {
  433. var selectedTool:String = CheckBox(e.target).name;
  434. switch (selectedTool)
  435. {
  436. case CENTER:
  437. map.centeringMapSelected = isCenteringMap.selected;
  438. break;
  439. case ZOOM_OUT:
  440. map.zoomOutSelected = zoomOut.selected;
  441. break;
  442. case ZOOM_IN:
  443. map.zoomInSelected = zoomIn.selected;
  444. break;
  445. case WHEEL_ZOOM:
  446. map.wheelZoomSelected = wheelZoom.selected;
  447. break;
  448. case DRAG_MAP:
  449. map.dragSelected = dragBox.selected;
  450. break;
  451. case WHEEL_SKEW_VERTICALLY:
  452. map.skewMapVerticallySelected = wheelSkewVertically.selected;
  453. break;
  454. case WHEEL_SKEW_HORIZONTALLY:
  455. map.skewMapHorizontallySelected = wheelSkewHorizontally.selected;
  456. break;
  457. case ZOOM_RECTANGLE:
  458. map.zoomRectangleSelected = zoomRect.selected;
  459. break;
  460. case RESET_MAP:
  461. map.reset();
  462. resetMap.selected = false;
  463. break;
  464. case HAWK_EYE:
  465. if (hawkEye.selected)
  466. {
  467. hkView.followMouse = true;
  468. map.parent.addChildAt(hkView,map.parent.numChildren-1);
  469. } else {
  470. hkView.followMouse = false;
  471. map.parent.removeChild(hkView);
  472. }
  473. if (customCursor)
  474. manageCursor();
  475. break;
  476. }
  477. }
  478. private function redrawMouseCursor(e:MouseEvent):void
  479. {
  480. cursor.visible = true;
  481. cursor.x = e.stageX;
  482. cursor.y = e.stageY + 20;
  483. }
  484. private function tooltipHandler(e:MouseEvent):void
  485. {
  486. var selectedTool:String = CheckBox(e.target).name;
  487. switch (selectedTool)
  488. {
  489. case CENTER:
  490. toolTip = "Double click to center the mouse point"
  491. break;
  492. case ZOOM_OUT:
  493. toolTip = "Double click to zoom out from the mouse point"
  494. break;
  495. case ZOOM_IN:
  496. toolTip = "Double click to zoom the mouse point"
  497. break;
  498. case WHEEL_ZOOM:
  499. toolTip = "Use mouse wheel to zoom in/out the mouse point"
  500. break;
  501. case DRAG_MAP:
  502. toolTip = "Click and drag the map"
  503. break;
  504. case WHEEL_SKEW_VERTICALLY:
  505. toolTip = "Use mouse wheel to skew the map vertically"
  506. break;
  507. case WHEEL_SKEW_HORIZONTALLY:
  508. toolTip = "Use mouse wheel to skew the map horizontally"
  509. break;
  510. case ZOOM_RECTANGLE:
  511. toolTip = "Select a map area to zoom it"
  512. break;
  513. case RESET_MAP:
  514. toolTip = "Reset map to its original position and scale"
  515. break;
  516. case HAWK_EYE:
  517. toolTip = "Show circle with zoom when roll-over the map"
  518. break;
  519. }
  520. }
  521. private function updateBoxValue(e:MapEvent):void
  522. {
  523. map = Map(e.target);
  524. isCenteringMap.selected = map.centeringMapSelected;
  525. dragBox.selected = map.dragSelected;
  526. zoomIn.selected = map.zoomInSelected;
  527. zoomOut.selected = map.zoomOutSelected;
  528. zoomRect.selected = map.zoomRectangleSelected;
  529. wheelZoom.selected = map.wheelZoomSelected;
  530. wheelSkewVertically.selected = map.skewMapVerticallySelected;
  531. wheelSkewHorizontally.selected = map.skewMapHorizontallySelected;
  532. if (_customCursor)
  533. manageCursor();
  534. }
  535. private function registerMapListeners():void
  536. {
  537. map.addEventListener(MapEvent.MAP_PROPERTY_ON, updateBoxValue);
  538. }
  539. private function manageCursor():void
  540. {
  541. var c:Number = selectedUpIconColor;
  542. cursor.graphics.clear();
  543. var xOffset:Number = 0, space:Number = 3;
  544. if (isCenteringMap.selected)
  545. {
  546. with (cursor.graphics)
  547. {
  548. moveTo(xOffset + IconsUtils.size/2,IconsUtils.size/2);
  549. beginFill(c,1);
  550. drawRect(xOffset,0,IconsUtils.size, IconsUtils.size);
  551. endFill();
  552. moveTo(xOffset,IconsUtils.size/2);
  553. lineStyle(2,IconsUtils.BLACK,1);
  554. lineTo(xOffset + IconsUtils.size,IconsUtils.size/2);
  555. moveTo(xOffset + IconsUtils.size/2,0);
  556. lineStyle(2,IconsUtils.BLACK,1);
  557. lineTo(xOffset + IconsUtils.size/2,IconsUtils.size);
  558. }
  559. xOffset += IconsUtils.size + space;
  560. }
  561. if (zoomIn.selected)
  562. {
  563. with (cursor.graphics)
  564. {
  565. moveTo(xOffset + IconsUtils.size/2,IconsUtils.size/2);
  566. beginFill(c,1);
  567. drawCircle(xOffset + IconsUtils.size/2,IconsUtils.size/2,IconsUtils.size/2);
  568. endFill();
  569. moveTo(xOffset + 3,IconsUtils.size/2);
  570. lineStyle(IconsUtils.thick,IconsUtils.BLACK,1);
  571. lineTo(xOffset + IconsUtils.size-3,IconsUtils.size/2);
  572. moveTo(xOffset + IconsUtils.size/2,3);
  573. lineStyle(IconsUtils.thick,IconsUtils.BLACK,1);
  574. lineTo(xOffset + IconsUtils.size/2,IconsUtils.size-3);
  575. }
  576. xOffset += IconsUtils.size + space;
  577. }
  578. if (zoomOut.selected)
  579. {
  580. with (cursor.graphics)
  581. {
  582. moveTo(xOffset + IconsUtils.size/2,IconsUtils.size/2);
  583. beginFill(c,1);
  584. drawCircle(xOffset + IconsUtils.size/2,IconsUtils.size/2,IconsUtils.size/2);
  585. endFill();
  586. moveTo(xOffset + 3,IconsUtils.size/2);
  587. lineStyle(2,IconsUtils.BLACK,1);
  588. lineTo(xOffset + IconsUtils.size-3,IconsUtils.size/2);
  589. }
  590. xOffset += IconsUtils.size + space;
  591. }
  592. if (dragBox.selected)
  593. {
  594. with (cursor.graphics)
  595. {
  596. moveTo(xOffset + IconsUtils.size/2-3,IconsUtils.size/2-3);
  597. beginFill(IconsUtils.YELLOW,1);
  598. lineStyle(1,IconsUtils.YELLOW,1);
  599. drawRect(xOffset + IconsUtils.size/2-3,IconsUtils.size/2-3,IconsUtils.size/2+3,IconsUtils.size/2+3)
  600. endFill();
  601. moveTo(xOffset,0);
  602. beginFill(c,1);
  603. lineStyle(1,c,1);
  604. drawRect(xOffset,0,IconsUtils.size/2+3,IconsUtils.size/2+3)
  605. endFill();
  606. }
  607. xOffset += IconsUtils.size + space;
  608. }
  609. if (zoomRect.selected)
  610. {
  611. with (cursor.graphics)
  612. {
  613. // rect shape
  614. moveTo(xOffset,0);
  615. lineStyle(1,c,1);
  616. beginFill(IconsUtils.RED,1);
  617. drawRect(xOffset,0,IconsUtils.size*2/3,IconsUtils.size*2/3);
  618. endFill();
  619. // zoom in shape
  620. moveTo(xOffset + IconsUtils.size*2/3,IconsUtils.size*2/3);
  621. lineStyle(1,IconsUtils.BLACK);
  622. beginFill(c,1);
  623. drawCircle(xOffset +IconsUtils.size*2/3,IconsUtils.size*2/3,IconsUtils.size/3);
  624. endFill();
  625. moveTo(xOffset + IconsUtils.size*2/3,IconsUtils.size/3);
  626. lineStyle(IconsUtils.thick/2,IconsUtils.BLACK,1);
  627. lineTo(xOffset + IconsUtils.size*2/3,IconsUtils.size);
  628. moveTo(xOffset + IconsUtils.size/3,IconsUtils.size*2/3);
  629. lineStyle(IconsUtils.thick/2,IconsUtils.BLACK,1);
  630. lineTo(xOffset + IconsUtils.size,IconsUtils.size*2/3);
  631. }
  632. xOffset += IconsUtils.size + space;
  633. }
  634. if (wheelZoom.selected)
  635. {
  636. with (cursor.graphics)
  637. {
  638. // wheel shape
  639. moveTo(xOffset,0);
  640. lineStyle(3,c,1);
  641. lineTo(xOffset + IconsUtils.size,IconsUtils.size);
  642. moveTo(xOffset + IconsUtils.size/2,0);
  643. lineStyle(3,c,1);
  644. lineTo(xOffset + IconsUtils.size/2,IconsUtils.size);
  645. moveTo(xOffset,IconsUtils.size/2);
  646. lineStyle(3,c,1);
  647. lineTo(xOffset + IconsUtils.size,IconsUtils.size/2);
  648. moveTo(xOffset,0);
  649. lineStyle(3,c,1);
  650. lineTo(xOffset + IconsUtils.size,IconsUtils.size);
  651. // zoom shape
  652. moveTo(xOffset + IconsUtils.size/2,IconsUtils.size/2);
  653. lineStyle(1,IconsUtils.BLACK);
  654. beginFill(c,1);
  655. drawCircle(xOffset + IconsUtils.size/2,IconsUtils.size/2,IconsUtils.size/3);
  656. endFill();
  657. moveTo(xOffset + IconsUtils.size/2,IconsUtils.size/4);
  658. lineStyle(IconsUtils.thick/2,IconsUtils.BLACK,1);
  659. lineTo(xOffset + IconsUtils.size/2,IconsUtils.size*3/4);
  660. moveTo(xOffset + IconsUtils.size/4,IconsUtils.size/2);
  661. lineStyle(IconsUtils.thick/2,IconsUtils.BLACK,1);
  662. lineTo(xOffset + IconsUtils.size*3/4,IconsUtils.size/2);
  663. }
  664. xOffset += IconsUtils.size + space;
  665. }
  666. if (hawkEye.selected)
  667. {
  668. with (cursor.graphics)
  669. {
  670. moveTo(xOffset + IconsUtils.size/2,IconsUtils.size/2);
  671. beginFill(c,1);
  672. lineStyle(1,c,1);
  673. drawCircle(xOffset + IconsUtils.size/2,IconsUtils.size/2,IconsUtils.size/2);
  674. endFill();
  675. moveTo(xOffset + IconsUtils.size/2,IconsUtils.size/2);
  676. beginFill(IconsUtils.BLACK,1);
  677. lineStyle(1,IconsUtils.BLACK,1);
  678. drawCircle(xOffset + IconsUtils.size/2,IconsUtils.size/2,IconsUtils.size/4);
  679. endFill();
  680. }
  681. xOffset += IconsUtils.size + space;
  682. }
  683. if (!(isCenteringMap.selected || dragBox.selected || wheelZoom.selected || hawkEye.selected
  684. || zoomIn.selected || zoomOut.selected || zoomRect.selected))
  685. {
  686. cursor.visible = false;
  687. stage.removeEventListener(MouseEvent.MOUSE_MOVE, redrawMouseCursor);
  688. // Mouse.show();
  689. } else {
  690. stage.addEventListener(MouseEvent.MOUSE_MOVE, redrawMouseCursor);
  691. // Mouse.hide();
  692. }
  693. }
  694. }
  695. }