Search in sources :

Example 31 with Stroke

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

the class SymbolTypeFactory method getMinimumVersion.

/**
 * Gets the minimum version for the SLD symbol.
 *
 * @param parentObj the parent obj
 * @param sldObj the sld obj
 * @param vendorOptionsPresentList the vendor options present list
 */
public void getMinimumVersion(Object parentObj, Object sldObj, List<VendorOptionPresent> vendorOptionsPresentList) {
    GraphicalSymbol symbol = null;
    Graphic graphic = null;
    if (sldObj instanceof Graphic) {
        graphic = (Graphic) sldObj;
    } else if (sldObj instanceof Fill) {
        Fill fill = (Fill) sldObj;
        graphic = fill.getGraphicFill();
    } else if (sldObj instanceof Stroke) {
        Stroke stroke = (Stroke) sldObj;
        graphic = stroke.getGraphicStroke();
    }
    if (graphic != null) {
        List<GraphicalSymbol> graphicalSymbolList = graphic.graphicalSymbols();
        if ((graphicalSymbolList != null) && !graphicalSymbolList.isEmpty()) {
            symbol = graphicalSymbolList.get(0);
        }
    }
    if (symbol != null) {
        for (FieldState panel : symbolTypeFieldList) {
            if (panel.accept(symbol)) {
                panel.getMinimumVersion(parentObj, sldObj, vendorOptionsPresentList);
            }
        }
    }
}
Also used : Fill(org.geotools.styling.Fill) GraphicFill(org.opengis.style.GraphicFill) Stroke(org.geotools.styling.Stroke) Graphic(org.geotools.styling.Graphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol)

Example 32 with Stroke

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

the class VOGeoServerTextSymbolizer2 method populate.

/**
 * Populate.
 *
 * @param textSymbolizer the text symbolizer
 */
/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.detail.vendor.geoserver.VendorOptionInterface#populate(org.geotools.styling.TextSymbolizer)
     */
