Search in sources :

Example 1 with MarkImpl

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

the class DefaultSymbols method createArrow.

/**
 * Creates the arrow.
 *
 * @param angleFunction the angle function
 * @param locationFunction the location function
 * @param markerSymbol the marker symbol
 * @param isSourceArrow the is source arrow
 * @return the point symbolizer
 */
private static PointSymbolizer createArrow(FunctionName angleFunction, FunctionName locationFunction, String markerSymbol, boolean isSourceArrow) {
    String name = isSourceArrow ? Localisation.getString(SLDTreeTools.class, "TreeItem.sourceArrow") : Localisation.getString(SLDTreeTools.class, "TreeItem.destArrow");
    PointSymbolizer pointSymbolizer = createDefaultPointSymbolizer();
    pointSymbolizer.setName(name);
    Graphic graphic = pointSymbolizer.getGraphic();
    graphic.setSize(ff.literal(DEFAULT_ARROW_SIZE));
    List<GraphicalSymbol> graphicalSymbolList = graphic.graphicalSymbols();
    MarkImpl mark = (MarkImpl) graphicalSymbolList.get(0);
    Expression wellKnownName = ff.literal(markerSymbol);
    mark.setWellKnownName(wellKnownName);
    mark.getFill().setColor(ff.literal(DEFAULT_COLOUR));
    // Arrow rotation
    List<Expression> rotationArgumentList = new ArrayList<Expression>();
    String geometryFieldName = "geom";
    DataSourceInterface dsInfo = DataSourceFactory.getDataSource();
    if (dsInfo != null) {
        geometryFieldName = dsInfo.getGeometryFieldName();
    }
    rotationArgumentList.add(ff.property(geometryFieldName));
    Expression rotation = FunctionManager.getInstance().createExpression(angleFunction, rotationArgumentList);
    if (isSourceArrow) {
        graphic.setRotation(ff.add(ff.literal(DEGREES_180), rotation));
    } else {
        graphic.setRotation(rotation);
    }
    AnchorPoint anchorPoint = styleFactory.anchorPoint(ff.literal(0.5), ff.literal(0.5));
    graphic.setAnchorPoint(anchorPoint);
    // Set location of the arrow head
    List<Expression> endPointArgumentList = new ArrayList<Expression>();
    endPointArgumentList.add(ff.property(geometryFieldName));
    Expression geometry = FunctionManager.getInstance().createExpression(locationFunction, endPointArgumentList);
    pointSymbolizer.setGeometry(geometry);
    return pointSymbolizer;
}
Also used : DataSourceInterface(com.sldeditor.datasource.DataSourceInterface) PointSymbolizer(org.geotools.styling.PointSymbolizer) AnchorPoint(org.geotools.styling.AnchorPoint) Expression(org.opengis.filter.expression.Expression) Graphic(org.geotools.styling.Graphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol) ArrayList(java.util.ArrayList) MarkImpl(org.geotools.styling.MarkImpl) SLDTreeTools(com.sldeditor.ui.tree.SLDTreeTools)

Example 2 with MarkImpl

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

the class PolygonFillDetails method populate.

/**
 * Populate.
 *
 * @param selectedSymbol the selected symbol
 */
/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.iface.PopulateDetailsInterface#populate(com.sldeditor.ui.detail.SelectedSymbol)
     */
