From f9bbaed71769ad5a8527176ee0ff5c638523edd5 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 31 Aug 2016 11:34:16 +0200 Subject: [PATCH] Rename ol.DebugTile_ to ol.source.TileDebug.Tile_ --- src/ol/source/tiledebug.js | 134 ++++++++++++++++++------------------- 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/src/ol/source/tiledebug.js b/src/ol/source/tiledebug.js index 4d40bb02ff..0ef9e0439c 100644 --- a/src/ol/source/tiledebug.js +++ b/src/ol/source/tiledebug.js @@ -7,71 +7,6 @@ goog.require('ol.size'); goog.require('ol.source.Tile'); -/** - * @constructor - * @extends {ol.Tile} - * @param {ol.TileCoord} tileCoord Tile coordinate. - * @param {ol.Size} tileSize Tile size. - * @param {string} text Text. - * @private - */ -ol.DebugTile_ = function(tileCoord, tileSize, text) { - - ol.Tile.call(this, tileCoord, ol.Tile.State.LOADED); - - /** - * @private - * @type {ol.Size} - */ - this.tileSize_ = tileSize; - - /** - * @private - * @type {string} - */ - this.text_ = text; - - /** - * @private - * @type {Object.} - */ - this.canvasByContext_ = {}; - -}; -ol.inherits(ol.DebugTile_, ol.Tile); - - -/** - * Get the image element for this tile. - * @param {Object=} opt_context Optional context. Only used by the DOM - * renderer. - * @return {HTMLCanvasElement} Image. - */ -ol.DebugTile_.prototype.getImage = function(opt_context) { - var key = opt_context !== undefined ? ol.getUid(opt_context) : -1; - if (key in this.canvasByContext_) { - return this.canvasByContext_[key]; - } else { - - var tileSize = this.tileSize_; - var context = ol.dom.createCanvasContext2D(tileSize[0], tileSize[1]); - - context.strokeStyle = 'black'; - context.strokeRect(0.5, 0.5, tileSize[0] + 0.5, tileSize[1] + 0.5); - - context.fillStyle = 'black'; - context.textAlign = 'center'; - context.textBaseline = 'middle'; - context.font = '24px sans-serif'; - context.fillText(this.text_, tileSize[0] / 2, tileSize[1] / 2); - - this.canvasByContext_[key] = context.canvas; - return context.canvas; - - } -}; - - /** * @classdesc * A pseudo tile source, which does not fetch tiles from a server, but renders @@ -104,15 +39,80 @@ ol.inherits(ol.source.TileDebug, ol.source.Tile); ol.source.TileDebug.prototype.getTile = function(z, x, y) { var tileCoordKey = this.getKeyZXY(z, x, y); if (this.tileCache.containsKey(tileCoordKey)) { - return /** @type {!ol.DebugTile_} */ (this.tileCache.get(tileCoordKey)); + return /** @type {!ol.source.TileDebug.Tile_} */ (this.tileCache.get(tileCoordKey)); } else { var tileSize = ol.size.toSize(this.tileGrid.getTileSize(z)); var tileCoord = [z, x, y]; var textTileCoord = this.getTileCoordForTileUrlFunction(tileCoord); var text = !textTileCoord ? '' : this.getTileCoordForTileUrlFunction(textTileCoord).toString(); - var tile = new ol.DebugTile_(tileCoord, tileSize, text); + var tile = new ol.source.TileDebug.Tile_(tileCoord, tileSize, text); this.tileCache.set(tileCoordKey, tile); return tile; } }; + + +/** + * @constructor + * @extends {ol.Tile} + * @param {ol.TileCoord} tileCoord Tile coordinate. + * @param {ol.Size} tileSize Tile size. + * @param {string} text Text. + * @private + */ +ol.source.TileDebug.Tile_ = function(tileCoord, tileSize, text) { + + ol.Tile.call(this, tileCoord, ol.Tile.State.LOADED); + + /** + * @private + * @type {ol.Size} + */ + this.tileSize_ = tileSize; + + /** + * @private + * @type {string} + */ + this.text_ = text; + + /** + * @private + * @type {Object.} + */ + this.canvasByContext_ = {}; + +}; +ol.inherits(ol.source.TileDebug.Tile_, ol.Tile); + + +/** + * Get the image element for this tile. + * @param {Object=} opt_context Optional context. Only used by the DOM + * renderer. + * @return {HTMLCanvasElement} Image. + */ +ol.source.TileDebug.Tile_.prototype.getImage = function(opt_context) { + var key = opt_context !== undefined ? ol.getUid(opt_context) : -1; + if (key in this.canvasByContext_) { + return this.canvasByContext_[key]; + } else { + + var tileSize = this.tileSize_; + var context = ol.dom.createCanvasContext2D(tileSize[0], tileSize[1]); + + context.strokeStyle = 'black'; + context.strokeRect(0.5, 0.5, tileSize[0] + 0.5, tileSize[1] + 0.5); + + context.fillStyle = 'black'; + context.textAlign = 'center'; + context.textBaseline = 'middle'; + context.font = '24px sans-serif'; + context.fillText(this.text_, tileSize[0] / 2, tileSize[1] / 2); + + this.canvasByContext_[key] = context.canvas; + return context.canvas; + + } +};