@Override
public void populate(TextSymbolizer textSymbolizer) {
    if (textSymbolizer instanceof TextSymbolizer2) {
        TextSymbolizer2 textSymbol2 = (TextSymbolizer2) textSymbolizer;
        fieldConfigVisitor.populateField(FieldIdEnum.VO_TEXTSYMBOLIZER_2_FEATURE_DESCRIPTION, textSymbol2.getFeatureDescription());
        fieldConfigVisitor.populateField(FieldIdEnum.VO_TEXTSYMBOLIZER_2_SNIPPET, textSymbol2.getSnippet());
        OtherText otherText = textSymbol2.getOtherText();
        String target = null;
        Expression text = null;
        if (otherText != null) {
            target = otherText.getTarget();
            text = otherText.getText();
        }
        GroupConfigInterface group = getGroup(GroupIdEnum.VO_TEXTSYMBOLIZER_2_OTHERTEXT);
        if (group != null) {
            group.enable(otherText != null);
        }
        fieldConfigVisitor.populateTextField(FieldIdEnum.VO_TEXTSYMBOLIZER_2_OTHERTEXT_TARGET, target);
        fieldConfigVisitor.populateField(FieldIdEnum.VO_TEXTSYMBOLIZER_2_OTHERTEXT_TEXT, text);
        Graphic graphic = textSymbol2.getGraphic();
        boolean enableFill = false;
        boolean enableStroke = false;
        if (graphic == null) {
            graphic = getStyleFactory().createDefaultGraphic();
            graphic.setSize(getFilterFactory().literal(10.0));
            Mark mark = getStyleFactory().createMark();
            graphic.graphicalSymbols().add(mark);
        }
        Expression fillColour = getFilterFactory().literal(DefaultSymbols.defaultColour());
        Expression fillOpacity = getFilterFactory().literal(DefaultSymbols.defaultColourOpacity());
        Expression strokeColour = getFilterFactory().literal(DefaultSymbols.defaultColour());
        Expression strokeOpacity = getFilterFactory().literal(DefaultSymbols.defaultColourOpacity());
        Expression strokeLineWidth = null;
        List<GraphicalSymbol> graphicalSymbolList = graphic.graphicalSymbols();
        if (!graphicalSymbolList.isEmpty()) {
            GraphicalSymbol symbol = graphicalSymbolList.get(0);
            symbolTypeFactory.setValue(TextSymbolizer2.class, this.fieldConfigManager, graphic, symbol);
            if (symbol instanceof Mark) {
                Mark mark = (Mark) symbol;
                Fill fill = mark.getFill();
                if (fill != null) {
                    enableFill = true;
                    fillColour = fill.getColor();
                    fillOpacity = fill.getOpacity();
                }
                Stroke stroke = mark.getStroke();
                if (stroke != null) {
                    enableStroke = true;
                    strokeColour = stroke.getColor();
                    strokeOpacity = stroke.getOpacity();
                    strokeLineWidth = stroke.getWidth();
                }
            }
        }
        Expression expSize = graphic.getSize();
        Expression expRotation = graphic.getRotation();
        fieldConfigVisitor.populateField(FieldIdEnum.VO_TEXTSYMBOLIZER_2_SIZE, expSize);
        fieldConfigVisitor.populateField(FieldIdEnum.VO_TEXTSYMBOLIZER_2_ANGLE, expRotation);
        fieldConfigVisitor.populateField(FieldIdEnum.VO_TEXTSYMBOLIZER_2_FILL_COLOUR, fillColour);
        fieldConfigVisitor.populateField(FieldIdEnum.VO_TEXTSYMBOLIZER_2_FILL_OPACITY, fillOpacity);
        fieldConfigVisitor.populateField(FieldIdEnum.VO_TEXTSYMBOLIZER_2_STROKE_FILL_COLOUR, strokeColour);
        fieldConfigVisitor.populateField(FieldIdEnum.VO_TEXTSYMBOLIZER_2_STROKE_OPACITY, strokeOpacity);
        fieldConfigVisitor.populateField(FieldIdEnum.VO_TEXTSYMBOLIZER_2_STROKE_FILL_WIDTH, strokeLineWidth);
        GroupConfigInterface fillGroup = getGroup(GroupIdEnum.VO_TEXTSYMBOLIZER_2_FILL);
        if (fillGroup != null) {
            fillGroup.enable(enableFill);
        }
        GroupConfigInterface strokeGroup = getGroup(GroupIdEnum.VO_TEXTSYMBOLIZER_2_STROKE);
        if (strokeGroup != null) {
            group.enable(enableStroke);
        }
        group = getGroup(GroupIdEnum.VO_TEXTSYMBOLIZER_2_GRAPHIC);
        if (group != null) {
            group.enable(textSymbol2.getGraphic() != null);
        }
    }
}
Also used : Fill(org.geotools.styling.Fill) Stroke(org.geotools.styling.Stroke) TextSymbolizer2(org.geotools.styling.TextSymbolizer2) Expression(org.opengis.filter.expression.Expression) ExternalGraphic(org.geotools.styling.ExternalGraphic) Graphic(org.geotools.styling.Graphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol) Mark(org.geotools.styling.Mark) OtherText(org.geotools.styling.OtherText) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface)

Example 33 with Stroke

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

the class FieldConfigTTF method getValue.

/**
 * Gets the value.
 *
 * @param fieldConfigManager the field config manager
 * @param symbolType the symbol type
 * @param fillEnabled the fill enabled
 * @param strokeEnabled the stroke enabled
 * @return the value
 */
