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;
}
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());
}
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());
}
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;
}
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;
}
Aggregations