Search in sources :

Example 1 with GraphicFill

use of org.opengis.style.GraphicFill in project sldeditor by robward-scisys.

the class PolygonFillDetails method getGraphicFill.

/**
 * Gets the graphic fill.
 *
 * @return the graphic fill
 */
private GraphicFill getGraphicFill() {
    GroupConfigInterface fillGroup = getGroup(GroupIdEnum.FILL);
    boolean hasFill = fillGroup.isPanelEnabled();
    GroupConfigInterface strokeGroup = getGroup(GroupIdEnum.STROKE);
    boolean hasStroke = (strokeGroup == null) ? false : strokeGroup.isPanelEnabled();
    Expression opacity = null;
    Expression size = fieldConfigVisitor.getExpression(FieldIdEnum.SIZE);
    Expression rotation = fieldConfigVisitor.getExpression(FieldIdEnum.ANGLE);
    Expression symbolType = fieldConfigVisitor.getExpression(FieldIdEnum.SYMBOL_TYPE);
    // 
    // Anchor point
    // 
    AnchorPoint anchorPoint = null;
    GroupConfigInterface anchorPointPanel = getGroup(GroupIdEnum.ANCHORPOINT);
    if (anchorPointPanel.isPanelEnabled()) {
        anchorPoint = (AnchorPoint) getStyleFactory().anchorPoint(fieldConfigVisitor.getExpression(FieldIdEnum.ANCHOR_POINT_H), fieldConfigVisitor.getExpression(FieldIdEnum.ANCHOR_POINT_V));
        // default so it doesn't appear in the SLD
        if (DetailsUtilities.isSame(defaultAnchorPoint, anchorPoint)) {
            anchorPoint = null;
        }
    }
    // 
    // Displacement
    // 
    Displacement displacement = null;
    GroupConfigInterface displacementPanel = getGroup(GroupIdEnum.DISPLACEMENT);
    if (displacementPanel.isPanelEnabled()) {
        displacement = getStyleFactory().displacement(fieldConfigVisitor.getExpression(FieldIdEnum.DISPLACEMENT_X), fieldConfigVisitor.getExpression(FieldIdEnum.DISPLACEMENT_Y));
        // it doesn't appear in the SLD
        if (DetailsUtilities.isSame(defaultDisplacement, displacement)) {
            displacement = null;
        }
    }
    List<GraphicalSymbol> symbols = symbolTypeFactory.getValue(this.fieldConfigManager, symbolType, hasFill, hasStroke, selectedFillPanelId);
    GraphicFill graphicFill = getStyleFactory().graphicFill(symbols, opacity, size, rotation, anchorPoint, displacement);
    return graphicFill;
}
Also used : AnchorPoint(org.geotools.styling.AnchorPoint) Expression(org.opengis.filter.expression.Expression) GraphicFill(org.opengis.style.GraphicFill) GraphicalSymbol(org.opengis.style.GraphicalSymbol) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) Displacement(org.geotools.styling.Displacement)

Example 2 with GraphicFill

use of org.opengis.style.GraphicFill in project sldeditor by robward-scisys.

the class PolygonFillDetails method updateSymbol.

/**
 * Update symbol.
 */
private void updateSymbol() {
    if (!Controller.getInstance().isPopulating()) {
        if (symbolizer instanceof PolygonSymbolizer) {
            PolygonSymbolizerImpl newPolygonSymbolizer = (PolygonSymbolizerImpl) symbolizer;
            GraphicFill graphicFill = getGraphicFill();
            Fill fill = symbolTypeFactory.getFill(graphicFill, this.fieldConfigManager);
            Expression expOpacity = fieldConfigVisitor.getExpression(FieldIdEnum.OVERALL_OPACITY);
            // If field is not enabled it returns null
            if ((fill != null) && (expOpacity != null)) {
                fill.setOpacity(expOpacity);
            }
            newPolygonSymbolizer.setFill(fill);
            if (vendorOptionFillFactory != null) {
                vendorOptionFillFactory.updateSymbol(newPolygonSymbolizer);
            }
        }
        this.fireUpdateSymbol();
    }
}
Also used : PolygonSymbolizerImpl(org.geotools.styling.PolygonSymbolizerImpl) Fill(org.geotools.styling.Fill) GraphicFill(org.opengis.style.GraphicFill) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Expression(org.opengis.filter.expression.Expression) GraphicFill(org.opengis.style.GraphicFill)

