Search in sources :

Example 11 with GraphicalSymbol

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

the class VOGeoServerTextSymbolizer2 method updateSymbol.

/**
 * Update symbol.
 *
 * @param textSymbolizer the text symbolizer
 */
/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.detail.vendor.geoserver.VendorOptionInterface#updateSymbol(org.geotools.styling.TextSymbolizer)
     */
@Override
public void updateSymbol(TextSymbolizer textSymbolizer) {
    GroupConfigInterface fillGroup = getGroup(GroupIdEnum.VO_TEXTSYMBOLIZER_2_FILL);
    GroupConfigInterface strokeGroup = getGroup(GroupIdEnum.VO_TEXTSYMBOLIZER_2_STROKE);
    GroupConfigInterface group = null;
    if (textSymbolizer instanceof TextSymbolizer2) {
        TextSymbolizer2 textSymbol2 = (TextSymbolizer2) textSymbolizer;
        Expression featureDescription = fieldConfigVisitor.getExpression(FieldIdEnum.VO_TEXTSYMBOLIZER_2_FEATURE_DESCRIPTION);
        if (!featureDescription.toString().isEmpty()) {
            textSymbol2.setFeatureDescription(featureDescription);
        }
        Expression snippet = fieldConfigVisitor.getExpression(FieldIdEnum.VO_TEXTSYMBOLIZER_2_SNIPPET);
        if (!snippet.toString().isEmpty()) {
            textSymbol2.setSnippet(snippet);
        }
        // Extract OtherText
        OtherText otherText = null;
        group = getGroup(GroupIdEnum.VO_TEXTSYMBOLIZER_2_OTHERTEXT);
        if (group != null) {
            if (group.isPanelEnabled()) {
                String target = fieldConfigVisitor.getText(FieldIdEnum.VO_TEXTSYMBOLIZER_2_OTHERTEXT_TARGET);
                Expression text = fieldConfigVisitor.getExpression(FieldIdEnum.VO_TEXTSYMBOLIZER_2_OTHERTEXT_TEXT);
                if (!target.isEmpty() && !text.toString().isEmpty()) {
                    otherText = new OtherTextImpl();
                    otherText.setTarget(target);
                    otherText.setText(text);
                }
            }
        }
        textSymbol2.setOtherText(otherText);
        // Graphic
        Graphic graphic = null;
        group = getGroup(GroupIdEnum.VO_TEXTSYMBOLIZER_2_GRAPHIC);
        if (group.isPanelEnabled()) {
            Expression symbolType = fieldConfigVisitor.getExpression(FieldIdEnum.VO_TEXTSYMBOLIZER_2_SYMBOL_TYPE);
            boolean hasFill = (fillGroup == null) ? false : fillGroup.isPanelEnabled();
            boolean hasStroke = (strokeGroup == null) ? false : strokeGroup.isPanelEnabled();
            Expression size = fieldConfigVisitor.getExpression(FieldIdEnum.VO_TEXTSYMBOLIZER_2_SIZE);
            Expression rotation = fieldConfigVisitor.getExpression(FieldIdEnum.VO_TEXTSYMBOLIZER_2_ANGLE);
            List<GraphicalSymbol> symbols = symbolTypeFactory.getValue(fieldConfigManager, symbolType, hasFill, hasStroke, selectedFillPanelId);
            AnchorPoint anchor = null;
            Displacement displacement = null;
            graphic = getStyleFactory().graphic(symbols, null, size, rotation, anchor, displacement);
            if (!symbols.isEmpty()) {
                boolean overallOpacity = (symbols.get(0) instanceof ExternalGraphic);
                if (overallOpacity) {
                    Expression opacity = fieldConfigVisitor.getExpression(FieldIdEnum.VO_TEXTSYMBOLIZER_2_OVERALL_OPACITY);
                    graphic.setOpacity(opacity);
                }
            }
        }
        textSymbol2.setGraphic(graphic);
    }
}
Also used : ExternalGraphic(org.geotools.styling.ExternalGraphic) Graphic(org.geotools.styling.Graphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol) OtherText(org.geotools.styling.OtherText) ExternalGraphic(org.geotools.styling.ExternalGraphic) Displacement(org.geotools.styling.Displacement) OtherTextImpl(org.geotools.styling.OtherTextImpl) AnchorPoint(org.geotools.styling.AnchorPoint) TextSymbolizer2(org.geotools.styling.TextSymbolizer2) Expression(org.opengis.filter.expression.Expression) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface)

Example 12 with GraphicalSymbol

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

the class SLDExternalImagesTest method createGraphic.

/**
 * Creates the graphic.
 *
 * @param url the url
 * @param styleFactory the style factory
 * @return the graphic
 */
private Graphic createGraphic(URL url, StyleFactory styleFactory) {
    List<GraphicalSymbol> symbolList = new ArrayList<GraphicalSymbol>();
    ExternalGraphic externalGraphic = styleFactory.createExternalGraphic(url, "image/png");
    symbolList.add(externalGraphic);
    Graphic graphicFill = styleFactory.graphicFill(symbolList, null, null, null, null, null);
    return graphicFill;
}
Also used : ExternalGraphic(org.geotools.styling.ExternalGraphic) Graphic(org.geotools.styling.Graphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol) ArrayList(java.util.ArrayList) ExternalGraphic(org.geotools.styling.ExternalGraphic)

Example 13 with GraphicalSymbol

use of org.opengis.style.GraphicalSymbol in project polymap4-core by Polymap4.

the class StyleModelTest method testSimplePoint.

