Search in sources :

Example 16 with FeatureStyle

use of org.polymap.core.style.model.FeatureStyle in project polymap4-core by Polymap4.

the class StyleModelTest method testSimplePolygon.

@Test
public void testSimplePolygon() throws Exception {
    FeatureStyle fs = repo.newFeatureStyle();
    PolygonStyle style = fs.members().createElement(PolygonStyle.defaults);
    assertTrue(style.visibleIf.get() instanceof ConstantFilter);
    style.fill.get().color.createValue(ConstantColor.defaults(0, 0, 0));
    style.fill.get().opacity.createValue(ConstantNumber.defaults(0.0));
    style.stroke.get().color.createValue(ConstantColor.defaults(100, 100, 100));
    style.stroke.get().width.createValue(ConstantNumber.defaults(5.0));
    style.stroke.get().opacity.createValue(ConstantNumber.defaults(0.5));
    fs.store();
    log.info("SLD: " + repo.serializedFeatureStyle(fs.id(), String.class));
    Style result = repo.serializedFeatureStyle(fs.id(), Style.class).get();
    assertEquals(1, result.featureTypeStyles().size());
    FeatureTypeStyle fts = result.featureTypeStyles().get(0);
    assertEquals(1, fts.rules().size());
    Rule rule = fts.rules().get(0);
    assertEquals(0, rule.getMinScaleDenominator(), 0);
    assertEquals(Double.POSITIVE_INFINITY, rule.getMaxScaleDenominator(), 0);
    assertEquals(1, rule.symbolizers().size());
    assertNull(rule.getFilter());
    PolygonSymbolizer polygon = (PolygonSymbolizer) rule.symbolizers().get(0);
    assertEqualsLiteral(0.5, polygon.getStroke().getOpacity());
    assertEqualsLiteral(5.0, polygon.getStroke().getWidth());
    assertEqualsLiteral(0.0, polygon.getFill().getOpacity());
}
Also used : PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) ConstantFilter(org.polymap.core.style.model.feature.ConstantFilter) Style(org.geotools.styling.Style) ConstantStrokeDashStyle(org.polymap.core.style.model.feature.ConstantStrokeDashStyle) ConstantStrokeJoinStyle(org.polymap.core.style.model.feature.ConstantStrokeJoinStyle) FeatureStyle(org.polymap.core.style.model.FeatureStyle) PolygonStyle(org.polymap.core.style.model.feature.PolygonStyle) TextStyle(org.polymap.core.style.model.feature.TextStyle) ConstantStrokeCapStyle(org.polymap.core.style.model.feature.ConstantStrokeCapStyle) StrokeDashStyle(org.polymap.core.style.model.feature.StrokeDashStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) PointStyle(org.polymap.core.style.model.feature.PointStyle) LineStyle(org.polymap.core.style.model.feature.LineStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) PolygonStyle(org.polymap.core.style.model.feature.PolygonStyle) FeatureStyle(org.polymap.core.style.model.FeatureStyle) Test(org.junit.Test)

Example 17 with FeatureStyle

use of org.polymap.core.style.model.FeatureStyle in project polymap4-core by Polymap4.

the class StyleModelTest method testScaleMappedNumbers.