@Override
public List<GraphicalSymbol> getValue(GraphicPanelFieldManager fieldConfigManager, Expression symbolType, boolean fillEnabled, boolean strokeEnabled) {
    List<GraphicalSymbol> symbolList = new ArrayList<GraphicalSymbol>();
    Expression wellKnownName = null;
    if ((getConfigField() != null) && (fieldConfigManager != null)) {
        wellKnownName = getConfigField().getExpression();
        if (wellKnownName != null) {
            Stroke stroke = null;
            Fill fill = null;
            if (fillEnabled) {
                Expression expFillColour = null;
                Expression expFillColourOpacity = null;
                FieldConfigBase field = fieldConfigManager.get(fillFieldConfig.getColour());
                if (field != null) {
                    FieldConfigColour colourField = (FieldConfigColour) field;
                    expFillColour = colourField.getColourExpression();
                }
                field = fieldConfigManager.get(fillFieldConfig.getOpacity());
                if (field != null) {
                    expFillColourOpacity = field.getExpression();
                }
                fill = getStyleFactory().createFill(expFillColour, expFillColourOpacity);
            }
            // Size
            Expression expSize = null;
            // Rotation
            Expression expRotation = null;
            Mark mark = getStyleFactory().createMark(wellKnownName, stroke, fill, expSize, expRotation);
            symbolList.add(mark);
        }
    }
    return symbolList;
}
Also used : Stroke(org.geotools.styling.Stroke) Fill(org.geotools.styling.Fill) GraphicFill(org.opengis.style.GraphicFill) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) Expression(org.opengis.filter.expression.Expression) GraphicalSymbol(org.opengis.style.GraphicalSymbol) ArrayList(java.util.ArrayList) Mark(org.geotools.styling.Mark) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour)

Example 34 with Stroke

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

the class FieldConfigWindBarbs method getValue.

/**
 * Gets the value.
 *
 * @param fieldConfigManager the field config manager
 * @param symbolType the symbol type
 * @param fillEnabled the fill enabled
 * @param strokeEnabled the stroke enabled
 * @return the value
 */
@Override
public List<GraphicalSymbol> getValue(GraphicPanelFieldManager fieldConfigManager, Expression symbolType, boolean fillEnabled, boolean strokeEnabled) {
    List<GraphicalSymbol> symbolList = new ArrayList<GraphicalSymbol>();
    Expression wellKnownName = null;
    if ((getConfigField() != null) && (fieldConfigManager != null)) {
        wellKnownName = getConfigField().getExpression();
        if (wellKnownName != null) {
            Expression expFillColour = null;
            Expression expFillColourOpacity = null;
            FieldConfigBase field = fieldConfigManager.get(FieldIdEnum.FILL_COLOUR);
            if (field != null) {
                FieldConfigColour colourField = (FieldConfigColour) field;
                expFillColour = colourField.getColourExpression();
            }
            Stroke stroke = null;
            Fill fill = getStyleFactory().createFill(expFillColour, expFillColourOpacity);
            Expression size = null;
            Expression rotation = null;
            Mark mark = getStyleFactory().createMark(wellKnownName, stroke, fill, size, rotation);
            symbolList.add(mark);
        }
    }
    return symbolList;
}
Also used : Stroke(org.geotools.styling.Stroke) Fill(org.geotools.styling.Fill) GraphicFill(org.opengis.style.GraphicFill) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) Expression(org.opengis.filter.expression.Expression) GraphicalSymbol(org.opengis.style.GraphicalSymbol) ArrayList(java.util.ArrayList) Mark(org.geotools.styling.Mark) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour)

Example 35 with Stroke

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

the class FieldConfigArrow method getValue.

/**
 * Gets the value.
 *
 * @param fieldConfigManager the field config manager
 * @param symbolType the symbol type
 * @param fillEnabled the fill enabled
 * @param strokeEnabled the stroke enabled
 * @return the value
 */