@Override
public void populate(SelectedSymbol selectedSymbol) {
    Expression expSize = null;
    Expression expRotation = null;
    Expression expAnchorPointX = null;
    Expression expAnchorPointY = null;
    Expression expDisplacementX = null;
    Expression expDisplacementY = null;
    Expression expFillColour = null;
    Expression expGap = null;
    Expression expInitialGap = null;
    Fill fill = null;
    Expression expOpacity = null;
    symbolizer = null;
    if (selectedSymbol != null) {
        symbolizer = selectedSymbol.getSymbolizer();
        Graphic graphic = null;
        if (symbolizer instanceof PointSymbolizerImpl) {
            PointSymbolizer pointSymbolizer = (PointSymbolizer) symbolizer;
            graphic = pointSymbolizer.getGraphic();
            if (graphic != null) {
                List<GraphicalSymbol> graphicSymbolList = graphic.graphicalSymbols();
                if (!graphicSymbolList.isEmpty()) {
                    GraphicalSymbol graphicalSymbol = graphicSymbolList.get(0);
                    if (graphicalSymbol instanceof MarkImpl) {
                        MarkImpl mark = (MarkImpl) graphicalSymbol;
                        fill = mark.getFill();
                        if (fill != null) {
                            expOpacity = fill.getOpacity();
                        }
                    }
                }
            }
        } else if (symbolizer instanceof PolygonSymbolizerImpl) {
            PolygonSymbolizer polygonSymbolizer = (PolygonSymbolizer) symbolizer;
            if (polygonSymbolizer != null) {
                fill = polygonSymbolizer.getFill();
                if (fill != null) {
                    expOpacity = fill.getOpacity();
                    graphic = fill.getGraphicFill();
                }
            }
        }
        if (graphic == null) {
            if (fill != null) {
                expFillColour = fill.getColor();
            }
            if (fill == null) {
                symbolTypeFactory.setNoFill(this.fieldConfigManager);
            } else {
                symbolTypeFactory.setSolidFill(this.fieldConfigManager, expFillColour, expOpacity);
            }
        } else {
            expSize = graphic.getSize();
            expRotation = graphic.getRotation();
            // Anchor point
            AnchorPoint anchorPoint = graphic.getAnchorPoint();
            if (anchorPoint != null) {
                expAnchorPointX = anchorPoint.getAnchorPointX();
                expAnchorPointY = anchorPoint.getAnchorPointY();
            } else {
                expAnchorPointX = defaultAnchorPoint.getAnchorPointX();
                expAnchorPointY = defaultAnchorPoint.getAnchorPointY();
            }
            // Offset
            Displacement displacement = graphic.getDisplacement();
            if (displacement != null) {
                expDisplacementX = displacement.getDisplacementX();
                expDisplacementY = displacement.getDisplacementY();
            } else {
                expDisplacementX = defaultDisplacement.getDisplacementX();
                expDisplacementY = defaultDisplacement.getDisplacementY();
            }
            expGap = graphic.getGap();
            expInitialGap = graphic.getInitialGap();
            List<GraphicalSymbol> graphicalSymbolList = graphic.graphicalSymbols();
            if (!graphicalSymbolList.isEmpty()) {
                GraphicalSymbol symbol = graphicalSymbolList.get(0);
                symbolTypeFactory.setValue(PolygonSymbolizer.class, this.fieldConfigManager, graphic, symbol);
            }
        }
    }
    fieldConfigVisitor.populateField(FieldIdEnum.SIZE, expSize);
    fieldConfigVisitor.populateField(FieldIdEnum.ANGLE, expRotation);
    fieldConfigVisitor.populateField(FieldIdEnum.ANCHOR_POINT_H, expAnchorPointX);
    fieldConfigVisitor.populateField(FieldIdEnum.ANCHOR_POINT_V, expAnchorPointY);
    fieldConfigVisitor.populateField(FieldIdEnum.DISPLACEMENT_X, expDisplacementX);
    fieldConfigVisitor.populateField(FieldIdEnum.DISPLACEMENT_Y, expDisplacementY);
    fieldConfigVisitor.populateField(FieldIdEnum.GAP, expGap);
    fieldConfigVisitor.populateField(FieldIdEnum.INITIAL_GAP, expInitialGap);
    fieldConfigVisitor.populateField(FieldIdEnum.OVERALL_OPACITY, expOpacity);
    if (vendorOptionFillFactory != null) {
        if (symbolizer instanceof PolygonSymbolizer) {
            vendorOptionFillFactory.populate((PolygonSymbolizer) symbolizer);
        }
    }
    updateSymbol();
}
Also used : PolygonSymbolizerImpl(org.geotools.styling.PolygonSymbolizerImpl) PointSymbolizer(org.geotools.styling.PointSymbolizer) Fill(org.geotools.styling.Fill) GraphicFill(org.opengis.style.GraphicFill) AnchorPoint(org.geotools.styling.AnchorPoint) Expression(org.opengis.filter.expression.Expression) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Graphic(org.geotools.styling.Graphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol) MarkImpl(org.geotools.styling.MarkImpl) PointSymbolizerImpl(org.geotools.styling.PointSymbolizerImpl) Displacement(org.geotools.styling.Displacement)

Example 3 with MarkImpl

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

the class FieldConfigWKT 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;
            // Fill
            FillImpl fill = markerSymbol.getFill();
            if (fill != null) {
                populateColour(fieldConfigManager, fillFieldConfig, fill.getColor(), fill.getOpacity());
            }
            GroupConfigInterface fillGroup = fieldConfigManager.getGroup(fieldConfigManager.getComponentId(), fillFieldConfig.getGroup());
            if (fillGroup != null) {
                fillGroup.enable(fill != null);
            }
            // Stroke
            StrokeImpl stroke = markerSymbol.getStroke();
            if (stroke != null) {
                populateColour(fieldConfigManager, strokeFieldConfig, stroke.getColor(), stroke.getOpacity());
            }
            GroupConfigInterface strokeGroup = fieldConfigManager.getGroup(fieldConfigManager.getComponentId(), strokeFieldConfig.getGroup());
            if (strokeGroup != null) {
                strokeGroup.enable(stroke != null);
            }
            if (wktPanel != null) {
                wktPanel.populateExpression(markerSymbol.getWellKnownName().toString());
            }
            if (multiOptionPanel != null) {
                multiOptionPanel.setSelectedItem(WKT_SYMBOL_KEY);
            }
        }
    }
}
Also used : FillImpl(org.geotools.styling.FillImpl) Mark(org.geotools.styling.Mark) MarkImpl(org.geotools.styling.MarkImpl) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) StrokeImpl(org.geotools.styling.StrokeImpl)

Example 4 with MarkImpl

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

the class FieldConfigMarker 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;
                    List<ValueComboBoxData> localSymbolList = getLocalSymbolList();
                    if (localSymbolList != null) {
                        for (ValueComboBoxData data : localSymbolList) {
                            if (data.getKey().compareTo(valueString) == 0) {
                                return true;
                            }
                        }
                    }
                }
            }
        }
    }
    return false;
}
Also used : Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) MarkImpl(org.geotools.styling.MarkImpl) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Example 5 with MarkImpl

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

the class FieldConfigArrow 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(ArrowUtils.getArrowPrefix())) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) 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