use of org.geotools.styling.Graphic in project sldeditor by robward-scisys.
the class SLDExternalImagesTest method createGraphic.
/**
* Creates the graphic.
*
* @param url the url
* @param styleFactory the style factory
* @return the graphic
*/
private Graphic createGraphic(URL url, StyleFactory styleFactory) {
List<GraphicalSymbol> symbolList = new ArrayList<GraphicalSymbol>();
ExternalGraphic externalGraphic = styleFactory.createExternalGraphic(url, "image/png");
symbolList.add(externalGraphic);
Graphic graphicFill = styleFactory.graphicFill(symbolList, null, null, null, null, null);
return graphicFill;
}
use of org.geotools.styling.Graphic in project sldeditor by robward-scisys.
the class SelectedSymbolTest method getGraphic.
/**
* Gets the graphic.
*
* @param symbolizer the symbolizer
* @return the graphic
*/
private Graphic getGraphic(Symbolizer symbolizer) {
Graphic graphic = null;
if (symbolizer instanceof PointSymbolizerImpl) {
PointSymbolizer pointSymbolizer = (PointSymbolizer) symbolizer;
graphic = pointSymbolizer.getGraphic();
} else if (symbolizer instanceof PolygonSymbolizerImpl) {
PolygonSymbolizer polygonSymbolizer = (PolygonSymbolizer) symbolizer;
if (polygonSymbolizer != null) {
Fill fill = polygonSymbolizer.getFill();
if (fill != null) {
graphic = fill.getGraphicFill();
}
}
}
return graphic;
}
use of org.geotools.styling.Graphic in project sldeditor by robward-scisys.
the class SelectedSymbolTest method testGetGraphic.
/**
* Test method for {@link com.sldeditor.common.data.SelectedSymbol#getGraphic()}.
*/
@Test
public void testGetGraphic() {
SelectedSymbol.destroyInstance();
SelectedSymbol instance = SelectedSymbol.getInstance();
// CHECKSTYLE:OFF
Rule rule = DefaultSymbols.createNewRule();
FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
Style style = DefaultSymbols.createNewStyle();
NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
PolygonSymbolizer symbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
// CHECKSTYLE:ON
instance.createNewSLD(sld);
instance.setSld(sld);
System.out.println("Select named layer");
instance.addNewStyledLayer(namedLayer);
instance.setStyledLayer(namedLayer);
instance.addNewStyle(style);
instance.setStyle(style);
instance.addNewFeatureTypeStyle(fts);
instance.setFeatureTypeStyle(fts);
instance.addNewRule(rule);
instance.setRule(rule);
instance.addSymbolizerToRule(symbolizer);
instance.setSymbolizer(symbolizer);
Graphic graphic = getGraphic(symbolizer);
assertNull(graphic);
Fill graphicFill = DefaultSymbols.createDefaultGraphicFill();
PolygonSymbolizer newSymbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
newSymbolizer.setFill(graphicFill);
instance.addSymbolizerToRule(newSymbolizer);
instance.setSymbolizer(newSymbolizer);
graphic = getGraphic(newSymbolizer);
assertNotNull(graphic);
assertTrue(instance.hasFill());
assertTrue(instance.hasStroke());
LineSymbolizer lineSymbolizer = DefaultSymbols.createDefaultLineSymbolizer();
instance.addSymbolizerToRule(lineSymbolizer);
instance.setSymbolizer(lineSymbolizer);
graphic = getGraphic(lineSymbolizer);
assertNull(graphic);
assertFalse(instance.hasFill());
assertTrue(instance.hasStroke());
PointSymbolizer pointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer();
instance.addSymbolizerToRule(pointSymbolizer);
instance.setSymbolizer(pointSymbolizer);
graphic = getGraphic(pointSymbolizer);
assertNotNull(graphic);
assertTrue(instance.hasFill());
assertFalse(instance.hasStroke());
}
use of org.geotools.styling.Graphic in project sldeditor by robward-scisys.
the class SLDTreeLeafPointTest method testGetFill.
/**
* Test method for
* {@link com.sldeditor.common.tree.leaf.SLDTreeLeafPoint#getFill(org.opengis.style.Symbolizer)}.
*/
@Test
public void testGetFill() {
SLDTreeLeafPoint leaf = new SLDTreeLeafPoint();
assertNull(leaf.getFill(null));
assertNull(leaf.getFill(DefaultSymbols.createDefaultPolygonSymbolizer()));
PointSymbolizer pointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer();
Fill expectedFill = null;
Graphic graphic = pointSymbolizer.getGraphic();
if (graphic != null) {
List<GraphicalSymbol> symbolList = graphic.graphicalSymbols();
if ((symbolList != null) && !symbolList.isEmpty()) {
GraphicalSymbol obj = symbolList.get(0);
if (obj != null) {
if (obj instanceof MarkImpl) {
MarkImpl mark = (MarkImpl) obj;
expectedFill = mark.getFill();
}
}
}
}
assertEquals(expectedFill, leaf.getFill(pointSymbolizer));
}
use of org.geotools.styling.Graphic in project sldeditor by robward-scisys.
the class MultiLayerMarkerSymbol method convert.
/*
* (non-Javadoc)
*
* @see com.sldeditor.convert.esri.symbols.EsriMarkSymbolInterface#convert(com.google.gson.
* JsonElement)
*/
@Override
public List<Graphic> convert(JsonElement element) {
if (element == null)
return null;
List<Graphic> markList = null;
JsonArray layerList = element.getAsJsonArray();
if (layerList.size() > 0) {
markList = new ArrayList<Graphic>();
for (int index = 0; index < layerList.size(); index++) {
JsonObject obj = layerList.get(index).getAsJsonObject();
List<Graphic> markerSymbolList = SymbolManager.getInstance().getMarkerList(obj.get(MultiLayerMarkerSymbolKeys.MARKER).getAsJsonObject());
if (markerSymbolList != null) {
markList.addAll(markerSymbolList);
}
}
}
return markList;
}
Aggregations