Example 3 with GraphicFill

use of org.opengis.style.GraphicFill in project sldeditor by robward-scisys.

the class FieldConfigMarker method getFill.

/**
 * Gets the fill.
 *
 * @param graphicFill the graphic fill
 * @param fieldConfigManager the field config manager
 * @return the fill
 */
@Override
public Fill getFill(GraphicFill graphicFill, GraphicPanelFieldManager fieldConfigManager) {
    if (fieldConfigManager == null) {
        return null;
    }
    Expression fillColour = null;
    FieldConfigBase field = fieldConfigManager.get(fillFieldConfig.getColour());
    if (field != null) {
        if ((field instanceof FieldConfigColour) && field.isEnabled()) {
            fillColour = ((FieldConfigColour) field).getColourExpression();
        }
    }
    Expression fillColourOpacity = null;
    field = fieldConfigManager.get(fillFieldConfig.getOpacity());
    if (field != null) {
        fillColourOpacity = field.getExpression();
    }
    GraphicFill _graphicFill = null;
    Expression _fillColour = fillColour;
    Expression _fillColourOpacity = fillColourOpacity;
    if (graphicFill != null) {
        List<GraphicalSymbol> symbolList = graphicFill.graphicalSymbols();
        if ((symbolList != null) && (!symbolList.isEmpty())) {
            GraphicalSymbol symbol = symbolList.get(0);
            Mark mark = (Mark) symbol;
            if (mark.getWellKnownName() != null) {
                _graphicFill = graphicFill;
                _fillColour = null;
                _fillColourOpacity = null;
            }
        }
    }
    Fill fill = getStyleFactory().fill(_graphicFill, _fillColour, _fillColourOpacity);
    return fill;
}
Also used : Fill(org.geotools.styling.Fill) GraphicFill(org.opengis.style.GraphicFill) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) Expression(org.opengis.filter.expression.Expression) GraphicFill(org.opengis.style.GraphicFill) GraphicalSymbol(org.opengis.style.GraphicalSymbol) Mark(org.geotools.styling.Mark) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour)

Example 4 with GraphicFill

use of org.opengis.style.GraphicFill in project sldeditor by robward-scisys.

the class FieldConfigTTF method getFill.

/**
 * Gets the fill.
 *
 * @param graphicFill the graphic fill
 * @param fieldConfigManager the field config manager
 * @return the fill
 */
@Override
public Fill getFill(GraphicFill graphicFill, GraphicPanelFieldManager fieldConfigManager) {
    if (fieldConfigManager == null) {
        return null;
    }
    Expression fillColour = null;
    Expression fillColourOpacity = null;
    Fill fill = getStyleFactory().fill(graphicFill, fillColour, fillColourOpacity);
    return fill;
}
Also used : Fill(org.geotools.styling.Fill) GraphicFill(org.opengis.style.GraphicFill) Expression(org.opengis.filter.expression.Expression)

Example 5 with GraphicFill

use of org.opengis.style.GraphicFill in project sldeditor by robward-scisys.

the class LineFillSymbol method convertToFill.

/**
 * Convert to fill.
 *
 * @param layerName the layer name
 * @param element the element
 * @param transparency the transparency
 * @return the list
 */
