Search in sources :

Example 6 with MarkImpl

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

the class FieldConfigTTF 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) {
        return;
    }
    if (fieldConfigManager == null) {
        return;
    }
    MarkImpl markerSymbol = (MarkImpl) symbol;
    FillImpl fill = markerSymbol.getFill();
    Expression expFillColour = null;
    Expression expFillOpacity = null;
    if (fill != null) {
        expFillColour = fill.getColor();
        if (!isOverallOpacity(symbolizerType)) {
            expFillOpacity = fill.getOpacity();
        }
    }
    FieldConfigBase field = fieldConfigManager.get(fillFieldConfig.getColour());
    if (field != null) {
        field.populate(expFillColour);
    }
    // Opacity
    if (isOverallOpacity(symbolizerType)) {
        FieldConfigBase opacity = fieldConfigManager.get(FieldIdEnum.OVERALL_OPACITY);
        if (opacity != null) {
            opacity.populate(graphic.getOpacity());
        }
    }
    field = fieldConfigManager.get(fillFieldConfig.getOpacity());
    if (field != null) {
        field.populate(expFillOpacity);
    }
    Class<?> panelId = getCommonData().getPanelId();
    GroupConfigInterface fillGroup = fieldConfigManager.getGroup(panelId, fillFieldConfig.getGroup());
    if (fillGroup != null) {
        fillGroup.enable(expFillColour != null);
    }
    if (ttfPanel != null) {
        Expression wellKnownNameExpression = markerSymbol.getWellKnownName();
        String wellKnownName = null;
        if (wellKnownNameExpression != null) {
            wellKnownName = wellKnownNameExpression.toString();
        }
        ttfPanel.populateExpression(wellKnownName);
    }
    if (multiOptionPanel != null) {
        multiOptionPanel.setSelectedItem(TTF_SYMBOL_KEY);
    }
}
Also used : FillImpl(org.geotools.styling.FillImpl) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) Expression(org.opengis.filter.expression.Expression) MarkImpl(org.geotools.styling.MarkImpl) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface)

Example 7 with MarkImpl

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

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

Example 8 with MarkImpl

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

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

Example 9 with MarkImpl

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

the class SLDUtilsTest method testCreateSLDFromStringFile.

@Test
public void testCreateSLDFromStringFile() {
    StyleWrapper wrapper = new StyleWrapper();
    SLDData sldData = new SLDData(wrapper, expectedSld);
    String filename = "D:/tmp/test.sld";
    File file = new File(filename);
    sldData.setSLDFile(file);
    StyledLayerDescriptor sld = SLDUtils.createSLDFromString(null);
    assertNull(sld);
    sld = SLDUtils.createSLDFromString(sldData);
    StyledLayer[] styledLayers = sld.getStyledLayers();
    NamedLayer namedLayer = (NamedLayer) styledLayers[0];
    Style[] actualStyles = namedLayer.getStyles();
    PointSymbolizer pointSymbolizer = (PointSymbolizer) actualStyles[0].featureTypeStyles().get(0).rules().get(0).symbolizers().get(0);
    MarkImpl mark = (MarkImpl) pointSymbolizer.getGraphic().graphicalSymbols().get(0);
    assertEquals("circle", mark.getWellKnownName().toString());
    // Check resource locator
    try {
        URL url = file.getParentFile().toURI().toURL();
        String actualResourceLocator = sldData.getResourceLocator().toExternalForm();
        String expectedResourcelocator = url.toExternalForm();
        assertTrue(expectedResourcelocator.compareTo(actualResourceLocator) == 0);
    } catch (MalformedURLException e) {
        e.printStackTrace();
        fail();
    }
}
Also used : SLDData(com.sldeditor.common.data.SLDData) PointSymbolizer(org.geotools.styling.PointSymbolizer) MalformedURLException(java.net.MalformedURLException) StyledLayer(org.geotools.styling.StyledLayer) MarkImpl(org.geotools.styling.MarkImpl) URL(java.net.URL) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) StyleWrapper(com.sldeditor.common.data.StyleWrapper) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) File(java.io.File) NamedLayer(org.geotools.styling.NamedLayer) Test(org.junit.Test)

Example 10 with MarkImpl

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

the class SLDUtilsTest method testCreateSLDFromStringGeoServer.

@Test
public void testCreateSLDFromStringGeoServer() {
    SLDData sldData = new SLDData(null, expectedSld);
    String geoserverUrl = "http://localhost:8080/geoserver";
    GeoServerConnection connectionData = new GeoServerConnection();
    try {
        connectionData.setUrl(new URL(geoserverUrl));
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    sldData.setConnectionData(connectionData);
    StyledLayerDescriptor sld = SLDUtils.createSLDFromString(null);
    assertNull(sld);
    sld = SLDUtils.createSLDFromString(sldData);
    StyledLayer[] styledLayers = sld.getStyledLayers();
    NamedLayer namedLayer = (NamedLayer) styledLayers[0];
    Style[] actualStyles = namedLayer.getStyles();
    PointSymbolizer pointSymbolizer = (PointSymbolizer) actualStyles[0].featureTypeStyles().get(0).rules().get(0).symbolizers().get(0);
    MarkImpl mark = (MarkImpl) pointSymbolizer.getGraphic().graphicalSymbols().get(0);
    assertEquals("circle", mark.getWellKnownName().toString());
    // Check resource locator
    geoserverUrl = geoserverUrl + "/styles/";
    assertTrue(geoserverUrl.compareTo(sldData.getResourceLocator().toExternalForm()) == 0);
}
Also used : SLDData(com.sldeditor.common.data.SLDData) PointSymbolizer(org.geotools.styling.PointSymbolizer) MalformedURLException(java.net.MalformedURLException) StyledLayer(org.geotools.styling.StyledLayer) MarkImpl(org.geotools.styling.MarkImpl) GeoServerConnection(com.sldeditor.common.data.GeoServerConnection) URL(java.net.URL) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) NamedLayer(org.geotools.styling.NamedLayer) Test(org.junit.Test)

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