Add getters to ol.style.Image
This commit is contained in:
@@ -455,18 +455,20 @@ ol.render.canvas.Immediate.prototype.setFillStrokeStyles_ = function() {
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.setImageStyle = function(imageStyle) {
|
||||
if (!goog.isNull(imageStyle)) {
|
||||
goog.asserts.assert(!goog.isNull(imageStyle.anchor));
|
||||
goog.asserts.assert(goog.isDef(imageStyle.size));
|
||||
var anchor = imageStyle.getAnchor();
|
||||
goog.asserts.assert(!goog.isNull(anchor));
|
||||
var size = imageStyle.getSize();
|
||||
goog.asserts.assert(!goog.isNull(size));
|
||||
// FIXME pixel ratio
|
||||
var image = imageStyle.getImage(1);
|
||||
goog.asserts.assert(!goog.isNull(image));
|
||||
var state = this.state_;
|
||||
state.anchorX = imageStyle.anchor[0];
|
||||
state.anchorY = imageStyle.anchor[1];
|
||||
state.anchorX = anchor[0];
|
||||
state.anchorY = anchor[1];
|
||||
state.image = image;
|
||||
state.width = imageStyle.size[0];
|
||||
state.height = imageStyle.size[1];
|
||||
state.snapToPixel = imageStyle.snapToPixel;
|
||||
state.width = size[0];
|
||||
state.height = size[1];
|
||||
state.snapToPixel = imageStyle.getSnapToPixel();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -602,20 +602,22 @@ ol.render.canvas.ImageReplay.prototype.finish = function() {
|
||||
*/
|
||||
ol.render.canvas.ImageReplay.prototype.setImageStyle = function(imageStyle) {
|
||||
goog.asserts.assert(!goog.isNull(imageStyle));
|
||||
goog.asserts.assert(!goog.isNull(imageStyle.anchor));
|
||||
goog.asserts.assert(goog.isDef(imageStyle.size));
|
||||
var anchor = imageStyle.getAnchor();
|
||||
goog.asserts.assert(!goog.isNull(anchor));
|
||||
var size = imageStyle.getSize();
|
||||
goog.asserts.assert(!goog.isNull(size));
|
||||
// FIXME pixel ratio
|
||||
var hitDetectionImage = imageStyle.getHitDetectionImage(1);
|
||||
goog.asserts.assert(!goog.isNull(hitDetectionImage));
|
||||
var image = imageStyle.getImage(1);
|
||||
goog.asserts.assert(!goog.isNull(image));
|
||||
this.anchorX_ = imageStyle.anchor[0];
|
||||
this.anchorY_ = imageStyle.anchor[1];
|
||||
this.anchorX_ = anchor[0];
|
||||
this.anchorY_ = anchor[1];
|
||||
this.hitDetectionImage_ = hitDetectionImage;
|
||||
this.image_ = image;
|
||||
this.width_ = imageStyle.size[0];
|
||||
this.height_ = imageStyle.size[1];
|
||||
this.snapToPixel_ = imageStyle.snapToPixel;
|
||||
this.width_ = size[0];
|
||||
this.height_ = size[1];
|
||||
this.snapToPixel_ = imageStyle.getSnapToPixel();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -40,34 +40,40 @@ ol.style.Image = function(options) {
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {ol.Pixel}
|
||||
*/
|
||||
this.anchor = options.anchor;
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {ol.style.ImageState}
|
||||
*/
|
||||
this.imageState = options.imageState;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.rotation = options.rotation;
|
||||
this.rotation_ = options.rotation;
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {ol.Size}
|
||||
*/
|
||||
this.size = options.size;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean|undefined}
|
||||
*/
|
||||
this.snapToPixel = options.snapToPixel;
|
||||
this.snapToPixel_ = options.snapToPixel;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean|undefined}
|
||||
*/
|
||||
this.subtractViewRotation = options.subtractViewRotation;
|
||||
this.subtractViewRotation_ = options.subtractViewRotation;
|
||||
|
||||
};
|
||||
goog.inherits(ol.style.Image, goog.events.EventTarget);
|
||||
@@ -81,6 +87,54 @@ ol.style.Image.prototype.dispatchChangeEvent = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.Pixel} Anchor.
|
||||
*/
|
||||
ol.style.Image.prototype.getAnchor = function() {
|
||||
return this.anchor;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.style.ImageState} Image state.
|
||||
*/
|
||||
ol.style.Image.prototype.getImageState = function() {
|
||||
return this.imageState;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {number|undefined} Rotation.
|
||||
*/
|
||||
ol.style.Image.prototype.getRotation = function() {
|
||||
return this.rotation_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.Size} Size.
|
||||
*/
|
||||
ol.style.Image.prototype.getSize = function() {
|
||||
return this.size;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {boolean|undefined} Snap to pixel?
|
||||
*/
|
||||
ol.style.Image.prototype.getSnapToPixel = function() {
|
||||
return this.snapToPixel_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {boolean|undefined} Subtract view rotation?
|
||||
*/
|
||||
ol.style.Image.prototype.getSubtractViewRotation = function() {
|
||||
return this.subtractViewRotation_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @return {HTMLCanvasElement|HTMLVideoElement|Image} Image element.
|
||||
|
||||
Reference in New Issue
Block a user