Merge pull request #4111 from marcjansen/text-default-fill

Use a blackish default for filling texts
This commit is contained in:
Marc Jansen
2015-09-18 07:28:17 +09:00
3 changed files with 50 additions and 5 deletions
+1 -1
View File
@@ -6216,7 +6216,7 @@ olx.style.TextOptions.prototype.textBaseline;
/** /**
* Fill style. * Fill style. If none is provided, we'll use a dark fill-style (#333).
* @type {ol.style.Fill|undefined} * @type {ol.style.Fill|undefined}
* @api * @api
*/ */
+15 -1
View File
@@ -1,6 +1,9 @@
goog.provide('ol.style.Text'); goog.provide('ol.style.Text');
goog.require('ol.style.Fill');
/** /**
* @classdesc * @classdesc
@@ -54,7 +57,8 @@ ol.style.Text = function(opt_options) {
* @private * @private
* @type {ol.style.Fill} * @type {ol.style.Fill}
*/ */
this.fill_ = goog.isDef(options.fill) ? options.fill : null; this.fill_ = goog.isDef(options.fill) ? options.fill :
new ol.style.Fill({color: ol.style.Text.DEFAULT_FILL_COLOR_});
/** /**
* @private * @private
@@ -76,6 +80,16 @@ ol.style.Text = function(opt_options) {
}; };
/**
* The default fill color to use if no fill was set at construction time; a
* blackish `#333`.
*
* @const {string}
* @private
*/
ol.style.Text.DEFAULT_FILL_COLOR_ = '#333';
/** /**
* Get the font name. * Get the font name.
* @return {string|undefined} Font. * @return {string|undefined} Font.
+31
View File
@@ -0,0 +1,31 @@
goog.provide('ol.test.style.Text');
describe('ol.style.Text', function() {
describe('#constructor', function() {
it('uses a default fill style if none passed', function() {
var style = new ol.style.Text();
expect(style.getFill().getColor()).to.be('#333');
});
it('uses a provided fill style if one passed', function() {
var style = new ol.style.Text({
fill: new ol.style.Fill({color: '#123456'})
});
expect(style.getFill().getColor()).to.be('#123456');
});
it('can always be resetted to no color', function() {
var style = new ol.style.Text();
style.getFill().setColor();
expect(style.getFill().getColor()).to.be(undefined);
});
});
});
goog.require('ol.style.Fill');
goog.require('ol.style.Text');