Use fillColor and strokeColor instead of fillStyle and strokeStyle

The color names are more intuitive.  And if we want to support pattern strokes or fills, we'll need additional proerties to represent other pattern properties.
This commit is contained in:
Tim Schaub
2013-03-07 22:51:14 -07:00
parent 5ce114c1b6
commit faee18bae1
10 changed files with 156 additions and 154 deletions

View File

@@ -107,7 +107,7 @@ describe('ol.layer.Vector', function() {
symbolizers: [
new ol.style.Line({
strokeWidth: 2,
strokeStyle: new ol.Expression('colorProperty'),
strokeColor: new ol.Expression('colorProperty'),
opacity: 1
})
]
@@ -136,20 +136,20 @@ describe('ol.layer.Vector', function() {
var groups = layer.groupFeaturesBySymbolizerLiteral(features);
expect(groups.length).toBe(2);
expect(groups[0][0].length).toBe(1);
expect(groups[0][1].strokeStyle).toBe('#BADA55');
expect(groups[0][1].strokeColor).toBe('#BADA55');
expect(groups[1][0].length).toBe(2);
expect(groups[1][1].strokeStyle).toBe('#013');
expect(groups[1][1].strokeColor).toBe('#013');
});
it('groups equal symbolizers also when defined on features', function() {
var symbolizer = new ol.style.Line({
strokeWidth: 3,
strokeStyle: new ol.Expression('colorProperty'),
strokeColor: new ol.Expression('colorProperty'),
opacity: 1
});
var anotherSymbolizer = new ol.style.Line({
strokeWidth: 3,
strokeStyle: '#BADA55',
strokeColor: '#BADA55',
opacity: 1
});
var featureWithSymbolizers = new ol.Feature({

View File

@@ -7,16 +7,16 @@ describe('ol.style.LineLiteral', function() {
it('identifies equal literals', function() {
var literal = new ol.style.LineLiteral({
strokeWidth: 3,
strokeStyle: '#BADA55',
strokeColor: '#BADA55',
opacity: 1
});
var equalLiteral = new ol.style.LineLiteral({
strokeStyle: '#BADA55',
strokeColor: '#BADA55',
strokeWidth: 3,
opacity: 1
});
var differentLiteral = new ol.style.LineLiteral({
strokeStyle: '#013',
strokeColor: '#013',
strokeWidth: 3,
opacity: 1
});
@@ -34,7 +34,7 @@ describe('ol.style.Line', function() {
it('accepts literal values', function() {
var symbolizer = new ol.style.Line({
strokeStyle: '#BADA55',
strokeColor: '#BADA55',
strokeWidth: 3
});
expect(symbolizer).toBeA(ol.style.Line);

View File

@@ -7,19 +7,19 @@ describe('ol.style.PolygonLiteral', function() {
it('identifies equal literals', function() {
var literal = new ol.style.PolygonLiteral({
strokeWidth: 3,
strokeStyle: '#013',
fillStyle: '#BADA55',
strokeColor: '#013',
fillColor: '#BADA55',
opacity: 1
});
var equalLiteral = new ol.style.PolygonLiteral({
fillStyle: '#BADA55',
strokeStyle: '#013',
fillColor: '#BADA55',
strokeColor: '#013',
strokeWidth: 3,
opacity: 1
});
var differentLiteral = new ol.style.PolygonLiteral({
fillStyle: '#013',
strokeStyle: '#013',
fillColor: '#013',
strokeColor: '#013',
strokeWidth: 3,
opacity: 1
});
@@ -37,7 +37,7 @@ describe('ol.style.Polygon', function() {
it('accepts literal values', function() {
var symbolizer = new ol.style.Polygon({
fillStyle: '#BADA55',
fillColor: '#BADA55',
strokeWidth: 3
});
expect(symbolizer).toBeA(ol.style.Polygon);
@@ -46,7 +46,7 @@ describe('ol.style.Polygon', function() {
it('accepts expressions', function() {
var symbolizer = new ol.style.Polygon({
opacity: new ol.Expression('value / 100'),
fillStyle: new ol.Expression('fillAttr')
fillColor: new ol.Expression('fillAttr')
});
expect(symbolizer).toBeA(ol.style.Polygon);
});
@@ -58,7 +58,7 @@ describe('ol.style.Polygon', function() {
it('evaluates expressions with the given feature', function() {
var symbolizer = new ol.style.Polygon({
opacity: new ol.Expression('value / 100'),
fillStyle: new ol.Expression('fillAttr')
fillColor: new ol.Expression('fillAttr')
});
var feature = new ol.Feature({
@@ -69,20 +69,20 @@ describe('ol.style.Polygon', function() {
var literal = symbolizer.createLiteral(feature);
expect(literal).toBeA(ol.style.PolygonLiteral);
expect(literal.opacity).toBe(42 / 100);
expect(literal.fillStyle).toBe('#ff0000');
expect(literal.strokeStyle).toBeUndefined();
expect(literal.fillColor).toBe('#ff0000');
expect(literal.strokeColor).toBeUndefined();
});
it('applies default strokeWidth if only strokeStyle is given', function() {
it('applies default strokeWidth if only strokeColor is given', function() {
var symbolizer = new ol.style.Polygon({
strokeStyle: '#ff0000'
strokeColor: '#ff0000'
});
var literal = symbolizer.createLiteral();
expect(literal).toBeA(ol.style.PolygonLiteral);
expect(literal.strokeStyle).toBe('#ff0000');
expect(literal.strokeColor).toBe('#ff0000');
expect(literal.strokeWidth).toBe(1.5);
expect(literal.fillStyle).toBeUndefined();
expect(literal.fillColor).toBeUndefined();
});
});

View File

@@ -8,24 +8,24 @@ describe('ol.style.ShapeLiteral', function() {
var literal = new ol.style.ShapeLiteral({
type: ol.style.ShapeType.CIRCLE,
size: 4,
fillStyle: '#BADA55',
strokeStyle: '#013',
fillColor: '#BADA55',
strokeColor: '#013',
strokeWidth: 3,
opacity: 1
});
var equalLiteral = new ol.style.ShapeLiteral({
type: ol.style.ShapeType.CIRCLE,
size: 4,
fillStyle: '#BADA55',
strokeStyle: '#013',
fillColor: '#BADA55',
strokeColor: '#013',
strokeWidth: 3,
opacity: 1
});
var differentLiteral = new ol.style.ShapeLiteral({
type: ol.style.ShapeType.CIRCLE,
size: 4,
fillStyle: '#013',
strokeStyle: '#013',
fillColor: '#013',
strokeColor: '#013',
strokeWidth: 3,
opacity: 1
});
@@ -44,7 +44,7 @@ describe('ol.style.Shape', function() {
it('accepts literal values', function() {
var symbolizer = new ol.style.Shape({
size: 4,
fillStyle: '#BADA55'
fillColor: '#BADA55'
});
expect(symbolizer).toBeA(ol.style.Shape);
});
@@ -52,7 +52,7 @@ describe('ol.style.Shape', function() {
it('accepts expressions', function() {
var symbolizer = new ol.style.Shape({
size: new ol.Expression('sizeAttr'),
strokeStyle: new ol.Expression('color')
strokeColor: new ol.Expression('color')
});
expect(symbolizer).toBeA(ol.style.Shape);
});
@@ -65,7 +65,7 @@ describe('ol.style.Shape', function() {
var symbolizer = new ol.style.Shape({
size: new ol.Expression('sizeAttr'),
opacity: new ol.Expression('opacityAttr'),
fillStyle: '#BADA55'
fillColor: '#BADA55'
});
var feature = new ol.Feature({
@@ -83,8 +83,8 @@ describe('ol.style.Shape', function() {
var symbolizer = new ol.style.Shape({
size: 10,
opacity: 1,
fillStyle: '#BADA55',
strokeStyle: '#013',
fillColor: '#BADA55',
strokeColor: '#013',
strokeWidth: 2
});
@@ -92,8 +92,8 @@ describe('ol.style.Shape', function() {
expect(literal).toBeA(ol.style.ShapeLiteral);
expect(literal.size).toBe(10);
expect(literal.opacity).toBe(1);
expect(literal.fillStyle).toBe('#BADA55');
expect(literal.strokeStyle).toBe('#013');
expect(literal.fillColor).toBe('#BADA55');
expect(literal.strokeColor).toBe('#013');
expect(literal.strokeWidth).toBe(2);
});
@@ -101,7 +101,7 @@ describe('ol.style.Shape', function() {
var symbolizer = new ol.style.Shape({
size: new ol.Expression('sizeAttr'),
opacity: new ol.Expression('opacityAttr'),
fillStyle: '#BADA55'
fillColor: '#BADA55'
});
var feature = new ol.Feature({

View File

@@ -15,7 +15,7 @@ describe('ol.style.Style', function() {
symbolizers: [
new ol.style.Shape({
size: 4,
fillStyle: '#BADA55'
fillColor: '#BADA55'
})
]
})
@@ -24,7 +24,7 @@ describe('ol.style.Style', function() {
var feature = new ol.Feature();
feature.set('foo', 'bar');
expect(style.apply(feature).length).toBe(1);
expect(style.apply(feature)[0].fillStyle).toBe('#BADA55');
expect(style.apply(feature)[0].fillColor).toBe('#BADA55');
feature.set('foo', 'baz');
expect(style.apply(feature).length).toBe(0);
});