Search in sources :

Example 11 with PointStyle

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

the class StyleModelTest method propertyMappedColors.

@Ignore
@Test
public void propertyMappedColors() {
    FeatureStyle fs = repo.newFeatureStyle();
    // point
    PointStyle point = fs.members().createElement(PointStyle.defaults);
    point.diameter.createValue(ConstantNumber.defaults(5.0));
    point.fill.get().color.createValue(new ValueInitializer<FilterMappedColors>() {

        @Override
        public FilterMappedColors initialize(FilterMappedColors proto) throws Exception {
            proto.add(ff.equals(ff.property("foo"), ff.literal("big")), new Color(255, 0, 0));
            proto.add(ff.equals(ff.property("foo"), ff.literal("bigger")), new Color(0, 0, 255));
            proto.add(ff.and(ff.notEqual(ff.property("foo"), ff.literal("big")), ff.notEqual(ff.property("foo"), ff.literal("bigger"))), new Color(0, 0, 255));
            return proto;
        }
    });
    fs.store();
    log.info("SLD: " + repo.serializedFeatureStyle(fs.id(), String.class));
    Style style = repo.serializedFeatureStyle(fs.id(), Style.class, OutputFormat.GEOSERVER).get();
    List<FeatureTypeStyle> featureTypeStyles = style.featureTypeStyles();
    assertEquals(1, featureTypeStyles.size());
    assertEquals(Filter.INCLUDE, featureTypeStyles.get(0).rules().get(0).getFilter());
    log.info("SLD: " + repo.serializedFeatureStyle(fs.id(), String.class, OutputFormat.OGC));
    style = repo.serializedFeatureStyle(fs.id(), Style.class, OutputFormat.OGC).get();
    featureTypeStyles = style.featureTypeStyles();
    assertEquals(1, featureTypeStyles.size());
    assertEquals("[ foo = big ]", featureTypeStyles.get(0).rules().get(0).getFilter().toString());
    assertEquals("[ foo = bigger ]", featureTypeStyles.get(0).rules().get(1).getFilter().toString());
    assertEquals("[[ foo != big ] AND [ foo != bigger ]]", featureTypeStyles.get(0).rules().get(2).getFilter().toString());
}
Also used : PointStyle(org.polymap.core.style.model.feature.PointStyle) Color(java.awt.Color) ConstantColor(org.polymap.core.style.model.feature.ConstantColor) 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) FilterMappedColors(org.polymap.core.style.model.feature.FilterMappedColors) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureStyle(org.polymap.core.style.model.FeatureStyle) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 12 with PointStyle

use of org.polymap.core.style.model.feature.PointStyle 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)

Aggregations

PointStyle (org.polymap.core.style.model.feature.PointStyle)12 FeatureStyle (org.polymap.core.style.model.FeatureStyle)11 Test (org.junit.Test)10 LineStyle (org.polymap.core.style.model.feature.LineStyle)9 PolygonStyle (org.polymap.core.style.model.feature.PolygonStyle)9 TextStyle (org.polymap.core.style.model.feature.TextStyle)9 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)8 Style (org.geotools.styling.Style)8 ConstantStrokeCapStyle (org.polymap.core.style.model.feature.ConstantStrokeCapStyle)8 ConstantStrokeDashStyle (org.polymap.core.style.model.feature.ConstantStrokeDashStyle)8 ConstantStrokeJoinStyle (org.polymap.core.style.model.feature.ConstantStrokeJoinStyle)8 StrokeDashStyle (org.polymap.core.style.model.feature.StrokeDashStyle)8 PointSymbolizer (org.geotools.styling.PointSymbolizer)7 Ignore (org.junit.Ignore)5 ConstantFilter (org.polymap.core.style.model.feature.ConstantFilter)4 Rule (org.geotools.styling.Rule)3 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