Search in sources :

Example 11 with Stroke

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

the class DefaultSymbols method createDefaultLineSymbolizer.

/**
 * Creates the default line symbolizer.
 *
 * @return the line symbolizer
 */
public static LineSymbolizer createDefaultLineSymbolizer() {
    Stroke stroke = styleFactory.createStroke(ff.literal(DEFAULT_LINE_COLOUR), ff.literal(2));
    LineSymbolizer lineSymbolizer = styleFactory.createLineSymbolizer();
    lineSymbolizer.setStroke(stroke);
    return lineSymbolizer;
}
Also used : Stroke(org.geotools.styling.Stroke) LineSymbolizer(org.geotools.styling.LineSymbolizer)

Example 12 with Stroke

use of org.geotools.styling.Stroke 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 13 with Stroke

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

the class SLDExternalImagesTest method createTestPolygon.

/**
 * Creates the test polygon.
 *
 * @param url the url
 * @return the styled layer descriptor
 */
private StyledLayerDescriptor createTestPolygon(URL url) {
    StyleBuilder sb = new StyleBuilder();
    StyleFactory styleFactory = sb.getStyleFactory();
    StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
    NamedLayer namedLayer = styleFactory.createNamedLayer();
    sld.addStyledLayer(namedLayer);
    Style style = styleFactory.createStyle();
    namedLayer.addStyle(style);
    List<FeatureTypeStyle> ftsList = style.featureTypeStyles();
    FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
    ftsList.add(fts);
    Rule rule = styleFactory.createRule();
    fts.rules().add(rule);
    PolygonSymbolizer polygon = styleFactory.createPolygonSymbolizer();
    rule.symbolizers().add(polygon);
    Graphic graphicFill1 = createGraphic(url, styleFactory);
    Graphic graphicFill2 = createGraphic(url, styleFactory);
    Graphic graphicStroke = createGraphic(url, styleFactory);
    Fill fill = styleFactory.createFill(null, null, null, graphicFill1);
    polygon.setFill(fill);
    Stroke stroke = styleFactory.createStroke(null, null, null, null, null, null, null, graphicFill2, graphicStroke);
    polygon.setStroke(stroke);
    return sld;
}
Also used : StyleFactory(org.geotools.styling.StyleFactory) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) Fill(org.geotools.styling.Fill) Stroke(org.geotools.styling.Stroke) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) ExternalGraphic(org.geotools.styling.ExternalGraphic) Graphic(org.geotools.styling.Graphic) StyleBuilder(org.geotools.styling.StyleBuilder) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer)

Example 14 with Stroke

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

the class SLDExternalImagesTest method createTestLine.

/**
 * Creates the test line.
 *
 * @param url the url
 * @return the styled layer descriptor
 */
private StyledLayerDescriptor createTestLine(URL url) {
    StyleBuilder sb = new StyleBuilder();
    StyleFactory styleFactory = sb.getStyleFactory();
    StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
    NamedLayer namedLayer = styleFactory.createNamedLayer();
    sld.addStyledLayer(namedLayer);
    Style style = styleFactory.createStyle();
    namedLayer.addStyle(style);
    List<FeatureTypeStyle> ftsList = style.featureTypeStyles();
    FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
    ftsList.add(fts);
    Rule rule = styleFactory.createRule();
    fts.rules().add(rule);
    LineSymbolizer line = styleFactory.createLineSymbolizer();
    rule.symbolizers().add(line);
    Graphic graphicFill = createGraphic(url, styleFactory);
    Graphic graphicStroke = createGraphic(url, styleFactory);
    Stroke stroke = styleFactory.createStroke(null, null, null, null, null, null, null, graphicFill, graphicStroke);
    line.setStroke(stroke);
    return sld;
}
Also used : StyleFactory(org.geotools.styling.StyleFactory) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) Stroke(org.geotools.styling.Stroke) ExternalGraphic(org.geotools.styling.ExternalGraphic) Graphic(org.geotools.styling.Graphic) LineSymbolizer(org.geotools.styling.LineSymbolizer) StyleBuilder(org.geotools.styling.StyleBuilder) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer)

Example 15 with Stroke

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

the class SLDTreeLeafLineTest method testGetStroke.

/**
 * Test method for {@link com.sldeditor.common.tree.leaf.SLDTreeLeafLine#getStroke(org.opengis.style.Symbolizer)}.
 */
@Test
public void testGetStroke() {
    SLDTreeLeafLine leaf = new SLDTreeLeafLine();
    assertNull(leaf.getStroke(null));
    PolygonSymbolizer polygonSymbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
    assertNull(leaf.getStroke(polygonSymbolizer));
    LineSymbolizer lineSymbolizer = DefaultSymbols.createDefaultLineSymbolizer();
    Stroke stroke = leaf.getStroke(lineSymbolizer);
    assertEquals(stroke, lineSymbolizer.getStroke());
}
Also used : SLDTreeLeafLine(com.sldeditor.common.tree.leaf.SLDTreeLeafLine) Stroke(org.geotools.styling.Stroke) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer) Test(org.junit.Test)

Aggregations

Stroke (org.geotools.styling.Stroke)36 Fill (org.geotools.styling.Fill)18 Expression (org.opengis.filter.expression.Expression)16 JsonObject (com.google.gson.JsonObject)13 GraphicalSymbol (org.opengis.style.GraphicalSymbol)13 LineSymbolizer (org.geotools.styling.LineSymbolizer)12 ArrayList (java.util.ArrayList)11 Graphic (org.geotools.styling.Graphic)10 Mark (org.geotools.styling.Mark)10 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)10 GraphicFill (org.opengis.style.GraphicFill)8 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)7 JsonElement (com.google.gson.JsonElement)6 Symbolizer (org.geotools.styling.Symbolizer)6 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)5 Displacement (org.geotools.styling.Displacement)5 ExternalGraphic (org.geotools.styling.ExternalGraphic)5 GraphicStroke (org.opengis.style.GraphicStroke)5 JsonArray (com.google.gson.JsonArray)4 AnchorPoint (org.geotools.styling.AnchorPoint)4