/**
* @fileoverview bu.Viewer is an abstract class for all types of viewers.
* Each viewer should be focused en one type of geographical data, as
* ortho or 2D imagery and vector, oblique images, street 360 images,
* or 3D data.
* Created 23/03/2017.
* @author josea.hernandez@blom.no (Jose Antonio Hernandez)
* @copyright Blom Data S.L. 2017
*/
goog.provide('bu.Viewer');
goog.require('ol');
goog.require('ol.Object');
/**
* @classdesc
* This is an abstract class for all types of viewers.
* Each viewer should be focused en one type of geographical data, as
* ortho or 2D imagery and vector, oblique images, street 360 images,
* or 3D data.
*
* @constructor
* @extends {ol.Object}
* @param {bu.ViewerOptions} options Viewer options.
* @api
*/
bu.Viewer = function(options) {
ol.Object.call(this);
/**
* @type {bu.ViewType|undefined}
* @private
*/
this.viewType_ = null;
};
ol.inherits(bu.Viewer, ol.Object);
/**
* Return the type of the viewer.
* @return {bu.ViewType} The viewer type.
* @api
*/
bu.Viewer.prototype.getViewType = function() {
return /** @type {?bu.ViewType} */ (
this.viewType_);
};
/**
*
* @inheritDoc
*/
bu.Viewer.prototype.disposeInternal = function() {
this.setTarget(null);
ol.Object.prototype.disposeInternal.call(this);
};
/**
* Get the target in which the viewer is rendered.
* Note that this returns what is entered as an option or in setTarget:
* if that was an element, it returns an element; if a string, it returns that.
* @return {Element|string|undefined} The Element or id of the Element that the
* viewer is rendered in.
* @observable
* @api stable
*/
bu.Viewer.prototype.getTarget = function() {
return /** @type {Element|string|undefined} */ (
this.get(bu.ViewerProperty.TARGET));
};
/**
* Get the DOM element into which this viewer is rendered. In contrast to
* `getTarget` this method always return an `Element`, or `null` if the
* viewer has no target.
* @return {Element} The element that the viewer is rendered in.
* @api
*/
bu.Viewer.prototype.getTargetElement = function() {
var target = this.getTarget();
if (target !== undefined) {
return typeof target === 'string' ?
document.getElementById(target) :
target;
} else {
return null;
}
};
/**
* Set the target element to render this viewer into.
* @param {Element|string|undefined} target The Element or id of the Element
* that the viewer is rendered in.
* @observable
* @api stable
*/
bu.Viewer.prototype.setTarget = function(target) {
this.set(bu.ViewerProperty.TARGET, target);
};
/**
* Clones this viewer reinitializing the new one with main values of current one.
* This is an abstract method that must be implemented in derived classes.
* @return {bu.Viewer} The viewer cloned.
* @api
* @abstract
*/
bu.Viewer.prototype.clone = function() {};