Search in sources :

Example 16 with MarkImpl

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

the class FieldConfigMarker method setValue.

/**
 * Sets the value.
 *
 * @param symbolizerType the symbolizer type
 * @param fieldConfigManager the field config manager
 * @param multiOptionPanel the multi option panel
 * @param graphic the graphic
 * @param symbol the symbol
 */
@Override
public void setValue(Class<?> symbolizerType, GraphicPanelFieldManager fieldConfigManager, FieldConfigSymbolType multiOptionPanel, Graphic graphic, GraphicalSymbol symbol) {
    if ((symbol != null) && (fieldConfigManager != null)) {
        MarkImpl markerSymbol = (MarkImpl) symbol;
        Expression wellKnownNameExpression = markerSymbol.getWellKnownName();
        if (wellKnownNameExpression instanceof LiteralExpressionImpl) {
            LiteralExpressionImpl literal = (LiteralExpressionImpl) wellKnownNameExpression;
            FieldConfigBase field = fieldConfigManager.get(symbolSelectionField);
            if (field != null) {
                field.populate(literal);
            }
            Expression expFillColour = null;
            Expression expFillOpacity = null;
            Expression expStrokeColour = null;
            Expression expStrokeOpacity = null;
            Expression expStrokeWidth = null;
            // Which opacity attribute do we use?
            if (symbol instanceof MarkImpl) {
                MarkImpl markSymbol = (MarkImpl) symbol;
                Fill fill = markSymbol.getFill();
                if (fill != null) {
                    expFillColour = fill.getColor();
                    if (!isOverallOpacity(symbolizerType)) {
                        expFillOpacity = fill.getOpacity();
                    }
                }
                Stroke stroke = markSymbol.getStroke();
                if (stroke != null) {
                    expStrokeColour = stroke.getColor();
                    if (!isOverallOpacity(symbolizerType)) {
                        expStrokeOpacity = stroke.getOpacity();
                    }
                    expStrokeWidth = stroke.getWidth();
                }
            }
            if (isOverallOpacity(symbolizerType)) {
                FieldConfigBase opacity = fieldConfigManager.get(FieldIdEnum.OVERALL_OPACITY);
                if (opacity != null) {
                    opacity.populate(graphic.getOpacity());
                }
            }
            FieldConfigBase opacity = fieldConfigManager.get(fillFieldConfig.getOpacity());
            if (opacity != null) {
                opacity.populate(expFillOpacity);
            }
            opacity = fieldConfigManager.get(strokeFieldConfig.getOpacity());
            if (opacity != null) {
                opacity.populate(expStrokeOpacity);
            }
            Class<?> panelId = getCommonData().getPanelId();
            GroupConfigInterface fillGroup = fieldConfigManager.getGroup(panelId, fillFieldConfig.getGroup());
            GroupConfigInterface strokeGroup = fieldConfigManager.getGroup(panelId, strokeFieldConfig.getGroup());
            if ((fillGroup == null) || (strokeGroup == null)) {
                return;
            }
            if (literal.toString().startsWith(GEOSERVER_MARKER_PREFIX)) {
                fillGroup.enable(expStrokeColour != null);
                FieldConfigBase fillColour = fieldConfigManager.get(fillFieldConfig.getColour());
                if (fillColour != null) {
                    fillColour.populate(expStrokeColour);
                }
                opacity = fieldConfigManager.get(fillFieldConfig.getOpacity());
                if (opacity != null) {
                    opacity.populate(expStrokeOpacity);
                }
                strokeGroup.enable(false);
            } else {
                fillGroup.enable(expFillColour != null);
                FieldConfigBase fillColour = fieldConfigManager.get(fillFieldConfig.getColour());
                if (fillColour != null) {
                    fillColour.populate(expFillColour);
                }
                strokeGroup.enable(expStrokeColour != null);
                FieldConfigBase strokeColour = fieldConfigManager.get(strokeFieldConfig.getColour());
                if (strokeColour != null) {
                    strokeColour.populate(expStrokeColour);
                }
                FieldConfigBase strokeWidth = fieldConfigManager.get(FieldIdEnum.STROKE_FILL_WIDTH);
                if (strokeWidth != null) {
                    strokeWidth.populate(expStrokeWidth);
                }
            }
        }
    }
}
Also used : Fill(org.geotools.styling.Fill) GraphicFill(org.opengis.style.GraphicFill) Stroke(org.geotools.styling.Stroke) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) MarkImpl(org.geotools.styling.MarkImpl) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface)

