Search in sources :

Example 16 with Symbolizer

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

the class NewLineSLDTest method testNewLineSLD.

/**
 * Test new line sld.
 */
@Test
public void testNewLineSLD() {
    NewLineSLD newData = new NewLineSLD();
    StyledLayerDescriptor sld = newData.create();
    assertTrue(sld.layers().size() == 1);
    StyledLayer styledLayer = sld.layers().get(0);
    NamedLayer namedLayer = (NamedLayer) styledLayer;
    Symbolizer symbolizer = namedLayer.styles().get(0).featureTypeStyles().get(0).rules().get(0).symbolizers().get(0);
    assertTrue(symbolizer instanceof LineSymbolizer);
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) StyledLayer(org.geotools.styling.StyledLayer) LineSymbolizer(org.geotools.styling.LineSymbolizer) NewLineSLD(com.sldeditor.create.sld.NewLineSLD) NamedLayer(org.geotools.styling.NamedLayer) Symbolizer(org.geotools.styling.Symbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer) Test(org.junit.jupiter.api.Test)

Example 17 with Symbolizer

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

the class RuleDetailsTest method testRuleDetails.

/**
 * Test method for {@link
 * com.sldeditor.ui.detail.RuleDetails#RuleDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 * Test method for {@link
 * com.sldeditor.ui.detail.RuleDetails#populate(com.sldeditor.common.data.SelectedSymbol)}. Test
 * method for {@link
 * com.sldeditor.ui.detail.RuleDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for {@link com.sldeditor.ui.detail.RuleDetails#getFieldDataManager()}. Test
 * method for {@link com.sldeditor.ui.detail.RuleDetails#isDataPresent()}. Test method for
 * {@link com.sldeditor.ui.detail.RuleDetails#preLoadSymbol()}.
 */
@Test
public void testRuleDetails() {
    RuleDetails panel = new RuleDetails();
    panel.populate(null);
    // Set up test data
    StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
    SelectedSymbol.getInstance().createNewSLD(sld);
    NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
    String expectedNameLayerValue = "named layer test value";
    namedLayer.setName(expectedNameLayerValue);
    Style style = DefaultSymbols.createNewStyle();
    String expectedNameStyleValue = "style test value";
    style.setName(expectedNameStyleValue);
    namedLayer.addStyle(style);
    FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
    String expectedNameFTSValue = "feature type style test value";
    fts.setName(expectedNameFTSValue);
    style.featureTypeStyles().add(fts);
    Rule rule = DefaultSymbols.createNewRule();
    String expectedNameValue = "rule test value";
    rule.setName(expectedNameValue);
    Symbolizer symbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
    rule.symbolizers().add(symbolizer);
    fts.rules().add(rule);
    sld.layers().add(namedLayer);
    SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyle(style);
    SelectedSymbol.getInstance().setFeatureTypeStyle(fts);
    SelectedSymbol.getInstance().setRule(rule);
    panel.populate(SelectedSymbol.getInstance());
    GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
    assertNotNull(fieldDataManager);
    FieldConfigString filterField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.FILTER);
    String filterString = "STATE_ABBR >= 'B' AND STATE_ABBR <= 'O'";
    filterField.populateField(filterString);
    GroupConfig groupConfig = (GroupConfig) fieldDataManager.getGroup(RuleDetails.class, GroupIdEnum.SCALE);
    groupConfig.enable(true);
    panel.dataChanged(null);
    FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
    String actualValue = nameField.getStringValue();
    assertTrue(expectedNameValue.compareTo(actualValue) == 0);
    assertTrue(panel.isDataPresent());
    // Reset to default value
    panel.preLoadSymbol();
    actualValue = nameField.getStringValue();
    assertTrue("".compareTo(actualValue) == 0);
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) GroupConfig(com.sldeditor.ui.detail.config.base.GroupConfig) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer) Symbolizer(org.geotools.styling.Symbolizer) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) RuleDetails(com.sldeditor.ui.detail.RuleDetails) Test(org.junit.jupiter.api.Test)

Example 18 with Symbolizer

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

the class MultiLayerLineSymbol method convert.

/**
 * Convert.
 *
 * @param rule the rule
 * @param element the element
 * @param layerName the layer name
 * @param transparency the transparency
 */
