Search in sources :

Example 61 with Rule

use of org.geotools.styling.Rule in project sldeditor by robward-scisys.

the class ExtractAttributesTest method getRuleList.

/**
 * Gets the rule list.
 *
 * @param sld the sld
 * @return the rule list
 */
protected List<Rule> getRuleList(StyledLayerDescriptor sld) {
    NamedLayer namedLayer = (NamedLayer) sld.layers().get(0);
    List<Rule> ruleList = namedLayer.styles().get(0).featureTypeStyles().get(0).rules();
    return ruleList;
}
Also used : Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer)

Example 62 with Rule

use of org.geotools.styling.Rule in project sldeditor by robward-scisys.

the class ExtractAttributesTest method testIsBetween.

@Test
public void testIsBetween() {
    DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
    StyledLayerDescriptor sld = createTestSLD(dummy);
    List<Rule> ruleList = getRuleList(sld);
    Rule rule = DefaultSymbols.createNewRule();
    // Try isBetween
    Filter filter = ff.between(ff.property("test"), ff.literal("1.23"), ff.literal(4));
    rule.setFilter(filter);
    ruleList.clear();
    ruleList.add(rule);
    ExtractAttributes extract = new ExtractAttributes();
    extract.extractDefaultFields(sld);
    // Check fields extracted ok
    List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
    assertEquals(1, actualFieldnameList.size());
    DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
    assertEquals(Double.class, dataSourceField.getType());
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) DataSourceAttributeData(com.sldeditor.datasource.attribute.DataSourceAttributeData) Filter(org.opengis.filter.Filter) ExtractAttributes(com.sldeditor.datasource.impl.ExtractAttributes) Rule(org.geotools.styling.Rule) Test(org.junit.Test)

Example 63 with Rule

use of org.geotools.styling.Rule in project sldeditor by robward-scisys.

the class ExtractAttributesTest method testNotFilter.

@Test
public void testNotFilter() {
    DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
    StyledLayerDescriptor sld = createTestSLD(dummy);
    List<Rule> ruleList = getRuleList(sld);
    ExtractAttributes extract = new ExtractAttributes();
    Rule rule = DefaultSymbols.createNewRule();
    // Try with NOT
    extract = new ExtractAttributes();
    Filter filter = ff.not(ff.greater(ff.literal(42.1), ff.property("dble")));
    rule.setFilter(filter);
    ruleList.clear();
    ruleList.add(rule);
    extract.extractDefaultFields(sld);
    // Check fields extracted ok
    List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
    assertEquals(1, actualFieldnameList.size());
    DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
    assertEquals(Double.class, dataSourceField.getType());
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) DataSourceAttributeData(com.sldeditor.datasource.attribute.DataSourceAttributeData) Filter(org.opengis.filter.Filter) ExtractAttributes(com.sldeditor.datasource.impl.ExtractAttributes) Rule(org.geotools.styling.Rule) Test(org.junit.Test)

Example 64 with Rule

use of org.geotools.styling.Rule in project polymap4-core by Polymap4.

the class DefaultStyles method createPolygonStyle.

/**
 * Create a Style to draw polygon features with a thin blue outline and
 * a cyan fill
 */
public static Style createPolygonStyle(Style style) {
    // create a partially opaque outline stroke
    Stroke stroke = sf.createStroke(ff.literal(Color.DARK_GRAY), ff.literal(0.5), ff.literal(0.5));
    // create a partial opaque fill
    Fill fill = sf.createFill(ff.literal(Color.CYAN), ff.literal(0.5));
    /*
         * Setting the geometryPropertyName arg to null signals that we want to
         * draw the default geometry of features
         */
    PolygonSymbolizer sym = sf.createPolygonSymbolizer(stroke, fill, null);
    Rule rule = sf.createRule();
    rule.setName("Rule for PolygonSymbolizer");
    rule.symbolizers().add(sym);
    style.featureTypeStyles().get(0).rules().add(rule);
    return style;
}
Also used : Stroke(org.geotools.styling.Stroke) Fill(org.geotools.styling.Fill) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Rule(org.geotools.styling.Rule)

Example 65 with Rule

use of org.geotools.styling.Rule in project polymap4-core by Polymap4.

the class DefaultStyles method createLineStyle.

/**
 * Create a Style to draw line features as thin blue lines
 */
public static Style createLineStyle(Style style) {
    Stroke stroke = sf.createStroke(ff.literal(Color.DARK_GRAY), ff.literal(0.5));
    /*
         * Setting the geometryPropertyName arg to null signals that we want to
         * draw the default geometry of features
         */
    LineSymbolizer sym = sf.createLineSymbolizer(stroke, null);
    Rule rule = sf.createRule();
    rule.symbolizers().add(sym);
    rule.setName("Rule for LineSymbolizer");
    style.featureTypeStyles().get(0).rules().add(rule);
    return style;
}
Also used : Stroke(org.geotools.styling.Stroke) LineSymbolizer(org.geotools.styling.LineSymbolizer) Rule(org.geotools.styling.Rule)

Aggregations

Rule (org.geotools.styling.Rule)110 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)65 Style (org.geotools.styling.Style)60 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)51 Test (org.junit.Test)48 NamedLayer (org.geotools.styling.NamedLayer)38 PointSymbolizer (org.geotools.styling.PointSymbolizer)28 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)26 LineSymbolizer (org.geotools.styling.LineSymbolizer)24 Symbolizer (org.geotools.styling.Symbolizer)22 StyledLayer (org.geotools.styling.StyledLayer)19 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)16 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)16 TextSymbolizer (org.geotools.styling.TextSymbolizer)15 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)13 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)11 ArrayList (java.util.ArrayList)11 Filter (org.opengis.filter.Filter)11 UserLayerImpl (org.geotools.styling.UserLayerImpl)10 DataSourceAttributeData (com.sldeditor.datasource.attribute.DataSourceAttributeData)8