PageRenderTime 3991ms CodeModel.GetById 52ms RepoModel.GetById 5ms app.codeStats 1ms

/src/org/openzoom/flex/components/MultiScaleContainer.as

http://github.com/openzoom/sdk
ActionScript | 1009 lines | 571 code | 177 blank | 261 comment | 64 complexity | bd3290567aa1809bb507ec7a1a1ef81c MD5 | raw file
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // OpenZoom SDK
  4. //
  5. // Version: MPL 1.1/GPL 3/LGPL 3
  6. //
  7. // The contents of this file are subject to the Mozilla Public License Version
  8. // 1.1 (the "License"); you may not use this file except in compliance with
  9. // the License. You may obtain a copy of the License at
  10. // http://www.mozilla.org/MPL/
  11. //
  12. // Software distributed under the License is distributed on an "AS IS" basis,
  13. // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  14. // for the specific language governing rights and limitations under the
  15. // License.
  16. //
  17. // The Original Code is the OpenZoom SDK.
  18. //
  19. // The Initial Developer of the Original Code is Daniel Gasienica.
  20. // Portions created by the Initial Developer are Copyright (c) 2007-2010
  21. // the Initial Developer. All Rights Reserved.
  22. //
  23. // Contributor(s):
  24. // Daniel Gasienica <daniel@gasienica.ch>
  25. //
  26. // Alternatively, the contents of this file may be used under the terms of
  27. // either the GNU General Public License Version 3 or later (the "GPL"), or
  28. // the GNU Lesser General Public License Version 3 or later (the "LGPL"),
  29. // in which case the provisions of the GPL or the LGPL are applicable instead
  30. // of those above. If you wish to allow use of your version of this file only
  31. // under the terms of either the GPL or the LGPL, and not to allow others to
  32. // use your version of this file under the terms of the MPL, indicate your
  33. // decision by deleting the provisions above and replace them with the notice
  34. // and other provisions required by the GPL or the LGPL. If you do not delete
  35. // the provisions above, a recipient may use your version of this file under
  36. // the terms of any one of the MPL, the GPL or the LGPL.
  37. //
  38. ////////////////////////////////////////////////////////////////////////////////
  39. package org.openzoom.flex.components
  40. {
  41. import flash.display.DisplayObject;
  42. import flash.display.Graphics;
  43. import flash.display.Shape;
  44. import flash.display.Sprite;
  45. import flash.events.Event;
  46. import flash.geom.Point;
  47. import flash.geom.Rectangle;
  48. import mx.core.UIComponent;
  49. import org.openzoom.flash.core.openzoom_internal;
  50. import org.openzoom.flash.events.ViewportEvent;
  51. import org.openzoom.flash.net.ILoaderClient;
  52. import org.openzoom.flash.net.INetworkQueue;
  53. import org.openzoom.flash.net.NetworkQueue;
  54. import org.openzoom.flash.renderers.IRenderer;
  55. import org.openzoom.flash.renderers.images.ImagePyramidRenderManager;
  56. import org.openzoom.flash.renderers.images.ImagePyramidRenderer;
  57. import org.openzoom.flash.scene.IMultiScaleScene;
  58. import org.openzoom.flash.scene.IReadonlyMultiScaleScene;
  59. import org.openzoom.flash.scene.MultiScaleScene;
  60. import org.openzoom.flash.viewport.INormalizedViewport;
  61. import org.openzoom.flash.viewport.IViewportConstraint;
  62. import org.openzoom.flash.viewport.IViewportController;
  63. import org.openzoom.flash.viewport.IViewportTransformer;
  64. import org.openzoom.flash.viewport.NormalizedViewport;
  65. use namespace openzoom_internal;
  66. [DefaultProperty("children")]
  67. /**
  68. * Generic container for multiscale content.
  69. */
  70. public final class MultiScaleContainer extends UIComponent
  71. implements ILoaderClient
  72. {
  73. include "../../flash/core/Version.as"
  74. //--------------------------------------------------------------------------
  75. //
  76. // Class constants
  77. //
  78. //--------------------------------------------------------------------------
  79. private static const DEFAULT_VIEWPORT_WIDTH:Number = 800
  80. private static const DEFAULT_VIEWPORT_HEIGHT:Number = 600
  81. private static const DEFAULT_SCENE_WIDTH:Number = 24000
  82. private static const DEFAULT_SCENE_HEIGHT:Number = 18000
  83. private static const DEFAULT_SCENE_BACKGROUND_COLOR:uint = 0x333333
  84. private static const DEFAULT_SCENE_BACKGROUND_ALPHA:Number = 0
  85. //--------------------------------------------------------------------------
  86. //
  87. // Constructor
  88. //
  89. //--------------------------------------------------------------------------
  90. /**
  91. * Constructor.
  92. */
  93. public function MultiScaleContainer()
  94. {
  95. super()
  96. tabEnabled = false
  97. tabChildren = true
  98. }
  99. //--------------------------------------------------------------------------
  100. //
  101. // Variables
  102. //
  103. //--------------------------------------------------------------------------
  104. private var mouseCatcher:Sprite
  105. private var contentMask:Shape
  106. private var renderManager:ImagePyramidRenderManager
  107. //--------------------------------------------------------------------------
  108. //
  109. // Properties
  110. //
  111. //--------------------------------------------------------------------------
  112. // //----------------------------------
  113. // // scene
  114. // //----------------------------------
  115. //
  116. private var _scene:MultiScaleScene
  117. ;[Bindable(event="sceneChanged")]
  118. /**
  119. * @inheritDoc
  120. */
  121. public function get scene():IMultiScaleScene
  122. {
  123. return _scene
  124. }
  125. //----------------------------------
  126. // viewport
  127. //----------------------------------
  128. private var _viewport:NormalizedViewport
  129. ;[Bindable(event="viewportChanged")]
  130. /**
  131. * @inheritDoc
  132. */
  133. public function get viewport():NormalizedViewport
  134. {
  135. return _viewport
  136. }
  137. //----------------------------------
  138. // constraint
  139. //----------------------------------
  140. private var _constraint:IViewportConstraint
  141. private var constraintChanged:Boolean = false
  142. ;[Bindable(event="constraintChanged")]
  143. /**
  144. * @inheritDoc
  145. *
  146. * @see org.openzoom.flash.viewport.constraints.DefaultConstraint
  147. * @see org.openzoom.flash.viewport.constraints.NullConstraint
  148. */
  149. public function get constraint():IViewportConstraint
  150. {
  151. return _constraint
  152. }
  153. public function set constraint(value:IViewportConstraint):void
  154. {
  155. if (_constraint !== value)
  156. {
  157. _constraint = value
  158. constraintChanged = true
  159. invalidateProperties()
  160. dispatchEvent(new Event("constraintChanged"))
  161. }
  162. }
  163. //----------------------------------
  164. // loader
  165. //----------------------------------
  166. private var _loader:INetworkQueue
  167. public function get loader():INetworkQueue
  168. {
  169. return _loader
  170. }
  171. public function set loader(value:INetworkQueue):void
  172. {
  173. _loader = value
  174. }
  175. //----------------------------------
  176. // transformer
  177. //----------------------------------
  178. private var _transformer:IViewportTransformer
  179. private var transformerChanged:Boolean=false
  180. ;[Bindable(event="transformerChanged")]
  181. /**
  182. * @inheritDoc
  183. */
  184. public function get transformer():IViewportTransformer
  185. {
  186. return _transformer
  187. }
  188. public function set transformer(value:IViewportTransformer):void
  189. {
  190. if (_transformer !== value)
  191. {
  192. _transformer = value
  193. transformerChanged = true
  194. invalidateProperties()
  195. dispatchEvent(new Event("transformerChanged"))
  196. }
  197. }
  198. //----------------------------------
  199. // controllers
  200. //----------------------------------
  201. private var _controllers:Array = []
  202. private var _controllersHolder:Array = []
  203. private var controllersChanged:Boolean = false
  204. ;[ArrayElementType("org.openzoom.flash.viewport.IViewportController")]
  205. ;[Inspectable(arrayType="org.openzoom.flash.viewport.IViewportController")]
  206. ;[Bindable(event="controllersChanged")]
  207. /**
  208. * Controllers of type IViewportController applied to this MultiScaleImage.
  209. * For example, viewport controllers are used to navigate the MultiScaleImage
  210. * by mouse or keyboard.
  211. *
  212. * @see org.openzoom.flash.viewport.controllers.MouseController
  213. * @see org.openzoom.flash.viewport.controllers.KeyboardController
  214. * @see org.openzoom.flash.viewport.controllers.ContextMenuController
  215. */
  216. public function get controllers():Array
  217. {
  218. return _controllers.slice(0)
  219. }
  220. public function set controllers(value:Array):void
  221. {
  222. if (_controllers != value)
  223. {
  224. // remove old controllers
  225. for each (var oldController:IViewportController in _controllers)
  226. removeController(oldController)
  227. _controllersHolder = value.slice(0)
  228. controllersChanged = true
  229. invalidateProperties()
  230. dispatchEvent(new Event("controllersChanged"))
  231. }
  232. }
  233. //----------------------------------
  234. // children
  235. //----------------------------------
  236. private var _children:Array
  237. private var childrenChanged:Boolean = false
  238. public function get children():Array
  239. {
  240. return _children
  241. }
  242. public function set children(value:Array):void
  243. {
  244. if (_children != value)
  245. {
  246. _children = value
  247. childrenChanged = true
  248. invalidateProperties()
  249. }
  250. }
  251. //--------------------------------------------------------------------------
  252. //
  253. // Properties: Scene
  254. //
  255. //--------------------------------------------------------------------------
  256. //----------------------------------
  257. // sceneWidth
  258. //----------------------------------
  259. private var _sceneWidth:Number
  260. private var sceneWidthChanged:Boolean = false
  261. ;[Bindable(event="sceneResize")]
  262. /**
  263. * @copy org.openzoom.flash.scene.IMultiScaleScene#sceneWidth
  264. */
  265. public function get sceneWidth():Number
  266. {
  267. return scene ? scene.sceneWidth : _sceneWidth
  268. }
  269. public function set sceneWidth(value:Number):void
  270. {
  271. if (_sceneWidth != value)
  272. {
  273. _sceneWidth = value
  274. sceneWidthChanged = true
  275. invalidateProperties()
  276. }
  277. }
  278. //----------------------------------
  279. // sceneHeight
  280. //----------------------------------
  281. private var _sceneHeight:Number
  282. private var sceneHeightChanged:Boolean = false
  283. ;[Bindable(event="sceneHeightChanged")]
  284. /**
  285. * @copy org.openzoom.flash.scene.IMultiScaleScene#sceneHeight
  286. */
  287. public function get sceneHeight():Number
  288. {
  289. return scene ? scene.sceneHeight : _sceneHeight
  290. }
  291. public function set sceneHeight(value:Number):void
  292. {
  293. if (_sceneHeight != value)
  294. {
  295. _sceneHeight = value
  296. sceneHeightChanged = true
  297. invalidateProperties()
  298. }
  299. }
  300. //--------------------------------------------------------------------------
  301. //
  302. // Overridden methods: UIComponent
  303. //
  304. //--------------------------------------------------------------------------
  305. /**
  306. * @private
  307. */
  308. override protected function createChildren():void
  309. {
  310. super.createChildren()
  311. if (!scene)
  312. createScene()
  313. if (!viewport)
  314. createNormalizedViewport(_scene)
  315. if (!mouseCatcher)
  316. createMouseCatcher()
  317. if (!contentMask)
  318. createContentMask()
  319. if (!loader)
  320. createLoader()
  321. if (!renderManager)
  322. createRenderManager()
  323. }
  324. /**
  325. * @private
  326. */
  327. override protected function commitProperties():void
  328. {
  329. super.commitProperties()
  330. if (childrenChanged)
  331. {
  332. // remove all existing children
  333. while (numChildren > 0)
  334. removeChildAt(0)
  335. // for each (var child:DisplayObject in _children)
  336. // _scene.addItem(child)
  337. }
  338. if (sceneWidthChanged || sceneHeightChanged)
  339. {
  340. _scene.sceneWidth = _sceneWidth
  341. _scene.sceneHeight = _sceneHeight
  342. sceneWidthChanged = sceneHeightChanged = false
  343. dispatchEvent(new Event("sceneResize"))
  344. }
  345. if (transformerChanged)
  346. {
  347. viewport.transformer = _transformer
  348. transformerChanged = false
  349. }
  350. if (constraintChanged)
  351. {
  352. _viewport.transformer.constraint = _constraint
  353. constraintChanged = false
  354. }
  355. if (controllersChanged)
  356. {
  357. for each (var controller:IViewportController in _controllersHolder)
  358. addController(controller)
  359. _controllersHolder = []
  360. controllersChanged = false
  361. }
  362. if (zoomChanged || scaleChanged ||
  363. viewportXChanged || viewportYChanged ||
  364. viewportWidthChanged || viewportHeightChanged)
  365. {
  366. if (zoomChanged)
  367. {
  368. viewport.zoom = zoom
  369. zoomChanged = false
  370. }
  371. if (scaleChanged)
  372. {
  373. viewport.scale = scale
  374. scaleChanged = false
  375. }
  376. if (viewportXChanged || viewportYChanged)
  377. {
  378. viewport.panTo(viewportX, viewportY)
  379. viewportXChanged = viewportYChanged = false
  380. }
  381. if (viewportWidthChanged)
  382. {
  383. viewport.width = viewportWidth
  384. viewportWidthChanged = false
  385. }
  386. if (viewportHeightChanged)
  387. {
  388. viewport.height = viewportHeight
  389. viewportHeightChanged = false
  390. }
  391. dispatchEvent(new Event("transformUpdate"))
  392. }
  393. }
  394. /**
  395. * @private
  396. */
  397. override protected function updateDisplayList(unscaledWidth:Number,
  398. unscaledHeight:Number):void
  399. {
  400. if (viewport.viewportWidth != unscaledWidth ||
  401. viewport.viewportHeight != unscaledHeight)
  402. _viewport.setSize(unscaledWidth, unscaledHeight)
  403. if (mouseCatcher.width != unscaledWidth ||
  404. mouseCatcher.height != unscaledHeight)
  405. {
  406. mouseCatcher.width = unscaledWidth
  407. mouseCatcher.height = unscaledHeight
  408. }
  409. if (contentMask.width != unscaledWidth ||
  410. contentMask.height != unscaledHeight)
  411. {
  412. contentMask.width = unscaledWidth
  413. contentMask.height = unscaledHeight
  414. }
  415. var vp:INormalizedViewport = _viewport
  416. var targetWidth:Number = vp.viewportWidth / vp.width
  417. var targetHeight:Number = vp.viewportHeight / vp.height
  418. var targetX:Number = -vp.x * targetWidth
  419. var targetY:Number = -vp.y * targetHeight
  420. var target:DisplayObject = _scene.targetCoordinateSpace
  421. target.x = targetX
  422. target.y = targetY
  423. target.width = targetWidth
  424. target.height = targetHeight
  425. }
  426. //--------------------------------------------------------------------------
  427. //
  428. // Overridden properties: UIComponent
  429. //
  430. //--------------------------------------------------------------------------
  431. override public function get numChildren():int
  432. {
  433. return _scene ? _scene.numChildren : 0
  434. }
  435. //--------------------------------------------------------------------------
  436. //
  437. // Overridden methods: UIComponent
  438. //
  439. //--------------------------------------------------------------------------
  440. override public function addChild(child:DisplayObject):DisplayObject
  441. {
  442. return addChildAt(child, numChildren)
  443. }
  444. override public function removeChild(child:DisplayObject):DisplayObject
  445. {
  446. return removeChildAt(getChildIndex(child))
  447. }
  448. override public function addChildAt(child:DisplayObject,
  449. index:int):DisplayObject
  450. {
  451. var renderer:IRenderer = child as IRenderer
  452. if (renderer)
  453. {
  454. renderer.viewport = _viewport
  455. renderer.scene = IReadonlyMultiScaleScene(_scene)
  456. var imagePyramidRenderer:ImagePyramidRenderer = renderer as ImagePyramidRenderer
  457. if (imagePyramidRenderer)
  458. renderManager.addRenderer(imagePyramidRenderer)
  459. }
  460. return _scene.addChildAt(child, index)
  461. }
  462. override public function removeChildAt(index:int):DisplayObject
  463. {
  464. var child:DisplayObject = _scene.getChildAt(index)
  465. var renderer:IRenderer = child as IRenderer
  466. if (renderer)
  467. {
  468. var imagePyramidRenderer:ImagePyramidRenderer = renderer as ImagePyramidRenderer
  469. if (imagePyramidRenderer)
  470. renderManager.removeRenderer(imagePyramidRenderer)
  471. renderer.scene = null
  472. renderer.viewport = null
  473. }
  474. return _scene.removeChildAt(index)
  475. }
  476. override public function getChildAt(index:int):DisplayObject
  477. {
  478. return _scene.getChildAt(index)
  479. }
  480. override public function getChildByName(name:String):DisplayObject
  481. {
  482. return _scene.getChildByName(name)
  483. }
  484. override public function getChildIndex(child:DisplayObject):int
  485. {
  486. return _scene.getChildIndex(child)
  487. }
  488. override public function setChildIndex(child:DisplayObject,
  489. index:int):void
  490. {
  491. _scene.setChildIndex(child, index)
  492. }
  493. override public function swapChildren(child1:DisplayObject,
  494. child2:DisplayObject):void
  495. {
  496. _scene.swapChildren(child1, child2)
  497. }
  498. override public function swapChildrenAt(index1:int,
  499. index2:int):void
  500. {
  501. _scene.swapChildrenAt(index1, index2)
  502. }
  503. //--------------------------------------------------------------------------
  504. //
  505. // Methods: Children
  506. //
  507. //--------------------------------------------------------------------------
  508. /**
  509. * @private
  510. */
  511. private function createScene():void
  512. {
  513. _scene = new MultiScaleScene(DEFAULT_SCENE_WIDTH,
  514. DEFAULT_SCENE_HEIGHT,
  515. DEFAULT_SCENE_BACKGROUND_COLOR,
  516. DEFAULT_SCENE_BACKGROUND_ALPHA)
  517. super.addChild(_scene)
  518. dispatchEvent(new Event("sceneChanged"))
  519. }
  520. /**
  521. * @private
  522. */
  523. private function createMouseCatcher():void
  524. {
  525. mouseCatcher = new Sprite()
  526. var g:Graphics = mouseCatcher.graphics
  527. g.beginFill(0x000000, 0)
  528. g.drawRect(0, 0, 100, 100)
  529. g.endFill()
  530. mouseCatcher.mouseEnabled = false
  531. super.addChild(mouseCatcher)
  532. }
  533. /**
  534. * @private
  535. */
  536. private function createContentMask():void
  537. {
  538. contentMask = new Shape()
  539. var g:Graphics = contentMask.graphics
  540. g.beginFill(0xFF0000, 0)
  541. g.drawRect(0, 0, 100, 100)
  542. g.endFill()
  543. super.addChild(contentMask)
  544. mask = contentMask
  545. }
  546. private function createNormalizedViewport(scene:IReadonlyMultiScaleScene):void
  547. {
  548. _viewport = new NormalizedViewport(DEFAULT_VIEWPORT_WIDTH,
  549. DEFAULT_VIEWPORT_HEIGHT,
  550. scene)
  551. _viewport.addEventListener(ViewportEvent.TRANSFORM_START,
  552. viewport_transformStartHandler,
  553. false, 0, true)
  554. _viewport.addEventListener(ViewportEvent.TRANSFORM_UPDATE,
  555. viewport_transformUpdateHandler,
  556. false, 0, true)
  557. _viewport.addEventListener(ViewportEvent.TRANSFORM_END,
  558. viewport_transformEndHandler,
  559. false, 0, true)
  560. dispatchEvent(new Event("viewportChanged"))
  561. }
  562. private function createLoader():void
  563. {
  564. _loader = new NetworkQueue()
  565. }
  566. private function createRenderManager():void
  567. {
  568. renderManager = new ImagePyramidRenderManager(this, scene, viewport, loader)
  569. }
  570. //--------------------------------------------------------------------------
  571. //
  572. // Event handlers: Viewport
  573. //
  574. //--------------------------------------------------------------------------
  575. private function viewport_transformStartHandler(event:ViewportEvent):void
  576. {
  577. // trace("ViewportEvent.TRANSFORM_START")
  578. invalidateDisplayList()
  579. }
  580. private function viewport_transformUpdateHandler(event:ViewportEvent):void
  581. {
  582. // trace("ViewportEvent.TRANSFORM_UPDATE")
  583. // TODO: Test…
  584. invalidateDisplayList()
  585. }
  586. private function viewport_transformEndHandler(event:ViewportEvent):void
  587. {
  588. // trace("ViewportEvent.TRANSFORM_END")
  589. invalidateDisplayList()
  590. }
  591. //--------------------------------------------------------------------------
  592. //
  593. // Methods: Controllers
  594. //
  595. //--------------------------------------------------------------------------
  596. /**
  597. * @private
  598. */
  599. private function addController(controller:IViewportController):Boolean
  600. {
  601. if (_controllers.indexOf(controller) != -1)
  602. return false
  603. _controllers.push(controller)
  604. controller.viewport = _viewport
  605. controller.view = this
  606. return true
  607. }
  608. /**
  609. * @private
  610. */
  611. private function removeController(controller:IViewportController):Boolean
  612. {
  613. if (_controllers.indexOf(controller) == -1)
  614. return false
  615. _controllers.splice(_controllers.indexOf(controller), 1)
  616. controller.viewport = null
  617. controller.view = null
  618. return true
  619. }
  620. //--------------------------------------------------------------------------
  621. //
  622. // Properties: IMultiScaleContainer
  623. //
  624. //--------------------------------------------------------------------------
  625. //----------------------------------
  626. // zoom
  627. //----------------------------------
  628. private var _zoom:Number
  629. private var zoomChanged:Boolean = false
  630. ;[Bindable(event="transformUpdate")]
  631. // FIXME
  632. /**
  633. * @copy org.openzoom.flash.viewport.IViewport#zoom
  634. */
  635. public function get zoom():Number
  636. {
  637. return _zoom
  638. }
  639. public function set zoom(value:Number):void
  640. {
  641. if (_zoom != value)
  642. {
  643. _zoom = value
  644. zoomChanged = true
  645. invalidateProperties()
  646. }
  647. }
  648. //----------------------------------
  649. // scale
  650. //----------------------------------
  651. private var _scale:Number
  652. private var scaleChanged:Boolean = false
  653. ;[Bindable(event="transformUpdate")]
  654. // FIXME
  655. /**
  656. * @copy org.openzoom.flash.viewport.IViewport#scale
  657. */
  658. public function get scale():Number
  659. {
  660. return _scale
  661. }
  662. public function set scale(value:Number):void
  663. {
  664. if (_scale != value)
  665. {
  666. _scale = value
  667. scaleChanged = true
  668. invalidateProperties()
  669. }
  670. }
  671. //----------------------------------
  672. // viewportX
  673. //----------------------------------
  674. private var _viewportX:Number
  675. private var viewportXChanged:Boolean = false
  676. ;[Bindable(event="transformUpdate")]
  677. /**
  678. * @copy org.openzoom.flash.viewport.IViewport#x
  679. */
  680. public function get viewportX():Number
  681. {
  682. return _viewportX
  683. }
  684. public function set viewportX(value:Number):void
  685. {
  686. if (_viewportX != value)
  687. {
  688. _viewportX = value
  689. viewportXChanged = true
  690. invalidateProperties()
  691. }
  692. }
  693. //----------------------------------
  694. // viewportY
  695. //----------------------------------
  696. private var _viewportY:Number
  697. private var viewportYChanged:Boolean = false
  698. ;[Bindable(event="transformUpdate")]
  699. /**
  700. * @copy org.openzoom.flash.viewport.IViewport#y
  701. */
  702. public function get viewportY():Number
  703. {
  704. return _viewportY
  705. }
  706. public function set viewportY(value:Number):void
  707. {
  708. if (_viewportY != value)
  709. {
  710. _viewportY = value
  711. viewportYChanged = true
  712. invalidateProperties()
  713. }
  714. }
  715. //----------------------------------
  716. // viewportWidth
  717. //----------------------------------
  718. private var _viewportWidth:Number
  719. private var viewportWidthChanged:Boolean = false
  720. ;[Bindable(event="transformUpdate")]
  721. /**
  722. * @copy org.openzoom.flash.viewport.IViewport#width
  723. */
  724. public function get viewportWidth():Number
  725. {
  726. return _viewportWidth
  727. }
  728. public function set viewportWidth(value:Number):void
  729. {
  730. if (_viewportWidth != value)
  731. {
  732. _viewportWidth = value
  733. viewportWidthChanged = true
  734. invalidateProperties()
  735. }
  736. }
  737. //----------------------------------
  738. // viewportHeight
  739. //----------------------------------
  740. private var _viewportHeight:Number
  741. private var viewportHeightChanged:Boolean = false
  742. ;[Bindable(event="transformUpdate")]
  743. /**
  744. * @copy org.openzoom.flash.viewport.IViewport#height
  745. */
  746. public function get viewportHeight():Number
  747. {
  748. return _viewportHeight
  749. }
  750. public function set viewportHeight(value:Number):void
  751. {
  752. if (_viewportHeight != value)
  753. {
  754. _viewportHeight = value
  755. viewportHeightChanged = true
  756. invalidateProperties()
  757. }
  758. }
  759. //--------------------------------------------------------------------------
  760. //
  761. // Methods: IMultiScaleImage
  762. //
  763. //--------------------------------------------------------------------------
  764. /**
  765. * @copy org.openzoom.flash.viewport.IViewport#zoomTo()
  766. */
  767. public function zoomTo(zoom:Number,
  768. transformX:Number=0.5,
  769. transformY:Number=0.5,
  770. immediately:Boolean=false):void
  771. {
  772. viewport.zoomTo(zoom, transformX, transformY, immediately)
  773. }
  774. /**
  775. * @copy org.openzoom.flash.viewport.IViewport#zoomBy()
  776. */
  777. public function zoomBy(factor:Number,
  778. transformX:Number=0.5,
  779. transformY:Number=0.5,
  780. immediately:Boolean=false):void
  781. {
  782. viewport.zoomBy(factor, transformX, transformY, immediately)
  783. }
  784. /**
  785. * @copy org.openzoom.flash.viewport.IViewport#panTo()
  786. */
  787. public function panTo(x:Number, y:Number,
  788. immediately:Boolean=false):void
  789. {
  790. viewport.panTo(x, y, immediately)
  791. }
  792. /**
  793. * @copy org.openzoom.flash.viewport.IViewport#panBy()
  794. */
  795. public function panBy(deltaX:Number,
  796. deltaY:Number,
  797. immediately:Boolean=false):void
  798. {
  799. viewport.panBy(deltaX, deltaY, immediately)
  800. }
  801. /**
  802. * @copy org.openzoom.flash.viewport.IViewport#fitToBounds()
  803. */
  804. public function fitToBounds(bounds:Rectangle,
  805. scale:Number=1.0,
  806. immediately:Boolean=false):void
  807. {
  808. viewport.fitToBounds(bounds, scale, immediately)
  809. }
  810. /**
  811. * @copy org.openzoom.flash.viewport.IViewport#showAll()
  812. */
  813. public function showAll(immediately:Boolean=false):void
  814. {
  815. viewport.showAll(immediately)
  816. }
  817. /**
  818. * @copy org.openzoom.flash.viewport.IViewport#localToScene()
  819. */
  820. public function localToScene(point:Point):Point
  821. {
  822. return viewport.localToScene(point)
  823. }
  824. /**
  825. * @copy org.openzoom.flash.viewport.IViewport#sceneToLocal()
  826. */
  827. public function sceneToLocal(point:Point):Point
  828. {
  829. return viewport.sceneToLocal(point)
  830. }
  831. }
  832. }