Search in sources :

Example 16 with Graphic

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;
}
Also used : ExternalGraphic(org.geotools.styling.ExternalGraphic) Graphic(org.geotools.styling.Graphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol) ArrayList(java.util.ArrayList) ExternalGraphic(org.geotools.styling.ExternalGraphic)

Example 17 with Graphic

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;
}
Also used : PolygonSymbolizerImpl(org.geotools.styling.PolygonSymbolizerImpl) PointSymbolizer(org.geotools.styling.PointSymbolizer) Fill(org.geotools.styling.Fill) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Graphic(org.geotools.styling.Graphic) PointSymbolizerImpl(org.geotools.styling.PointSymbolizerImpl)

Example 18 with 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());
}
Also used : SelectedSymbol(com.sldeditor.common.data.SelectedSymbol) PointSymbolizer(org.geotools.styling.PointSymbolizer) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) Fill(org.geotools.styling.Fill) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Graphic(org.geotools.styling.Graphic) LineSymbolizer(org.geotools.styling.LineSymbolizer) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer) Test(org.junit.Test)

Example 19 with Graphic

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));
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) Fill(org.geotools.styling.Fill) Graphic(org.geotools.styling.Graphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol) SLDTreeLeafPoint(com.sldeditor.common.tree.leaf.SLDTreeLeafPoint) MarkImpl(org.geotools.styling.MarkImpl) Test(org.junit.Test)

Example 20 with Graphic

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;
}
Also used : JsonArray(com.google.gson.JsonArray) Graphic(org.geotools.styling.Graphic) JsonObject(com.google.gson.JsonObject)

Aggregations

Graphic (org.geotools.styling.Graphic)34 PointSymbolizer (org.geotools.styling.PointSymbolizer)17 GraphicalSymbol (org.opengis.style.GraphicalSymbol)16 Fill (org.geotools.styling.Fill)13 Expression (org.opengis.filter.expression.Expression)12 ExternalGraphic (org.geotools.styling.ExternalGraphic)11 Stroke (org.geotools.styling.Stroke)10 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)9 AnchorPoint (org.geotools.styling.AnchorPoint)8 Displacement (org.geotools.styling.Displacement)8 ArrayList (java.util.ArrayList)7 Mark (org.geotools.styling.Mark)7 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)6 MarkImpl (org.geotools.styling.MarkImpl)6 Rule (org.geotools.styling.Rule)6 JsonObject (com.google.gson.JsonObject)5 LineSymbolizer (org.geotools.styling.LineSymbolizer)5 JsonElement (com.google.gson.JsonElement)4 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)4 NamedLayer (org.geotools.styling.NamedLayer)4