@Override
public List<GraphicalSymbol> getValue(GraphicPanelFieldManager fieldConfigManager, Expression symbolType, boolean fillEnabled, boolean strokeEnabled) {
    List<GraphicalSymbol> symbolList = new ArrayList<GraphicalSymbol>();
    if (fieldConfigManager != null) {
        Expression wellKnownName = null;
        if (getConfigField() != null) {
            wellKnownName = getConfigField().getExpression();
            if (wellKnownName != null) {
                // Stroke colour
                FieldConfigBase field = null;
                Stroke stroke = null;
                if (strokeEnabled && (strokeFieldConfig != null)) {
                    Expression expStrokeColour = null;
                    Expression expStrokeColourOpacity = null;
                    field = fieldConfigManager.get(strokeFieldConfig.getColour());
                    if (field != null) {
                        if (field instanceof FieldConfigColour) {
                            FieldConfigColour colourField = (FieldConfigColour) field;
                            expStrokeColour = colourField.getColourExpression();
                        }
                    }
                    field = fieldConfigManager.get(strokeFieldConfig.getOpacity());
                    if (field != null) {
                        expStrokeColourOpacity = field.getExpression();
                    }
                    stroke = getStyleFactory().createStroke(expStrokeColour, expStrokeColourOpacity);
                }
                // Fill colour
                Fill fill = null;
                if (fillEnabled && (fillFieldConfig != null)) {
                    Expression expFillColour = null;
                    Expression expFillColourOpacity = null;
                    field = fieldConfigManager.get(fillFieldConfig.getColour());
                    if (field != null) {
                        if (field instanceof FieldConfigColour) {
                            FieldConfigColour colourField = (FieldConfigColour) field;
                            expFillColour = colourField.getColourExpression();
                        }
                    }
                    field = fieldConfigManager.get(fillFieldConfig.getOpacity());
                    if (field != null) {
                        expFillColourOpacity = field.getExpression();
                    }
                    fill = getStyleFactory().createFill(expFillColour, expFillColourOpacity);
                }
                field = fieldConfigManager.get(FieldIdEnum.STROKE_WIDTH);
                if (field != null) {
                    Expression strokeWidth = field.getExpression();
                    stroke.setWidth(strokeWidth);
                }
                Expression symbolSize = null;
                field = fieldConfigManager.get(FieldIdEnum.STROKE_SYMBOL_SIZE);
                if (field != null) {
                    symbolSize = field.getExpression();
                }
                Expression rotation = null;
                Mark mark = getStyleFactory().createMark(wellKnownName, stroke, fill, symbolSize, rotation);
                symbolList.add(mark);
            }
        }
    }
    return symbolList;
}
Also used : Stroke(org.geotools.styling.Stroke) Fill(org.geotools.styling.Fill) GraphicFill(org.opengis.style.GraphicFill) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) Expression(org.opengis.filter.expression.Expression) GraphicalSymbol(org.opengis.style.GraphicalSymbol) ArrayList(java.util.ArrayList) Mark(org.geotools.styling.Mark) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour)

Aggregations

Stroke (org.geotools.styling.Stroke)36 Fill (org.geotools.styling.Fill)18 Expression (org.opengis.filter.expression.Expression)16 JsonObject (com.google.gson.JsonObject)13 GraphicalSymbol (org.opengis.style.GraphicalSymbol)13 LineSymbolizer (org.geotools.styling.LineSymbolizer)12 ArrayList (java.util.ArrayList)11 Graphic (org.geotools.styling.Graphic)10 Mark (org.geotools.styling.Mark)10 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)10 GraphicFill (org.opengis.style.GraphicFill)8 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)7 JsonElement (com.google.gson.JsonElement)6 Symbolizer (org.geotools.styling.Symbolizer)6 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)5 Displacement (org.geotools.styling.Displacement)5 ExternalGraphic (org.geotools.styling.ExternalGraphic)5 GraphicStroke (org.opengis.style.GraphicStroke)5 JsonArray (com.google.gson.JsonArray)4 AnchorPoint (org.geotools.styling.AnchorPoint)4