Example 17 with MarkImpl

use of org.geotools.styling.MarkImpl 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 18 with MarkImpl

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

the class FieldConfigWKT method accept.

/**
 * Accept.
 *
 * @param symbol the symbol
 * @return true, if successful
 */
@Override
public boolean accept(GraphicalSymbol symbol) {
    if (symbol != null) {
        if (symbol instanceof MarkImpl) {
            MarkImpl marker = (MarkImpl) symbol;
            Expression expression = marker.getWellKnownName();
            if (expression instanceof LiteralExpressionImpl) {
                LiteralExpressionImpl lExpression = (LiteralExpressionImpl) expression;
                Object value = lExpression.getValue();
                if (value instanceof String) {
                    String valueString = (String) value;
                    if (valueString.startsWith(WKT_PREFIX)) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) MarkImpl(org.geotools.styling.MarkImpl)

Example 19 with MarkImpl

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

the class FieldConfigArrow method setValue.

/**
 * Sets the value.
 *
 * @param symbolizerType the symbolizer type
 * @param fieldConfigManager the field config manager
 * @param multiOptionPanel the multi option panel
 * @param graphic the graphic
 * @param symbol the symbol
 */
@Override
public void setValue(Class<?> symbolizerType, GraphicPanelFieldManager fieldConfigManager, FieldConfigSymbolType multiOptionPanel, Graphic graphic, GraphicalSymbol symbol) {
    if ((symbol != null) && (fieldConfigManager != null)) {
        if (symbol instanceof Mark) {
            MarkImpl markerSymbol = (MarkImpl) symbol;
            FillImpl fill = markerSymbol.getFill();
            if (fill != null) {
                Expression expFillColour = fill.getColor();
                Expression expFillColourOpacity = fill.getOpacity();
                FieldConfigBase field = fieldConfigManager.get(FieldIdEnum.FILL_COLOUR);
                if (field != null) {
                    field.populate(expFillColour);
                }
                field = fieldConfigManager.get(FieldIdEnum.OVERALL_OPACITY);
                if (field != null) {
                    field.populate(expFillColourOpacity);
                }
            }
            if (arrowPanel != null) {
                arrowPanel.populateExpression(markerSymbol.getWellKnownName().toString());
            }
            if (multiOptionPanel != null) {
                multiOptionPanel.setSelectedItem(ARROW_SYMBOL_KEY);
            }
        }
    }
}
Also used : FillImpl(org.geotools.styling.FillImpl) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) Expression(org.opengis.filter.expression.Expression) Mark(org.geotools.styling.Mark) MarkImpl(org.geotools.styling.MarkImpl)

Aggregations

MarkImpl (org.geotools.styling.MarkImpl)19 Expression (org.opengis.filter.expression.Expression)12 PointSymbolizer (org.geotools.styling.PointSymbolizer)8 GraphicalSymbol (org.opengis.style.GraphicalSymbol)7 LiteralExpressionImpl (org.geotools.filter.LiteralExpressionImpl)6 Graphic (org.geotools.styling.Graphic)6 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)4 Fill (org.geotools.styling.Fill)4 Stroke (org.geotools.styling.Stroke)4 Test (org.junit.Test)4 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)3 AnchorPoint (org.geotools.styling.AnchorPoint)3 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)3 FillImpl (org.geotools.styling.FillImpl)3 Mark (org.geotools.styling.Mark)3 NamedLayer (org.geotools.styling.NamedLayer)3 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)3 Style (org.geotools.styling.Style)3 StyledLayer (org.geotools.styling.StyledLayer)3 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)3