Rename Layer to Store and LayerRendereOptions to Layer

This commit is contained in:
Tom Payne
2012-07-10 17:36:20 +02:00
committed by Tom Payne
parent 5de1ac3dd6
commit 01cb568a50
5 changed files with 120 additions and 120 deletions

View File

@@ -5,13 +5,13 @@ goog.require('ol.Bounds');
goog.require('ol.Camera');
goog.require('ol.Extent');
goog.require('ol.Layer');
goog.require('ol.LayerRendererOptions');
goog.require('ol.Object');
goog.require('ol.Projection');
goog.require('ol.Store');
goog.require('ol.TileBounds');
goog.require('ol.TileCoord');
goog.require('ol.TileGrid');
goog.require('ol.TileLayer');
goog.require('ol.TileStore');
goog.require('ol.TileUrlFunction');
goog.require('ol.TileUrlFunctionType');
goog.require('ol.TransformFunction');

View File

@@ -1,18 +1,16 @@
goog.provide('ol.Layer');
goog.require('ol.Extent');
goog.require('ol.Object');
goog.require('ol.Projection');
goog.require('ol.Store');
/**
* @enum {string}
* @private
*/
ol.LayerProperty_ = {
ATTRIBUTION: 'attribution',
EXTENT: 'extent',
PROJECTION: 'projection'
ol.LayerRendererOptionsProperty_ = {
OPACITY: 'opacity',
VISIBLE: 'visible'
};
@@ -20,61 +18,62 @@ ol.LayerProperty_ = {
/**
* @constructor
* @extends {ol.Object}
* @param {ol.Store} store Store.
*/
ol.Layer = function() {
ol.Layer = function(store) {
goog.base(this);
this.setExtent(null);
this.setProjection(null);
/**
* @private
* @type {ol.Store}
*/
this.store_ = store;
this.setVisible(true);
this.setOpacity(1);
};
goog.inherits(ol.Layer, ol.Object);
/**
* @return {string|undefined} Attribution.
* @return {number} Opacity.
*/
ol.Layer.prototype.getAttribution = function() {
return /** @type {string} */ (this.get(ol.LayerProperty_.ATTRIBUTION));
ol.Layer.prototype.getOpacity = function() {
return /** @type {number} */ (
this.get(ol.LayerRendererOptionsProperty_.OPACITY));
};
/**
* @return {ol.Extent} Extent.
* @return {ol.Store} Store.
*/
ol.Layer.prototype.getExtent = function() {
return /** @type {ol.Extent} */ (this.get(ol.LayerProperty_.EXTENT));
ol.Layer.prototype.getStore = function() {
return this.store_;
};
/**
* @return {ol.Projection} Projection.
* @return {boolean} Visible.
*/
ol.Layer.prototype.getProjection = function() {
return /** @type {ol.Projection} */ (this.get(ol.LayerProperty_.PROJECTION));
ol.Layer.prototype.getVisible = function() {
return /** @type {boolean} */ (
this.get(ol.LayerRendererOptionsProperty_.VISIBLE));
};
/**
* @param {string|undefined} attribution Attribution.
* @param {number} opacity Opacity.
*/
ol.Layer.prototype.setAttribution = function(attribution) {
this.set(ol.LayerProperty_.ATTRIBUTION, attribution);
ol.Layer.prototype.setOpacity = function(opacity) {
this.set(ol.LayerRendererOptionsProperty_.OPACITY, opacity);
};
/**
* @param {ol.Extent} extent Extent.
* @param {boolean} visible Visible.
*/
ol.Layer.prototype.setExtent = function(extent) {
this.set(ol.LayerProperty_.EXTENT, extent);
};
/**
* @param {ol.Projection} projection Projetion.
*/
ol.Layer.prototype.setProjection = function(projection) {
this.set(ol.LayerProperty_.PROJECTION, projection);
ol.Layer.prototype.setVisible = function(visible) {
this.set(ol.LayerRendererOptionsProperty_.VISIBLE, visible);
};

View File

@@ -1,79 +0,0 @@
goog.provide('ol.LayerRendererOptions');
goog.require('ol.Layer');
goog.require('ol.Object');
/**
* @enum {string}
* @private
*/
ol.LayerRendererOptionsProperty_ = {
OPACITY: 'opacity',
VISIBLE: 'visible'
};
/**
* @constructor
* @extends {ol.Object}
* @param {ol.Layer} layer Layer.
*/
ol.LayerRendererOptions = function(layer) {
goog.base(this);
/**
* @private
* @type {ol.Layer}
*/
this.layer_ = layer;
this.setVisible(true);
this.setOpacity(1);
};
goog.inherits(ol.LayerRendererOptions, ol.Object);
/**
* @return {ol.Layer} Layer.
*/
ol.LayerRendererOptions.prototype.getLayer = function() {
return this.layer_;
};
/**
* @return {number} Opacity.
*/
ol.LayerRendererOptions.prototype.getOpacity = function() {
return /** @type {number} */ (
this.get(ol.LayerRendererOptionsProperty_.OPACITY));
};
/**
* @return {boolean} Visible.
*/
ol.LayerRendererOptions.prototype.getVisible = function() {
return /** @type {boolean} */ (
this.get(ol.LayerRendererOptionsProperty_.VISIBLE));
};
/**
* @param {number} opacity Opacity.
*/
ol.LayerRendererOptions.prototype.setOpacity = function(opacity) {
this.set(ol.LayerRendererOptionsProperty_.OPACITY, opacity);
};
/**
* @param {boolean} visible Visible.
*/
ol.LayerRendererOptions.prototype.setVisible = function(visible) {
this.set(ol.LayerRendererOptionsProperty_.VISIBLE, visible);
};

80
src/ol/store.js Normal file
View File

@@ -0,0 +1,80 @@
goog.provide('ol.Store');
goog.require('ol.Extent');
goog.require('ol.Object');
goog.require('ol.Projection');
/**
* @enum {string}
* @private
*/
ol.StoreProperty_ = {
ATTRIBUTION: 'attribution',
EXTENT: 'extent',
PROJECTION: 'projection'
};
/**
* @constructor
* @extends {ol.Object}
*/
ol.Store = function() {
goog.base(this);
this.setExtent(null);
this.setProjection(null);
};
goog.inherits(ol.Store, ol.Object);
/**
* @return {string|undefined} Attribution.
*/
ol.Store.prototype.getAttribution = function() {
return /** @type {string} */ (this.get(ol.StoreProperty_.ATTRIBUTION));
};
/**
* @return {ol.Extent} Extent.
*/
ol.Store.prototype.getExtent = function() {
return /** @type {ol.Extent} */ (this.get(ol.StoreProperty_.EXTENT));
};
/**
* @return {ol.Projection} Projection.
*/
ol.Store.prototype.getProjection = function() {
return /** @type {ol.Projection} */ (this.get(ol.StoreProperty_.PROJECTION));
};
/**
* @param {string|undefined} attribution Attribution.
*/
ol.Store.prototype.setAttribution = function(attribution) {
this.set(ol.StoreProperty_.ATTRIBUTION, attribution);
};
/**
* @param {ol.Extent} extent Extent.
*/
ol.Store.prototype.setExtent = function(extent) {
this.set(ol.StoreProperty_.EXTENT, extent);
};
/**
* @param {ol.Projection} projection Projetion.
*/
ol.Store.prototype.setProjection = function(projection) {
this.set(ol.StoreProperty_.PROJECTION, projection);
};

View File

@@ -1,6 +1,6 @@
goog.provide('ol.TileLayer');
goog.provide('ol.TileStore');
goog.require('ol.Layer');
goog.require('ol.Store');
goog.require('ol.TileCoord');
goog.require('ol.TileGrid');
goog.require('ol.TileUrlFunctionType');
@@ -9,11 +9,11 @@ goog.require('ol.TileUrlFunctionType');
/**
* @constructor
* @extends {ol.Layer}
* @extends {ol.Store}
* @param {ol.TileGrid} tileGrid Tile grid.
* @param {ol.TileUrlFunctionType} tileUrlFunction Tile URL.
*/
ol.TileLayer = function(tileGrid, tileUrlFunction) {
ol.TileStore = function(tileGrid, tileUrlFunction) {
goog.base(this);
@@ -30,14 +30,14 @@ ol.TileLayer = function(tileGrid, tileUrlFunction) {
this.tileUrlFunction_ = tileUrlFunction;
};
goog.inherits(ol.TileLayer, ol.Layer);
goog.inherits(ol.TileStore, ol.Store);
/**
* @param {ol.TileCoord} tileCoord Tile coordinate.
* @return {string} Tile coord URL.
*/
ol.TileLayer.prototype.getTileCoordUrl = function(tileCoord) {
ol.TileStore.prototype.getTileCoordUrl = function(tileCoord) {
// FIXME maybe wrap x and y
return this.tileUrlFunction_(tileCoord);
};
@@ -46,6 +46,6 @@ ol.TileLayer.prototype.getTileCoordUrl = function(tileCoord) {
/**
* @return {ol.TileGrid} Tile grid.
*/
ol.TileLayer.prototype.getTileGrid = function() {
ol.TileStore.prototype.getTileGrid = function() {
return this.tileGrid_;
};