Search in sources :

Example 21 with GraphicalSymbol

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

the class StrokeDetails method updateSymbol.

/**
 * Update symbol.
 */
private void updateSymbol() {
    if (!Controller.getInstance().isPopulating()) {
        Stroke stroke = getStroke();
        if (symbolizer instanceof PointSymbolizer) {
            PointSymbolizer pointSymbol = (PointSymbolizer) symbolizer;
            Graphic graphic = pointSymbol.getGraphic();
            GraphicalSymbol symbol = graphic.graphicalSymbols().get(0);
            if (symbol instanceof MarkImpl) {
                MarkImpl markerSymbol = (MarkImpl) symbol;
                markerSymbol.setStroke(stroke);
                SelectedSymbol.getInstance().replaceSymbolizer(pointSymbol);
                this.fireUpdateSymbol();
            }
        } else if (symbolizer instanceof LineSymbolizer) {
            LineSymbolizer lineSymbol = (LineSymbolizer) symbolizer;
            lineSymbol.setStroke(stroke);
            SelectedSymbol.getInstance().replaceSymbolizer(lineSymbol);
            this.fireUpdateSymbol();
        } else if (symbolizer instanceof PolygonSymbolizer) {
            PolygonSymbolizer polygonSymbol = (PolygonSymbolizer) symbolizer;
            polygonSymbol.setStroke(stroke);
            SelectedSymbol.getInstance().replaceSymbolizer(polygonSymbol);
            this.fireUpdateSymbol();
        }
    }
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) GraphicStroke(org.opengis.style.GraphicStroke) Stroke(org.geotools.styling.Stroke) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Graphic(org.geotools.styling.Graphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol) LineSymbolizer(org.geotools.styling.LineSymbolizer) MarkImpl(org.geotools.styling.MarkImpl)

Example 22 with GraphicalSymbol

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

the class StrokeDetails method getStroke.

/**
 * Gets the stroke.
 *
 * @return the stroke
 */
public Stroke getStroke() {
    Expression join = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_LINE_JOIN);
    Expression lineCap = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_LINE_CAP);
    Expression offset = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_OFFSET);
    Expression strokeWidth = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_WIDTH);
    ValueComboBoxData symbolTypeValue = fieldConfigVisitor.getComboBox(FieldIdEnum.STROKE_STYLE);
    Expression symbolType = null;
    if (symbolTypeValue != null) {
        symbolType = getFilterFactory().literal(symbolTypeValue.getKey());
    }
    List<Float> dashList = createDashArray(fieldConfigVisitor.getText(FieldIdEnum.STROKE_DASH_ARRAY));
    float[] dashes = convertDashListToArray(dashList);
    FieldConfigBase fdmFillColour = fieldConfigManager.get(FieldIdEnum.STROKE_FILL_COLOUR);
    FieldConfigColour colourField = (FieldConfigColour) fdmFillColour;
    Expression fillColour = colourField.getColourExpression();
    Expression opacity = fieldConfigVisitor.getExpression(FieldIdEnum.OVERALL_OPACITY);
    boolean isLine = true;
    if (symbolTypeValue != null) {
        isLine = (symbolTypeValue.getKey().compareTo(SOLID_LINE_KEY) == 0);
    }
    boolean fillColourEnabled = isPanelEnabled(GroupIdEnum.FILLCOLOUR);
    boolean strokeColourEnabled = isPanelEnabled(GroupIdEnum.STROKECOLOUR);
    Stroke stroke = null;
    if (isLine) {
        opacity = fieldConfigVisitor.getExpression(FieldIdEnum.LINE_FILL_OPACITY);
        stroke = getStyleFactory().stroke(fillColour, opacity, strokeWidth, join, lineCap, dashes, offset);
    } else {
        stroke = getStyleFactory().getDefaultStroke();
        AnchorPoint anchorPoint = getStyleFactory().anchorPoint(fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_ANCHOR_POINT_H), fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_ANCHOR_POINT_V));
        // default so it doesn't appear in the SLD
        if (DetailsUtilities.isSame(defaultAnchorPoint, anchorPoint)) {
            anchorPoint = null;
        }
        Displacement displacement = getStyleFactory().displacement(fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_DISPLACEMENT_X), fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_DISPLACEMENT_Y));
        // so it doesn't appear in the SLD
        if (DetailsUtilities.isSame(defaultDisplacement, displacement)) {
            displacement = null;
        }
        List<GraphicalSymbol> symbols = symbolTypeFactory.getValue(this.fieldConfigManager, symbolType, fillColourEnabled, strokeColourEnabled, selectedFillPanelId);
        Expression initalGap = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_INITIAL_GAP);
        Expression gap = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_GAP);
        Expression rotation = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_ANGLE);
        Expression symbolSize = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_SIZE);
        GraphicStroke graphicStroke = getStyleFactory().graphicStroke(symbols, opacity, symbolSize, rotation, anchorPoint, displacement, initalGap, gap);
        boolean overallOpacity = symbolTypeFactory.isOverallOpacity(PointSymbolizer.class, selectedFillPanelId);
        if (overallOpacity) {
            stroke.setOpacity(opacity);
        }
        stroke.setGraphicStroke(graphicStroke);
        stroke.setWidth(strokeWidth);
    }
    return stroke;
}
Also used : GraphicStroke(org.opengis.style.GraphicStroke) Stroke(org.geotools.styling.Stroke) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) GraphicalSymbol(org.opengis.style.GraphicalSymbol) GraphicStroke(org.opengis.style.GraphicStroke) Displacement(org.geotools.styling.Displacement) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) AnchorPoint(org.geotools.styling.AnchorPoint) ConstantExpression(org.geotools.filter.ConstantExpression) Expression(org.opengis.filter.expression.Expression) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour)