@Test
public void testSimplePoint() throws Exception {
    FeatureStyle fs = repo.newFeatureStyle();
    PointStyle style = fs.members().createElement(PointStyle.defaults);
    assertTrue(style.visibleIf.get() instanceof ConstantFilter);
    style.diameter.createValue(ConstantNumber.defaults(100.0));
    style.rotation.createValue(ConstantNumber.defaults(45.0));
    style.fill.get().color.createValue(ConstantColor.defaults(0, 0, 0));
    style.fill.get().opacity.createValue(ConstantNumber.defaults(0.0));
    style.stroke.get().color.createValue(ConstantColor.defaults(100, 100, 100));
    style.stroke.get().width.createValue(ConstantNumber.defaults(5.0));
    style.stroke.get().opacity.createValue(ConstantNumber.defaults(0.5));
    fs.store();
    log.info("SLD: " + repo.serializedFeatureStyle(fs.id(), String.class));
    Style result = repo.serializedFeatureStyle(fs.id(), Style.class).get();
    assertEquals(1, result.featureTypeStyles().size());
    FeatureTypeStyle fts = result.featureTypeStyles().get(0);
    assertEquals(1, fts.rules().size());
    Rule rule = fts.rules().get(0);
    assertEquals(0, rule.getMinScaleDenominator(), 0);
    assertEquals(Double.POSITIVE_INFINITY, rule.getMaxScaleDenominator(), 0);
    assertEquals(1, rule.symbolizers().size());
    assertNull(rule.getFilter());
    PointSymbolizer sym = (PointSymbolizer) rule.symbolizers().get(0);
    assertEqualsLiteral(100.0, sym.getGraphic().getSize());
    assertEqualsLiteral(45.0, sym.getGraphic().getRotation());
    assertEquals(1, sym.getGraphic().graphicalSymbols().size());
    GraphicalSymbol symbol = sym.getGraphic().graphicalSymbols().get(0);
    Mark mark = (Mark) symbol;
    assertEqualsLiteral(0.0, mark.getFill().getOpacity());
    assertEqualsLiteral(0.5, mark.getStroke().getOpacity());
    assertEqualsLiteral(5.0, mark.getStroke().getWidth());
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) PointStyle(org.polymap.core.style.model.feature.PointStyle) GraphicalSymbol(org.opengis.style.GraphicalSymbol) ConstantFilter(org.polymap.core.style.model.feature.ConstantFilter) Style(org.geotools.styling.Style) ConstantStrokeDashStyle(org.polymap.core.style.model.feature.ConstantStrokeDashStyle) ConstantStrokeJoinStyle(org.polymap.core.style.model.feature.ConstantStrokeJoinStyle) FeatureStyle(org.polymap.core.style.model.FeatureStyle) PolygonStyle(org.polymap.core.style.model.feature.PolygonStyle) TextStyle(org.polymap.core.style.model.feature.TextStyle) ConstantStrokeCapStyle(org.polymap.core.style.model.feature.ConstantStrokeCapStyle) StrokeDashStyle(org.polymap.core.style.model.feature.StrokeDashStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) PointStyle(org.polymap.core.style.model.feature.PointStyle) LineStyle(org.polymap.core.style.model.feature.LineStyle) Mark(org.geotools.styling.Mark) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) FeatureStyle(org.polymap.core.style.model.FeatureStyle) Test(org.junit.Test)

Example 14 with GraphicalSymbol

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

the class SelectedSymbolTest method testGetSymbolList.

/**
 * Test method for
 * {@link com.sldeditor.common.data.SelectedSymbol#getSymbolList(org.opengis.style.GraphicalSymbol)}.
 */
@Test
public void testGetSymbolList() {
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    Stroke stroke = null;
    Fill fill = styleFactory.createFill(ff.literal(DefaultSymbols.defaultColour()));
    GraphicalSymbol symbolToAdd = styleFactory.mark(ff.literal("circle"), fill, stroke);
    List<GraphicalSymbol> symbolList = SelectedSymbol.getInstance().getSymbolList(symbolToAdd);
    assertEquals(1, symbolList.size());
    assertEquals(symbolToAdd, symbolList.get(0));
}
Also used : Stroke(org.opengis.style.Stroke) Fill(org.geotools.styling.Fill) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) GraphicalSymbol(org.opengis.style.GraphicalSymbol) FilterFactory(org.opengis.filter.FilterFactory) Test(org.junit.Test)

Example 15 with GraphicalSymbol

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

the class SLDTreeLeafPointTest method testGetFill.

/**
 * Test method for
 * {@link com.sldeditor.common.tree.leaf.SLDTreeLeafPoint#getFill(org.opengis.style.Symbolizer)}.
 */
@Test
public void testGetFill() {
    SLDTreeLeafPoint leaf = new SLDTreeLeafPoint();
    assertNull(leaf.getFill(null));
    assertNull(leaf.getFill(DefaultSymbols.createDefaultPolygonSymbolizer()));
    PointSymbolizer pointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer();
    Fill expectedFill = null;
    Graphic graphic = pointSymbolizer.getGraphic();
    if (graphic != null) {
        List<GraphicalSymbol> symbolList = graphic.graphicalSymbols();
        if ((symbolList != null) && !symbolList.isEmpty()) {
            GraphicalSymbol obj = symbolList.get(0);
            if (obj != null) {
                if (obj instanceof MarkImpl) {
                    MarkImpl mark = (MarkImpl) obj;
                    expectedFill = mark.getFill();
                }
            }
        }
    }
    assertEquals(expectedFill, leaf.getFill(pointSymbolizer));
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) Fill(org.geotools.styling.Fill) Graphic(org.geotools.styling.Graphic) GraphicalSymbol(org.opengis.style.GraphicalSymbol) SLDTreeLeafPoint(com.sldeditor.common.tree.leaf.SLDTreeLeafPoint) MarkImpl(org.geotools.styling.MarkImpl) Test(org.junit.Test)

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