Remove goog.isNull in render classes

This commit is contained in:
Marc Jansen
2015-09-29 15:19:39 +02:00
parent f5788a32a7
commit 31a68e21a5
5 changed files with 133 additions and 144 deletions

View File

@@ -62,11 +62,11 @@ goog.inherits(ol.render.Box, goog.Disposable);
* @return {ol.geom.Polygon} Geometry. * @return {ol.geom.Polygon} Geometry.
*/ */
ol.render.Box.prototype.createGeometry_ = function() { ol.render.Box.prototype.createGeometry_ = function() {
goog.asserts.assert(!goog.isNull(this.startPixel_), goog.asserts.assert(this.startPixel_,
'this.startPixel_ should not be null'); 'this.startPixel_ must be truthy');
goog.asserts.assert(!goog.isNull(this.endPixel_), goog.asserts.assert(this.endPixel_,
'this.endPixel_ should not be null'); 'this.endPixel_ must be truthy');
goog.asserts.assert(!goog.isNull(this.map_), 'this.map_ should not be null'); goog.asserts.assert(this.map_, 'this.map_ must be truthy');
var startPixel = this.startPixel_; var startPixel = this.startPixel_;
var endPixel = this.endPixel_; var endPixel = this.endPixel_;
var pixels = [ var pixels = [
@@ -98,7 +98,7 @@ ol.render.Box.prototype.handleMapPostCompose_ = function(event) {
var geometry = this.geometry_; var geometry = this.geometry_;
goog.asserts.assert(geometry, 'geometry should be defined'); goog.asserts.assert(geometry, 'geometry should be defined');
var style = this.style_; var style = this.style_;
goog.asserts.assert(!goog.isNull(style), 'style should not be null'); goog.asserts.assert(style, 'style must be truthy');
// use drawAsync(Infinity) to draw above everything // use drawAsync(Infinity) to draw above everything
event.vectorContext.drawAsync(Infinity, function(render) { event.vectorContext.drawAsync(Infinity, function(render) {
render.setFillStrokeStyle(style.getFill(), style.getStroke()); render.setFillStrokeStyle(style.getFill(), style.getStroke());
@@ -120,9 +120,7 @@ ol.render.Box.prototype.getGeometry = function() {
* @private * @private
*/ */
ol.render.Box.prototype.requestMapRenderFrame_ = function() { ol.render.Box.prototype.requestMapRenderFrame_ = function() {
if (!goog.isNull(this.map_) && if (this.map_ && this.startPixel_ && this.endPixel_) {
!goog.isNull(this.startPixel_) &&
!goog.isNull(this.endPixel_)) {
this.map_.render(); this.map_.render();
} }
}; };
@@ -132,14 +130,14 @@ ol.render.Box.prototype.requestMapRenderFrame_ = function() {
* @param {ol.Map} map Map. * @param {ol.Map} map Map.
*/ */
ol.render.Box.prototype.setMap = function(map) { ol.render.Box.prototype.setMap = function(map) {
if (!goog.isNull(this.postComposeListenerKey_)) { if (this.postComposeListenerKey_) {
goog.events.unlistenByKey(this.postComposeListenerKey_); goog.events.unlistenByKey(this.postComposeListenerKey_);
this.postComposeListenerKey_ = null; this.postComposeListenerKey_ = null;
this.map_.render(); this.map_.render();
this.map_ = null; this.map_ = null;
} }
this.map_ = map; this.map_ = map;
if (!goog.isNull(this.map_)) { if (this.map_) {
this.postComposeListenerKey_ = goog.events.listen( this.postComposeListenerKey_ = goog.events.listen(
map, ol.render.EventType.POSTCOMPOSE, this.handleMapPostCompose_, false, map, ol.render.EventType.POSTCOMPOSE, this.handleMapPostCompose_, false,
this); this);

View File

@@ -249,7 +249,7 @@ ol.render.canvas.Immediate =
*/ */
ol.render.canvas.Immediate.prototype.drawImages_ = ol.render.canvas.Immediate.prototype.drawImages_ =
function(flatCoordinates, offset, end, stride) { function(flatCoordinates, offset, end, stride) {
if (goog.isNull(this.image_)) { if (!this.image_) {
return; return;
} }
goog.asserts.assert(offset === 0, 'offset should be 0'); goog.asserts.assert(offset === 0, 'offset should be 0');
@@ -312,13 +312,13 @@ ol.render.canvas.Immediate.prototype.drawImages_ =
*/ */
ol.render.canvas.Immediate.prototype.drawText_ = ol.render.canvas.Immediate.prototype.drawText_ =
function(flatCoordinates, offset, end, stride) { function(flatCoordinates, offset, end, stride) {
if (goog.isNull(this.textState_) || this.text_ === '') { if (!this.textState_ || this.text_ === '') {
return; return;
} }
if (!goog.isNull(this.textFillState_)) { if (this.textFillState_) {
this.setContextFillState_(this.textFillState_); this.setContextFillState_(this.textFillState_);
} }
if (!goog.isNull(this.textStrokeState_)) { if (this.textStrokeState_) {
this.setContextStrokeState_(this.textStrokeState_); this.setContextStrokeState_(this.textStrokeState_);
} }
this.setContextTextState_(this.textState_); this.setContextTextState_(this.textState_);
@@ -343,10 +343,10 @@ ol.render.canvas.Immediate.prototype.drawText_ =
goog.vec.Mat4.getElement(localTransform, 0, 3), goog.vec.Mat4.getElement(localTransform, 0, 3),
goog.vec.Mat4.getElement(localTransform, 1, 3)); goog.vec.Mat4.getElement(localTransform, 1, 3));
} }
if (!goog.isNull(this.textStrokeState_)) { if (this.textStrokeState_) {
context.strokeText(this.text_, x, y); context.strokeText(this.text_, x, y);
} }
if (!goog.isNull(this.textFillState_)) { if (this.textFillState_) {
context.fillText(this.text_, x, y); context.fillText(this.text_, x, y);
} }
} }
@@ -437,11 +437,11 @@ ol.render.canvas.Immediate.prototype.drawCircleGeometry =
if (!ol.extent.intersects(this.extent_, circleGeometry.getExtent())) { if (!ol.extent.intersects(this.extent_, circleGeometry.getExtent())) {
return; return;
} }
if (!goog.isNull(this.fillState_) || !goog.isNull(this.strokeState_)) { if (this.fillState_ || this.strokeState_) {
if (!goog.isNull(this.fillState_)) { if (this.fillState_) {
this.setContextFillState_(this.fillState_); this.setContextFillState_(this.fillState_);
} }
if (!goog.isNull(this.strokeState_)) { if (this.strokeState_) {
this.setContextStrokeState_(this.strokeState_); this.setContextStrokeState_(this.strokeState_);
} }
var pixelCoordinates = ol.geom.transformSimpleGeometry2D( var pixelCoordinates = ol.geom.transformSimpleGeometry2D(
@@ -453,10 +453,10 @@ ol.render.canvas.Immediate.prototype.drawCircleGeometry =
context.beginPath(); context.beginPath();
context.arc( context.arc(
pixelCoordinates[0], pixelCoordinates[1], radius, 0, 2 * Math.PI); pixelCoordinates[0], pixelCoordinates[1], radius, 0, 2 * Math.PI);
if (!goog.isNull(this.fillState_)) { if (this.fillState_) {
context.fill(); context.fill();
} }
if (!goog.isNull(this.strokeState_)) { if (this.strokeState_) {
context.stroke(); context.stroke();
} }
} }
@@ -535,7 +535,7 @@ ol.render.canvas.Immediate.prototype.drawPointGeometry =
function(pointGeometry, feature) { function(pointGeometry, feature) {
var flatCoordinates = pointGeometry.getFlatCoordinates(); var flatCoordinates = pointGeometry.getFlatCoordinates();
var stride = pointGeometry.getStride(); var stride = pointGeometry.getStride();
if (!goog.isNull(this.image_)) { if (this.image_) {
this.drawImages_(flatCoordinates, 0, flatCoordinates.length, stride); this.drawImages_(flatCoordinates, 0, flatCoordinates.length, stride);
} }
if (this.text_ !== '') { if (this.text_ !== '') {
@@ -556,7 +556,7 @@ ol.render.canvas.Immediate.prototype.drawMultiPointGeometry =
function(multiPointGeometry, feature) { function(multiPointGeometry, feature) {
var flatCoordinates = multiPointGeometry.getFlatCoordinates(); var flatCoordinates = multiPointGeometry.getFlatCoordinates();
var stride = multiPointGeometry.getStride(); var stride = multiPointGeometry.getStride();
if (!goog.isNull(this.image_)) { if (this.image_) {
this.drawImages_(flatCoordinates, 0, flatCoordinates.length, stride); this.drawImages_(flatCoordinates, 0, flatCoordinates.length, stride);
} }
if (this.text_ !== '') { if (this.text_ !== '') {
@@ -578,7 +578,7 @@ ol.render.canvas.Immediate.prototype.drawLineStringGeometry =
if (!ol.extent.intersects(this.extent_, lineStringGeometry.getExtent())) { if (!ol.extent.intersects(this.extent_, lineStringGeometry.getExtent())) {
return; return;
} }
if (!goog.isNull(this.strokeState_)) { if (this.strokeState_) {
this.setContextStrokeState_(this.strokeState_); this.setContextStrokeState_(this.strokeState_);
var context = this.context_; var context = this.context_;
var flatCoordinates = lineStringGeometry.getFlatCoordinates(); var flatCoordinates = lineStringGeometry.getFlatCoordinates();
@@ -609,7 +609,7 @@ ol.render.canvas.Immediate.prototype.drawMultiLineStringGeometry =
if (!ol.extent.intersects(this.extent_, geometryExtent)) { if (!ol.extent.intersects(this.extent_, geometryExtent)) {
return; return;
} }
if (!goog.isNull(this.strokeState_)) { if (this.strokeState_) {
this.setContextStrokeState_(this.strokeState_); this.setContextStrokeState_(this.strokeState_);
var context = this.context_; var context = this.context_;
var flatCoordinates = multiLineStringGeometry.getFlatCoordinates(); var flatCoordinates = multiLineStringGeometry.getFlatCoordinates();
@@ -644,21 +644,21 @@ ol.render.canvas.Immediate.prototype.drawPolygonGeometry =
if (!ol.extent.intersects(this.extent_, polygonGeometry.getExtent())) { if (!ol.extent.intersects(this.extent_, polygonGeometry.getExtent())) {
return; return;
} }
if (!goog.isNull(this.strokeState_) || !goog.isNull(this.fillState_)) { if (this.strokeState_ || this.fillState_) {
if (!goog.isNull(this.fillState_)) { if (this.fillState_) {
this.setContextFillState_(this.fillState_); this.setContextFillState_(this.fillState_);
} }
if (!goog.isNull(this.strokeState_)) { if (this.strokeState_) {
this.setContextStrokeState_(this.strokeState_); this.setContextStrokeState_(this.strokeState_);
} }
var context = this.context_; var context = this.context_;
context.beginPath(); context.beginPath();
this.drawRings_(polygonGeometry.getOrientedFlatCoordinates(), this.drawRings_(polygonGeometry.getOrientedFlatCoordinates(),
0, polygonGeometry.getEnds(), polygonGeometry.getStride()); 0, polygonGeometry.getEnds(), polygonGeometry.getStride());
if (!goog.isNull(this.fillState_)) { if (this.fillState_) {
context.fill(); context.fill();
} }
if (!goog.isNull(this.strokeState_)) { if (this.strokeState_) {
context.stroke(); context.stroke();
} }
} }
@@ -681,11 +681,11 @@ ol.render.canvas.Immediate.prototype.drawMultiPolygonGeometry =
if (!ol.extent.intersects(this.extent_, multiPolygonGeometry.getExtent())) { if (!ol.extent.intersects(this.extent_, multiPolygonGeometry.getExtent())) {
return; return;
} }
if (!goog.isNull(this.strokeState_) || !goog.isNull(this.fillState_)) { if (this.strokeState_ || this.fillState_) {
if (!goog.isNull(this.fillState_)) { if (this.fillState_) {
this.setContextFillState_(this.fillState_); this.setContextFillState_(this.fillState_);
} }
if (!goog.isNull(this.strokeState_)) { if (this.strokeState_) {
this.setContextStrokeState_(this.strokeState_); this.setContextStrokeState_(this.strokeState_);
} }
var context = this.context_; var context = this.context_;
@@ -698,10 +698,10 @@ ol.render.canvas.Immediate.prototype.drawMultiPolygonGeometry =
var ends = endss[i]; var ends = endss[i];
context.beginPath(); context.beginPath();
offset = this.drawRings_(flatCoordinates, offset, ends, stride); offset = this.drawRings_(flatCoordinates, offset, ends, stride);
if (!goog.isNull(this.fillState_)) { if (this.fillState_) {
context.fill(); context.fill();
} }
if (!goog.isNull(this.strokeState_)) { if (this.strokeState_) {
context.stroke(); context.stroke();
} }
} }
@@ -744,7 +744,7 @@ ol.render.canvas.Immediate.prototype.setContextFillState_ =
function(fillState) { function(fillState) {
var context = this.context_; var context = this.context_;
var contextFillState = this.contextFillState_; var contextFillState = this.contextFillState_;
if (goog.isNull(contextFillState)) { if (!contextFillState) {
context.fillStyle = fillState.fillStyle; context.fillStyle = fillState.fillStyle;
this.contextFillState_ = { this.contextFillState_ = {
fillStyle: fillState.fillStyle fillStyle: fillState.fillStyle
@@ -765,7 +765,7 @@ ol.render.canvas.Immediate.prototype.setContextStrokeState_ =
function(strokeState) { function(strokeState) {
var context = this.context_; var context = this.context_;
var contextStrokeState = this.contextStrokeState_; var contextStrokeState = this.contextStrokeState_;
if (goog.isNull(contextStrokeState)) { if (!contextStrokeState) {
context.lineCap = strokeState.lineCap; context.lineCap = strokeState.lineCap;
if (ol.has.CANVAS_LINE_DASH) { if (ol.has.CANVAS_LINE_DASH) {
context.setLineDash(strokeState.lineDash); context.setLineDash(strokeState.lineDash);
@@ -818,7 +818,7 @@ ol.render.canvas.Immediate.prototype.setContextTextState_ =
function(textState) { function(textState) {
var context = this.context_; var context = this.context_;
var contextTextState = this.contextTextState_; var contextTextState = this.contextTextState_;
if (goog.isNull(contextTextState)) { if (!contextTextState) {
context.font = textState.font; context.font = textState.font;
context.textAlign = textState.textAlign; context.textAlign = textState.textAlign;
context.textBaseline = textState.textBaseline; context.textBaseline = textState.textBaseline;
@@ -852,16 +852,16 @@ ol.render.canvas.Immediate.prototype.setContextTextState_ =
*/ */
ol.render.canvas.Immediate.prototype.setFillStrokeStyle = ol.render.canvas.Immediate.prototype.setFillStrokeStyle =
function(fillStyle, strokeStyle) { function(fillStyle, strokeStyle) {
if (goog.isNull(fillStyle)) { if (!fillStyle) {
this.fillState_ = null; this.fillState_ = null;
} else { } else {
var fillStyleColor = fillStyle.getColor(); var fillStyleColor = fillStyle.getColor();
this.fillState_ = { this.fillState_ = {
fillStyle: ol.color.asString(!goog.isNull(fillStyleColor) ? fillStyle: ol.color.asString(fillStyleColor ?
fillStyleColor : ol.render.canvas.defaultFillStyle) fillStyleColor : ol.render.canvas.defaultFillStyle)
}; };
} }
if (goog.isNull(strokeStyle)) { if (!strokeStyle) {
this.strokeState_ = null; this.strokeState_ = null;
} else { } else {
var strokeStyleColor = strokeStyle.getColor(); var strokeStyleColor = strokeStyle.getColor();
@@ -881,7 +881,7 @@ ol.render.canvas.Immediate.prototype.setFillStrokeStyle =
strokeStyleWidth : ol.render.canvas.defaultLineWidth), strokeStyleWidth : ol.render.canvas.defaultLineWidth),
miterLimit: strokeStyleMiterLimit !== undefined ? miterLimit: strokeStyleMiterLimit !== undefined ?
strokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit, strokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit,
strokeStyle: ol.color.asString(!goog.isNull(strokeStyleColor) ? strokeStyle: ol.color.asString(strokeStyleColor ?
strokeStyleColor : ol.render.canvas.defaultStrokeStyle) strokeStyleColor : ol.render.canvas.defaultStrokeStyle)
}; };
} }
@@ -896,7 +896,7 @@ ol.render.canvas.Immediate.prototype.setFillStrokeStyle =
* @api * @api
*/ */
ol.render.canvas.Immediate.prototype.setImageStyle = function(imageStyle) { ol.render.canvas.Immediate.prototype.setImageStyle = function(imageStyle) {
if (goog.isNull(imageStyle)) { if (!imageStyle) {
this.image_ = null; this.image_ = null;
} else { } else {
var imageAnchor = imageStyle.getAnchor(); var imageAnchor = imageStyle.getAnchor();
@@ -904,14 +904,10 @@ ol.render.canvas.Immediate.prototype.setImageStyle = function(imageStyle) {
var imageImage = imageStyle.getImage(1); var imageImage = imageStyle.getImage(1);
var imageOrigin = imageStyle.getOrigin(); var imageOrigin = imageStyle.getOrigin();
var imageSize = imageStyle.getSize(); var imageSize = imageStyle.getSize();
goog.asserts.assert(!goog.isNull(imageAnchor), goog.asserts.assert(imageAnchor, 'imageAnchor must be truthy');
'imageAnchor should not be null'); goog.asserts.assert(imageImage, 'imageImage must be truthy');
goog.asserts.assert(!goog.isNull(imageImage), goog.asserts.assert(imageOrigin, 'imageOrigin must be truthy');
'imageImage should not be null'); goog.asserts.assert(imageSize, 'imageSize must be truthy');
goog.asserts.assert(!goog.isNull(imageOrigin),
'imageOrigin should not be null');
goog.asserts.assert(!goog.isNull(imageSize),
'imageSize should not be null');
this.imageAnchorX_ = imageAnchor[0]; this.imageAnchorX_ = imageAnchor[0];
this.imageAnchorY_ = imageAnchor[1]; this.imageAnchorY_ = imageAnchor[1];
this.imageHeight_ = imageSize[1]; this.imageHeight_ = imageSize[1];
@@ -936,21 +932,21 @@ ol.render.canvas.Immediate.prototype.setImageStyle = function(imageStyle) {
* @api * @api
*/ */
ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) { ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) {
if (goog.isNull(textStyle)) { if (!textStyle) {
this.text_ = ''; this.text_ = '';
} else { } else {
var textFillStyle = textStyle.getFill(); var textFillStyle = textStyle.getFill();
if (goog.isNull(textFillStyle)) { if (!textFillStyle) {
this.textFillState_ = null; this.textFillState_ = null;
} else { } else {
var textFillStyleColor = textFillStyle.getColor(); var textFillStyleColor = textFillStyle.getColor();
this.textFillState_ = { this.textFillState_ = {
fillStyle: ol.color.asString(!goog.isNull(textFillStyleColor) ? fillStyle: ol.color.asString(textFillStyleColor ?
textFillStyleColor : ol.render.canvas.defaultFillStyle) textFillStyleColor : ol.render.canvas.defaultFillStyle)
}; };
} }
var textStrokeStyle = textStyle.getStroke(); var textStrokeStyle = textStyle.getStroke();
if (goog.isNull(textStrokeStyle)) { if (!textStrokeStyle) {
this.textStrokeState_ = null; this.textStrokeState_ = null;
} else { } else {
var textStrokeStyleColor = textStrokeStyle.getColor(); var textStrokeStyleColor = textStrokeStyle.getColor();
@@ -970,7 +966,7 @@ ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) {
textStrokeStyleWidth : ol.render.canvas.defaultLineWidth, textStrokeStyleWidth : ol.render.canvas.defaultLineWidth,
miterLimit: textStrokeStyleMiterLimit !== undefined ? miterLimit: textStrokeStyleMiterLimit !== undefined ?
textStrokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit, textStrokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit,
strokeStyle: ol.color.asString(!goog.isNull(textStrokeStyleColor) ? strokeStyle: ol.color.asString(textStrokeStyleColor ?
textStrokeStyleColor : ol.render.canvas.defaultStrokeStyle) textStrokeStyleColor : ol.render.canvas.defaultStrokeStyle)
}; };
} }

View File

@@ -451,7 +451,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
'5th instruction should be a string'); '5th instruction should be a string');
goog.asserts.assert(goog.isNumber(instruction[5]), goog.asserts.assert(goog.isNumber(instruction[5]),
'6th instruction should be a number'); '6th instruction should be a number');
goog.asserts.assert(!goog.isNull(instruction[6]), goog.asserts.assert(instruction[6],
'7th instruction should not be null'); '7th instruction should not be null');
var usePixelRatio = instruction[7] !== undefined ? var usePixelRatio = instruction[7] !== undefined ?
instruction[7] : true; instruction[7] : true;
@@ -568,11 +568,11 @@ ol.render.canvas.Replay.prototype.reverseHitDetectionInstructions_ =
* @param {ol.Feature} feature Feature. * @param {ol.Feature} feature Feature.
*/ */
ol.render.canvas.Replay.prototype.endGeometry = function(geometry, feature) { ol.render.canvas.Replay.prototype.endGeometry = function(geometry, feature) {
goog.asserts.assert(!goog.isNull(this.beginGeometryInstruction1_), goog.asserts.assert(this.beginGeometryInstruction1_,
'this.beginGeometryInstruction1_ should not be null'); 'this.beginGeometryInstruction1_ should not be null');
this.beginGeometryInstruction1_[2] = this.instructions.length; this.beginGeometryInstruction1_[2] = this.instructions.length;
this.beginGeometryInstruction1_ = null; this.beginGeometryInstruction1_ = null;
goog.asserts.assert(!goog.isNull(this.beginGeometryInstruction2_), goog.asserts.assert(this.beginGeometryInstruction2_,
'this.beginGeometryInstruction2_ should not be null'); 'this.beginGeometryInstruction2_ should not be null');
this.beginGeometryInstruction2_[2] = this.hitDetectionInstructions.length; this.beginGeometryInstruction2_[2] = this.hitDetectionInstructions.length;
this.beginGeometryInstruction2_ = null; this.beginGeometryInstruction2_ = null;
@@ -716,7 +716,7 @@ ol.render.canvas.ImageReplay.prototype.drawCoordinates_ =
*/ */
ol.render.canvas.ImageReplay.prototype.drawPointGeometry = ol.render.canvas.ImageReplay.prototype.drawPointGeometry =
function(pointGeometry, feature) { function(pointGeometry, feature) {
if (goog.isNull(this.image_)) { if (!this.image_) {
return; return;
} }
goog.asserts.assert(this.anchorX_ !== undefined, goog.asserts.assert(this.anchorX_ !== undefined,
@@ -769,7 +769,7 @@ ol.render.canvas.ImageReplay.prototype.drawPointGeometry =
*/ */
ol.render.canvas.ImageReplay.prototype.drawMultiPointGeometry = ol.render.canvas.ImageReplay.prototype.drawMultiPointGeometry =
function(multiPointGeometry, feature) { function(multiPointGeometry, feature) {
if (goog.isNull(this.image_)) { if (!this.image_) {
return; return;
} }
goog.asserts.assert(this.anchorX_ !== undefined, goog.asserts.assert(this.anchorX_ !== undefined,
@@ -843,19 +843,18 @@ ol.render.canvas.ImageReplay.prototype.finish = function() {
* @inheritDoc * @inheritDoc
*/ */
ol.render.canvas.ImageReplay.prototype.setImageStyle = function(imageStyle) { ol.render.canvas.ImageReplay.prototype.setImageStyle = function(imageStyle) {
goog.asserts.assert(!goog.isNull(imageStyle), goog.asserts.assert(imageStyle, 'imageStyle should not be null');
'imageStyle should not be null');
var anchor = imageStyle.getAnchor(); var anchor = imageStyle.getAnchor();
goog.asserts.assert(!goog.isNull(anchor), 'anchor should not be null'); goog.asserts.assert(anchor, 'anchor should not be null');
var size = imageStyle.getSize(); var size = imageStyle.getSize();
goog.asserts.assert(!goog.isNull(size), 'size should not be null'); goog.asserts.assert(size, 'size should not be null');
var hitDetectionImage = imageStyle.getHitDetectionImage(1); var hitDetectionImage = imageStyle.getHitDetectionImage(1);
goog.asserts.assert(!goog.isNull(hitDetectionImage), goog.asserts.assert(hitDetectionImage,
'hitDetectionImage should not be null'); 'hitDetectionImage should not be null');
var image = imageStyle.getImage(1); var image = imageStyle.getImage(1);
goog.asserts.assert(!goog.isNull(image), 'image should not be null'); goog.asserts.assert(image, 'image should not be null');
var origin = imageStyle.getOrigin(); var origin = imageStyle.getOrigin();
goog.asserts.assert(!goog.isNull(origin), 'origin should not be null'); goog.asserts.assert(origin, 'origin should not be null');
this.anchorX_ = anchor[0]; this.anchorX_ = anchor[0];
this.anchorY_ = anchor[1]; this.anchorY_ = anchor[1];
this.hitDetectionImage_ = hitDetectionImage; this.hitDetectionImage_ = hitDetectionImage;
@@ -947,7 +946,7 @@ ol.render.canvas.LineStringReplay.prototype.drawFlatCoordinates_ =
* @inheritDoc * @inheritDoc
*/ */
ol.render.canvas.LineStringReplay.prototype.getBufferedMaxExtent = function() { ol.render.canvas.LineStringReplay.prototype.getBufferedMaxExtent = function() {
if (goog.isNull(this.bufferedMaxExtent_)) { if (!this.bufferedMaxExtent_) {
this.bufferedMaxExtent_ = ol.extent.clone(this.maxExtent); this.bufferedMaxExtent_ = ol.extent.clone(this.maxExtent);
if (this.maxLineWidth > 0) { if (this.maxLineWidth > 0) {
var width = this.resolution * (this.maxLineWidth + 1) / 2; var width = this.resolution * (this.maxLineWidth + 1) / 2;
@@ -972,7 +971,7 @@ ol.render.canvas.LineStringReplay.prototype.setStrokeStyle_ = function() {
goog.asserts.assert(strokeStyle !== undefined, goog.asserts.assert(strokeStyle !== undefined,
'strokeStyle should be defined'); 'strokeStyle should be defined');
goog.asserts.assert(lineCap !== undefined, 'lineCap should be defined'); goog.asserts.assert(lineCap !== undefined, 'lineCap should be defined');
goog.asserts.assert(!goog.isNull(lineDash), 'lineDash should not be null'); goog.asserts.assert(lineDash, 'lineDash should not be null');
goog.asserts.assert(lineJoin !== undefined, 'lineJoin should be defined'); goog.asserts.assert(lineJoin !== undefined, 'lineJoin should be defined');
goog.asserts.assert(lineWidth !== undefined, 'lineWidth should be defined'); goog.asserts.assert(lineWidth !== undefined, 'lineWidth should be defined');
goog.asserts.assert(miterLimit !== undefined, 'miterLimit should be defined'); goog.asserts.assert(miterLimit !== undefined, 'miterLimit should be defined');
@@ -1007,7 +1006,7 @@ ol.render.canvas.LineStringReplay.prototype.setStrokeStyle_ = function() {
ol.render.canvas.LineStringReplay.prototype.drawLineStringGeometry = ol.render.canvas.LineStringReplay.prototype.drawLineStringGeometry =
function(lineStringGeometry, feature) { function(lineStringGeometry, feature) {
var state = this.state_; var state = this.state_;
goog.asserts.assert(!goog.isNull(state), 'state should not be null'); goog.asserts.assert(state, 'state should not be null');
var strokeStyle = state.strokeStyle; var strokeStyle = state.strokeStyle;
var lineWidth = state.lineWidth; var lineWidth = state.lineWidth;
if (strokeStyle === undefined || lineWidth === undefined) { if (strokeStyle === undefined || lineWidth === undefined) {
@@ -1035,7 +1034,7 @@ ol.render.canvas.LineStringReplay.prototype.drawLineStringGeometry =
ol.render.canvas.LineStringReplay.prototype.drawMultiLineStringGeometry = ol.render.canvas.LineStringReplay.prototype.drawMultiLineStringGeometry =
function(multiLineStringGeometry, feature) { function(multiLineStringGeometry, feature) {
var state = this.state_; var state = this.state_;
goog.asserts.assert(!goog.isNull(state), 'state should not be null'); goog.asserts.assert(state, 'state should not be null');
var strokeStyle = state.strokeStyle; var strokeStyle = state.strokeStyle;
var lineWidth = state.lineWidth; var lineWidth = state.lineWidth;
if (strokeStyle === undefined || lineWidth === undefined) { if (strokeStyle === undefined || lineWidth === undefined) {
@@ -1067,7 +1066,7 @@ ol.render.canvas.LineStringReplay.prototype.drawMultiLineStringGeometry =
*/ */
ol.render.canvas.LineStringReplay.prototype.finish = function() { ol.render.canvas.LineStringReplay.prototype.finish = function() {
var state = this.state_; var state = this.state_;
goog.asserts.assert(!goog.isNull(state), 'state should not be null'); goog.asserts.assert(state, 'state should not be null');
if (state.lastStroke != this.coordinates.length) { if (state.lastStroke != this.coordinates.length) {
this.instructions.push([ol.render.canvas.Instruction.STROKE]); this.instructions.push([ol.render.canvas.Instruction.STROKE]);
} }
@@ -1081,19 +1080,17 @@ ol.render.canvas.LineStringReplay.prototype.finish = function() {
*/ */
ol.render.canvas.LineStringReplay.prototype.setFillStrokeStyle = ol.render.canvas.LineStringReplay.prototype.setFillStrokeStyle =
function(fillStyle, strokeStyle) { function(fillStyle, strokeStyle) {
goog.asserts.assert(!goog.isNull(this.state_), goog.asserts.assert(this.state_, 'this.state_ should not be null');
'this.state_ should not be null'); goog.asserts.assert(!fillStyle, 'fillStyle should be null');
goog.asserts.assert(goog.isNull(fillStyle), 'fillStyle should be null'); goog.asserts.assert(strokeStyle, 'strokeStyle should not be null');
goog.asserts.assert(!goog.isNull(strokeStyle),
'strokeStyle should not be null');
var strokeStyleColor = strokeStyle.getColor(); var strokeStyleColor = strokeStyle.getColor();
this.state_.strokeStyle = ol.color.asString(!goog.isNull(strokeStyleColor) ? this.state_.strokeStyle = ol.color.asString(strokeStyleColor ?
strokeStyleColor : ol.render.canvas.defaultStrokeStyle); strokeStyleColor : ol.render.canvas.defaultStrokeStyle);
var strokeStyleLineCap = strokeStyle.getLineCap(); var strokeStyleLineCap = strokeStyle.getLineCap();
this.state_.lineCap = strokeStyleLineCap !== undefined ? this.state_.lineCap = strokeStyleLineCap !== undefined ?
strokeStyleLineCap : ol.render.canvas.defaultLineCap; strokeStyleLineCap : ol.render.canvas.defaultLineCap;
var strokeStyleLineDash = strokeStyle.getLineDash(); var strokeStyleLineDash = strokeStyle.getLineDash();
this.state_.lineDash = !goog.isNull(strokeStyleLineDash) ? this.state_.lineDash = strokeStyleLineDash ?
strokeStyleLineDash : ol.render.canvas.defaultLineDash; strokeStyleLineDash : ol.render.canvas.defaultLineDash;
var strokeStyleLineJoin = strokeStyle.getLineJoin(); var strokeStyleLineJoin = strokeStyle.getLineJoin();
this.state_.lineJoin = strokeStyleLineJoin !== undefined ? this.state_.lineJoin = strokeStyleLineJoin !== undefined ?
@@ -1217,7 +1214,7 @@ ol.render.canvas.PolygonReplay.prototype.drawFlatCoordinatess_ =
ol.render.canvas.PolygonReplay.prototype.drawCircleGeometry = ol.render.canvas.PolygonReplay.prototype.drawCircleGeometry =
function(circleGeometry, feature) { function(circleGeometry, feature) {
var state = this.state_; var state = this.state_;
goog.asserts.assert(!goog.isNull(state), 'state should not be null'); goog.asserts.assert(state, 'state should not be null');
var fillStyle = state.fillStyle; var fillStyle = state.fillStyle;
var strokeStyle = state.strokeStyle; var strokeStyle = state.strokeStyle;
if (fillStyle === undefined && strokeStyle === undefined) { if (fillStyle === undefined && strokeStyle === undefined) {
@@ -1270,7 +1267,7 @@ ol.render.canvas.PolygonReplay.prototype.drawCircleGeometry =
ol.render.canvas.PolygonReplay.prototype.drawPolygonGeometry = ol.render.canvas.PolygonReplay.prototype.drawPolygonGeometry =
function(polygonGeometry, feature) { function(polygonGeometry, feature) {
var state = this.state_; var state = this.state_;
goog.asserts.assert(!goog.isNull(state), 'state should not be null'); goog.asserts.assert(state, 'state should not be null');
var fillStyle = state.fillStyle; var fillStyle = state.fillStyle;
var strokeStyle = state.strokeStyle; var strokeStyle = state.strokeStyle;
if (fillStyle === undefined && strokeStyle === undefined) { if (fillStyle === undefined && strokeStyle === undefined) {
@@ -1306,7 +1303,7 @@ ol.render.canvas.PolygonReplay.prototype.drawPolygonGeometry =
ol.render.canvas.PolygonReplay.prototype.drawMultiPolygonGeometry = ol.render.canvas.PolygonReplay.prototype.drawMultiPolygonGeometry =
function(multiPolygonGeometry, feature) { function(multiPolygonGeometry, feature) {
var state = this.state_; var state = this.state_;
goog.asserts.assert(!goog.isNull(state), 'state should not be null'); goog.asserts.assert(state, 'state should not be null');
var fillStyle = state.fillStyle; var fillStyle = state.fillStyle;
var strokeStyle = state.strokeStyle; var strokeStyle = state.strokeStyle;
if (fillStyle === undefined && strokeStyle === undefined) { if (fillStyle === undefined && strokeStyle === undefined) {
@@ -1345,8 +1342,7 @@ ol.render.canvas.PolygonReplay.prototype.drawMultiPolygonGeometry =
* @inheritDoc * @inheritDoc
*/ */
ol.render.canvas.PolygonReplay.prototype.finish = function() { ol.render.canvas.PolygonReplay.prototype.finish = function() {
goog.asserts.assert(!goog.isNull(this.state_), goog.asserts.assert(this.state_, 'this.state_ should not be null');
'this.state_ should not be null');
this.reverseHitDetectionInstructions_(); this.reverseHitDetectionInstructions_();
this.state_ = null; this.state_ = null;
// We want to preserve topology when drawing polygons. Polygons are // We want to preserve topology when drawing polygons. Polygons are
@@ -1368,7 +1364,7 @@ ol.render.canvas.PolygonReplay.prototype.finish = function() {
* @inheritDoc * @inheritDoc
*/ */
ol.render.canvas.PolygonReplay.prototype.getBufferedMaxExtent = function() { ol.render.canvas.PolygonReplay.prototype.getBufferedMaxExtent = function() {
if (goog.isNull(this.bufferedMaxExtent_)) { if (!this.bufferedMaxExtent_) {
this.bufferedMaxExtent_ = ol.extent.clone(this.maxExtent); this.bufferedMaxExtent_ = ol.extent.clone(this.maxExtent);
if (this.maxLineWidth > 0) { if (this.maxLineWidth > 0) {
var width = this.resolution * (this.maxLineWidth + 1) / 2; var width = this.resolution * (this.maxLineWidth + 1) / 2;
@@ -1384,27 +1380,26 @@ ol.render.canvas.PolygonReplay.prototype.getBufferedMaxExtent = function() {
*/ */
ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyle = ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyle =
function(fillStyle, strokeStyle) { function(fillStyle, strokeStyle) {
goog.asserts.assert(!goog.isNull(this.state_), goog.asserts.assert(this.state_, 'this.state_ should not be null');
'this.state_ should not be null'); goog.asserts.assert(fillStyle || strokeStyle,
goog.asserts.assert(!goog.isNull(fillStyle) || !goog.isNull(strokeStyle),
'fillStyle or strokeStyle should not be null'); 'fillStyle or strokeStyle should not be null');
var state = this.state_; var state = this.state_;
if (!goog.isNull(fillStyle)) { if (fillStyle) {
var fillStyleColor = fillStyle.getColor(); var fillStyleColor = fillStyle.getColor();
state.fillStyle = ol.color.asString(!goog.isNull(fillStyleColor) ? state.fillStyle = ol.color.asString(fillStyleColor ?
fillStyleColor : ol.render.canvas.defaultFillStyle); fillStyleColor : ol.render.canvas.defaultFillStyle);
} else { } else {
state.fillStyle = undefined; state.fillStyle = undefined;
} }
if (!goog.isNull(strokeStyle)) { if (strokeStyle) {
var strokeStyleColor = strokeStyle.getColor(); var strokeStyleColor = strokeStyle.getColor();
state.strokeStyle = ol.color.asString(!goog.isNull(strokeStyleColor) ? state.strokeStyle = ol.color.asString(strokeStyleColor ?
strokeStyleColor : ol.render.canvas.defaultStrokeStyle); strokeStyleColor : ol.render.canvas.defaultStrokeStyle);
var strokeStyleLineCap = strokeStyle.getLineCap(); var strokeStyleLineCap = strokeStyle.getLineCap();
state.lineCap = strokeStyleLineCap !== undefined ? state.lineCap = strokeStyleLineCap !== undefined ?
strokeStyleLineCap : ol.render.canvas.defaultLineCap; strokeStyleLineCap : ol.render.canvas.defaultLineCap;
var strokeStyleLineDash = strokeStyle.getLineDash(); var strokeStyleLineDash = strokeStyle.getLineDash();
state.lineDash = !goog.isNull(strokeStyleLineDash) ? state.lineDash = strokeStyleLineDash ?
strokeStyleLineDash.slice() : ol.render.canvas.defaultLineDash; strokeStyleLineDash.slice() : ol.render.canvas.defaultLineDash;
var strokeStyleLineJoin = strokeStyle.getLineJoin(); var strokeStyleLineJoin = strokeStyle.getLineJoin();
state.lineJoin = strokeStyleLineJoin !== undefined ? state.lineJoin = strokeStyleLineJoin !== undefined ?
@@ -1451,7 +1446,7 @@ ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyles_ = function() {
} }
if (strokeStyle !== undefined) { if (strokeStyle !== undefined) {
goog.asserts.assert(lineCap !== undefined, 'lineCap should be defined'); goog.asserts.assert(lineCap !== undefined, 'lineCap should be defined');
goog.asserts.assert(!goog.isNull(lineDash), 'lineDash should not be null'); goog.asserts.assert(lineDash, 'lineDash should not be null');
goog.asserts.assert(lineJoin !== undefined, 'lineJoin should be defined'); goog.asserts.assert(lineJoin !== undefined, 'lineJoin should be defined');
goog.asserts.assert(lineWidth !== undefined, 'lineWidth should be defined'); goog.asserts.assert(lineWidth !== undefined, 'lineWidth should be defined');
goog.asserts.assert(miterLimit !== undefined, goog.asserts.assert(miterLimit !== undefined,
@@ -1566,15 +1561,15 @@ goog.inherits(ol.render.canvas.TextReplay, ol.render.canvas.Replay);
ol.render.canvas.TextReplay.prototype.drawText = ol.render.canvas.TextReplay.prototype.drawText =
function(flatCoordinates, offset, end, stride, geometry, feature) { function(flatCoordinates, offset, end, stride, geometry, feature) {
if (this.text_ === '' || if (this.text_ === '' ||
goog.isNull(this.textState_) || !this.textState_ ||
(goog.isNull(this.textFillState_) && (this.textFillState_ &&
goog.isNull(this.textStrokeState_))) { !this.textStrokeState_)) {
return; return;
} }
if (!goog.isNull(this.textFillState_)) { if (this.textFillState_) {
this.setReplayFillState_(this.textFillState_); this.setReplayFillState_(this.textFillState_);
} }
if (!goog.isNull(this.textStrokeState_)) { if (this.textStrokeState_) {
this.setReplayStrokeState_(this.textStrokeState_); this.setReplayStrokeState_(this.textStrokeState_);
} }
this.setReplayTextState_(this.textState_); this.setReplayTextState_(this.textState_);
@@ -1582,8 +1577,8 @@ ol.render.canvas.TextReplay.prototype.drawText =
var myBegin = this.coordinates.length; var myBegin = this.coordinates.length;
var myEnd = var myEnd =
this.appendFlatCoordinates(flatCoordinates, offset, end, stride, false); this.appendFlatCoordinates(flatCoordinates, offset, end, stride, false);
var fill = !goog.isNull(this.textFillState_); var fill = this.textFillState_;
var stroke = !goog.isNull(this.textStrokeState_); var stroke = this.textStrokeState_;
var drawTextInstruction = [ var drawTextInstruction = [
ol.render.canvas.Instruction.DRAW_TEXT, myBegin, myEnd, this.text_, ol.render.canvas.Instruction.DRAW_TEXT, myBegin, myEnd, this.text_,
this.textOffsetX_, this.textOffsetY_, this.textRotation_, this.textScale_, this.textOffsetX_, this.textOffsetY_, this.textRotation_, this.textScale_,
@@ -1601,7 +1596,7 @@ ol.render.canvas.TextReplay.prototype.drawText =
ol.render.canvas.TextReplay.prototype.setReplayFillState_ = ol.render.canvas.TextReplay.prototype.setReplayFillState_ =
function(fillState) { function(fillState) {
var replayFillState = this.replayFillState_; var replayFillState = this.replayFillState_;
if (!goog.isNull(replayFillState) && if (replayFillState &&
replayFillState.fillStyle == fillState.fillStyle) { replayFillState.fillStyle == fillState.fillStyle) {
return; return;
} }
@@ -1609,7 +1604,7 @@ ol.render.canvas.TextReplay.prototype.setReplayFillState_ =
[ol.render.canvas.Instruction.SET_FILL_STYLE, fillState.fillStyle]; [ol.render.canvas.Instruction.SET_FILL_STYLE, fillState.fillStyle];
this.instructions.push(setFillStyleInstruction); this.instructions.push(setFillStyleInstruction);
this.hitDetectionInstructions.push(setFillStyleInstruction); this.hitDetectionInstructions.push(setFillStyleInstruction);
if (goog.isNull(replayFillState)) { if (!replayFillState) {
this.replayFillState_ = { this.replayFillState_ = {
fillStyle: fillState.fillStyle fillStyle: fillState.fillStyle
}; };
@@ -1626,7 +1621,7 @@ ol.render.canvas.TextReplay.prototype.setReplayFillState_ =
ol.render.canvas.TextReplay.prototype.setReplayStrokeState_ = ol.render.canvas.TextReplay.prototype.setReplayStrokeState_ =
function(strokeState) { function(strokeState) {
var replayStrokeState = this.replayStrokeState_; var replayStrokeState = this.replayStrokeState_;
if (!goog.isNull(replayStrokeState) && if (replayStrokeState &&
replayStrokeState.lineCap == strokeState.lineCap && replayStrokeState.lineCap == strokeState.lineCap &&
replayStrokeState.lineDash == strokeState.lineDash && replayStrokeState.lineDash == strokeState.lineDash &&
replayStrokeState.lineJoin == strokeState.lineJoin && replayStrokeState.lineJoin == strokeState.lineJoin &&
@@ -1642,7 +1637,7 @@ ol.render.canvas.TextReplay.prototype.setReplayStrokeState_ =
]; ];
this.instructions.push(setStrokeStyleInstruction); this.instructions.push(setStrokeStyleInstruction);
this.hitDetectionInstructions.push(setStrokeStyleInstruction); this.hitDetectionInstructions.push(setStrokeStyleInstruction);
if (goog.isNull(replayStrokeState)) { if (!replayStrokeState) {
this.replayStrokeState_ = { this.replayStrokeState_ = {
lineCap: strokeState.lineCap, lineCap: strokeState.lineCap,
lineDash: strokeState.lineDash, lineDash: strokeState.lineDash,
@@ -1669,7 +1664,7 @@ ol.render.canvas.TextReplay.prototype.setReplayStrokeState_ =
ol.render.canvas.TextReplay.prototype.setReplayTextState_ = ol.render.canvas.TextReplay.prototype.setReplayTextState_ =
function(textState) { function(textState) {
var replayTextState = this.replayTextState_; var replayTextState = this.replayTextState_;
if (!goog.isNull(replayTextState) && if (replayTextState &&
replayTextState.font == textState.font && replayTextState.font == textState.font &&
replayTextState.textAlign == textState.textAlign && replayTextState.textAlign == textState.textAlign &&
replayTextState.textBaseline == textState.textBaseline) { replayTextState.textBaseline == textState.textBaseline) {
@@ -1679,7 +1674,7 @@ ol.render.canvas.TextReplay.prototype.setReplayTextState_ =
textState.font, textState.textAlign, textState.textBaseline]; textState.font, textState.textAlign, textState.textBaseline];
this.instructions.push(setTextStyleInstruction); this.instructions.push(setTextStyleInstruction);
this.hitDetectionInstructions.push(setTextStyleInstruction); this.hitDetectionInstructions.push(setTextStyleInstruction);
if (goog.isNull(replayTextState)) { if (!replayTextState) {
this.replayTextState_ = { this.replayTextState_ = {
font: textState.font, font: textState.font,
textAlign: textState.textAlign, textAlign: textState.textAlign,
@@ -1697,17 +1692,17 @@ ol.render.canvas.TextReplay.prototype.setReplayTextState_ =
* @inheritDoc * @inheritDoc
*/ */
ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle) { ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle) {
if (goog.isNull(textStyle)) { if (!textStyle) {
this.text_ = ''; this.text_ = '';
} else { } else {
var textFillStyle = textStyle.getFill(); var textFillStyle = textStyle.getFill();
if (goog.isNull(textFillStyle)) { if (!textFillStyle) {
this.textFillState_ = null; this.textFillState_ = null;
} else { } else {
var textFillStyleColor = textFillStyle.getColor(); var textFillStyleColor = textFillStyle.getColor();
var fillStyle = ol.color.asString(!goog.isNull(textFillStyleColor) ? var fillStyle = ol.color.asString(textFillStyleColor ?
textFillStyleColor : ol.render.canvas.defaultFillStyle); textFillStyleColor : ol.render.canvas.defaultFillStyle);
if (goog.isNull(this.textFillState_)) { if (!this.textFillState_) {
this.textFillState_ = { this.textFillState_ = {
fillStyle: fillStyle fillStyle: fillStyle
}; };
@@ -1717,7 +1712,7 @@ ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle) {
} }
} }
var textStrokeStyle = textStyle.getStroke(); var textStrokeStyle = textStyle.getStroke();
if (goog.isNull(textStrokeStyle)) { if (!textStrokeStyle) {
this.textStrokeState_ = null; this.textStrokeState_ = null;
} else { } else {
var textStrokeStyleColor = textStrokeStyle.getColor(); var textStrokeStyleColor = textStrokeStyle.getColor();
@@ -1736,9 +1731,9 @@ ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle) {
textStrokeStyleWidth : ol.render.canvas.defaultLineWidth; textStrokeStyleWidth : ol.render.canvas.defaultLineWidth;
var miterLimit = textStrokeStyleMiterLimit !== undefined ? var miterLimit = textStrokeStyleMiterLimit !== undefined ?
textStrokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit; textStrokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit;
var strokeStyle = ol.color.asString(!goog.isNull(textStrokeStyleColor) ? var strokeStyle = ol.color.asString(textStrokeStyleColor ?
textStrokeStyleColor : ol.render.canvas.defaultStrokeStyle); textStrokeStyleColor : ol.render.canvas.defaultStrokeStyle);
if (goog.isNull(this.textStrokeState_)) { if (!this.textStrokeState_) {
this.textStrokeState_ = { this.textStrokeState_ = {
lineCap: lineCap, lineCap: lineCap,
lineDash: lineDash, lineDash: lineDash,
@@ -1771,7 +1766,7 @@ ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle) {
textTextAlign : ol.render.canvas.defaultTextAlign; textTextAlign : ol.render.canvas.defaultTextAlign;
var textBaseline = textTextBaseline !== undefined ? var textBaseline = textTextBaseline !== undefined ?
textTextBaseline : ol.render.canvas.defaultTextBaseline; textTextBaseline : ol.render.canvas.defaultTextBaseline;
if (goog.isNull(this.textState_)) { if (!this.textState_) {
this.textState_ = { this.textState_ = {
font: font, font: font,
textAlign: textAlign, textAlign: textAlign,

View File

@@ -58,14 +58,14 @@ ol.renderer.vector.renderCircleGeometry_ =
'geometry should be an ol.geom.Circle'); 'geometry should be an ol.geom.Circle');
var fillStyle = style.getFill(); var fillStyle = style.getFill();
var strokeStyle = style.getStroke(); var strokeStyle = style.getStroke();
if (!goog.isNull(fillStyle) || !goog.isNull(strokeStyle)) { if (fillStyle || strokeStyle) {
var polygonReplay = replayGroup.getReplay( var polygonReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.POLYGON); style.getZIndex(), ol.render.ReplayType.POLYGON);
polygonReplay.setFillStrokeStyle(fillStyle, strokeStyle); polygonReplay.setFillStrokeStyle(fillStyle, strokeStyle);
polygonReplay.drawCircleGeometry(geometry, feature); polygonReplay.drawCircleGeometry(geometry, feature);
} }
var textStyle = style.getText(); var textStyle = style.getText();
if (!goog.isNull(textStyle)) { if (textStyle) {
var textReplay = replayGroup.getReplay( var textReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.TEXT); style.getZIndex(), ol.render.ReplayType.TEXT);
textReplay.setTextStyle(textStyle); textReplay.setTextStyle(textStyle);
@@ -89,7 +89,7 @@ ol.renderer.vector.renderFeature = function(
var loading = false; var loading = false;
var imageStyle, imageState; var imageStyle, imageState;
imageStyle = style.getImage(); imageStyle = style.getImage();
if (!goog.isNull(imageStyle)) { if (imageStyle) {
imageState = imageStyle.getImageState(); imageState = imageStyle.getImageState();
if (imageState == ol.style.ImageState.LOADED || if (imageState == ol.style.ImageState.LOADED ||
imageState == ol.style.ImageState.ERROR) { imageState == ol.style.ImageState.ERROR) {
@@ -168,14 +168,14 @@ ol.renderer.vector.renderLineStringGeometry_ =
goog.asserts.assertInstanceof(geometry, ol.geom.LineString, goog.asserts.assertInstanceof(geometry, ol.geom.LineString,
'geometry should be an ol.geom.LineString'); 'geometry should be an ol.geom.LineString');
var strokeStyle = style.getStroke(); var strokeStyle = style.getStroke();
if (!goog.isNull(strokeStyle)) { if (strokeStyle) {
var lineStringReplay = replayGroup.getReplay( var lineStringReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.LINE_STRING); style.getZIndex(), ol.render.ReplayType.LINE_STRING);
lineStringReplay.setFillStrokeStyle(null, strokeStyle); lineStringReplay.setFillStrokeStyle(null, strokeStyle);
lineStringReplay.drawLineStringGeometry(geometry, feature); lineStringReplay.drawLineStringGeometry(geometry, feature);
} }
var textStyle = style.getText(); var textStyle = style.getText();
if (!goog.isNull(textStyle)) { if (textStyle) {
var textReplay = replayGroup.getReplay( var textReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.TEXT); style.getZIndex(), ol.render.ReplayType.TEXT);
textReplay.setTextStyle(textStyle); textReplay.setTextStyle(textStyle);
@@ -196,14 +196,14 @@ ol.renderer.vector.renderMultiLineStringGeometry_ =
goog.asserts.assertInstanceof(geometry, ol.geom.MultiLineString, goog.asserts.assertInstanceof(geometry, ol.geom.MultiLineString,
'geometry should be an ol.geom.MultiLineString'); 'geometry should be an ol.geom.MultiLineString');
var strokeStyle = style.getStroke(); var strokeStyle = style.getStroke();
if (!goog.isNull(strokeStyle)) { if (strokeStyle) {
var lineStringReplay = replayGroup.getReplay( var lineStringReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.LINE_STRING); style.getZIndex(), ol.render.ReplayType.LINE_STRING);
lineStringReplay.setFillStrokeStyle(null, strokeStyle); lineStringReplay.setFillStrokeStyle(null, strokeStyle);
lineStringReplay.drawMultiLineStringGeometry(geometry, feature); lineStringReplay.drawMultiLineStringGeometry(geometry, feature);
} }
var textStyle = style.getText(); var textStyle = style.getText();
if (!goog.isNull(textStyle)) { if (textStyle) {
var textReplay = replayGroup.getReplay( var textReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.TEXT); style.getZIndex(), ol.render.ReplayType.TEXT);
textReplay.setTextStyle(textStyle); textReplay.setTextStyle(textStyle);
@@ -227,14 +227,14 @@ ol.renderer.vector.renderMultiPolygonGeometry_ =
'geometry should be an ol.geom.MultiPolygon'); 'geometry should be an ol.geom.MultiPolygon');
var fillStyle = style.getFill(); var fillStyle = style.getFill();
var strokeStyle = style.getStroke(); var strokeStyle = style.getStroke();
if (!goog.isNull(strokeStyle) || !goog.isNull(fillStyle)) { if (strokeStyle || fillStyle) {
var polygonReplay = replayGroup.getReplay( var polygonReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.POLYGON); style.getZIndex(), ol.render.ReplayType.POLYGON);
polygonReplay.setFillStrokeStyle(fillStyle, strokeStyle); polygonReplay.setFillStrokeStyle(fillStyle, strokeStyle);
polygonReplay.drawMultiPolygonGeometry(geometry, feature); polygonReplay.drawMultiPolygonGeometry(geometry, feature);
} }
var textStyle = style.getText(); var textStyle = style.getText();
if (!goog.isNull(textStyle)) { if (textStyle) {
var textReplay = replayGroup.getReplay( var textReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.TEXT); style.getZIndex(), ol.render.ReplayType.TEXT);
textReplay.setTextStyle(textStyle); textReplay.setTextStyle(textStyle);
@@ -257,7 +257,7 @@ ol.renderer.vector.renderPointGeometry_ =
goog.asserts.assertInstanceof(geometry, ol.geom.Point, goog.asserts.assertInstanceof(geometry, ol.geom.Point,
'geometry should be an ol.geom.Point'); 'geometry should be an ol.geom.Point');
var imageStyle = style.getImage(); var imageStyle = style.getImage();
if (!goog.isNull(imageStyle)) { if (imageStyle) {
if (imageStyle.getImageState() != ol.style.ImageState.LOADED) { if (imageStyle.getImageState() != ol.style.ImageState.LOADED) {
return; return;
} }
@@ -267,7 +267,7 @@ ol.renderer.vector.renderPointGeometry_ =
imageReplay.drawPointGeometry(geometry, feature); imageReplay.drawPointGeometry(geometry, feature);
} }
var textStyle = style.getText(); var textStyle = style.getText();
if (!goog.isNull(textStyle)) { if (textStyle) {
var textReplay = replayGroup.getReplay( var textReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.TEXT); style.getZIndex(), ol.render.ReplayType.TEXT);
textReplay.setTextStyle(textStyle); textReplay.setTextStyle(textStyle);
@@ -288,7 +288,7 @@ ol.renderer.vector.renderMultiPointGeometry_ =
goog.asserts.assertInstanceof(geometry, ol.geom.MultiPoint, goog.asserts.assertInstanceof(geometry, ol.geom.MultiPoint,
'geometry should be an ol.goem.MultiPoint'); 'geometry should be an ol.goem.MultiPoint');
var imageStyle = style.getImage(); var imageStyle = style.getImage();
if (!goog.isNull(imageStyle)) { if (imageStyle) {
if (imageStyle.getImageState() != ol.style.ImageState.LOADED) { if (imageStyle.getImageState() != ol.style.ImageState.LOADED) {
return; return;
} }
@@ -298,7 +298,7 @@ ol.renderer.vector.renderMultiPointGeometry_ =
imageReplay.drawMultiPointGeometry(geometry, feature); imageReplay.drawMultiPointGeometry(geometry, feature);
} }
var textStyle = style.getText(); var textStyle = style.getText();
if (!goog.isNull(textStyle)) { if (textStyle) {
var textReplay = replayGroup.getReplay( var textReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.TEXT); style.getZIndex(), ol.render.ReplayType.TEXT);
textReplay.setTextStyle(textStyle); textReplay.setTextStyle(textStyle);
@@ -322,14 +322,14 @@ ol.renderer.vector.renderPolygonGeometry_ =
'geometry should be an ol.geom.Polygon'); 'geometry should be an ol.geom.Polygon');
var fillStyle = style.getFill(); var fillStyle = style.getFill();
var strokeStyle = style.getStroke(); var strokeStyle = style.getStroke();
if (!goog.isNull(fillStyle) || !goog.isNull(strokeStyle)) { if (fillStyle || strokeStyle) {
var polygonReplay = replayGroup.getReplay( var polygonReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.POLYGON); style.getZIndex(), ol.render.ReplayType.POLYGON);
polygonReplay.setFillStrokeStyle(fillStyle, strokeStyle); polygonReplay.setFillStrokeStyle(fillStyle, strokeStyle);
polygonReplay.drawPolygonGeometry(geometry, feature); polygonReplay.drawPolygonGeometry(geometry, feature);
} }
var textStyle = style.getText(); var textStyle = style.getText();
if (!goog.isNull(textStyle)) { if (textStyle) {
var textReplay = replayGroup.getReplay( var textReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.TEXT); style.getZIndex(), ol.render.ReplayType.TEXT);
textReplay.setTextStyle(textStyle); textReplay.setTextStyle(textStyle);

View File

@@ -222,9 +222,9 @@ ol.render.webgl.ImageReplay.prototype.getDeleteResourcesFunction =
// be used by other ImageReplay instances (for other layers). And // be used by other ImageReplay instances (for other layers). And
// they will be deleted when disposing of the ol.webgl.Context // they will be deleted when disposing of the ol.webgl.Context
// object. // object.
goog.asserts.assert(!goog.isNull(this.verticesBuffer_), goog.asserts.assert(this.verticesBuffer_,
'verticesBuffer must not be null'); 'verticesBuffer must not be null');
goog.asserts.assert(!goog.isNull(this.indicesBuffer_), goog.asserts.assert(this.indicesBuffer_,
'indicesBuffer must not be null'); 'indicesBuffer must not be null');
var verticesBuffer = this.verticesBuffer_; var verticesBuffer = this.verticesBuffer_;
var indicesBuffer = this.indicesBuffer_; var indicesBuffer = this.indicesBuffer_;
@@ -514,12 +514,12 @@ ol.render.webgl.ImageReplay.prototype.replay = function(context,
var gl = context.getGL(); var gl = context.getGL();
// bind the vertices buffer // bind the vertices buffer
goog.asserts.assert(!goog.isNull(this.verticesBuffer_), goog.asserts.assert(this.verticesBuffer_,
'verticesBuffer must not be null'); 'verticesBuffer must not be null');
context.bindBuffer(goog.webgl.ARRAY_BUFFER, this.verticesBuffer_); context.bindBuffer(goog.webgl.ARRAY_BUFFER, this.verticesBuffer_);
// bind the indices buffer // bind the indices buffer
goog.asserts.assert(!goog.isNull(this.indicesBuffer_), goog.asserts.assert(this.indicesBuffer_,
'indecesBuffer must not be null'); 'indecesBuffer must not be null');
context.bindBuffer(goog.webgl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer_); context.bindBuffer(goog.webgl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer_);
@@ -532,7 +532,7 @@ ol.render.webgl.ImageReplay.prototype.replay = function(context,
// get the locations // get the locations
var locations; var locations;
if (goog.isNull(this.defaultLocations_)) { if (!this.defaultLocations_) {
locations = locations =
new ol.render.webgl.imagereplay.shader.Default.Locations(gl, program); new ol.render.webgl.imagereplay.shader.Default.Locations(gl, program);
this.defaultLocations_ = locations; this.defaultLocations_ = locations;
@@ -863,20 +863,20 @@ ol.render.webgl.ImageReplay.prototype.setImageStyle = function(imageStyle) {
var rotation = imageStyle.getRotation(); var rotation = imageStyle.getRotation();
var size = imageStyle.getSize(); var size = imageStyle.getSize();
var scale = imageStyle.getScale(); var scale = imageStyle.getScale();
goog.asserts.assert(!goog.isNull(anchor), 'imageStyle anchor is not null'); goog.asserts.assert(anchor, 'imageStyle anchor is not null');
goog.asserts.assert(!goog.isNull(image), 'imageStyle image is not null'); goog.asserts.assert(image, 'imageStyle image is not null');
goog.asserts.assert(!goog.isNull(imageSize), goog.asserts.assert(imageSize,
'imageStyle imageSize is not null'); 'imageStyle imageSize is not null');
goog.asserts.assert(!goog.isNull(hitDetectionImage), goog.asserts.assert(hitDetectionImage,
'imageStyle hitDetectionImage is not null'); 'imageStyle hitDetectionImage is not null');
goog.asserts.assert(!goog.isNull(hitDetectionImageSize), goog.asserts.assert(hitDetectionImageSize,
'imageStyle hitDetectionImageSize is not null'); 'imageStyle hitDetectionImageSize is not null');
goog.asserts.assert(opacity !== undefined, 'imageStyle opacity is defined'); goog.asserts.assert(opacity !== undefined, 'imageStyle opacity is defined');
goog.asserts.assert(!goog.isNull(origin), 'imageStyle origin is not null'); goog.asserts.assert(origin, 'imageStyle origin is not null');
goog.asserts.assert(rotateWithView !== undefined, goog.asserts.assert(rotateWithView !== undefined,
'imageStyle rotateWithView is defined'); 'imageStyle rotateWithView is defined');
goog.asserts.assert(rotation !== undefined, 'imageStyle rotation is defined'); goog.asserts.assert(rotation !== undefined, 'imageStyle rotation is defined');
goog.asserts.assert(!goog.isNull(size), 'imageStyle size is not null'); goog.asserts.assert(size, 'imageStyle size is not null');
goog.asserts.assert(scale !== undefined, 'imageStyle scale is defined'); goog.asserts.assert(scale !== undefined, 'imageStyle scale is defined');
var currentImage; var currentImage;