diff --git a/src/ol/render/box.js b/src/ol/render/box.js index 59bc2aae9a..7a416a392a 100644 --- a/src/ol/render/box.js +++ b/src/ol/render/box.js @@ -62,11 +62,11 @@ goog.inherits(ol.render.Box, goog.Disposable); * @return {ol.geom.Polygon} Geometry. */ ol.render.Box.prototype.createGeometry_ = function() { - goog.asserts.assert(!goog.isNull(this.startPixel_), - 'this.startPixel_ should not be null'); - goog.asserts.assert(!goog.isNull(this.endPixel_), - 'this.endPixel_ should not be null'); - goog.asserts.assert(!goog.isNull(this.map_), 'this.map_ should not be null'); + goog.asserts.assert(this.startPixel_, + 'this.startPixel_ must be truthy'); + goog.asserts.assert(this.endPixel_, + 'this.endPixel_ must be truthy'); + goog.asserts.assert(this.map_, 'this.map_ must be truthy'); var startPixel = this.startPixel_; var endPixel = this.endPixel_; var pixels = [ @@ -98,7 +98,7 @@ ol.render.Box.prototype.handleMapPostCompose_ = function(event) { var geometry = this.geometry_; goog.asserts.assert(geometry, 'geometry should be defined'); 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 event.vectorContext.drawAsync(Infinity, function(render) { render.setFillStrokeStyle(style.getFill(), style.getStroke()); @@ -120,9 +120,7 @@ ol.render.Box.prototype.getGeometry = function() { * @private */ ol.render.Box.prototype.requestMapRenderFrame_ = function() { - if (!goog.isNull(this.map_) && - !goog.isNull(this.startPixel_) && - !goog.isNull(this.endPixel_)) { + if (this.map_ && this.startPixel_ && this.endPixel_) { this.map_.render(); } }; @@ -132,14 +130,14 @@ ol.render.Box.prototype.requestMapRenderFrame_ = function() { * @param {ol.Map} map Map. */ ol.render.Box.prototype.setMap = function(map) { - if (!goog.isNull(this.postComposeListenerKey_)) { + if (this.postComposeListenerKey_) { goog.events.unlistenByKey(this.postComposeListenerKey_); this.postComposeListenerKey_ = null; this.map_.render(); this.map_ = null; } this.map_ = map; - if (!goog.isNull(this.map_)) { + if (this.map_) { this.postComposeListenerKey_ = goog.events.listen( map, ol.render.EventType.POSTCOMPOSE, this.handleMapPostCompose_, false, this); diff --git a/src/ol/render/canvas/canvasimmediate.js b/src/ol/render/canvas/canvasimmediate.js index 662eb13acb..2d90610ffe 100644 --- a/src/ol/render/canvas/canvasimmediate.js +++ b/src/ol/render/canvas/canvasimmediate.js @@ -249,7 +249,7 @@ ol.render.canvas.Immediate = */ ol.render.canvas.Immediate.prototype.drawImages_ = function(flatCoordinates, offset, end, stride) { - if (goog.isNull(this.image_)) { + if (!this.image_) { return; } 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_ = function(flatCoordinates, offset, end, stride) { - if (goog.isNull(this.textState_) || this.text_ === '') { + if (!this.textState_ || this.text_ === '') { return; } - if (!goog.isNull(this.textFillState_)) { + if (this.textFillState_) { this.setContextFillState_(this.textFillState_); } - if (!goog.isNull(this.textStrokeState_)) { + if (this.textStrokeState_) { this.setContextStrokeState_(this.textStrokeState_); } 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, 1, 3)); } - if (!goog.isNull(this.textStrokeState_)) { + if (this.textStrokeState_) { context.strokeText(this.text_, x, y); } - if (!goog.isNull(this.textFillState_)) { + if (this.textFillState_) { context.fillText(this.text_, x, y); } } @@ -437,11 +437,11 @@ ol.render.canvas.Immediate.prototype.drawCircleGeometry = if (!ol.extent.intersects(this.extent_, circleGeometry.getExtent())) { return; } - if (!goog.isNull(this.fillState_) || !goog.isNull(this.strokeState_)) { - if (!goog.isNull(this.fillState_)) { + if (this.fillState_ || this.strokeState_) { + if (this.fillState_) { this.setContextFillState_(this.fillState_); } - if (!goog.isNull(this.strokeState_)) { + if (this.strokeState_) { this.setContextStrokeState_(this.strokeState_); } var pixelCoordinates = ol.geom.transformSimpleGeometry2D( @@ -453,10 +453,10 @@ ol.render.canvas.Immediate.prototype.drawCircleGeometry = context.beginPath(); context.arc( pixelCoordinates[0], pixelCoordinates[1], radius, 0, 2 * Math.PI); - if (!goog.isNull(this.fillState_)) { + if (this.fillState_) { context.fill(); } - if (!goog.isNull(this.strokeState_)) { + if (this.strokeState_) { context.stroke(); } } @@ -535,7 +535,7 @@ ol.render.canvas.Immediate.prototype.drawPointGeometry = function(pointGeometry, feature) { var flatCoordinates = pointGeometry.getFlatCoordinates(); var stride = pointGeometry.getStride(); - if (!goog.isNull(this.image_)) { + if (this.image_) { this.drawImages_(flatCoordinates, 0, flatCoordinates.length, stride); } if (this.text_ !== '') { @@ -556,7 +556,7 @@ ol.render.canvas.Immediate.prototype.drawMultiPointGeometry = function(multiPointGeometry, feature) { var flatCoordinates = multiPointGeometry.getFlatCoordinates(); var stride = multiPointGeometry.getStride(); - if (!goog.isNull(this.image_)) { + if (this.image_) { this.drawImages_(flatCoordinates, 0, flatCoordinates.length, stride); } if (this.text_ !== '') { @@ -578,7 +578,7 @@ ol.render.canvas.Immediate.prototype.drawLineStringGeometry = if (!ol.extent.intersects(this.extent_, lineStringGeometry.getExtent())) { return; } - if (!goog.isNull(this.strokeState_)) { + if (this.strokeState_) { this.setContextStrokeState_(this.strokeState_); var context = this.context_; var flatCoordinates = lineStringGeometry.getFlatCoordinates(); @@ -609,7 +609,7 @@ ol.render.canvas.Immediate.prototype.drawMultiLineStringGeometry = if (!ol.extent.intersects(this.extent_, geometryExtent)) { return; } - if (!goog.isNull(this.strokeState_)) { + if (this.strokeState_) { this.setContextStrokeState_(this.strokeState_); var context = this.context_; var flatCoordinates = multiLineStringGeometry.getFlatCoordinates(); @@ -644,21 +644,21 @@ ol.render.canvas.Immediate.prototype.drawPolygonGeometry = if (!ol.extent.intersects(this.extent_, polygonGeometry.getExtent())) { return; } - if (!goog.isNull(this.strokeState_) || !goog.isNull(this.fillState_)) { - if (!goog.isNull(this.fillState_)) { + if (this.strokeState_ || this.fillState_) { + if (this.fillState_) { this.setContextFillState_(this.fillState_); } - if (!goog.isNull(this.strokeState_)) { + if (this.strokeState_) { this.setContextStrokeState_(this.strokeState_); } var context = this.context_; context.beginPath(); this.drawRings_(polygonGeometry.getOrientedFlatCoordinates(), 0, polygonGeometry.getEnds(), polygonGeometry.getStride()); - if (!goog.isNull(this.fillState_)) { + if (this.fillState_) { context.fill(); } - if (!goog.isNull(this.strokeState_)) { + if (this.strokeState_) { context.stroke(); } } @@ -681,11 +681,11 @@ ol.render.canvas.Immediate.prototype.drawMultiPolygonGeometry = if (!ol.extent.intersects(this.extent_, multiPolygonGeometry.getExtent())) { return; } - if (!goog.isNull(this.strokeState_) || !goog.isNull(this.fillState_)) { - if (!goog.isNull(this.fillState_)) { + if (this.strokeState_ || this.fillState_) { + if (this.fillState_) { this.setContextFillState_(this.fillState_); } - if (!goog.isNull(this.strokeState_)) { + if (this.strokeState_) { this.setContextStrokeState_(this.strokeState_); } var context = this.context_; @@ -698,10 +698,10 @@ ol.render.canvas.Immediate.prototype.drawMultiPolygonGeometry = var ends = endss[i]; context.beginPath(); offset = this.drawRings_(flatCoordinates, offset, ends, stride); - if (!goog.isNull(this.fillState_)) { + if (this.fillState_) { context.fill(); } - if (!goog.isNull(this.strokeState_)) { + if (this.strokeState_) { context.stroke(); } } @@ -744,7 +744,7 @@ ol.render.canvas.Immediate.prototype.setContextFillState_ = function(fillState) { var context = this.context_; var contextFillState = this.contextFillState_; - if (goog.isNull(contextFillState)) { + if (!contextFillState) { context.fillStyle = fillState.fillStyle; this.contextFillState_ = { fillStyle: fillState.fillStyle @@ -765,7 +765,7 @@ ol.render.canvas.Immediate.prototype.setContextStrokeState_ = function(strokeState) { var context = this.context_; var contextStrokeState = this.contextStrokeState_; - if (goog.isNull(contextStrokeState)) { + if (!contextStrokeState) { context.lineCap = strokeState.lineCap; if (ol.has.CANVAS_LINE_DASH) { context.setLineDash(strokeState.lineDash); @@ -818,7 +818,7 @@ ol.render.canvas.Immediate.prototype.setContextTextState_ = function(textState) { var context = this.context_; var contextTextState = this.contextTextState_; - if (goog.isNull(contextTextState)) { + if (!contextTextState) { context.font = textState.font; context.textAlign = textState.textAlign; context.textBaseline = textState.textBaseline; @@ -852,16 +852,16 @@ ol.render.canvas.Immediate.prototype.setContextTextState_ = */ ol.render.canvas.Immediate.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) { - if (goog.isNull(fillStyle)) { + if (!fillStyle) { this.fillState_ = null; } else { var fillStyleColor = fillStyle.getColor(); this.fillState_ = { - fillStyle: ol.color.asString(!goog.isNull(fillStyleColor) ? + fillStyle: ol.color.asString(fillStyleColor ? fillStyleColor : ol.render.canvas.defaultFillStyle) }; } - if (goog.isNull(strokeStyle)) { + if (!strokeStyle) { this.strokeState_ = null; } else { var strokeStyleColor = strokeStyle.getColor(); @@ -881,7 +881,7 @@ ol.render.canvas.Immediate.prototype.setFillStrokeStyle = strokeStyleWidth : ol.render.canvas.defaultLineWidth), miterLimit: strokeStyleMiterLimit !== undefined ? strokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit, - strokeStyle: ol.color.asString(!goog.isNull(strokeStyleColor) ? + strokeStyle: ol.color.asString(strokeStyleColor ? strokeStyleColor : ol.render.canvas.defaultStrokeStyle) }; } @@ -896,7 +896,7 @@ ol.render.canvas.Immediate.prototype.setFillStrokeStyle = * @api */ ol.render.canvas.Immediate.prototype.setImageStyle = function(imageStyle) { - if (goog.isNull(imageStyle)) { + if (!imageStyle) { this.image_ = null; } else { var imageAnchor = imageStyle.getAnchor(); @@ -904,14 +904,10 @@ ol.render.canvas.Immediate.prototype.setImageStyle = function(imageStyle) { var imageImage = imageStyle.getImage(1); var imageOrigin = imageStyle.getOrigin(); var imageSize = imageStyle.getSize(); - goog.asserts.assert(!goog.isNull(imageAnchor), - 'imageAnchor should not be null'); - goog.asserts.assert(!goog.isNull(imageImage), - 'imageImage should not be null'); - goog.asserts.assert(!goog.isNull(imageOrigin), - 'imageOrigin should not be null'); - goog.asserts.assert(!goog.isNull(imageSize), - 'imageSize should not be null'); + goog.asserts.assert(imageAnchor, 'imageAnchor must be truthy'); + goog.asserts.assert(imageImage, 'imageImage must be truthy'); + goog.asserts.assert(imageOrigin, 'imageOrigin must be truthy'); + goog.asserts.assert(imageSize, 'imageSize must be truthy'); this.imageAnchorX_ = imageAnchor[0]; this.imageAnchorY_ = imageAnchor[1]; this.imageHeight_ = imageSize[1]; @@ -936,21 +932,21 @@ ol.render.canvas.Immediate.prototype.setImageStyle = function(imageStyle) { * @api */ ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) { - if (goog.isNull(textStyle)) { + if (!textStyle) { this.text_ = ''; } else { var textFillStyle = textStyle.getFill(); - if (goog.isNull(textFillStyle)) { + if (!textFillStyle) { this.textFillState_ = null; } else { var textFillStyleColor = textFillStyle.getColor(); this.textFillState_ = { - fillStyle: ol.color.asString(!goog.isNull(textFillStyleColor) ? + fillStyle: ol.color.asString(textFillStyleColor ? textFillStyleColor : ol.render.canvas.defaultFillStyle) }; } var textStrokeStyle = textStyle.getStroke(); - if (goog.isNull(textStrokeStyle)) { + if (!textStrokeStyle) { this.textStrokeState_ = null; } else { var textStrokeStyleColor = textStrokeStyle.getColor(); @@ -970,7 +966,7 @@ ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) { textStrokeStyleWidth : ol.render.canvas.defaultLineWidth, miterLimit: textStrokeStyleMiterLimit !== undefined ? textStrokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit, - strokeStyle: ol.color.asString(!goog.isNull(textStrokeStyleColor) ? + strokeStyle: ol.color.asString(textStrokeStyleColor ? textStrokeStyleColor : ol.render.canvas.defaultStrokeStyle) }; } diff --git a/src/ol/render/canvas/canvasreplay.js b/src/ol/render/canvas/canvasreplay.js index cafb415cd0..2043330560 100644 --- a/src/ol/render/canvas/canvasreplay.js +++ b/src/ol/render/canvas/canvasreplay.js @@ -451,7 +451,7 @@ ol.render.canvas.Replay.prototype.replay_ = function( '5th instruction should be a string'); goog.asserts.assert(goog.isNumber(instruction[5]), '6th instruction should be a number'); - goog.asserts.assert(!goog.isNull(instruction[6]), + goog.asserts.assert(instruction[6], '7th instruction should not be null'); var usePixelRatio = instruction[7] !== undefined ? instruction[7] : true; @@ -568,11 +568,11 @@ ol.render.canvas.Replay.prototype.reverseHitDetectionInstructions_ = * @param {ol.Feature} feature 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_[2] = this.instructions.length; this.beginGeometryInstruction1_ = null; - goog.asserts.assert(!goog.isNull(this.beginGeometryInstruction2_), + goog.asserts.assert(this.beginGeometryInstruction2_, 'this.beginGeometryInstruction2_ should not be null'); this.beginGeometryInstruction2_[2] = this.hitDetectionInstructions.length; this.beginGeometryInstruction2_ = null; @@ -716,7 +716,7 @@ ol.render.canvas.ImageReplay.prototype.drawCoordinates_ = */ ol.render.canvas.ImageReplay.prototype.drawPointGeometry = function(pointGeometry, feature) { - if (goog.isNull(this.image_)) { + if (!this.image_) { return; } goog.asserts.assert(this.anchorX_ !== undefined, @@ -769,7 +769,7 @@ ol.render.canvas.ImageReplay.prototype.drawPointGeometry = */ ol.render.canvas.ImageReplay.prototype.drawMultiPointGeometry = function(multiPointGeometry, feature) { - if (goog.isNull(this.image_)) { + if (!this.image_) { return; } goog.asserts.assert(this.anchorX_ !== undefined, @@ -843,19 +843,18 @@ ol.render.canvas.ImageReplay.prototype.finish = function() { * @inheritDoc */ ol.render.canvas.ImageReplay.prototype.setImageStyle = function(imageStyle) { - goog.asserts.assert(!goog.isNull(imageStyle), - 'imageStyle should not be null'); + goog.asserts.assert(imageStyle, 'imageStyle should not be null'); 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(); - 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); - goog.asserts.assert(!goog.isNull(hitDetectionImage), + goog.asserts.assert(hitDetectionImage, 'hitDetectionImage should not be null'); 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(); - 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.anchorY_ = anchor[1]; this.hitDetectionImage_ = hitDetectionImage; @@ -947,7 +946,7 @@ ol.render.canvas.LineStringReplay.prototype.drawFlatCoordinates_ = * @inheritDoc */ ol.render.canvas.LineStringReplay.prototype.getBufferedMaxExtent = function() { - if (goog.isNull(this.bufferedMaxExtent_)) { + if (!this.bufferedMaxExtent_) { this.bufferedMaxExtent_ = ol.extent.clone(this.maxExtent); if (this.maxLineWidth > 0) { var width = this.resolution * (this.maxLineWidth + 1) / 2; @@ -972,7 +971,7 @@ ol.render.canvas.LineStringReplay.prototype.setStrokeStyle_ = function() { goog.asserts.assert(strokeStyle !== undefined, 'strokeStyle 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(lineWidth !== undefined, 'lineWidth 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 = function(lineStringGeometry, feature) { 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 lineWidth = state.lineWidth; if (strokeStyle === undefined || lineWidth === undefined) { @@ -1035,7 +1034,7 @@ ol.render.canvas.LineStringReplay.prototype.drawLineStringGeometry = ol.render.canvas.LineStringReplay.prototype.drawMultiLineStringGeometry = function(multiLineStringGeometry, feature) { 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 lineWidth = state.lineWidth; if (strokeStyle === undefined || lineWidth === undefined) { @@ -1067,7 +1066,7 @@ ol.render.canvas.LineStringReplay.prototype.drawMultiLineStringGeometry = */ ol.render.canvas.LineStringReplay.prototype.finish = function() { 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) { 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 = function(fillStyle, strokeStyle) { - goog.asserts.assert(!goog.isNull(this.state_), - 'this.state_ should not be null'); - goog.asserts.assert(goog.isNull(fillStyle), 'fillStyle should be null'); - goog.asserts.assert(!goog.isNull(strokeStyle), - 'strokeStyle should not be null'); + goog.asserts.assert(this.state_, 'this.state_ should not be null'); + goog.asserts.assert(!fillStyle, 'fillStyle should be null'); + goog.asserts.assert(strokeStyle, 'strokeStyle should not be null'); 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); var strokeStyleLineCap = strokeStyle.getLineCap(); this.state_.lineCap = strokeStyleLineCap !== undefined ? strokeStyleLineCap : ol.render.canvas.defaultLineCap; var strokeStyleLineDash = strokeStyle.getLineDash(); - this.state_.lineDash = !goog.isNull(strokeStyleLineDash) ? + this.state_.lineDash = strokeStyleLineDash ? strokeStyleLineDash : ol.render.canvas.defaultLineDash; var strokeStyleLineJoin = strokeStyle.getLineJoin(); this.state_.lineJoin = strokeStyleLineJoin !== undefined ? @@ -1217,7 +1214,7 @@ ol.render.canvas.PolygonReplay.prototype.drawFlatCoordinatess_ = ol.render.canvas.PolygonReplay.prototype.drawCircleGeometry = function(circleGeometry, feature) { 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 strokeStyle = state.strokeStyle; if (fillStyle === undefined && strokeStyle === undefined) { @@ -1270,7 +1267,7 @@ ol.render.canvas.PolygonReplay.prototype.drawCircleGeometry = ol.render.canvas.PolygonReplay.prototype.drawPolygonGeometry = function(polygonGeometry, feature) { 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 strokeStyle = state.strokeStyle; if (fillStyle === undefined && strokeStyle === undefined) { @@ -1306,7 +1303,7 @@ ol.render.canvas.PolygonReplay.prototype.drawPolygonGeometry = ol.render.canvas.PolygonReplay.prototype.drawMultiPolygonGeometry = function(multiPolygonGeometry, feature) { 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 strokeStyle = state.strokeStyle; if (fillStyle === undefined && strokeStyle === undefined) { @@ -1345,8 +1342,7 @@ ol.render.canvas.PolygonReplay.prototype.drawMultiPolygonGeometry = * @inheritDoc */ ol.render.canvas.PolygonReplay.prototype.finish = function() { - goog.asserts.assert(!goog.isNull(this.state_), - 'this.state_ should not be null'); + goog.asserts.assert(this.state_, 'this.state_ should not be null'); this.reverseHitDetectionInstructions_(); this.state_ = null; // We want to preserve topology when drawing polygons. Polygons are @@ -1368,7 +1364,7 @@ ol.render.canvas.PolygonReplay.prototype.finish = function() { * @inheritDoc */ ol.render.canvas.PolygonReplay.prototype.getBufferedMaxExtent = function() { - if (goog.isNull(this.bufferedMaxExtent_)) { + if (!this.bufferedMaxExtent_) { this.bufferedMaxExtent_ = ol.extent.clone(this.maxExtent); if (this.maxLineWidth > 0) { 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 = function(fillStyle, strokeStyle) { - goog.asserts.assert(!goog.isNull(this.state_), - 'this.state_ should not be null'); - goog.asserts.assert(!goog.isNull(fillStyle) || !goog.isNull(strokeStyle), + goog.asserts.assert(this.state_, 'this.state_ should not be null'); + goog.asserts.assert(fillStyle || strokeStyle, 'fillStyle or strokeStyle should not be null'); var state = this.state_; - if (!goog.isNull(fillStyle)) { + if (fillStyle) { var fillStyleColor = fillStyle.getColor(); - state.fillStyle = ol.color.asString(!goog.isNull(fillStyleColor) ? + state.fillStyle = ol.color.asString(fillStyleColor ? fillStyleColor : ol.render.canvas.defaultFillStyle); } else { state.fillStyle = undefined; } - if (!goog.isNull(strokeStyle)) { + if (strokeStyle) { var strokeStyleColor = strokeStyle.getColor(); - state.strokeStyle = ol.color.asString(!goog.isNull(strokeStyleColor) ? + state.strokeStyle = ol.color.asString(strokeStyleColor ? strokeStyleColor : ol.render.canvas.defaultStrokeStyle); var strokeStyleLineCap = strokeStyle.getLineCap(); state.lineCap = strokeStyleLineCap !== undefined ? strokeStyleLineCap : ol.render.canvas.defaultLineCap; var strokeStyleLineDash = strokeStyle.getLineDash(); - state.lineDash = !goog.isNull(strokeStyleLineDash) ? + state.lineDash = strokeStyleLineDash ? strokeStyleLineDash.slice() : ol.render.canvas.defaultLineDash; var strokeStyleLineJoin = strokeStyle.getLineJoin(); state.lineJoin = strokeStyleLineJoin !== undefined ? @@ -1451,7 +1446,7 @@ ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyles_ = function() { } if (strokeStyle !== undefined) { 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(lineWidth !== undefined, 'lineWidth should be defined'); 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 = function(flatCoordinates, offset, end, stride, geometry, feature) { if (this.text_ === '' || - goog.isNull(this.textState_) || - (goog.isNull(this.textFillState_) && - goog.isNull(this.textStrokeState_))) { + !this.textState_ || + (this.textFillState_ && + !this.textStrokeState_)) { return; } - if (!goog.isNull(this.textFillState_)) { + if (this.textFillState_) { this.setReplayFillState_(this.textFillState_); } - if (!goog.isNull(this.textStrokeState_)) { + if (this.textStrokeState_) { this.setReplayStrokeState_(this.textStrokeState_); } this.setReplayTextState_(this.textState_); @@ -1582,8 +1577,8 @@ ol.render.canvas.TextReplay.prototype.drawText = var myBegin = this.coordinates.length; var myEnd = this.appendFlatCoordinates(flatCoordinates, offset, end, stride, false); - var fill = !goog.isNull(this.textFillState_); - var stroke = !goog.isNull(this.textStrokeState_); + var fill = this.textFillState_; + var stroke = this.textStrokeState_; var drawTextInstruction = [ ol.render.canvas.Instruction.DRAW_TEXT, myBegin, myEnd, this.text_, this.textOffsetX_, this.textOffsetY_, this.textRotation_, this.textScale_, @@ -1601,7 +1596,7 @@ ol.render.canvas.TextReplay.prototype.drawText = ol.render.canvas.TextReplay.prototype.setReplayFillState_ = function(fillState) { var replayFillState = this.replayFillState_; - if (!goog.isNull(replayFillState) && + if (replayFillState && replayFillState.fillStyle == fillState.fillStyle) { return; } @@ -1609,7 +1604,7 @@ ol.render.canvas.TextReplay.prototype.setReplayFillState_ = [ol.render.canvas.Instruction.SET_FILL_STYLE, fillState.fillStyle]; this.instructions.push(setFillStyleInstruction); this.hitDetectionInstructions.push(setFillStyleInstruction); - if (goog.isNull(replayFillState)) { + if (!replayFillState) { this.replayFillState_ = { fillStyle: fillState.fillStyle }; @@ -1626,7 +1621,7 @@ ol.render.canvas.TextReplay.prototype.setReplayFillState_ = ol.render.canvas.TextReplay.prototype.setReplayStrokeState_ = function(strokeState) { var replayStrokeState = this.replayStrokeState_; - if (!goog.isNull(replayStrokeState) && + if (replayStrokeState && replayStrokeState.lineCap == strokeState.lineCap && replayStrokeState.lineDash == strokeState.lineDash && replayStrokeState.lineJoin == strokeState.lineJoin && @@ -1642,7 +1637,7 @@ ol.render.canvas.TextReplay.prototype.setReplayStrokeState_ = ]; this.instructions.push(setStrokeStyleInstruction); this.hitDetectionInstructions.push(setStrokeStyleInstruction); - if (goog.isNull(replayStrokeState)) { + if (!replayStrokeState) { this.replayStrokeState_ = { lineCap: strokeState.lineCap, lineDash: strokeState.lineDash, @@ -1669,7 +1664,7 @@ ol.render.canvas.TextReplay.prototype.setReplayStrokeState_ = ol.render.canvas.TextReplay.prototype.setReplayTextState_ = function(textState) { var replayTextState = this.replayTextState_; - if (!goog.isNull(replayTextState) && + if (replayTextState && replayTextState.font == textState.font && replayTextState.textAlign == textState.textAlign && replayTextState.textBaseline == textState.textBaseline) { @@ -1679,7 +1674,7 @@ ol.render.canvas.TextReplay.prototype.setReplayTextState_ = textState.font, textState.textAlign, textState.textBaseline]; this.instructions.push(setTextStyleInstruction); this.hitDetectionInstructions.push(setTextStyleInstruction); - if (goog.isNull(replayTextState)) { + if (!replayTextState) { this.replayTextState_ = { font: textState.font, textAlign: textState.textAlign, @@ -1697,17 +1692,17 @@ ol.render.canvas.TextReplay.prototype.setReplayTextState_ = * @inheritDoc */ ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle) { - if (goog.isNull(textStyle)) { + if (!textStyle) { this.text_ = ''; } else { var textFillStyle = textStyle.getFill(); - if (goog.isNull(textFillStyle)) { + if (!textFillStyle) { this.textFillState_ = null; } else { var textFillStyleColor = textFillStyle.getColor(); - var fillStyle = ol.color.asString(!goog.isNull(textFillStyleColor) ? + var fillStyle = ol.color.asString(textFillStyleColor ? textFillStyleColor : ol.render.canvas.defaultFillStyle); - if (goog.isNull(this.textFillState_)) { + if (!this.textFillState_) { this.textFillState_ = { fillStyle: fillStyle }; @@ -1717,7 +1712,7 @@ ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle) { } } var textStrokeStyle = textStyle.getStroke(); - if (goog.isNull(textStrokeStyle)) { + if (!textStrokeStyle) { this.textStrokeState_ = null; } else { var textStrokeStyleColor = textStrokeStyle.getColor(); @@ -1736,9 +1731,9 @@ ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle) { textStrokeStyleWidth : ol.render.canvas.defaultLineWidth; var miterLimit = textStrokeStyleMiterLimit !== undefined ? textStrokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit; - var strokeStyle = ol.color.asString(!goog.isNull(textStrokeStyleColor) ? + var strokeStyle = ol.color.asString(textStrokeStyleColor ? textStrokeStyleColor : ol.render.canvas.defaultStrokeStyle); - if (goog.isNull(this.textStrokeState_)) { + if (!this.textStrokeState_) { this.textStrokeState_ = { lineCap: lineCap, lineDash: lineDash, @@ -1771,7 +1766,7 @@ ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle) { textTextAlign : ol.render.canvas.defaultTextAlign; var textBaseline = textTextBaseline !== undefined ? textTextBaseline : ol.render.canvas.defaultTextBaseline; - if (goog.isNull(this.textState_)) { + if (!this.textState_) { this.textState_ = { font: font, textAlign: textAlign, diff --git a/src/ol/render/vector.js b/src/ol/render/vector.js index 4623c46a6d..30b4d4c32e 100644 --- a/src/ol/render/vector.js +++ b/src/ol/render/vector.js @@ -58,14 +58,14 @@ ol.renderer.vector.renderCircleGeometry_ = 'geometry should be an ol.geom.Circle'); var fillStyle = style.getFill(); var strokeStyle = style.getStroke(); - if (!goog.isNull(fillStyle) || !goog.isNull(strokeStyle)) { + if (fillStyle || strokeStyle) { var polygonReplay = replayGroup.getReplay( style.getZIndex(), ol.render.ReplayType.POLYGON); polygonReplay.setFillStrokeStyle(fillStyle, strokeStyle); polygonReplay.drawCircleGeometry(geometry, feature); } var textStyle = style.getText(); - if (!goog.isNull(textStyle)) { + if (textStyle) { var textReplay = replayGroup.getReplay( style.getZIndex(), ol.render.ReplayType.TEXT); textReplay.setTextStyle(textStyle); @@ -89,7 +89,7 @@ ol.renderer.vector.renderFeature = function( var loading = false; var imageStyle, imageState; imageStyle = style.getImage(); - if (!goog.isNull(imageStyle)) { + if (imageStyle) { imageState = imageStyle.getImageState(); if (imageState == ol.style.ImageState.LOADED || imageState == ol.style.ImageState.ERROR) { @@ -168,14 +168,14 @@ ol.renderer.vector.renderLineStringGeometry_ = goog.asserts.assertInstanceof(geometry, ol.geom.LineString, 'geometry should be an ol.geom.LineString'); var strokeStyle = style.getStroke(); - if (!goog.isNull(strokeStyle)) { + if (strokeStyle) { var lineStringReplay = replayGroup.getReplay( style.getZIndex(), ol.render.ReplayType.LINE_STRING); lineStringReplay.setFillStrokeStyle(null, strokeStyle); lineStringReplay.drawLineStringGeometry(geometry, feature); } var textStyle = style.getText(); - if (!goog.isNull(textStyle)) { + if (textStyle) { var textReplay = replayGroup.getReplay( style.getZIndex(), ol.render.ReplayType.TEXT); textReplay.setTextStyle(textStyle); @@ -196,14 +196,14 @@ ol.renderer.vector.renderMultiLineStringGeometry_ = goog.asserts.assertInstanceof(geometry, ol.geom.MultiLineString, 'geometry should be an ol.geom.MultiLineString'); var strokeStyle = style.getStroke(); - if (!goog.isNull(strokeStyle)) { + if (strokeStyle) { var lineStringReplay = replayGroup.getReplay( style.getZIndex(), ol.render.ReplayType.LINE_STRING); lineStringReplay.setFillStrokeStyle(null, strokeStyle); lineStringReplay.drawMultiLineStringGeometry(geometry, feature); } var textStyle = style.getText(); - if (!goog.isNull(textStyle)) { + if (textStyle) { var textReplay = replayGroup.getReplay( style.getZIndex(), ol.render.ReplayType.TEXT); textReplay.setTextStyle(textStyle); @@ -227,14 +227,14 @@ ol.renderer.vector.renderMultiPolygonGeometry_ = 'geometry should be an ol.geom.MultiPolygon'); var fillStyle = style.getFill(); var strokeStyle = style.getStroke(); - if (!goog.isNull(strokeStyle) || !goog.isNull(fillStyle)) { + if (strokeStyle || fillStyle) { var polygonReplay = replayGroup.getReplay( style.getZIndex(), ol.render.ReplayType.POLYGON); polygonReplay.setFillStrokeStyle(fillStyle, strokeStyle); polygonReplay.drawMultiPolygonGeometry(geometry, feature); } var textStyle = style.getText(); - if (!goog.isNull(textStyle)) { + if (textStyle) { var textReplay = replayGroup.getReplay( style.getZIndex(), ol.render.ReplayType.TEXT); textReplay.setTextStyle(textStyle); @@ -257,7 +257,7 @@ ol.renderer.vector.renderPointGeometry_ = goog.asserts.assertInstanceof(geometry, ol.geom.Point, 'geometry should be an ol.geom.Point'); var imageStyle = style.getImage(); - if (!goog.isNull(imageStyle)) { + if (imageStyle) { if (imageStyle.getImageState() != ol.style.ImageState.LOADED) { return; } @@ -267,7 +267,7 @@ ol.renderer.vector.renderPointGeometry_ = imageReplay.drawPointGeometry(geometry, feature); } var textStyle = style.getText(); - if (!goog.isNull(textStyle)) { + if (textStyle) { var textReplay = replayGroup.getReplay( style.getZIndex(), ol.render.ReplayType.TEXT); textReplay.setTextStyle(textStyle); @@ -288,7 +288,7 @@ ol.renderer.vector.renderMultiPointGeometry_ = goog.asserts.assertInstanceof(geometry, ol.geom.MultiPoint, 'geometry should be an ol.goem.MultiPoint'); var imageStyle = style.getImage(); - if (!goog.isNull(imageStyle)) { + if (imageStyle) { if (imageStyle.getImageState() != ol.style.ImageState.LOADED) { return; } @@ -298,7 +298,7 @@ ol.renderer.vector.renderMultiPointGeometry_ = imageReplay.drawMultiPointGeometry(geometry, feature); } var textStyle = style.getText(); - if (!goog.isNull(textStyle)) { + if (textStyle) { var textReplay = replayGroup.getReplay( style.getZIndex(), ol.render.ReplayType.TEXT); textReplay.setTextStyle(textStyle); @@ -322,14 +322,14 @@ ol.renderer.vector.renderPolygonGeometry_ = 'geometry should be an ol.geom.Polygon'); var fillStyle = style.getFill(); var strokeStyle = style.getStroke(); - if (!goog.isNull(fillStyle) || !goog.isNull(strokeStyle)) { + if (fillStyle || strokeStyle) { var polygonReplay = replayGroup.getReplay( style.getZIndex(), ol.render.ReplayType.POLYGON); polygonReplay.setFillStrokeStyle(fillStyle, strokeStyle); polygonReplay.drawPolygonGeometry(geometry, feature); } var textStyle = style.getText(); - if (!goog.isNull(textStyle)) { + if (textStyle) { var textReplay = replayGroup.getReplay( style.getZIndex(), ol.render.ReplayType.TEXT); textReplay.setTextStyle(textStyle); diff --git a/src/ol/render/webgl/webglreplay.js b/src/ol/render/webgl/webglreplay.js index 07d4090171..7fe8ba6c1c 100644 --- a/src/ol/render/webgl/webglreplay.js +++ b/src/ol/render/webgl/webglreplay.js @@ -222,9 +222,9 @@ ol.render.webgl.ImageReplay.prototype.getDeleteResourcesFunction = // be used by other ImageReplay instances (for other layers). And // they will be deleted when disposing of the ol.webgl.Context // object. - goog.asserts.assert(!goog.isNull(this.verticesBuffer_), + goog.asserts.assert(this.verticesBuffer_, 'verticesBuffer must not be null'); - goog.asserts.assert(!goog.isNull(this.indicesBuffer_), + goog.asserts.assert(this.indicesBuffer_, 'indicesBuffer must not be null'); var verticesBuffer = this.verticesBuffer_; var indicesBuffer = this.indicesBuffer_; @@ -514,12 +514,12 @@ ol.render.webgl.ImageReplay.prototype.replay = function(context, var gl = context.getGL(); // bind the vertices buffer - goog.asserts.assert(!goog.isNull(this.verticesBuffer_), + goog.asserts.assert(this.verticesBuffer_, 'verticesBuffer must not be null'); context.bindBuffer(goog.webgl.ARRAY_BUFFER, this.verticesBuffer_); // bind the indices buffer - goog.asserts.assert(!goog.isNull(this.indicesBuffer_), + goog.asserts.assert(this.indicesBuffer_, 'indecesBuffer must not be null'); context.bindBuffer(goog.webgl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer_); @@ -532,7 +532,7 @@ ol.render.webgl.ImageReplay.prototype.replay = function(context, // get the locations var locations; - if (goog.isNull(this.defaultLocations_)) { + if (!this.defaultLocations_) { locations = new ol.render.webgl.imagereplay.shader.Default.Locations(gl, program); this.defaultLocations_ = locations; @@ -863,20 +863,20 @@ ol.render.webgl.ImageReplay.prototype.setImageStyle = function(imageStyle) { var rotation = imageStyle.getRotation(); var size = imageStyle.getSize(); var scale = imageStyle.getScale(); - goog.asserts.assert(!goog.isNull(anchor), 'imageStyle anchor is not null'); - goog.asserts.assert(!goog.isNull(image), 'imageStyle image is not null'); - goog.asserts.assert(!goog.isNull(imageSize), + goog.asserts.assert(anchor, 'imageStyle anchor is not null'); + goog.asserts.assert(image, 'imageStyle image is not null'); + goog.asserts.assert(imageSize, 'imageStyle imageSize is not null'); - goog.asserts.assert(!goog.isNull(hitDetectionImage), + goog.asserts.assert(hitDetectionImage, 'imageStyle hitDetectionImage is not null'); - goog.asserts.assert(!goog.isNull(hitDetectionImageSize), + goog.asserts.assert(hitDetectionImageSize, 'imageStyle hitDetectionImageSize is not null'); 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, 'imageStyle rotateWithView 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'); var currentImage;