Search in sources :

Example 1 with PolygonSymbolizerImpl

use of org.geotools.styling.PolygonSymbolizerImpl 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 2 with PolygonSymbolizerImpl

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

the class PolygonFillDetails method updateSymbol.

/**
 * Update symbol.
 */
private void updateSymbol() {
    if (!Controller.getInstance().isPopulating()) {
        if (symbolizer instanceof PolygonSymbolizer) {
            PolygonSymbolizerImpl newPolygonSymbolizer = (PolygonSymbolizerImpl) symbolizer;
            GraphicFill graphicFill = getGraphicFill();
            Fill fill = symbolTypeFactory.getFill(graphicFill, this.fieldConfigManager);
            Expression expOpacity = fieldConfigVisitor.getExpression(FieldIdEnum.OVERALL_OPACITY);
            // If field is not enabled it returns null
            if ((fill != null) && (expOpacity != null)) {
                fill.setOpacity(expOpacity);
            }
            newPolygonSymbolizer.setFill(fill);
            if (vendorOptionFillFactory != null) {
                vendorOptionFillFactory.updateSymbol(newPolygonSymbolizer);
            }
        }
        this.fireUpdateSymbol();
    }
}
Also used : PolygonSymbolizerImpl(org.geotools.styling.PolygonSymbolizerImpl) Fill(org.geotools.styling.Fill) GraphicFill(org.opengis.style.GraphicFill) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Expression(org.opengis.filter.expression.Expression) GraphicFill(org.opengis.style.GraphicFill)

Example 3 with PolygonSymbolizerImpl

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

the class SelectedSymbolTest method getGraphic.

/**
 * Gets the graphic.
 *
 * @param symbolizer the symbolizer
 * @return the graphic
 */
private Graphic getGraphic(Symbolizer symbolizer) {
    Graphic graphic = null;
    if (symbolizer instanceof PointSymbolizerImpl) {
        PointSymbolizer pointSymbolizer = (PointSymbolizer) symbolizer;
        graphic = pointSymbolizer.getGraphic();
    } else if (symbolizer instanceof PolygonSymbolizerImpl) {
        PolygonSymbolizer polygonSymbolizer = (PolygonSymbolizer) symbolizer;
        if (polygonSymbolizer != null) {
            Fill fill = polygonSymbolizer.getFill();
            if (fill != null) {
                graphic = fill.getGraphicFill();
            }
        }
    }
    return graphic;
}
Also used : PolygonSymbolizerImpl(org.geotools.styling.PolygonSymbolizerImpl) PointSymbolizer(org.geotools.styling.PointSymbolizer) Fill(org.geotools.styling.Fill) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Graphic(org.geotools.styling.Graphic) PointSymbolizerImpl(org.geotools.styling.PointSymbolizerImpl)

Example 4 with PolygonSymbolizerImpl

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

the class SymbolizerDetailsPanel method getMinimumVersion.

