use of org.geotools.styling.Symbolizer in project sldeditor by robward-scisys.
the class NewLineSLDTest method testNewLineSLD.
/**
* Test new line sld.
*/
@Test
public void testNewLineSLD() {
NewLineSLD newData = new NewLineSLD();
StyledLayerDescriptor sld = newData.create();
assertTrue(sld.layers().size() == 1);
StyledLayer styledLayer = sld.layers().get(0);
NamedLayer namedLayer = (NamedLayer) styledLayer;
Symbolizer symbolizer = namedLayer.styles().get(0).featureTypeStyles().get(0).rules().get(0).symbolizers().get(0);
assertTrue(symbolizer instanceof LineSymbolizer);
}
use of org.geotools.styling.Symbolizer in project sldeditor by robward-scisys.
the class RuleDetailsTest method testRuleDetails.
/**
* Test method for {@link
* com.sldeditor.ui.detail.RuleDetails#RuleDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
* Test method for {@link
* com.sldeditor.ui.detail.RuleDetails#populate(com.sldeditor.common.data.SelectedSymbol)}. Test
* method for {@link
* com.sldeditor.ui.detail.RuleDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
* Test method for {@link com.sldeditor.ui.detail.RuleDetails#getFieldDataManager()}. Test
* method for {@link com.sldeditor.ui.detail.RuleDetails#isDataPresent()}. Test method for
* {@link com.sldeditor.ui.detail.RuleDetails#preLoadSymbol()}.
*/
@Test
public void testRuleDetails() {
RuleDetails panel = new RuleDetails();
panel.populate(null);
// Set up test data
StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
SelectedSymbol.getInstance().createNewSLD(sld);
NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
String expectedNameLayerValue = "named layer test value";
namedLayer.setName(expectedNameLayerValue);
Style style = DefaultSymbols.createNewStyle();
String expectedNameStyleValue = "style test value";
style.setName(expectedNameStyleValue);
namedLayer.addStyle(style);
FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
String expectedNameFTSValue = "feature type style test value";
fts.setName(expectedNameFTSValue);
style.featureTypeStyles().add(fts);
Rule rule = DefaultSymbols.createNewRule();
String expectedNameValue = "rule test value";
rule.setName(expectedNameValue);
Symbolizer symbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
rule.symbolizers().add(symbolizer);
fts.rules().add(rule);
sld.layers().add(namedLayer);
SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
SelectedSymbol.getInstance().setStyledLayer(namedLayer);
SelectedSymbol.getInstance().setStyle(style);
SelectedSymbol.getInstance().setFeatureTypeStyle(fts);
SelectedSymbol.getInstance().setRule(rule);
panel.populate(SelectedSymbol.getInstance());
GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
assertNotNull(fieldDataManager);
FieldConfigString filterField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.FILTER);
String filterString = "STATE_ABBR >= 'B' AND STATE_ABBR <= 'O'";
filterField.populateField(filterString);
GroupConfig groupConfig = (GroupConfig) fieldDataManager.getGroup(RuleDetails.class, GroupIdEnum.SCALE);
groupConfig.enable(true);
panel.dataChanged(null);
FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
String actualValue = nameField.getStringValue();
assertTrue(expectedNameValue.compareTo(actualValue) == 0);
assertTrue(panel.isDataPresent());
// Reset to default value
panel.preLoadSymbol();
actualValue = nameField.getStringValue();
assertTrue("".compareTo(actualValue) == 0);
}
use of org.geotools.styling.Symbolizer in project sldeditor by robward-scisys.
the class MultiLayerLineSymbol method convert.
/**
* Convert.
*
* @param rule the rule
* @param element the element
* @param layerName the layer name
* @param transparency the transparency
*/
@Override
public void convert(Rule rule, JsonElement element, String layerName, int transparency) {
if (rule == null)
return;
if (element == null)
return;
JsonArray layerArray = element.getAsJsonArray();
List<Symbolizer> symbolizerList = rule.symbolizers();
if (layerArray.size() > 0) {
for (int index = 0; index < layerArray.size(); index++) {
JsonObject obj = layerArray.get(index).getAsJsonObject();
List<Stroke> strokeList = null;
JsonElement jsonOutlineElement = obj.get(MultiLayerLineSymbolKeys.LINE);
strokeList = SymbolManager.getInstance().getStrokeList(jsonOutlineElement);
if (strokeList != null) {
for (Stroke stroke : strokeList) {
LineSymbolizer lineSymbolizer = styleFactory.createLineSymbolizer(stroke, null);
symbolizerList.add(lineSymbolizer);
}
}
}
}
}
use of org.geotools.styling.Symbolizer in project sldeditor by robward-scisys.
the class PictureFillSymbol method convert.
/* (non-Javadoc)
* @see com.sldeditor.convert.esri.symbols.EsriSymbolInterface#convert(org.geotools.styling.Rule, com.google.gson.JsonElement, java.lang.String, int)
*/
@Override
public void convert(Rule rule, JsonElement element, String layerName, int transparency) {
if (rule == null)
return;
if (element == null)
return;
JsonObject obj = element.getAsJsonObject();
List<Symbolizer> symbolizerList = rule.symbolizers();
List<Stroke> strokeList = SymbolManager.getInstance().getStrokeList(obj.get(PictureFillSymbolKeys.OUTLINE));
Stroke stroke = null;
if (!strokeList.isEmpty()) {
stroke = strokeList.get(0);
}
Fill fill = getFill(layerName, obj, transparency);
PolygonSymbolizer polygonSymbolizer = styleFactory.createPolygonSymbolizer(stroke, fill, null);
symbolizerList.add(polygonSymbolizer);
}
use of org.geotools.styling.Symbolizer in project sldeditor by robward-scisys.
the class PictureFillSymbol method convertToFill.
/* (non-Javadoc)
* @see com.sldeditor.convert.esri.symbols.EsriFillSymbolInterface#convertToFill(java.lang.String, com.google.gson.JsonElement, int)
*/
@Override
public List<Symbolizer> convertToFill(String layerName, JsonElement element, int transparency) {
if (element == null)
return null;
JsonObject obj = element.getAsJsonObject();
List<Symbolizer> symbolizerList = new ArrayList<Symbolizer>();
Fill fill = getFill(layerName, obj, transparency);
PolygonSymbolizer polygon = styleFactory.createPolygonSymbolizer();
polygon.setStroke(null);
polygon.setFill(fill);
symbolizerList.add(polygon);
return symbolizerList;
}
Aggregations