Changeset 67
- Timestamp:
- 01/22/07 22:41:36 (2 years ago)
- Files:
-
- branches/darren tile painting (deleted)
- trunk/as2/lib/com/modestmaps/core/Coordinate.as (modified) (2 diffs)
- trunk/as2/lib/com/modestmaps/core/mapproviders/AbstractMapProvider.as (modified) (4 diffs)
- trunk/as2/lib/com/modestmaps/core/mapproviders/AbstractMicrosoftMapProvider.as (modified) (5 diffs)
- trunk/as2/lib/com/modestmaps/core/mapproviders/IMapProvider.as (modified) (1 diff)
- trunk/as2/lib/com/modestmaps/core/mapproviders/MapProviderFactory.as (modified) (1 diff)
- trunk/as2/lib/com/modestmaps/core/mapproviders/MicrosoftAerialMapProvider.as (modified) (3 diffs)
- trunk/as2/lib/com/modestmaps/core/mapproviders/MicrosoftDelayedAerialMapProvider.as (modified) (3 diffs)
- trunk/as2/lib/com/modestmaps/core/mapproviders/MicrosoftHybridMapProvider.as (modified) (3 diffs)
- trunk/as2/lib/com/modestmaps/core/mapproviders/MicrosoftRoadMapProvider.as (modified) (3 diffs)
- trunk/as2/lib/com/modestmaps/core/mapproviders/VanillaMapProvider.as (modified) (1 diff)
- trunk/as2/lib/com/modestmaps/core/Tile.as (modified) (15 diffs)
- trunk/as2/lib/com/modestmaps/core/TileGrid.as (modified) (21 diffs)
- trunk/as2/lib/com/modestmaps/events (copied) (copied from branches/darren tile painting/as2/lib/com/modestmaps/events)
- trunk/as2/lib/com/modestmaps/geo (copied) (copied from branches/darren tile painting/as2/lib/com/modestmaps/geo)
- trunk/as2/lib/com/modestmaps/io/IRequest.as (copied) (copied from branches/darren tile painting/as2/lib/com/modestmaps/io/IRequest.as)
- trunk/as2/lib/com/modestmaps/io/LoadMovieThrottledRequest.as (copied) (copied from branches/darren tile painting/as2/lib/com/modestmaps/io/LoadMovieThrottledRequest.as)
- trunk/as2/lib/com/modestmaps/io/RequestThrottler.as (modified) (6 diffs)
- trunk/as2/lib/com/modestmaps/io/ThrottledRequest.as (copied) (copied from branches/darren tile painting/as2/lib/com/modestmaps/io/ThrottledRequest.as)
- trunk/as2/lib/mx/events (copied) (copied from branches/darren tile painting/as2/lib/mx/events)
- trunk/as2/lib/SampleClient.as (modified) (3 diffs)
- trunk/as2/lib/SampleFlashLiteClient.as (modified) (5 diffs)
- trunk/as2/SampleClient.html (copied) (copied from branches/darren tile painting/as2/SampleClient.html)
- trunk/as2/swfobject.js (copied) (copied from branches/darren tile painting/as2/swfobject.js)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/as2/lib/com/modestmaps/core/Coordinate.as
r42 r67 15 15 { 16 16 return '(' + row + ',' + column + ' @' + zoom + ')'; 17 } 18 19 public function copy():Coordinate 20 { 21 return new Coordinate(row, column, zoom); 17 22 } 18 23 … … 65 70 return new Coordinate(row, column - (distance ? distance : 1), zoom); 66 71 } 72 73 /* 74 * Returns true if the the two coordinates refer to the same Tile location. 75 */ 76 public function equalTo( coord : Coordinate ) : Boolean 77 { 78 return coord.row == this.row && coord.column == this.column && coord.zoom == this.zoom; 79 } 67 80 } trunk/as2/lib/com/modestmaps/core/mapproviders/AbstractMapProvider.as
r44 r67 1 import mx.events.EventDispatcher; 2 1 3 import com.modestmaps.core.mapproviders.IMapProvider; 2 4 import com.modestmaps.io.RequestThrottler; 3 5 import com.modestmaps.core.Coordinate; 6 import com.modestmaps.events.IDispatchable; 7 import com.modestmaps.geo.IProjection; 8 import com.modestmaps.geo.LinearProjection; 9 import com.modestmaps.geo.Transformation; 10 import com.modestmaps.geo.Location; 4 11 5 12 /** … … 7 14 */ 8 15 class com.modestmaps.core.mapproviders.AbstractMapProvider 16 implements IDispatchable 9 17 { 18 // Event Types 19 public static var EVENT_PAINT_COMPLETE : String = "onPaintComplete"; 20 10 21 private var __requestThrottler : RequestThrottler; 22 private var __projection:IProjection; 11 23 24 // tracks if we're set up to broadcast events 25 private static var _dispatcherInited : Boolean = false; 26 27 /* 28 * Constructor. 29 */ 12 30 private function AbstractMapProvider() 13 31 { 14 __requestThrottler = RequestThrottler.getInstance(); 32 // only set up broadcasting once, in the prototype 33 if ( !_dispatcherInited ) 34 { 35 EventDispatcher.initialize( this.__proto__ ); 36 _dispatcherInited = true; 37 } 38 39 __requestThrottler = RequestThrottler.getInstance(); 40 41 var t:Transformation = new Transformation(1, 0, 0, 0, 1, 0); 42 __projection = new LinearProjection(Coordinate.MAX_ZOOM, t); 15 43 } 16 44 … … 22 50 public function createLabel( clip : MovieClip, label : String ) : Void 23 51 { 52 clip["labelTF"].removeTextField(); 53 24 54 clip.createTextField('labelTF', 1, 0, 0, 1, 1); 25 55 var tf : TextField = clip["labelTF"]; … … 29 59 tf.text = label; 30 60 } 61 62 // Private Methods 63 64 private function raisePaintComplete( clip : MovieClip, coord : Coordinate ) : Void 65 { 66 var eventObj : Object = 67 { 68 target : this, 69 type : EVENT_PAINT_COMPLETE, 70 clip : clip, 71 coord : coord 72 }; 73 dispatchEvent( eventObj ); 74 } 75 76 // IDispatchable 77 public function addEventListener( type : String, handler ) : Void 78 { 79 super.addEventListener( type, handler ); 80 } 81 82 public function removeEventListener( type : String, handler ) : Void 83 { 84 super.removeEventListener( type, handler ); 85 } 86 87 public function dispatchEvent( eventObj : Object ) : Void 88 { 89 super.dispatchEvent( eventObj ); 90 } 91 92 /* 93 * Return projected and transformed coordinate for a location. 94 */ 95 public function locationCoordinate(location:Location):Coordinate 96 { 97 return __projection.locationCoordinate(location); 98 } 99 100 /* 101 * Return untransformed and unprojected location for a coordinate. 102 */ 103 public function coordinateLocation(coordinate:Coordinate):Location 104 { 105 return __projection.coordinateLocation(coordinate); 106 } 31 107 } trunk/as2/lib/com/modestmaps/core/mapproviders/AbstractMicrosoftMapProvider.as
r44 r67 2 2 import com.modestmaps.core.Coordinate; 3 3 import com.modestmaps.util.BinaryUtil; 4 import com.modestmaps.io.LoadMovieThrottledRequest; 5 import mx.utils.Delegate; 6 import com.modestmaps.geo.MercatorProjection; 7 import com.modestmaps.geo.Transformation; 4 8 5 9 /** … … 10 14 { 11 15 public static var BASE_URL : String; 16 public static var ASSET_EXTENSION : String; 12 17 13 18 function AbstractMicrosoftMapProvider() 14 19 { 15 20 super(); 21 22 // see: http://track.stamen.com/modestmap/wiki/TileCoordinateComparisons#TileGeolocations 23 var t:Transformation = new Transformation(1.068070779e7, 0, 3.355443185e7, 24 0, -1.068070890e7, 3.355443057e7); 25 26 __projection = new MercatorProjection(26, t); 16 27 } 17 28 … … 20 31 super.paint( clip, coord ); 21 32 22 __requestThrottler.enqueue( clip.image, getTileUrl( coord ) ); 33 var request : LoadMovieThrottledRequest = new LoadMovieThrottledRequest( clip.image, getTileUrl( coord ) ); 34 request.addEventListener( LoadMovieThrottledRequest.EVENT_REQUEST_ERROR, Delegate.create( this, this.onRequestError )); 35 request.addEventListener( LoadMovieThrottledRequest.EVENT_RESPONSE_COMPLETE, Delegate.create( this, this.onResponseComplete )); 36 request.addEventListener( LoadMovieThrottledRequest.EVENT_RESPONSE_ERROR, Delegate.create( this, this.onResponseError )); 37 request.send(); 23 38 24 39 createLabel( clip, coord.toString() ); … … 26 41 27 42 /* 28 * Abstract method, implemented by concrete subclass. 43 * Returns the value of BASE_URL for the class. 44 */ 45 public function get baseUrl() : String 46 { 47 throw new Error( "Abstract method not implemented by subclass." ); 48 return null; 49 } 50 51 /* 52 * Returns the value of ASSET_EXTENSION for the class. 53 */ 54 public function get assetExtension() : String 55 { 56 throw new Error( "Abstract method not implemented by subclass." ); 57 return null; 58 } 59 60 /* 61 * Returns the url needed to get the tile image. 29 62 */ 30 63 private function getTileUrl( coord : Coordinate ) : String 31 64 { 65 throw new Error( "Abstract method not implemented by subclass." ); 32 66 return null; 33 67 } … … 51 85 return zoomString; 52 86 } 87 88 /* 89 * Given a URL, returns the coordinates that the URL refers to. 90 */ 91 private function getCoordinateFromURL( url : String ) : Coordinate 92 { 93 var row, col, zoom : Number; 94 95 // first locate the meaty bits (i.e. the zoomString). 96 var zoomString : String = url.substring( baseUrl.length ); 97 zoomString = zoomString.substring( 0, zoomString.indexOf( assetExtension ) ); 98 99 // now work backwards to determine row and col 100 zoom = zoomString.length; 101 102 var rowStr : String = ""; 103 var colStr : String = ""; 104 var tempStr : String = ""; 105 106 for ( var i : Number = 0; i < zoom; i++ ) 107 { 108 tempStr = BinaryUtil.convertToBinary( parseInt( zoomString.charAt( i ) ) ); 109 colStr += tempStr.charAt( tempStr.length-1 ); 110 rowStr += tempStr.charAt( tempStr.length-2 ); 111 } 112 113 row = BinaryUtil.convertToDecimal( rowStr ); 114 col = BinaryUtil.convertToDecimal( colStr ); 115 116 var coord : Coordinate = new Coordinate( row, col, zoom ); 117 return coord; 118 } 119 120 // Event Handlers 121 122 private function onRequestError( eventObj : Object ) : Void 123 { 124 } 125 126 private function onResponseComplete( eventObj : Object ) : Void 127 { 128 var clip : MovieClip = MovieClip( eventObj.clip ); 129 var url : String = String( eventObj.url ); 130 131 raisePaintComplete( clip, getCoordinateFromURL( url ) ); 132 } 133 134 private function onResponseError( eventObj : Object ) : Void 135 { 136 } 53 137 } trunk/as2/lib/com/modestmaps/core/mapproviders/IMapProvider.as
r44 r67 3 3 */ 4 4 import com.modestmaps.core.Coordinate; 5 import com.modestmaps.geo.Location; 5 6 6 7 interface com.modestmaps.core.mapproviders.IMapProvider 7 8 { 8 9 public function paint( clip : MovieClip, coord : Coordinate ) : Void; 10 11 /* 12 * Return projected and transformed coordinate for a location. 13 */ 14 public function locationCoordinate(location:Location):Coordinate; 15 16 /* 17 * Return untransformed and unprojected location for a coordinate. 18 */ 19 public function coordinateLocation(coordinate:Coordinate):Location; 9 20 } trunk/as2/lib/com/modestmaps/core/mapproviders/MapProviderFactory.as
r43 r67 54 54 55 55 case MapProviders.MICROSOFT_HYBRID : 56 return new Microsoft AerialMapProvider();56 return new MicrosoftHybridMapProvider(); 57 57 58 58 case MapProviders.MICROSOFT_DELAYED : trunk/as2/lib/com/modestmaps/core/mapproviders/MicrosoftAerialMapProvider.as
r44 r67 3 3 import com.modestmaps.core.Coordinate; 4 4 import com.modestmaps.util.BinaryUtil; 5 import com.modestmaps.events.IDispatchable; 5 6 6 7 /** … … 10 11 class com.modestmaps.core.mapproviders.MicrosoftAerialMapProvider 11 12 extends AbstractMicrosoftMapProvider 12 implements IMapProvider 13 implements IMapProvider, IDispatchable 13 14 { 14 15 private static var BASE_URL : String = "http://a0.ortho.tiles.virtualearth.net/tiles/a"; 16 private static var ASSET_EXTENSION : String = ".jpeg"; 15 17 16 18 public function toString() : String … … 19 21 } 20 22 23 public function get baseUrl() : String 24 { 25 return BASE_URL; 26 } 27 28 public function get assetExtension() : String 29 { 30 return ASSET_EXTENSION; 31 } 32 21 33 private function getTileUrl( coord : Coordinate ) : String 22 34 { 23 var url : String = BASE_URL + getZoomString( coord ) + ".jpeg?g=45";35 var url : String = BASE_URL + getZoomString( coord ) + ASSET_EXTENSION + "?g=45"; 24 36 25 37 //trace (this + ": Mapped " + coord.toString() + " to URL: " + url); trunk/as2/lib/com/modestmaps/core/mapproviders/MicrosoftDelayedAerialMapProvider.as
r44 r67 3 3 import com.modestmaps.core.Coordinate; 4 4 import com.modestmaps.util.BinaryUtil; 5 import com.modestmaps.events.IDispatchable; 5 6 6 7 /** … … 10 11 class com.modestmaps.core.mapproviders.MicrosoftDelayedAerialMapProvider 11 12 extends AbstractMicrosoftMapProvider 12 implements IMapProvider 13 implements IMapProvider, IDispatchable 13 14 { 14 15 private static var BASE_URL : String = "http://modestmap.com/proxy/index.php/a"; 16 private static var ASSET_EXTENSION : String = ".jpeg"; 15 17 16 18 public function toString() : String … … 19 21 } 20 22 23 public function get baseUrl() : String 24 { 25 return BASE_URL; 26 } 27 28 public function get assetExtension() : String 29 { 30 return ASSET_EXTENSION; 31 } 32 21 33 private function getTileUrl( coord : Coordinate ) : String 22 34 { 23 var url : String = BASE_URL + getZoomString( coord ) + ".jpeg?g=45";35 var url : String = BASE_URL + getZoomString( coord ) + ASSET_EXTENSION + "?g=45"; 24 36 25 37 //trace (this + ": Mapped " + tile.toString() + " to URL: " + url); trunk/as2/lib/com/modestmaps/core/mapproviders/MicrosoftHybridMapProvider.as
r44 r67 3 3 import com.modestmaps.core.Coordinate; 4 4 import com.modestmaps.util.BinaryUtil; 5 import com.modestmaps.events.IDispatchable; 5 6 6 7 /** … … 10 11 class com.modestmaps.core.mapproviders.MicrosoftHybridMapProvider 11 12 extends AbstractMicrosoftMapProvider 12 implements IMapProvider 13 implements IMapProvider, IDispatchable 13 14 { 14 15 private static var BASE_URL : String = "http://h1.ortho.tiles.virtualearth.net/tiles/h"; 16 private static var ASSET_EXTENSION : String = ".jpeg"; 15 17 16 18 public function toString() : String … … 19 21 } 20 22 23 public function get baseUrl() : String 24 { 25 return BASE_URL; 26 } 27 28 public function get assetExtension() : String 29 { 30 return ASSET_EXTENSION; 31 } 32 21 33 private function getTileUrl( coord : Coordinate ) : String 22 34 { 23 var url : String = BASE_URL + getZoomString( coord ) + ".jpeg?g=45"; 24 25 //trace (this + ": Mapped " + tile.toString() + " to URL: " + url); 26 35 var url : String = BASE_URL + getZoomString( coord ) + ASSET_EXTENSION + "?g=45"; 27 36 return url; 28 37 } trunk/as2/lib/com/modestmaps/core/mapproviders/MicrosoftRoadMapProvider.as
r44 r67 2 2 import com.modestmaps.core.mapproviders.AbstractMicrosoftMapProvider; 3 3 import com.modestmaps.core.Coordinate; 4 import com.modestmaps.events.IDispatchable; 4 5 5 6 … … 10 11 class com.modestmaps.core.mapproviders.MicrosoftRoadMapProvider 11 12 extends AbstractMicrosoftMapProvider 12 implements IMapProvider 13 implements IMapProvider, IDispatchable 13 14 { 14 15 private static var BASE_URL : String = "http://r3.ortho.tiles.virtualearth.net/tiles/r"; 16 private static var ASSET_EXTENSION : String = ".png"; 15 17 16 18 public function toString() : String … … 19 21 } 20 22 23 public function get baseUrl() : String 24 { 25 return BASE_URL; 26 } 27 28 public function get assetExtension() : String 29 { 30 return ASSET_EXTENSION; 31 } 32 21 33 private function getTileUrl( coord : Coordinate ) : String 22 34 { 23 var url : String = BASE_URL + getZoomString( coord ) + ".png?g=45";35 var url : String = BASE_URL + getZoomString( coord ) + ASSET_EXTENSION + "?g=45"; 24 36 25 37 //trace (this + ": Mapped " + tile.toString() + " to URL: " + url); trunk/as2/lib/com/modestmaps/core/mapproviders/VanillaMapProvider.as
r44 r67 6 6 import com.modestmaps.core.mapproviders.AbstractMapProvider; 7 7 import com.modestmaps.core.Coordinate; 8 import com.modestmaps.events.IDispatchable; 8 9 9 10 class com.modestmaps.core.mapproviders.VanillaMapProvider 10 11 extends AbstractMapProvider 11 implements IMapProvider 12 implements IMapProvider, IDispatchable 12 13 { 13 14 public function paintTile( clip : MovieClip, coord : Coordinate ) : Void trunk/as2/lib/com/modestmaps/core/Tile.as
r44 r67 5 5 import com.modestmaps.core.TileGrid; 6 6 import com.modestmaps.core.mapproviders.IMapProvider; 7 import com.modestmaps.core.mapproviders.AbstractMapProvider; 8 import mx.utils.Delegate; 9 import com.modestmaps.events.IDispatchable; 7 10 8 11 class com.modestmaps.core.Tile … … 11 14 public var grid:TileGrid; 12 15 13 p ublic var coord:Coordinate;16 private var __coord : Coordinate; 14 17 15 /*16 public var row:Number = 0;17 public var column:Number = 0;18 public var zoom:Number = 0;19 */20 21 18 public var width:Number; 22 19 public var height:Number; … … 25 22 public var origin:Boolean; 26 23 27 public var displayClip : MovieClip; 24 // Keeps track of all clips awaiting painting. 25 private var __displayClips : Array; 26 27 private var __paintCompleteDelegate : Function; 28 28 29 29 public static var symbolName:String = '__Packages.com.modestmaps.core.Tile'; … … 34 34 { 35 35 super(); 36 37 __displayClips = new Array(); 38 39 __paintCompleteDelegate = Delegate.create( this, this.onPaintComplete ); 36 40 } 37 41 42 public function get coord() : Coordinate 43 { 44 return __coord; 45 } 46 public function set coord( coord : Coordinate ) : Void 47 { 48 __coord = coord; 49 redraw(); 50 } 51 38 52 public function center():Point 39 53 { … … 44 58 { 45 59 coord = new Coordinate(Math.floor(coord.row / 2), Math.floor(coord.column / 2), coord.zoom + 1); 46 redraw();47 60 } 48 61 … … 50 63 { 51 64 coord = new Coordinate(coord.row * 2, coord.column * 2, coord.zoom - 1); 52 redraw();53 65 } 54 66 … … 56 68 { 57 69 coord = new Coordinate(coord.row * 2, coord.column * 2 + 1, coord.zoom - 1); 58 redraw();59 70 } 60 71 … … 62 73 { 63 74 coord = new Coordinate(coord.row * 2 + 1, coord.column * 2, coord.zoom - 1); 64 redraw();65 75 } 66 76 … … 68 78 { 69 79 coord = new Coordinate(coord.row * 2 + 1, coord.column * 2 + 1, coord.zoom - 1); 70 redraw();71 80 } 72 81 … … 74 83 { 75 84 coord = coord.up(distance); 76 redraw();77 85 } 78 86 … … 80 88 { 81 89 coord = coord.right(distance); 82 redraw();83 90 } 84 91 … … 86 93 { 87 94 coord = coord.down(distance); 88 redraw();89 95 } 90 96 … … 92 98 { 93 99 coord = coord.left(distance); 94 redraw();95 100 } 96 101 … … 102 107 public function redraw():Void 103 108 { 109 _level0.tile.log("redraw: " + coord.toString()); 110 111 IDispatchable( grid.mapProvider ).addEventListener( AbstractMapProvider.EVENT_PAINT_COMPLETE, __paintCompleteDelegate ); 104 112 paint( grid.mapProvider ); 105 113 … … 111 119 // set up the proper clip to paint here 112 120 113 var clip : MovieClip = this.createEmptyMovieClip( "display", this.getNextHighestDepth() ); 121 var clipId : Number = this.getNextHighestDepth(); 122 var clip : MovieClip = this.createEmptyMovieClip( "display" + clipId, clipId ); 123 124 // hide all other displayClips to avoid weird "repaint" effect 125 var count : Number = __displayClips.length; 126 while ( count-- ) 127 { 128 __displayClips[count].clip._visible = false; 129 } 130 131 __displayClips.push ( { clip : clip, coord : coord } ); 114 132 115 133 mapProvider.paint( clip, coord ); 116 134 } 117 135 136 // Event Handlers 137 138 private function onPaintComplete( eventObj : Object ) : Void 139 { 140 var coord : Coordinate = Coordinate( eventObj.coord ); 141 142 if ( this.coord.equalTo( coord ) ) 143 { 144 IDispatchable( grid.mapProvider ).removeEventListener( AbstractMapProvider.EVENT_PAINT_COMPLETE, __paintCompleteDelegate ); 145 146 // remove all other displayClips /below/ this clip 147 var dcCoord : Coordinate; 148 for ( var i : Number = 0; i < __displayClips.length; i++ ) 149 { 150 dcCoord = Coordinate( __displayClips[i].coord ); 151 if ( dcCoord.equalTo( this.coord ) ) 152 break; 153 else 154 { 155 __displayClips[i].clip.removeMovieClip(); 156 __displayClips.splice( i, 1 ); 157 i--; 158 } 159 } 160 } 161 } 118 162 } trunk/as2/lib/com/modestmaps/core/TileGrid.as
r44 r67 4 4 import com.modestmaps.core.Tile; 5 5 import com.modestmaps.core.mapproviders.IMapProvider; 6 import com.modestmaps.core.mapproviders.MapProviderFactory;7 import com.modestmaps.core.mapproviders.MapProviders;8 6 9 7 import mx.utils.Delegate; … … 38 36 39 37 // For testing purposes. 38 public var labelContainer:MovieClip; 40 39 public var label:TextField; 41 40 … … 49 48 50 49 // Who do we get our Map graphics from? 51 public var mapProviderType:Number; 52 public var mapProvider : IMapProvider; 50 public var mapProvider:IMapProvider; 53 51 54 52 public static var symbolName:String = '__Packages.com.modestmaps.core.TileGrid'; … … 58 56 public function TileGrid() 59 57 { 60 setMapProvider(mapProviderType); 58 this.createEmptyMovieClip( "labelContainer", getNextHighestDepth() ); 59 labelContainer.createTextField('label', 1, 10, 10, width-20, height-20); 60 label = labelContainer["label"]; 61 label.selectable = false; 62 label.textColor = 0xFF6600; 63 64 log('FUCK YEAH '+width+'x'+height); 61 65 62 66 buildWell(); … … 87 91 88 92 allocateTiles(); 89 redraw(); 90 91 createTextField('label', getNextHighestDepth(), 10, 10, width-20, height-20); 92 label.selectable = false; 93 94 log('FUCK YEAH '+width+'x'+height); 93 redraw(); 94 95 labelContainer.swapDepths( getNextHighestDepth() ); 95 96 } 96 97 … … 104 105 well.onRelease = Delegate.create(this, this.stopWellDrag); 105 106 well.onReleaseOutside = Delegate.create(this, this.stopWellDrag); 107 108 /* 109 // So the log is visible... 110 var c:Color = new Color(well); 111 var t:Object = c.getTransform(); 112 t.ra = 20; 113 t.rb = 204; 114 t.ga = 20; 115 t.gb = 204; 116 t.ba = 20; 117 t.bb = 204; 118 c.setTransform(t); 119 */ 106 120 } 107 121 … … 142 156 { 143 157 label.text += msg + '\n'; 158 label.scroll = label.maxscroll; 144 159 } 145 160 … … 147 162 { 148 163 label.text = ''; 149 }150 151 private function setMapProvider( mapProviderType : Number ) : Void152 {153 this.mapProviderType = mapProviderType;154 var mapProviderFactory : MapProviderFactory = MapProviderFactory.getInstance();155 mapProvider = MapProviderFactory.getInstance().getMapProvider( mapProviderType );156 164 } 157 165 … … 214 222 } 215 223 216 /*217 224 private function pointCoordinate(point:Point):Coordinate 218 225 { … … 223 230 // an arbitrary reference tile, zoomed to the maximum 224 231 tile = tiles[0]; 225 tileCoord = new Coordinate(tile.row, tile.column, tile.zoom);226 tileCoord .zoomTo(Coordinate.MAX_ZOOM);232 tileCoord = tile.coord.copy(); 233 tileCoord = tileCoord.zoomTo(Coordinate.MAX_ZOOM); 227 234 228 235 // distance in tile widths from reference tile to point 229 236 var xTiles:Number = (point.x - tile._x) / tileWidth; 230 237 var yTiles:Number = (point.y - tile._y) / tileHeight; 231 238 232 239 // distance in rows & columns at maximum zoom 233 var xDistance:Number = xTiles * Math.pow(2, (Coordinate.MAX_ZOOM - tile. zoom));234 var yDistance:Number = yTiles * Math.pow(2, (Coordinate.MAX_ZOOM - tile. zoom));240 var xDistance:Number = xTiles * Math.pow(2, (Coordinate.MAX_ZOOM - tile.coord.zoom)); 241 var yDistance:Number = yTiles * Math.pow(2, (Coordinate.MAX_ZOOM - tile.coord.zoom)); 235 242 236 243 // new point coordinate reflecting that distance … … 239 246 tileCoord.zoom); 240 247 241 return pointCoord; 242 } 243 */ 248 return pointCoord.zoomTo(tile.coord.zoom); 249 } 250 251 public function topLeftCoordinate():Coordinate 252 { 253 var point:Point = new Point(0, 0); 254 255 localToGlobal(point); 256 well.globalToLocal(point); 257 258 return pointCoordinate(point); 259 } 260 261 public function bottomRightCoordinate():Coordinate 262 { 263 var point:Point = new Point(width, height); 264 265 localToGlobal(point); 266 well.globalToLocal(point); 267 268 return pointCoordinate(point); 269 } 244 270 245 271 /* … … 263 289 max.y = well._y - max.y; 264 290 265 log('min/max for drag: '+min+', '+max+' ('+topLeftOutLimit+', '+bottomRightInLimit+')');291 //log('min/max for drag: '+min+', '+max+' ('+topLeftOutLimit+', '+bottomRightInLimit+')'); 266 292 267 293 // weird negative edge conditions, limit all movement on an axis … … 326 352 } 327 353 328 public function startZoomIn():Void354 public function zoomIn(amount:Number):Void 329 355 { 330 356 if(zoomLevel >= bottomRightInLimit.zoom && Math.round(well._xscale) >= 100) 331 357 return; 332 358 333 well._xscale *= Math.pow(2, .25);334 well._yscale *= Math.pow(2, .25);359 well._xscale *= Math.pow(2, amount); 360 well._yscale *= Math.pow(2, amount); 335 361 336 362 normalizeWell(); … … 341 367 } 342 368 343 public function startZoomOut():Void369 public function zoomOut(amount:Number):Void 344 370 { 345 371 if(zoomLevel <= topLeftOutLimit.zoom && Math.round(well._xscale) <= 100) 346 372 return; 347 373 348 well._xscale /= Math.pow(2, .25);349 well._yscale /= Math.pow(2, .25);374 well._xscale /= Math.pow(2, amount); 375 well._yscale /= Math.pow(2, amount); 350 376 351 377 normalizeWell(); … … 356 382 } 357 383 358 /* 359 * TODO: 360 * Size relative to stage is currently hard-coded, but shouldn't be. 361 */ 362 public function onResize():Void 363 { 364 width = Stage.width - 2 * _x; 365 height = Stage.height - 2 * _y; 384 public function resizeTo(bottomLeft:Point):Void 385 { 386 width = bottomLeft.x; 387 height = bottomLeft.y; 366 388 367 389 centerWell(false); … … 371 393 } 372 394 373 public function pan East( pixels : Number ) :Void374 { 375 well._x -= pixels;376 positionTiles();377 centerWell(true);395 public function panRight(pixels:Number):Void 396 { 397 well._x -= pixels; 398 positionTiles(); 399 centerWell(true); 378 400 } 379 401 380 public function pan West( pixels : Number ) :Void381 { 382 well._x += pixels;383 positionTiles();402 public function panLeft(pixels:Number):Void 403 { 404 well._x += pixels; 405 positionTiles(); 384 406 centerWell(true); 385 407 } 386 387 public function panNorth( pixels : Number ) : Void388 {389 well._y -= pixels;390 positionTiles();391 centerWell(true);392 }393 408 394 public function pan South( pixels : Number ) :Void395 { 396 well._y += pixels;397 positionTiles();409 public function panUp(pixels:Number):Void 410 { 411 well._y += pixels; 412 positionTiles(); 398 413 centerWell(true); 399 414 } 415 416 public function panDown(pixels:Number):Void 417 { 418 well._y -= pixels; 419 positionTiles(); 420 centerWell(true); 421 } 422 423 /** 424 * Find out whether a tile is at the grid's native zoom level. 425 */ 426 private function nativeZoom(tile:Tile):Boolean 427 { 428 return (tile.coord.zoom == zoomLevel); 429 } 400 430 401 431 /** … … 502 532 503 533 f