/**
 * Gets the minimum version vendor option present in the SLD.
 *
 * @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) {
    Class<?> parentClass = null;
    Class<?> classSelected = sldObj.getClass();
    if (sldObj instanceof StyledLayerDescriptor) {
    // No parent
    } else if (sldObj instanceof StyledLayer) {
        parentClass = StyledLayerDescriptor.class;
    } else if (sldObj instanceof Style) {
        parentClass = StyledLayer.class;
    } else if (sldObj instanceof FeatureTypeStyle) {
        parentClass = Style.class;
    } else if (sldObj instanceof Rule) {
        parentClass = FeatureTypeStyle.class;
    } else if (sldObj instanceof Symbolizer) {
        parentClass = Rule.class;
    }
    internal_getMinimumVersion(parentObj, sldObj, vendorOptionsPresentList, parentClass, classSelected);
    if (sldObj instanceof PointSymbolizerImpl) {
        PointSymbolizerImpl pointSymbolizer = (PointSymbolizerImpl) sldObj;
        parentClass = PointSymbolizerImpl.class;
        classSelected = FillImpl.class;
        internal_getMinimumVersion(pointSymbolizer, pointSymbolizer.getGraphic(), vendorOptionsPresentList, parentClass, classSelected);
    } else if (sldObj instanceof LineSymbolizerImpl) {
        LineSymbolizerImpl lineSymbolizer = (LineSymbolizerImpl) sldObj;
        parentClass = LineSymbolizerImpl.class;
        classSelected = StrokeImpl.class;
        internal_getMinimumVersion(lineSymbolizer, lineSymbolizer.getStroke(), vendorOptionsPresentList, parentClass, classSelected);
    } else if (sldObj instanceof PolygonSymbolizerImpl) {
        PolygonSymbolizerImpl polygonSymbolizer = (PolygonSymbolizerImpl) sldObj;
        parentClass = PolygonSymbolizerImpl.class;
        classSelected = FillImpl.class;
        internal_getMinimumVersion(polygonSymbolizer, polygonSymbolizer.getFill(), vendorOptionsPresentList, parentClass, classSelected);
        classSelected = StrokeImpl.class;
        internal_getMinimumVersion(polygonSymbolizer, polygonSymbolizer.getStroke(), vendorOptionsPresentList, parentClass, classSelected);
    } else if (sldObj instanceof TextSymbolizerImpl) {
        TextSymbolizerImpl textSymbolizer = (TextSymbolizerImpl) sldObj;
        parentClass = Rule.class;
        classSelected = TextSymbolizerImpl.class;
        internal_getMinimumVersion(parentObj, textSymbolizer, vendorOptionsPresentList, parentClass, classSelected);
    } else if (sldObj instanceof RasterSymbolizerImpl) {
        RasterSymbolizerImpl rasterSymbolizer = (RasterSymbolizerImpl) sldObj;
        parentClass = Rule.class;
        classSelected = RasterSymbolizerImpl.class;
        internal_getMinimumVersion(parentObj, rasterSymbolizer, vendorOptionsPresentList, parentClass, classSelected);
    }
}
Also used : TextSymbolizerImpl(org.geotools.styling.TextSymbolizerImpl) StyledLayer(org.geotools.styling.StyledLayer) LineSymbolizerImpl(org.geotools.styling.LineSymbolizerImpl) StrokeImpl(org.geotools.styling.StrokeImpl) Symbolizer(org.geotools.styling.Symbolizer) RasterSymbolizerImpl(org.geotools.styling.RasterSymbolizerImpl) PolygonSymbolizerImpl(org.geotools.styling.PolygonSymbolizerImpl) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) PointSymbolizerImpl(org.geotools.styling.PointSymbolizerImpl)

Aggregations

PolygonSymbolizerImpl (org.geotools.styling.PolygonSymbolizerImpl)4 Fill (org.geotools.styling.Fill)3 PointSymbolizerImpl (org.geotools.styling.PointSymbolizerImpl)3 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)3 Graphic (org.geotools.styling.Graphic)2 PointSymbolizer (org.geotools.styling.PointSymbolizer)2 Expression (org.opengis.filter.expression.Expression)2 GraphicFill (org.opengis.style.GraphicFill)2 AnchorPoint (org.geotools.styling.AnchorPoint)1 Displacement (org.geotools.styling.Displacement)1 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)1 LineSymbolizerImpl (org.geotools.styling.LineSymbolizerImpl)1 MarkImpl (org.geotools.styling.MarkImpl)1 RasterSymbolizerImpl (org.geotools.styling.RasterSymbolizerImpl)1 Rule (org.geotools.styling.Rule)1 StrokeImpl (org.geotools.styling.StrokeImpl)1 Style (org.geotools.styling.Style)1 StyledLayer (org.geotools.styling.StyledLayer)1 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)1 Symbolizer (org.geotools.styling.Symbolizer)1