home *** CD-ROM | disk | FTP | other *** search
- package qs.controls
- {
- import flash.geom.Rectangle;
- import mx.core.UIComponent;
- import qs.controls.fisheyeClasses.FisheyeAxis;
- import qs.controls.fisheyeClasses.FisheyeBase;
- import qs.controls.fisheyeClasses.FisheyeItem;
-
- public class FisheyeTile extends FisheyeBase
- {
- private var _vMouseItems:Array = [];
-
- private var _colLength:int;
-
- private var _vItems:Array = [];
-
- private var _direction:String = "vertical";
-
- private var _tileHeight:int;
-
- private var _hItems:Array = [];
-
- private var _pdata:Array = [];
-
- private var _rowLength:int = 4;
-
- protected var hAxis:FisheyeAxis = new FisheyeAxis();
-
- private var _hMouseItems:Array = [];
-
- private var _mouseData:Array = [];
-
- protected var vAxis:FisheyeAxis = new FisheyeAxis();
-
- private var _tileWidth:int;
-
- private var _mouseBounds:Rectangle = new Rectangle();
-
- public function FisheyeTile()
- {
- super();
- this.hAxis.direction = "horizontal";
- this.vAxis.direction = "vertical";
- }
-
- override protected function findItemForPosition(param1:Number, param2:Number) : Number
- {
- var _loc3_:Number = NaN;
- var _loc4_:Number = NaN;
- var _loc8_:FisheyeItem = null;
- var _loc9_:Number = NaN;
- var _loc10_:Number = NaN;
- var _loc5_:Number = Infinity;
- if(dataProvider.length == 0)
- {
- return NaN;
- }
- if(this._mouseBounds.contains(param1,param2) == false)
- {
- return NaN;
- }
- var _loc6_:int = 0;
- while(_loc6_ < this._hMouseItems.length)
- {
- _loc8_ = this._hMouseItems[_loc6_];
- _loc9_ = _loc8_.x + _loc8_.eomWidth * _loc8_.scale / 2;
- _loc10_ = param1 - _loc9_;
- if(Math.abs(_loc10_) >= Math.abs(_loc5_))
- {
- break;
- }
- _loc5_ = _loc10_;
- _loc3_ = _loc6_;
- _loc6_++;
- }
- if(isNaN(_loc3_))
- {
- return NaN;
- }
- _loc5_ = Infinity;
- var _loc7_:int = 0;
- while(_loc7_ < this._vMouseItems.length)
- {
- _loc8_ = this._vMouseItems[_loc7_];
- _loc9_ = _loc8_.y + _loc8_.eomHeight * _loc8_.scale / 2;
- _loc10_ = param2 - _loc9_;
- if(Math.abs(_loc10_) >= Math.abs(_loc5_))
- {
- break;
- }
- _loc5_ = _loc10_;
- _loc4_ = _loc7_;
- _loc7_++;
- }
- if(isNaN(_loc4_))
- {
- return NaN;
- }
- return _loc4_ * this._rowLength + _loc3_;
- }
-
- override protected function commitProperties() : void
- {
- var _loc2_:int = 0;
- var _loc3_:int = 0;
- var _loc1_:Boolean = this.itemsChanged;
- super.commitProperties();
- if(_loc1_)
- {
- this._hItems = [];
- this._vItems = [];
- this._hMouseItems = [];
- this._vMouseItems = [];
- this._colLength = Math.ceil(dataProvider.length / this._rowLength);
- _loc2_ = 0;
- while(_loc2_ < this._rowLength)
- {
- this._hItems[_loc2_] = new FisheyeItem();
- this._hMouseItems[_loc2_] = new FisheyeItem();
- _loc2_++;
- }
- _loc3_ = 0;
- while(_loc3_ < this._colLength)
- {
- this._vItems[_loc3_] = new FisheyeItem();
- this._vMouseItems[_loc3_] = new FisheyeItem();
- _loc3_++;
- }
- }
- }
-
- public function set rowLength(param1:int) : void
- {
- this._rowLength = param1;
- }
-
- override protected function measure() : void
- {
- var _loc1_:int = 0;
- var _loc3_:UIComponent = null;
- this._tileWidth = 0;
- this._tileHeight = 0;
- _loc1_ = 0;
- while(_loc1_ < renderers.length)
- {
- _loc3_ = renderers[_loc1_];
- this._tileWidth = Math.max(this._tileWidth,_loc3_.getExplicitOrMeasuredWidth());
- this._tileHeight = Math.max(this._tileHeight,_loc3_.getExplicitOrMeasuredHeight());
- _loc1_++;
- }
- this._tileWidth = Math.max(this._tileWidth,this._tileHeight);
- this._tileHeight = this._tileWidth;
- _loc1_ = 0;
- while(_loc1_ < this._rowLength)
- {
- this._hItems[_loc1_].eomWidth = this._hMouseItems[_loc1_].eomWidth = this._tileWidth;
- this._hItems[_loc1_].eomHeight = this._hMouseItems[_loc1_].eomHeight = this._tileHeight;
- _loc1_++;
- }
- var _loc2_:int = 0;
- while(_loc2_ < this._colLength)
- {
- this._vItems[_loc2_].eomWidth = this._vMouseItems[_loc2_].eomWidth = this._tileWidth;
- this._vItems[_loc2_].eomHeight = this._vMouseItems[_loc2_].eomHeight = this._tileHeight;
- _loc2_++;
- }
- animator.invalidateLayout();
- }
-
- public function get rowLength() : int
- {
- return this._rowLength;
- }
-
- override protected function updateDisplayList(param1:Number, param2:Number) : void
- {
- populateMajorAxisForDefault(this._hMouseItems,this.hAxis,param1);
- align(this._hMouseItems,this.hAxis);
- populateMajorAxisForDefault(this._vMouseItems,this.vAxis,param2);
- align(this._vMouseItems,this.vAxis);
- var _loc3_:FisheyeItem = this._hMouseItems[0];
- var _loc4_:FisheyeItem = this._hMouseItems[this._hMouseItems.length - 1];
- var _loc5_:FisheyeItem = this._vMouseItems[0];
- var _loc6_:FisheyeItem = this._vMouseItems[this._vMouseItems.length - 1];
- this._mouseBounds.left = _loc3_.x + _loc3_.eomWidth * _loc3_.scale / 2 - _loc3_.eomWidth / 2;
- this._mouseBounds.top = _loc5_.y + _loc5_.eomHeight * _loc5_.scale / 2 - _loc5_.eomHeight / 2;
- this._mouseBounds.right = _loc4_.x + _loc4_.eomWidth * _loc4_.scale / 2 + _loc4_.eomWidth / 2;
- this._mouseBounds.bottom = _loc6_.y + _loc6_.eomHeight * _loc6_.scale / 2 + _loc6_.eomHeight / 2;
- super.updateDisplayList(param1,param2);
- }
-
- override protected function generateLayout() : void
- {
- var _loc5_:int = 0;
- var _loc6_:Number = NaN;
- var _loc7_:FisheyeItem = null;
- var _loc8_:Number = NaN;
- var _loc9_:Number = NaN;
- var _loc10_:FisheyeItem = null;
- var _loc11_:Number = NaN;
- var _loc12_:int = 0;
- var _loc13_:Number = NaN;
- var _loc14_:int = 0;
- var _loc15_:UIComponent = null;
- var _loc16_:LayoutTarget = null;
- var _loc17_:Number = NaN;
- var _loc18_:Number = NaN;
- var _loc19_:Number = NaN;
- var _loc1_:int = int(dataProvider.length);
- var _loc2_:Number = isNaN(hilightedItemIndex) ? selectedItemIndex : hilightedItemIndex;
- if(isNaN(_loc2_))
- {
- populateMajorAxisForDefault(this._hItems,this.hAxis,unscaledWidth);
- align(this._hItems,this.hAxis);
- populateMajorAxisForDefault(this._vItems,this.vAxis,unscaledHeight);
- align(this._vItems,this.vAxis);
- }
- else
- {
- _loc6_ = _loc2_ % this._rowLength;
- _loc7_ = this._hMouseItems[_loc6_];
- _loc8_ = _loc7_.x + _loc7_.eomWidth * _loc7_.scale - this._tileWidth * maxScaleWithDefault / 2;
- if(_loc8_ < 0)
- {
- _loc8_ = 0;
- }
- if(_loc8_ + this._tileWidth * maxScaleWithDefault > unscaledWidth)
- {
- _loc8_ = unscaledWidth - this._tileWidth * maxScaleWithDefault;
- }
- populateMajorAxisFor(this._hItems.slice(_loc6_),0,unscaledWidth - _loc8_,this.hAxis);
- _loc5_ = _loc6_;
- while(_loc5_ < this._rowLength)
- {
- this._hItems[_loc5_].x += _loc8_;
- _loc5_++;
- }
- if(_loc6_ > 0)
- {
- populateMajorAxisFor(this._hItems.slice(0,_loc6_),_loc6_,_loc8_ - defaultSpacingWithDefault,this.hAxis);
- _loc7_ = this._hItems[_loc6_ - 1];
- _loc13_ = _loc8_ - (_loc7_.x + _loc7_.eomWidth * _loc7_.scale + defaultSpacingWithDefault);
- _loc12_ = 0;
- while(_loc12_ < _loc6_)
- {
- this._hItems[_loc12_].x += _loc13_;
- _loc12_++;
- }
- }
- _loc9_ = Math.floor(_loc2_ / this._rowLength);
- _loc10_ = this._vMouseItems[_loc9_];
- _loc11_ = _loc10_.y + _loc10_.eomHeight * _loc10_.scale - this._tileHeight * maxScaleWithDefault / 2;
- if(_loc11_ < 0)
- {
- _loc11_ = 0;
- }
- if(_loc11_ + this._tileHeight * maxScaleWithDefault > unscaledHeight)
- {
- _loc11_ = unscaledHeight - this._tileHeight * maxScaleWithDefault;
- }
- populateMajorAxisFor(this._vItems.slice(_loc9_),0,unscaledHeight - _loc11_,this.vAxis);
- _loc12_ = _loc9_;
- while(_loc12_ < this._colLength)
- {
- this._vItems[_loc12_].y += _loc11_;
- _loc12_++;
- }
- if(_loc9_ > 0)
- {
- populateMajorAxisFor(this._vItems.slice(0,_loc9_),_loc9_,_loc11_ - defaultSpacingWithDefault,this.vAxis);
- _loc10_ = this._vItems[_loc9_ - 1];
- _loc13_ = _loc11_ - (_loc10_.y + _loc10_.eomHeight * _loc10_.scale + defaultSpacingWithDefault);
- _loc14_ = 0;
- while(_loc14_ < _loc9_)
- {
- this._vItems[_loc14_].y += _loc13_;
- _loc14_++;
- }
- }
- }
- var _loc3_:String = getStyle("zoomMode");
- var _loc4_:* = _loc3_ != "resize";
- _loc5_ = 0;
- while(_loc5_ < _loc1_)
- {
- _loc15_ = renderers[_loc5_];
- _loc7_ = this._hItems[_loc5_ % this._rowLength];
- _loc10_ = this._vItems[Math.floor(_loc5_ / this._rowLength)];
- _loc16_ = animator.targetFor(_loc15_);
- if(_loc4_)
- {
- _loc17_ = _loc7_.eomWidth * _loc7_.scale / (_loc10_.eomHeight * _loc10_.scale);
- _loc18_ = _loc15_.getExplicitOrMeasuredWidth() / _loc15_.getExplicitOrMeasuredHeight();
- if(_loc18_ / _loc17_ > 1)
- {
- _loc19_ = _loc7_.eomWidth * _loc7_.scale / _loc15_.getExplicitOrMeasuredWidth();
- _loc16_.scaleX = _loc16_.scaleY = _loc19_;
- _loc16_.x = _loc7_.x;
- _loc16_.y = _loc10_.y + _loc10_.eomWidth * _loc10_.scale / 2 - _loc15_.getExplicitOrMeasuredHeight() * _loc19_ / 2;
- }
- else
- {
- _loc19_ = _loc10_.eomHeight * _loc10_.scale / _loc15_.getExplicitOrMeasuredHeight();
- if(isNaN(_loc19_))
- {
- _loc19_ = 0;
- }
- _loc16_.scaleX = _loc16_.scaleY = _loc19_;
- _loc16_.x = _loc7_.x + _loc7_.eomHeight * _loc7_.scale / 2 - _loc15_.getExplicitOrMeasuredWidth() * _loc19_ / 2;
- _loc16_.y = _loc10_.y;
- }
- _loc16_.unscaledWidth = _loc15_.getExplicitOrMeasuredWidth();
- _loc16_.unscaledHeight = _loc15_.getExplicitOrMeasuredHeight();
- }
- else
- {
- _loc16_.x = _loc7_.x;
- _loc16_.unscaledWidth = _loc7_.eomWidth * _loc7_.scale;
- _loc16_.y = _loc10_.y;
- _loc16_.unscaledHeight = _loc10_.eomHeight * _loc10_.scale;
- _loc16_.scaleX = _loc16_.scaleY = 1;
- }
- _loc5_++;
- }
- }
- }
- }
-
-