/* (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 (layerName == null) {
        return null;
    }
    if (element == null) {
        return null;
    }
    List<Symbolizer> symbolizerList = new ArrayList<Symbolizer>();
    JsonObject obj = element.getAsJsonObject();
    Expression size = ff.literal(getDouble(obj, LineFillSymbolKeys.SEPARATION));
    Expression opacity = null;
    double lineAngle = normaliseAngle(getDouble(obj, CommonSymbolKeys.ANGLE));
    Expression rotation = null;
    AnchorPoint anchorPoint = null;
    Displacement displacement = null;
    Expression fillColour = getColour(obj.get(LineFillSymbolKeys.FILL_COLOUR));
    Expression fillColourOpacity = null;
    Expression join = null;
    Expression cap = null;
    float[] dashes = null;
    Expression offset = null;
    Expression width = ff.literal(1.0);
    Stroke outlineStroke = null;
    List<Stroke> strokeList = SymbolManager.getInstance().getStrokeList(obj.get(LineFillSymbolKeys.OUTLINE));
    // TODO
    if ((strokeList != null) && (strokeList.size() == 1)) {
        outlineStroke = strokeList.get(0);
        width = outlineStroke.getWidth();
    }
    Expression wellKnownName = null;
    if (isDoubleEqual(lineAngle, 0.0) || isDoubleEqual(lineAngle, 180.0)) {
        wellKnownName = ff.literal("shape://horline");
    } else if (isDoubleEqual(lineAngle, 90.0) || isDoubleEqual(lineAngle, 270.0)) {
        wellKnownName = ff.literal("shape://vertline");
    } else if (isDoubleEqual(lineAngle, 45.0) || isDoubleEqual(lineAngle, 225.0)) {
        wellKnownName = ff.literal("shape://slash");
    } else if (isDoubleEqual(lineAngle, 135.0) || isDoubleEqual(lineAngle, 315.0)) {
        wellKnownName = ff.literal("shape://backslash");
    } else {
        wellKnownName = ff.literal("shape://vertline");
        rotation = ff.literal(lineAngle);
    }
    Fill fill = null;
    Stroke markStroke = styleFactory.stroke(fillColour, fillColourOpacity, width, join, cap, dashes, offset);
    Mark mark = styleFactory.createMark(wellKnownName, markStroke, fill, size, rotation);
    List<GraphicalSymbol> symbolList = new ArrayList<GraphicalSymbol>();
    symbolList.add(mark);
    GraphicFill graphicFill = styleFactory.graphicFill(symbolList, opacity, size, rotation, anchorPoint, displacement);
    Fill completeFill = styleFactory.fill(graphicFill, null, null);
    PolygonSymbolizer polygonSymbolizer = styleFactory.createPolygonSymbolizer();
    polygonSymbolizer.setFill(completeFill);
    polygonSymbolizer.setStroke(outlineStroke);
    symbolizerList.add(polygonSymbolizer);
    return symbolizerList;
}
Also used : Stroke(org.geotools.styling.Stroke) GraphicFill(org.opengis.style.GraphicFill) Fill(org.geotools.styling.Fill) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) GraphicalSymbol(org.opengis.style.GraphicalSymbol) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) Mark(org.geotools.styling.Mark) Symbolizer(org.geotools.styling.Symbolizer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Displacement(org.geotools.styling.Displacement) AnchorPoint(org.geotools.styling.AnchorPoint) Expression(org.opengis.filter.expression.Expression) GraphicFill(org.opengis.style.GraphicFill)

Aggregations

GraphicFill (org.opengis.style.GraphicFill)10 Fill (org.geotools.styling.Fill)9 Expression (org.opengis.filter.expression.Expression)7 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)4 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)4 AnchorPoint (org.geotools.styling.AnchorPoint)3 Displacement (org.geotools.styling.Displacement)3 GraphicalSymbol (org.opengis.style.GraphicalSymbol)3 JsonObject (com.google.gson.JsonObject)2 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)2 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)2 PointFillDetails (com.sldeditor.ui.detail.PointFillDetails)2 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)2 FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)2 FieldConfigSymbolType (com.sldeditor.ui.detail.config.FieldConfigSymbolType)2 Mark (org.geotools.styling.Mark)2 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)2 StyleBuilder (org.geotools.styling.StyleBuilder)2 Test (org.junit.Test)2 JsonElement (com.google.gson.JsonElement)1