Search in sources :

Example 6 with Fill

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

the class SimpleFillSymbol 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>();
    Expression fillColour = getColour(obj.get(SimpleFillSymbolKeys.FILL_COLOUR));
    Expression transparencyExpression = getTransparency(transparency);
    Fill fill = null;
    if (fillColour != null) {
        fill = styleFactory.createFill(fillColour, transparencyExpression);
    }
    PolygonSymbolizer polygon = styleFactory.createPolygonSymbolizer();
    polygon.setStroke(null);
    polygon.setFill(fill);
    symbolizerList.add(polygon);
    return symbolizerList;
}
Also used : Fill(org.geotools.styling.Fill) Expression(org.opengis.filter.expression.Expression) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) Symbolizer(org.geotools.styling.Symbolizer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer)

Example 7 with Fill

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

the class SimpleMarkerSymbol method convert.

/**
 * Convert.
 *
 * @param element the element
 * @return the graphic marker list
 */
@Override
public List<Graphic> convert(JsonElement element) {
    if (element == null)
        return null;
    JsonObject obj = element.getAsJsonObject();
    List<Graphic> markList = new ArrayList<Graphic>();
    double angle = getDouble(obj, CommonSymbolKeys.ANGLE);
    double outlineSize = getDouble(obj, SimpleMarkerSymbolKeys.OUTLINE_SIZE);
    double size = getDouble(obj, CommonSymbolKeys.SIZE);
    int style = getInt(obj, CommonSymbolKeys.STYLE);
    double xOffset = getDouble(obj, CommonSymbolKeys.X_OFFSET);
    double yOffset = getDouble(obj, CommonSymbolKeys.Y_OFFSET);
    Expression markerColour = getColour(obj.get(CommonSymbolKeys.COLOUR));
    Expression outlineColour = getColour(obj.get(SimpleMarkerSymbolKeys.OUTLINE_COLOUR));
    Expression wellKnownName = ff.literal(styleMap.get(style));
    Stroke stroke = null;
    if (outlineSize > 0.0) {
        stroke = styleFactory.createStroke(outlineColour, ff.literal(outlineSize));
    }
    Fill fill = styleFactory.createFill(markerColour);
    Mark mark = styleFactory.createMark(wellKnownName, stroke, fill, ff.literal(size), ff.literal(angle));
    Expression expressionOpacity = null;
    ExternalGraphic[] externalGraphics = null;
    Symbol[] symbols = null;
    Mark[] marks = new Mark[1];
    marks[0] = mark;
    Graphic graphic = styleFactory.createGraphic(externalGraphics, marks, symbols, expressionOpacity, ff.literal(size), ff.literal(angle));
    // Set offset
    if ((xOffset > 0.0) && (yOffset > 0.0)) {
        Displacement displacement = styleFactory.displacement(ff.literal(xOffset), ff.literal(yOffset));
        graphic.setDisplacement(displacement);
    }
    markList.add(graphic);
    return markList;
}
Also used : Stroke(org.geotools.styling.Stroke) Fill(org.geotools.styling.Fill) ExternalGraphic(org.geotools.styling.ExternalGraphic) Graphic(org.geotools.styling.Graphic) Symbol(org.geotools.styling.Symbol) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) Mark(org.geotools.styling.Mark) ExternalGraphic(org.geotools.styling.ExternalGraphic) Displacement(org.geotools.styling.Displacement) Expression(org.opengis.filter.expression.Expression)

Example 8 with Fill

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

the class DefaultSymbols method createDefaultGraphicFill.

/**
 * Creates a default graphic fill.
 *
 * @return the fill
 */
public static Fill createDefaultGraphicFill() {
    Graphic graphicFill = styleFactory.createDefaultGraphic();
    Expression colour = ff.literal(DEFAULT_FILL_COLOUR);
    Expression backgroundColour = null;
    Expression opacity = ff.literal(1.0);
    Fill fill = styleFactory.createFill(colour, backgroundColour, opacity, graphicFill);
    return fill;
}
Also used : Fill(org.geotools.styling.Fill) Expression(org.opengis.filter.expression.Expression) Graphic(org.geotools.styling.Graphic)

Example 9 with Fill

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

the class DefaultSymbols method createDefaultPolygonSymbolizer.

/**
 * Creates the default polygon symbolizer.
 *
 * @return the polygon symbolizer
 */
public static PolygonSymbolizer createDefaultPolygonSymbolizer() {
    Stroke stroke = styleFactory.createStroke(ff.literal(DEFAULT_LINE_COLOUR), ff.literal(2));
    Fill fill = styleFactory.getDefaultFill();
    PolygonSymbolizer polygonSymbolizer = styleFactory.createPolygonSymbolizer();
    polygonSymbolizer.setStroke(stroke);
    polygonSymbolizer.setFill(fill);
    return polygonSymbolizer;
}
Also used : Stroke(org.geotools.styling.Stroke) Fill(org.geotools.styling.Fill) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer)

Example 10 with Fill

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

the class PolygonFillDetails method populate.

/**
 * Populate.
 *
 * @param selectedSymbol the selected symbol
 */
/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.iface.PopulateDetailsInterface#populate(com.sldeditor.ui.detail.SelectedSymbol)
     */
