Search in sources :

Example 6 with GraphicalSymbol

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

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

the class RuleDetails method updateSymbol.

/**
 * Update symbol.
 */
private void updateSymbol() {
    if (!Controller.getInstance().isPopulating()) {
        StandardData standardData = getStandardData();
        double minScale = getMinimumValue(fieldConfigManager.get(FieldIdEnum.MINIMUM_SCALE));
        double maxScale = getMaximumValue(fieldConfigManager.get(FieldIdEnum.MAXIMUM_SCALE));
        // 
        // Read filter string
        // 
        String filterText = fieldConfigVisitor.getText(FieldIdEnum.FILTER);
        Filter filter = originalFilter;
        if (originalFilter == null) {
            try {
                if (!filterText.isEmpty()) {
                    filter = CQL.toFilter(filterText);
                }
            } catch (CQLException e) {
                filter = originalFilter;
                ConsoleManager.getInstance().exception(this, e);
            }
        }
        // 
        // Use existing symbolizers
        // 
        org.geotools.styling.Rule existingRule = SelectedSymbol.getInstance().getRule();
        if (existingRule != null) {
            List<org.geotools.styling.Symbolizer> symbolizerList = existingRule.symbolizers();
            org.geotools.styling.Symbolizer[] symbolizerArray = new org.geotools.styling.Symbolizer[symbolizerList.size()];
            int index = 0;
            for (org.geotools.styling.Symbolizer symbolizer : symbolizerList) {
                symbolizerArray[index] = symbolizer;
                index++;
            }
            // 
            // Legend
            // 
            GraphicLegend existingLegend = existingRule.getLegend();
            Graphic[] legendGraphics = null;
            if (existingLegend != null) {
                int legendGraphicCount = existingLegend.graphicalSymbols().size();
                legendGraphics = new Graphic[legendGraphicCount];
                index = 0;
                for (GraphicalSymbol graphicalSymbol : existingLegend.graphicalSymbols()) {
                    legendGraphics[index] = (Graphic) graphicalSymbol;
                    index++;
                }
            } else {
                legendGraphics = new Graphic[0];
            }
            // 
            // Else filter
            // 
            boolean isElseFilter = fieldConfigVisitor.getBoolean(FieldIdEnum.ELSE_FILTER);
            // 
            // Create new rule object
            // 
            Rule rule = getStyleFactory().createRule(symbolizerArray, standardData.description, legendGraphics, standardData.name, filter, isElseFilter, maxScale, minScale);
            SelectedSymbol.getInstance().replaceRule((org.geotools.styling.Rule) rule);
            this.fireUpdateSymbol();
        }
    }
}
Also used : Graphic(org.geotools.styling.Graphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol) GraphicLegend(org.opengis.style.GraphicLegend) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) Filter(org.opengis.filter.Filter) CQLException(org.geotools.filter.text.cql2.CQLException) Rule(org.opengis.style.Rule)

Example 8 with GraphicalSymbol

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

the class FieldConfigWKT 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 stroke = null;
                Fill fill = null;
                // Stroke colour
                FieldConfigBase field = null;
                if (strokeEnabled) {
                    Expression expStrokeColour = null;
                    Expression expStrokeColourOpacity = null;
                    field = fieldConfigManager.get(this.strokeFieldConfig.getColour());
                    if (field != null) {
                        if (field instanceof FieldConfigColour) {
                            FieldConfigColour colourField = (FieldConfigColour) field;
                            expStrokeColour = colourField.getColourExpression();
                        }
                    }
                    // Stroke width
                    Expression strokeWidth = null;
                    field = fieldConfigManager.get(this.strokeFieldConfig.getWidth());
                    if (field != null) {
                        strokeWidth = field.getExpression();
                    }
                    // Opacity
                    field = fieldConfigManager.get(this.strokeFieldConfig.getOpacity());
                    if (field != null) {
                        expStrokeColourOpacity = field.getExpression();
                    }
                    stroke = getStyleFactory().createStroke(expStrokeColour, strokeWidth, expStrokeColourOpacity);
                }
                // Fill colour
                if (fillEnabled) {
                    Expression expFillColour = null;
                    Expression expFillColourOpacity = null;
                    field = fieldConfigManager.get(this.fillFieldConfig.getColour());
                    if (field != null) {
                        if (field instanceof FieldConfigColour) {
                            FieldConfigColour colourField = (FieldConfigColour) field;
                            expFillColour = colourField.getColourExpression();
                        }
                    }
                    // Opacity
                    field = fieldConfigManager.get(this.fillFieldConfig.getOpacity());
                    if (field != null) {
                        expFillColourOpacity = field.getExpression();
                    }
                    fill = getStyleFactory().createFill(expFillColour, expFillColourOpacity);
                }
                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)

Example 9 with GraphicalSymbol

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

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

the class FieldConfigFilename 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> symbols = null;
    if (externalGraphicPanel != null) {
        ExternalGraphic extGraphic = externalGraphicPanel.getSymbol();
        symbols = SelectedSymbol.getInstance().getSymbolList(extGraphic);
    }
    return symbols;
}
Also used : GraphicalSymbol(org.opengis.style.GraphicalSymbol) ExternalGraphic(org.geotools.styling.ExternalGraphic)

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