@Override
public void convert(Rule rule, JsonElement element, String layerName, int transparency) {
    if (rule == null)
        return;
    if (element == null)
        return;
    JsonArray layerArray = element.getAsJsonArray();
    List<Symbolizer> symbolizerList = rule.symbolizers();
    if (layerArray.size() > 0) {
        for (int index = 0; index < layerArray.size(); index++) {
            JsonObject obj = layerArray.get(index).getAsJsonObject();
            List<Stroke> strokeList = null;
            JsonElement jsonOutlineElement = obj.get(MultiLayerLineSymbolKeys.LINE);
            strokeList = SymbolManager.getInstance().getStrokeList(jsonOutlineElement);
            if (strokeList != null) {
                for (Stroke stroke : strokeList) {
                    LineSymbolizer lineSymbolizer = styleFactory.createLineSymbolizer(stroke, null);
                    symbolizerList.add(lineSymbolizer);
                }
            }
        }
    }
}
Also used : JsonArray(com.google.gson.JsonArray) Stroke(org.geotools.styling.Stroke) JsonElement(com.google.gson.JsonElement) LineSymbolizer(org.geotools.styling.LineSymbolizer) JsonObject(com.google.gson.JsonObject) Symbolizer(org.geotools.styling.Symbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer)

Example 19 with Symbolizer

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

the class PictureFillSymbol method convert.

/* (non-Javadoc)
     * @see com.sldeditor.convert.esri.symbols.EsriSymbolInterface#convert(org.geotools.styling.Rule, com.google.gson.JsonElement, java.lang.String, int)
     */
@Override
public void convert(Rule rule, JsonElement element, String layerName, int transparency) {
    if (rule == null)
        return;
    if (element == null)
        return;
    JsonObject obj = element.getAsJsonObject();
    List<Symbolizer> symbolizerList = rule.symbolizers();
    List<Stroke> strokeList = SymbolManager.getInstance().getStrokeList(obj.get(PictureFillSymbolKeys.OUTLINE));
    Stroke stroke = null;
    if (!strokeList.isEmpty()) {
        stroke = strokeList.get(0);
    }
    Fill fill = getFill(layerName, obj, transparency);
    PolygonSymbolizer polygonSymbolizer = styleFactory.createPolygonSymbolizer(stroke, fill, null);
    symbolizerList.add(polygonSymbolizer);
}
Also used : Stroke(org.geotools.styling.Stroke) Fill(org.geotools.styling.Fill) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) JsonObject(com.google.gson.JsonObject) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Symbolizer(org.geotools.styling.Symbolizer)

Example 20 with Symbolizer

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

the class PictureFillSymbol method convertToFill.

/* (non-Javadoc)
     * @see com.sldeditor.convert.esri.symbols.EsriFillSymbolInterface#convertToFill(java.lang.String, com.google.gson.JsonElement, int)
     */
@Override
public List<Symbolizer> convertToFill(String layerName, JsonElement element, int transparency) {
    if (element == null)
        return null;
    JsonObject obj = element.getAsJsonObject();
    List<Symbolizer> symbolizerList = new ArrayList<Symbolizer>();
    Fill fill = getFill(layerName, obj, transparency);
    PolygonSymbolizer polygon = styleFactory.createPolygonSymbolizer();
    polygon.setStroke(null);
    polygon.setFill(fill);
    symbolizerList.add(polygon);
    return symbolizerList;
}
Also used : Fill(org.geotools.styling.Fill) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Symbolizer(org.geotools.styling.Symbolizer)

Aggregations

Symbolizer (org.geotools.styling.Symbolizer)65 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)29 LineSymbolizer (org.geotools.styling.LineSymbolizer)28 PointSymbolizer (org.geotools.styling.PointSymbolizer)27 Rule (org.geotools.styling.Rule)21 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)20 Style (org.geotools.styling.Style)18 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)15 TextSymbolizer (org.geotools.styling.TextSymbolizer)15 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)14 Test (org.junit.jupiter.api.Test)13 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)12 JsonObject (com.google.gson.JsonObject)11 StyledLayer (org.geotools.styling.StyledLayer)11 NamedLayer (org.geotools.styling.NamedLayer)10 ArrayList (java.util.ArrayList)8 JsonElement (com.google.gson.JsonElement)7 Stroke (org.geotools.styling.Stroke)6 JsonArray (com.google.gson.JsonArray)5 Expression (org.opengis.filter.expression.Expression)5