@Override
public void populate(SelectedSymbol selectedSymbol) {
    Expression expSize = null;
    Expression expRotation = null;
    Expression expAnchorPointX = null;
    Expression expAnchorPointY = null;
    Expression expDisplacementX = null;
    Expression expDisplacementY = null;
    Expression expFillColour = null;
    Expression expGap = null;
    Expression expInitialGap = null;
    Fill fill = null;
    Expression expOpacity = null;
    symbolizer = null;
    if (selectedSymbol != null) {
        symbolizer = selectedSymbol.getSymbolizer();
        Graphic graphic = null;
        if (symbolizer instanceof PointSymbolizerImpl) {
            PointSymbolizer pointSymbolizer = (PointSymbolizer) symbolizer;
            graphic = pointSymbolizer.getGraphic();
            if (graphic != null) {
                List<GraphicalSymbol> graphicSymbolList = graphic.graphicalSymbols();
                if (!graphicSymbolList.isEmpty()) {
                    GraphicalSymbol graphicalSymbol = graphicSymbolList.get(0);
                    if (graphicalSymbol instanceof MarkImpl) {
                        MarkImpl mark = (MarkImpl) graphicalSymbol;
                        fill = mark.getFill();
                        if (fill != null) {
                            expOpacity = fill.getOpacity();
                        }
                    }
                }
            }
        } else if (symbolizer instanceof PolygonSymbolizerImpl) {
            PolygonSymbolizer polygonSymbolizer = (PolygonSymbolizer) symbolizer;
            if (polygonSymbolizer != null) {
                fill = polygonSymbolizer.getFill();
                if (fill != null) {
                    expOpacity = fill.getOpacity();
                    graphic = fill.getGraphicFill();
                }
            }
        }
        if (graphic == null) {
            if (fill != null) {
                expFillColour = fill.getColor();
            }
            if (fill == null) {
                symbolTypeFactory.setNoFill(this.fieldConfigManager);
            } else {
                symbolTypeFactory.setSolidFill(this.fieldConfigManager, expFillColour, expOpacity);
            }
        } else {
            expSize = graphic.getSize();
            expRotation = graphic.getRotation();
            // Anchor point
            AnchorPoint anchorPoint = graphic.getAnchorPoint();
            if (anchorPoint != null) {
                expAnchorPointX = anchorPoint.getAnchorPointX();
                expAnchorPointY = anchorPoint.getAnchorPointY();
            } else {
                expAnchorPointX = defaultAnchorPoint.getAnchorPointX();
                expAnchorPointY = defaultAnchorPoint.getAnchorPointY();
            }
            // Offset
            Displacement displacement = graphic.getDisplacement();
            if (displacement != null) {
                expDisplacementX = displacement.getDisplacementX();
                expDisplacementY = displacement.getDisplacementY();
            } else {
                expDisplacementX = defaultDisplacement.getDisplacementX();
                expDisplacementY = defaultDisplacement.getDisplacementY();
            }
            expGap = graphic.getGap();
            expInitialGap = graphic.getInitialGap();
            List<GraphicalSymbol> graphicalSymbolList = graphic.graphicalSymbols();
            if (!graphicalSymbolList.isEmpty()) {
                GraphicalSymbol symbol = graphicalSymbolList.get(0);
                symbolTypeFactory.setValue(PolygonSymbolizer.class, this.fieldConfigManager, graphic, symbol);
            }
        }
    }
    fieldConfigVisitor.populateField(FieldIdEnum.SIZE, expSize);
    fieldConfigVisitor.populateField(FieldIdEnum.ANGLE, expRotation);
    fieldConfigVisitor.populateField(FieldIdEnum.ANCHOR_POINT_H, expAnchorPointX);
    fieldConfigVisitor.populateField(FieldIdEnum.ANCHOR_POINT_V, expAnchorPointY);
    fieldConfigVisitor.populateField(FieldIdEnum.DISPLACEMENT_X, expDisplacementX);
    fieldConfigVisitor.populateField(FieldIdEnum.DISPLACEMENT_Y, expDisplacementY);
    fieldConfigVisitor.populateField(FieldIdEnum.GAP, expGap);
    fieldConfigVisitor.populateField(FieldIdEnum.INITIAL_GAP, expInitialGap);
    fieldConfigVisitor.populateField(FieldIdEnum.OVERALL_OPACITY, expOpacity);
    if (vendorOptionFillFactory != null) {
        if (symbolizer instanceof PolygonSymbolizer) {
            vendorOptionFillFactory.populate((PolygonSymbolizer) symbolizer);
        }
    }
    updateSymbol();
}
Also used : PolygonSymbolizerImpl(org.geotools.styling.PolygonSymbolizerImpl) PointSymbolizer(org.geotools.styling.PointSymbolizer) Fill(org.geotools.styling.Fill) GraphicFill(org.opengis.style.GraphicFill) AnchorPoint(org.geotools.styling.AnchorPoint) Expression(org.opengis.filter.expression.Expression) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Graphic(org.geotools.styling.Graphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol) MarkImpl(org.geotools.styling.MarkImpl) PointSymbolizerImpl(org.geotools.styling.PointSymbolizerImpl) Displacement(org.geotools.styling.Displacement)

Aggregations

Fill (org.geotools.styling.Fill)39 Expression (org.opengis.filter.expression.Expression)23 Stroke (org.geotools.styling.Stroke)18 GraphicFill (org.opengis.style.GraphicFill)17 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)14 GraphicalSymbol (org.opengis.style.GraphicalSymbol)14 Graphic (org.geotools.styling.Graphic)13 ArrayList (java.util.ArrayList)11 Mark (org.geotools.styling.Mark)11 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)10 JsonObject (com.google.gson.JsonObject)9 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)8 AnchorPoint (org.geotools.styling.AnchorPoint)7 Displacement (org.geotools.styling.Displacement)7 PointSymbolizer (org.geotools.styling.PointSymbolizer)6 Test (org.junit.Test)6 ExternalGraphic (org.geotools.styling.ExternalGraphic)5 JsonElement (com.google.gson.JsonElement)4 MarkImpl (org.geotools.styling.MarkImpl)4 Symbolizer (org.geotools.styling.Symbolizer)4