Search in sources :

Example 26 with GraphicalSymbol

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

the class FieldConfigTTF 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>();
    Expression wellKnownName = null;
    if ((getConfigField() != null) && (fieldConfigManager != null)) {
        wellKnownName = getConfigField().getExpression();
        if (wellKnownName != null) {
            Stroke stroke = null;
            Fill fill = null;
            if (fillEnabled) {
                Expression expFillColour = null;
                Expression expFillColourOpacity = null;
                FieldConfigBase field = fieldConfigManager.get(fillFieldConfig.getColour());
                if (field != null) {
                    FieldConfigColour colourField = (FieldConfigColour) field;
                    expFillColour = colourField.getColourExpression();
                }
                field = fieldConfigManager.get(fillFieldConfig.getOpacity());
                if (field != null) {
                    expFillColourOpacity = field.getExpression();
                }
                fill = getStyleFactory().createFill(expFillColour, expFillColourOpacity);
            }
            // Size
            Expression expSize = null;
            // Rotation
            Expression expRotation = null;
            Mark mark = getStyleFactory().createMark(wellKnownName, stroke, fill, expSize, expRotation);
            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 27 with GraphicalSymbol

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

the class FieldConfigWindBarbs 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>();
    Expression wellKnownName = null;
    if ((getConfigField() != null) && (fieldConfigManager != null)) {
        wellKnownName = getConfigField().getExpression();
        if (wellKnownName != null) {
            Expression expFillColour = null;
            Expression expFillColourOpacity = null;
            FieldConfigBase field = fieldConfigManager.get(FieldIdEnum.FILL_COLOUR);
            if (field != null) {
                FieldConfigColour colourField = (FieldConfigColour) field;
                expFillColour = colourField.getColourExpression();
            }
            Stroke stroke = null;
            Fill fill = getStyleFactory().createFill(expFillColour, expFillColourOpacity);
            Expression size = null;
            Expression rotation = null;
            Mark mark = getStyleFactory().createMark(wellKnownName, stroke, fill, size, 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 28 with GraphicalSymbol

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

the class FieldConfigArrow 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 colour
                FieldConfigBase field = null;
                Stroke stroke = null;
                if (strokeEnabled && (strokeFieldConfig != null)) {
                    Expression expStrokeColour = null;
                    Expression expStrokeColourOpacity = null;
                    field = fieldConfigManager.get(strokeFieldConfig.getColour());
                    if (field != null) {
                        if (field instanceof FieldConfigColour) {
                            FieldConfigColour colourField = (FieldConfigColour) field;
                            expStrokeColour = colourField.getColourExpression();
                        }
                    }
                    field = fieldConfigManager.get(strokeFieldConfig.getOpacity());
                    if (field != null) {
                        expStrokeColourOpacity = field.getExpression();
                    }
                    stroke = getStyleFactory().createStroke(expStrokeColour, expStrokeColourOpacity);
                }
                // Fill colour
                Fill fill = null;
                if (fillEnabled && (fillFieldConfig != null)) {
                    Expression expFillColour = null;
                    Expression expFillColourOpacity = null;
                    field = fieldConfigManager.get(fillFieldConfig.getColour());
                    if (field != null) {
                        if (field instanceof FieldConfigColour) {
                            FieldConfigColour colourField = (FieldConfigColour) field;
                            expFillColour = colourField.getColourExpression();
                        }
                    }
                    field = fieldConfigManager.get(fillFieldConfig.getOpacity());
                    if (field != null) {
                        expFillColourOpacity = field.getExpression();
                    }
                    fill = getStyleFactory().createFill(expFillColour, expFillColourOpacity);
                }
                field = fieldConfigManager.get(FieldIdEnum.STROKE_WIDTH);
                if (field != null) {
                    Expression strokeWidth = field.getExpression();
                    stroke.setWidth(strokeWidth);
                }
                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 29 with GraphicalSymbol

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

the class FieldConfigMarkerTest method testGetValue.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker#getValue(com.sldeditor.ui.detail.GraphicPanelFieldManager, org.opengis.filter.expression.Expression, boolean, boolean)}.
 */
@Test
public void testGetValue() {
    // Test it with null values
    boolean valueOnly = true;
    ColourFieldConfig fillConfig = new ColourFieldConfig(GroupIdEnum.FILL, FieldIdEnum.FILL_COLOUR, FieldIdEnum.OVERALL_OPACITY, FieldIdEnum.STROKE_WIDTH);
    ColourFieldConfig strokeConfig = new ColourFieldConfig(GroupIdEnum.STROKE, FieldIdEnum.STROKE_STROKE_COLOUR, FieldIdEnum.OVERALL_OPACITY, FieldIdEnum.STROKE_FILL_WIDTH);
    FieldConfigMarker field = new FieldConfigMarker(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), fillConfig, strokeConfig, null);
    assertNull(field.getStringValue());
    GraphicPanelFieldManager fieldConfigManager = null;
    Expression symbolType = null;
    List<GraphicalSymbol> actualValue = field.getValue(fieldConfigManager, symbolType, false, false);
    assertNull(actualValue);
    Class<?> panelId = PointFillDetails.class;
    fieldConfigManager = new GraphicPanelFieldManager(panelId);
    String actualMarkerSymbol = "solid";
    StyleBuilder styleBuilder = new StyleBuilder();
    symbolType = styleBuilder.literalExpression(actualMarkerSymbol);
    FieldIdEnum colourFieldId = FieldIdEnum.FILL_COLOUR;
    FieldConfigColour colourField = new FieldConfigColour(new FieldConfigCommonData(panelId, colourFieldId, "", false));
    colourField.createUI();
    String expectedColourValue = "#012345";
    colourField.setTestValue(null, expectedColourValue);
    double expectedOpacityValue = 0.72;
    FieldConfigSlider opacityField = new FieldConfigSlider(new FieldConfigCommonData(panelId, colourFieldId, "", false));
    opacityField.createUI();
    opacityField.populateField(expectedOpacityValue);
    FieldConfigBase symbolSelectionField = new FieldConfigSymbolType(new FieldConfigCommonData(panelId, colourFieldId, "", false));
    symbolSelectionField.createUI();
    fieldConfigManager.add(colourFieldId, colourField);
    FieldIdEnum opacityFieldId = FieldIdEnum.OVERALL_OPACITY;
    fieldConfigManager.add(opacityFieldId, opacityField);
    FieldIdEnum symbolSelectionFieldId = FieldIdEnum.SYMBOL_TYPE;
    fieldConfigManager.add(symbolSelectionFieldId, symbolSelectionField);
    // Try without setting any fields
    actualValue = field.getValue(fieldConfigManager, symbolType, false, false);
    assertNotNull(actualValue);
    assertEquals(1, actualValue.size());
    Mark actualSymbol = (Mark) actualValue.get(0);
    assertNull(actualSymbol.getWellKnownName());
    // Try with symbol type of solid
    FieldConfigMarker field2 = new FieldConfigMarker(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), fillConfig, strokeConfig, symbolSelectionFieldId);
    actualValue = field2.getValue(fieldConfigManager, symbolType, false, false);
    assertNotNull(actualValue);
    assertEquals(1, actualValue.size());
    actualSymbol = (Mark) actualValue.get(0);
    assertNull(actualSymbol.getWellKnownName());
    // Try with symbol type of circle
    actualMarkerSymbol = "circle";
    symbolType = styleBuilder.literalExpression(actualMarkerSymbol);
    actualValue = field2.getValue(fieldConfigManager, symbolType, false, false);
    assertNotNull(actualValue);
    assertEquals(1, actualValue.size());
    actualSymbol = (Mark) actualValue.get(0);
    assertTrue(actualSymbol.getWellKnownName().toString().compareTo(actualMarkerSymbol) == 0);
    assertNull(actualSymbol.getFill());
    assertNull(actualSymbol.getStroke());
    // Enable stroke and fill flags
    actualValue = field2.getValue(fieldConfigManager, symbolType, true, true);
    assertNotNull(actualValue);
    assertEquals(1, actualValue.size());
    actualSymbol = (Mark) actualValue.get(0);
    assertTrue(actualSymbol.getWellKnownName().toString().compareTo(actualMarkerSymbol) == 0);
    assertNotNull(actualSymbol.getFill());
    assertNotNull(actualSymbol.getStroke());
}
Also used : FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) GraphicalSymbol(org.opengis.style.GraphicalSymbol) StyleBuilder(org.geotools.styling.StyleBuilder) FieldConfigSlider(com.sldeditor.ui.detail.config.FieldConfigSlider) Mark(org.geotools.styling.Mark) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Expression(org.opengis.filter.expression.Expression) FieldConfigMarker(com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker) ColourFieldConfig(com.sldeditor.ui.detail.ColourFieldConfig) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour) PointFillDetails(com.sldeditor.ui.detail.PointFillDetails) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) FieldConfigSymbolType(com.sldeditor.ui.detail.config.FieldConfigSymbolType) Test(org.junit.Test)

Example 30 with GraphicalSymbol

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

the class FieldConfigFilenameTest method testGetValue.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename#getValue(com.sldeditor.ui.detail.GraphicPanelFieldManager, org.opengis.filter.expression.Expression, boolean, boolean)}.
 */
@Test
public void testGetValue() {
    boolean valueOnly = true;
    FieldConfigFilename field = new FieldConfigFilename(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), null, null, null);
    assertNull(field.getValue(null, null, false, false));
    field.createUI();
    List<GraphicalSymbol> actualValue = field.getValue(null, null, false, false);
    assertFalse(actualValue.isEmpty());
}
Also used : FieldConfigFilename(com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename) GraphicalSymbol(org.opengis.style.GraphicalSymbol) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) 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