Example 23 with GraphicalSymbol

use of org.opengis.style.GraphicalSymbol 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 24 with GraphicalSymbol

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

the class WindBarbDetails method getWellKnownName.

/**
 * Gets the well known name.
 *
 * @param symbolizer the symbolizer
 * @return the well known name
 */
private Expression getWellKnownName(Symbolizer symbolizer) {
    Expression wellKnownName = null;
    if (symbolizer instanceof PointSymbolizerImpl) {
        PointSymbolizerImpl point = (PointSymbolizerImpl) symbolizer;
        List<GraphicalSymbol> graphicalSymbolList = point.getGraphic().graphicalSymbols();
        if ((graphicalSymbolList != null) && !graphicalSymbolList.isEmpty()) {
            GraphicalSymbol graphicalSymbol = graphicalSymbolList.get(0);
            if (graphicalSymbol instanceof MarkImpl) {
                MarkImpl mark = (MarkImpl) graphicalSymbol;
                wellKnownName = mark.getWellKnownName();
            }
        }
    }
    return wellKnownName;
}
Also used : ConstantExpression(org.geotools.filter.ConstantExpression) Expression(org.opengis.filter.expression.Expression) GraphicalSymbol(org.opengis.style.GraphicalSymbol) MarkImpl(org.geotools.styling.MarkImpl) PointSymbolizerImpl(org.geotools.styling.PointSymbolizerImpl)

Example 25 with GraphicalSymbol

use of org.opengis.style.GraphicalSymbol 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)

Aggregations

GraphicalSymbol (org.opengis.style.GraphicalSymbol)36 Expression (org.opengis.filter.expression.Expression)23 Graphic (org.geotools.styling.Graphic)16 Fill (org.geotools.styling.Fill)14 Mark (org.geotools.styling.Mark)14 Stroke (org.geotools.styling.Stroke)12 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)11 AnchorPoint (org.geotools.styling.AnchorPoint)11 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)10 Test (org.junit.Test)10 Displacement (org.geotools.styling.Displacement)9 PointSymbolizer (org.geotools.styling.PointSymbolizer)9 GraphicFill (org.opengis.style.GraphicFill)9 ArrayList (java.util.ArrayList)8 ExternalGraphic (org.geotools.styling.ExternalGraphic)7 MarkImpl (org.geotools.styling.MarkImpl)7 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)6 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)6 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)5 ColourFieldConfig (com.sldeditor.ui.detail.ColourFieldConfig)5