@Test
public void testScaleMappedNumbers() throws Exception {
    FeatureStyle fs = repo.newFeatureStyle();
    PointStyle point = fs.members().createElement(PointStyle.defaults);
    point.diameter.createValue(ScaleMappedPrimitives.defaults()).add(0, 1, new Double(1)).add(1, 2, new Double(2)).add(2, Double.POSITIVE_INFINITY, new Double(3));
    fs.store();
    log.info("SLD: " + repo.serializedFeatureStyle(fs.id(), String.class));
    Style result = repo.serializedFeatureStyle(fs.id(), Style.class).get();
    assertEquals(1, result.featureTypeStyles().size());
    FeatureTypeStyle fts = result.featureTypeStyles().get(0);
    assertEquals(3, fts.rules().size());
    assertEqualsLiteral(1.0, ((PointSymbolizer) fts.rules().get(0).symbolizers().get(0)).getGraphic().getSize());
    assertEqualsLiteral(2.0, ((PointSymbolizer) fts.rules().get(1).symbolizers().get(0)).getGraphic().getSize());
    assertEqualsLiteral(3.0, ((PointSymbolizer) fts.rules().get(2).symbolizers().get(0)).getGraphic().getSize());
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) PointStyle(org.polymap.core.style.model.feature.PointStyle) Style(org.geotools.styling.Style) ConstantStrokeDashStyle(org.polymap.core.style.model.feature.ConstantStrokeDashStyle) ConstantStrokeJoinStyle(org.polymap.core.style.model.feature.ConstantStrokeJoinStyle) FeatureStyle(org.polymap.core.style.model.FeatureStyle) PolygonStyle(org.polymap.core.style.model.feature.PolygonStyle) TextStyle(org.polymap.core.style.model.feature.TextStyle) ConstantStrokeCapStyle(org.polymap.core.style.model.feature.ConstantStrokeCapStyle) StrokeDashStyle(org.polymap.core.style.model.feature.StrokeDashStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) PointStyle(org.polymap.core.style.model.feature.PointStyle) LineStyle(org.polymap.core.style.model.feature.LineStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureStyle(org.polymap.core.style.model.FeatureStyle) Test(org.junit.Test)

Example 18 with FeatureStyle

use of org.polymap.core.style.model.FeatureStyle in project polymap4-core by Polymap4.

the class StyleModelTest method simpleLine.

@Ignore
@Test
public void simpleLine() throws Exception {
    FeatureStyle fs = repo.newFeatureStyle();
    // point
    LineStyle line = fs.members().createElement(LineStyle.defaults);
    line.fill.get().color.createValue(ConstantColor.defaults(0, 0, 100));
    line.fill.get().width.createValue(ConstantNumber.defaults(15.0));
    line.fill.get().strokeStyle.get().capStyle.createValue(ConstantStrokeCapStyle.defaults());
    line.fill.get().strokeStyle.get().dashStyle.createValue(ConstantStrokeDashStyle.defaults(StrokeDashStyle.dashdot));
    line.fill.get().strokeStyle.get().joinStyle.createValue(ConstantStrokeJoinStyle.defaults());
    line.stroke.get().color.createValue(ConstantColor.defaults(100, 0, 0));
    line.stroke.get().width.createValue(ConstantNumber.defaults(2.0));
    line.stroke.get().strokeStyle.get().capStyle.createValue(ConstantStrokeCapStyle.defaults());
    line.stroke.get().strokeStyle.get().dashStyle.createValue(ConstantStrokeDashStyle.defaults());
    line.stroke.get().strokeStyle.get().joinStyle.createValue(ConstantStrokeJoinStyle.defaults());
    fs.store();
    log.info("SLD: " + repo.serializedFeatureStyle(fs.id(), String.class));
}
Also used : LineStyle(org.polymap.core.style.model.feature.LineStyle) FeatureStyle(org.polymap.core.style.model.FeatureStyle) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

FeatureStyle (org.polymap.core.style.model.FeatureStyle)18 Test (org.junit.Test)17 PointStyle (org.polymap.core.style.model.feature.PointStyle)14 LineStyle (org.polymap.core.style.model.feature.LineStyle)13 PolygonStyle (org.polymap.core.style.model.feature.PolygonStyle)13 TextStyle (org.polymap.core.style.model.feature.TextStyle)13 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)11 Style (org.geotools.styling.Style)11 ConstantStrokeCapStyle (org.polymap.core.style.model.feature.ConstantStrokeCapStyle)11 ConstantStrokeDashStyle (org.polymap.core.style.model.feature.ConstantStrokeDashStyle)11 ConstantStrokeJoinStyle (org.polymap.core.style.model.feature.ConstantStrokeJoinStyle)11 StrokeDashStyle (org.polymap.core.style.model.feature.StrokeDashStyle)11 Ignore (org.junit.Ignore)8 PointSymbolizer (org.geotools.styling.PointSymbolizer)7 ConstantFilter (org.polymap.core.style.model.feature.ConstantFilter)7 Rule (org.geotools.styling.Rule)6 FilterMappedPrimitives (org.polymap.core.style.model.feature.FilterMappedPrimitives)2 Cloner (com.rits.cloning.Cloner)1 Color (java.awt.Color)1 List (java.util.List)1