Java Code Examples for org.geotools.styling.Style#featureTypeStyles()

The following examples show how to use org.geotools.styling.Style#featureTypeStyles() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SelectedSymbol.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Checks if the selected Style contains a raster symbol.
 *
 * @return true, if is raster symbol
 */
public boolean isRasterSymbol() {
    Style style = getStyle();

    if (style != null) {
        for (FeatureTypeStyle fts : style.featureTypeStyles()) {
            for (Rule rule : fts.rules()) {
                for (Symbolizer symbolizer : rule.symbolizers()) {
                    if (symbolizer instanceof RasterSymbolizer) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
 
Example 2
Source File: ExtractValidFieldTypes.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Process styles.
 *
 * @param fieldsUpdated the fields updated
 * @param styleList the style list
 * @param featureList the feature list
 * @return true, if successful
 */
private static boolean processStyles(
        boolean fieldsUpdated,
        List<org.geotools.styling.Style> styleList,
        FeatureSource<SimpleFeatureType, SimpleFeature> featureList) {
    for (Style style : styleList) {
        for (FeatureTypeStyle fts : style.featureTypeStyles()) {
            for (Rule rule : fts.rules()) {
                Object drawMe = null;
                try {
                    drawMe = featureList.getFeatures().features().next();
                } catch (IOException | NoSuchElementException e) {
                    ConsoleManager.getInstance().exception(ExtractValidFieldTypes.class, e);
                }

                fieldsUpdated = processRule(fieldsUpdated, rule, drawMe);
            }
        }
    }
    return fieldsUpdated;
}
 
Example 3
Source File: SelectedSymbol.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Checks for only one rule.
 *
 * @return true, if successful
 */
public boolean hasOnlyOneRule() {
    boolean oneRule = false;

    int noOfRules = 0;

    List<StyledLayer> styledLayers = sld.layers();

    for (StyledLayer styledLayer : styledLayers) {
        List<Style> styleList = SLDUtils.getStylesList(styledLayer);

        for (Style style : styleList) {
            for (FeatureTypeStyle fts : style.featureTypeStyles()) {
                noOfRules += fts.rules().size();
            }
        }
    }

    oneRule = (noOfRules == 1);

    logger.debug(String.format("Number of rules : %d", noOfRules));

    return oneRule;
}
 
Example 4
Source File: SLDUtils.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Traverse symbolizers.
 *
 * @param sld the sld
 * @param traverseSymbolizersInterface the traverse symbolizers interface
 */
public static void traverseSymbolizers(
        StyledLayerDescriptor sld, TraverseSymbolizersInterface traverseSymbolizersInterface) {
    List<StyledLayer> styledLayerList = sld.layers();

    for (StyledLayer styledLayer : styledLayerList) {
        List<Style> styleList = SLDUtils.getStylesList(styledLayer);

        for (Style style : styleList) {
            for (FeatureTypeStyle fts : style.featureTypeStyles()) {
                for (Rule rule : fts.rules()) {
                    for (org.opengis.style.Symbolizer symbolizer : rule.symbolizers()) {
                        processSymbolizer(symbolizer, traverseSymbolizersInterface);
                    }
                }
            }
        }
    }
}
 
Example 5
Source File: SLDTree.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Populate styles.
 *
 * @param styledLayerTreeNode the styled layer tree node
 * @param styleList the style list
 */
private void populateStyles(DefaultMutableTreeNode styledLayerTreeNode, List<Style> styleList) {
    for (Style style : styleList) {
        DefaultMutableTreeNode styleTreeNode = addObject(styledLayerTreeNode, style, true);

        for (FeatureTypeStyle fts : style.featureTypeStyles()) {
            DefaultMutableTreeNode ftsTreeNode = addObject(styleTreeNode, fts, true);

            for (Rule rule : fts.rules()) {
                DefaultMutableTreeNode ruleTreeNode = addObject(ftsTreeNode, rule, true);

                for (Symbolizer symbolizer : rule.symbolizers()) {
                    populateSymbolizer(ruleTreeNode, symbolizer);
                }
            }
        }
    }
}
 
Example 6
Source File: StyleWrapper.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
public StyleWrapper(Style style) {
    this.style = style;
    name = style.getName();

    List<FeatureTypeStyle> featureTypeStyles = style.featureTypeStyles();
    for (FeatureTypeStyle featureTypeStyle : featureTypeStyles) {
        FeatureTypeStyleWrapper fstW = new FeatureTypeStyleWrapper(featureTypeStyle, this);
        featureTypeStylesWrapperList.add(fstW);
    }
}
 
Example 7
Source File: StyleDetails.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/** Update symbol. */
private void updateSymbol() {
    if (!Controller.getInstance().isPopulating()) {
        StandardData standardData = getStandardData();

        boolean isDefault = fieldConfigVisitor.getBoolean(FieldIdEnum.DEFAULT_STYLE);

        Style existingStyle = SelectedSymbol.getInstance().getStyle();
        if (existingStyle != null) {
            List<org.opengis.style.FeatureTypeStyle> newFTSList = new ArrayList<>();
            for (org.opengis.style.FeatureTypeStyle fts : existingStyle.featureTypeStyles()) {
                newFTSList.add(fts);
            }

            Symbolizer defaultSymbolizer = null;
            Style newStyle =
                    getStyleFactory()
                            .style(
                                    standardData.getName(),
                                    standardData.getDescription(),
                                    isDefault,
                                    newFTSList,
                                    defaultSymbolizer);

            SelectedSymbol.getInstance().replaceStyle(newStyle);

            this.fireUpdateSymbol();
        }
    }
}
 
Example 8
Source File: SLDUtils.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Find rule.
 *
 * @param sld the sld
 * @param ruleToFind the rule to find
 * @param otherSLD the other SLD
 * @return the rule
 */
public static Rule findRule(
        StyledLayerDescriptor sld, Rule ruleToFind, StyledLayerDescriptor otherSLD) {
    if (sld != null) {
        List<StyledLayer> styledLayerList = sld.layers();

        int styledLayerIndex = 0;
        int styleIndex = 0;
        int ftsIndex = 0;
        int ruleIndex = 0;

        for (StyledLayer styledLayer : styledLayerList) {
            List<Style> styleList = getStylesList(styledLayer);

            styleIndex = 0;
            for (Style style : styleList) {
                ftsIndex = 0;
                for (FeatureTypeStyle fts : style.featureTypeStyles()) {
                    ruleIndex = fts.rules().indexOf(ruleToFind);
                    if (ruleIndex > -1) {
                        return findEquivalentRule(
                                otherSLD, styledLayerIndex, styleIndex, ftsIndex, ruleIndex);
                    }
                    ftsIndex++;
                }
                styleIndex++;
            }
            styledLayerIndex++;
        }
    }
    return null;
}
 
Example 9
Source File: ScaleToolPanelTest.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Test method for {@link
 * com.sldeditor.tool.scale.ScaleToolPanel#ScaleToolPanel(com.sldeditor.common.SLDEditorInterface)}.
 */
@Test
void testScaleToolPanel() {
    TestSLDEditorInterface app = new TestSLDEditorInterface();

    TestScaleToolPanel testObj = new TestScaleToolPanel(app);

    DummyScaleSLDFile testData = new DummyScaleSLDFile();

    List<SLDDataInterface> sldDataList = new ArrayList<SLDDataInterface>();

    SLDEditorFile.getInstance().setSLDData(testData.getSLDData());
    sldDataList.add(testData.getSLDData());

    testObj.populate(sldDataList);

    double expectedMinScale = 100.0;
    testObj.setMinScale(0, expectedMinScale);
    double expectedMaxScale = 999.0;
    testObj.setMaxScale(1, expectedMaxScale);

    // Make no changes
    testObj.saveData();

    // Should be the same as before
    assertNotNull(app.savedSldData);

    StyledLayerDescriptor sld = SLDUtils.createSLDFromString(app.savedSldData);

    List<Rule> ruleList = null;

    if (sld != null) {
        List<StyledLayer> styledLayerList = sld.layers();

        if (styledLayerList != null) {
            for (StyledLayer styledLayer : styledLayerList) {
                if (styledLayer instanceof NamedLayerImpl) {
                    NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;

                    for (Style style : namedLayerImpl.styles()) {
                        for (FeatureTypeStyle fts : style.featureTypeStyles()) {
                            ruleList = fts.rules();
                        }
                    }
                }
            }
        }
    }

    assertNotNull(ruleList);

    assertTrue(Math.abs(ruleList.get(0).getMinScaleDenominator() - expectedMinScale) < 0.0001);
    assertTrue(Math.abs(ruleList.get(1).getMaxScaleDenominator() - expectedMaxScale) < 0.0001);
}
 
Example 10
Source File: SelectedSymbol.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Update internal data based on the supplied mask.
 *
 * @param maskValue the mask value
 */
private void updateInternalData(SelectedSymbolMask.SymbolMaskEnum maskValue) {
    SymbolData localSymbolData = new SymbolData();
    SelectedSymbolMask mask = new SelectedSymbolMask(maskValue);

    if (sld == null) {
        return;
    }

    List<StyledLayer> styledLayers = sld.layers();

    if (!styledLayers.isEmpty()) {
        localSymbolData.initialiseSelectedStyledLayerIndex();
        for (StyledLayer styledLayer : styledLayers) {
            localSymbolData.setStyledLayer(styledLayer);

            if (styledLayer == symbolData.getStyledLayer()) {
                this.symbolData.update(localSymbolData);
                return;
            }

            List<Style> styleList = null;

            if (mask.shouldContinue(SelectedSymbolMask.SymbolMaskEnum.E_STYLED_LAYER)) {
                styleList = SLDUtils.getStylesList(styledLayer);
            }

            if (mask.shouldContinue(SelectedSymbolMask.SymbolMaskEnum.E_STYLE)
                    && (styleList != null)
                    && !styleList.isEmpty()) {
                localSymbolData.initialiseSelectedStyleIndex();
                for (Style style : styleList) {
                    localSymbolData.setStyle(style);

                    if (style == symbolData.getStyle()) {
                        this.symbolData.update(localSymbolData);
                        return;
                    }

                    if (mask.shouldContinue(
                            SelectedSymbolMask.SymbolMaskEnum.E_FEATURE_TYPE_STYLE)) {
                        localSymbolData.initialiseSelectedFTSIndex();

                        for (FeatureTypeStyle fts : style.featureTypeStyles()) {
                            localSymbolData.setFeatureTypeStyle(fts);

                            if (fts == symbolData.getFeatureTypeStyle()) {
                                this.symbolData.update(localSymbolData);
                                return;
                            }

                            if (mask.shouldContinue(SelectedSymbolMask.SymbolMaskEnum.E_RULE)) {
                                localSymbolData.initialiseSelectedRuleIndex();
                                for (Rule rule : fts.rules()) {
                                    localSymbolData.setRule(rule);

                                    if (rule == symbolData.getRule()) {
                                        this.symbolData.update(localSymbolData);
                                        return;
                                    }

                                    if (mask.shouldContinue(
                                            SelectedSymbolMask.SymbolMaskEnum.E_SYMBOLIZER)) {
                                        localSymbolData.initialiseSelectedSymbolizerIndex();

                                        for (Symbolizer symbol : rule.symbolizers()) {
                                            localSymbolData.setSymbolizer(symbol);

                                            if (symbol == this.symbolData.getSymbolizer()) {
                                                this.symbolData.update(localSymbolData);
                                                return;
                                            } else {
                                                localSymbolData
                                                        .incrementSelectedSymbolizerIndex();
                                            }
                                        }
                                    }
                                    localSymbolData.incrementSelectedRuleIndex();
                                }
                            }
                            localSymbolData.incrementSelectedFTSIndex();
                        }
                    }
                    localSymbolData.incrementSelectedStyleIndex();
                }
            }
            localSymbolData.incrementSelectedStyledLayerIndex();
        }
    }
}
 
Example 11
Source File: ScaleToolPanelTest.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Test method for {@link
 * com.sldeditor.tool.scale.ScaleToolPanel#ScaleToolPanel(com.sldeditor.common.SLDEditorInterface)}.
 */
@Test
void testScaleToolPanelRevert() {
    TestSLDEditorInterface app = new TestSLDEditorInterface();

    TestScaleToolPanel testObj = new TestScaleToolPanel(app);

    DummyScaleSLDFile testData = new DummyScaleSLDFile();

    List<SLDDataInterface> sldDataList = new ArrayList<SLDDataInterface>();

    SLDEditorFile.getInstance().setSLDData(testData.getSLDData());
    sldDataList.add(testData.getSLDData());

    testObj.populate(sldDataList);

    StyledLayerDescriptor sld = SLDUtils.createSLDFromString(testData.getSLDData());

    List<Rule> ruleList = null;

    if (sld != null) {
        List<StyledLayer> styledLayerList = sld.layers();

        if (styledLayerList != null) {
            for (StyledLayer styledLayer : styledLayerList) {
                if (styledLayer instanceof NamedLayerImpl) {
                    NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;

                    for (Style style : namedLayerImpl.styles()) {
                        for (FeatureTypeStyle fts : style.featureTypeStyles()) {
                            ruleList = fts.rules();
                        }
                    }
                }
            }
        }
    }

    assertNotNull(ruleList);

    double originalMaxScale = ruleList.get(1).getMaxScaleDenominator();

    double expectedMinScale = 100.0;
    testObj.setMinScale(0, expectedMinScale);
    double expectedMaxScale = 999.0;
    testObj.setMaxScale(1, expectedMaxScale);

    // Make no changes
    testObj.revertData();

    assertNull(testObj.getMinScale(0));
    String stringValue = (String) testObj.getMaxScale(1);
    double actualScale = ScaleUtil.extractValue((String) stringValue);

    assertTrue(Math.abs(actualScale - originalMaxScale) < 0.0001);
}
 
Example 12
Source File: ScalePanelUtils.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Extracts all the rule scales.
 *
 * @param sldData the sld data
 * @return the scale sld data
 */
public static List<ScaleSLDData> containsScales(SLDDataInterface sldData) {

    List<ScaleSLDData> dataList = null;

    StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);

    if (sld != null) {
        List<StyledLayer> styledLayerList = sld.layers();

        for (StyledLayer styledLayer : styledLayerList) {
            if (styledLayer instanceof NamedLayerImpl) {
                NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;

                for (Style style : namedLayerImpl.styles()) {
                    for (FeatureTypeStyle fts : style.featureTypeStyles()) {
                        for (Rule rule : fts.rules()) {
                            double minScale = rule.getMinScaleDenominator();
                            double maxScale = rule.getMaxScaleDenominator();

                            if (isMinScaleSet(minScale) || isMaxScaleSet(maxScale)) {
                                if (dataList == null) {
                                    dataList = new ArrayList<>();
                                }
                                ScaleSLDData scaleSLDData = new ScaleSLDData(sld, sldData);

                                scaleSLDData.setNamedLayer(namedLayerImpl.getName());
                                scaleSLDData.setFeatureTypeStyle(fts.getName());
                                scaleSLDData.setStyle(style.getName());
                                scaleSLDData.setRule(rule);

                                if (isMinScaleSet(minScale)) {
                                    scaleSLDData.setMinScale(minScale);
                                }

                                if (isMaxScaleSet(maxScale)) {
                                    scaleSLDData.setMaxScale(maxScale);
                                }
                                dataList.add(scaleSLDData);
                            }
                        }
                    }
                }
            }
        }
    }
    return dataList;
}
 
Example 13
Source File: BatchUpdateFontUtils.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Contains font details.
 *
 * @param sldData the sld data
 * @return the scale sld data, returns null if invalid SLD string supplied.
 */
public static List<BatchUpdateFontData> containsFonts(SLDDataInterface sldData) {

    List<BatchUpdateFontData> dataList = null;

    StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);

    if (sld != null) {
        List<StyledLayer> styledLayerList = sld.layers();

        for (StyledLayer styledLayer : styledLayerList) {
            if (styledLayer instanceof NamedLayerImpl) {
                NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;

                for (Style style : namedLayerImpl.styles()) {
                    for (FeatureTypeStyle fts : style.featureTypeStyles()) {
                        for (Rule rule : fts.rules()) {
                            for (Symbolizer symbolizer : rule.symbolizers()) {
                                if (symbolizer instanceof TextSymbolizer) {
                                    TextSymbolizer textSymbol = (TextSymbolizer) symbolizer;
                                    Font font = textSymbol.getFont();
                                    if (font != null) {
                                        if (dataList == null) {
                                            dataList = new ArrayList<>();
                                        }
                                        BatchUpdateFontData fontSLDData =
                                                new BatchUpdateFontData(sld, sldData);

                                        fontSLDData.setNamedLayer(namedLayerImpl.getName());
                                        fontSLDData.setFeatureTypeStyle(fts.getName());
                                        fontSLDData.setStyle(style.getName());
                                        fontSLDData.setRule(rule);
                                        fontSLDData.setSymbolizer(textSymbol);
                                        fontSLDData.setFont(font);
                                        dataList.add(fontSLDData);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return dataList;
}
 
Example 14
Source File: UniqueValueRenderer.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
@Override
public StyledLayerDescriptor convert(JsonObject json, String layerName, double minScale, double maxScale, int transparency) {
    StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();

    NamedLayer namedLayer = styleFactory.createNamedLayer();

    boolean useDefaultSymbol = false;
    JsonElement useDefaultSymbolElement = json.get(UniqueValueRendererKeys.USE_DEFAULTSYMBOL);
    if(useDefaultSymbolElement != null)
    {
        useDefaultSymbol = useDefaultSymbolElement.getAsBoolean();
    }

    JsonElement jsonElement = json.get(CommonRendererKeys.LABEL);
    if(jsonElement != null)
    {
        namedLayer.setName(jsonElement.getAsString());
    }
    sld.addStyledLayer(namedLayer);

    Style style = styleFactory.createStyle();
    namedLayer.addStyle(style);

    List<FeatureTypeStyle> ftsList = style.featureTypeStyles();

    // style.setAbstract(json.get(IntermediateFileKeys.DESCRIPTION).getAsString());

    FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();

    ftsList.add(fts);

    JsonElement element = json.get(UniqueValueRendererKeys.VALUES);
    if(element != null)
    {
        JsonArray valueList = element.getAsJsonArray();

        for(int index = 0; index < valueList.size(); index ++)
        {
            JsonElement valueElement = valueList.get(index);
            if(valueElement != null)
            {
                Rule rule = styleFactory.createRule();
                JsonObject valueObj = valueElement.getAsJsonObject();

                String value = getString(valueObj, UniqueValueRendererKeys.VALUES_VALUE);

                String label = getString(valueObj, UniqueValueRendererKeys.VALUES_LABEL);
                rule.setName(label);

                createFilter(rule, json.get(UniqueValueRendererKeys.FIELDS), json.get(UniqueValueRendererKeys.FIELD_DELIMETER), value);

                // Heading /description
                String heading = getString(valueObj, UniqueValueRendererKeys.VALUES_HEADING);
                @SuppressWarnings("unused")
                String description = getString(valueObj, UniqueValueRendererKeys.VALUES_DESCRIPTION);

                if((heading != null) && !heading.isEmpty() || (label != null) && !label.isEmpty())
                {
                    if(label == null)
                    {
                        label = "";
                    }
                    InternationalString titleString = Text.text(label);
                    
                    if(heading == null)
                    {
                        heading = "";
                    }

                    InternationalString descriptionString = Text.text(heading);

                    Description descriptionObj = styleFactory.description(titleString, descriptionString);

                    rule.setDescription(descriptionObj);
                }

                if(minScale > 0.0)
                {
                    rule.setMinScaleDenominator(minScale);
                }

                if(maxScale > 0.0)
                {
                    rule.setMaxScaleDenominator(maxScale);
                }

                JsonElement jsonSymbolElement = valueObj.get(UniqueValueRendererKeys.VALUES_SYMBOL);
                SymbolManager.getInstance().convertSymbols(rule, layerName, transparency, jsonSymbolElement);

                if(useDefaultSymbol && value == null)
                {
                    rule.setIsElseFilter(true);
                }
                fts.rules().add(rule);
            }
        }
    }
    return sld;
}
 
Example 15
Source File: SLDExternalImagesTest.java    From sldeditor with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Creates the test point.
 *
 * @param url the url
 * @return the styled layer descriptor
 */
private StyledLayerDescriptor createTestPoint(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);

    PointSymbolizer point = styleFactory.createPointSymbolizer();

    rule.symbolizers().add(point);

    Graphic graphic = createGraphic(url, styleFactory);

    point.setGraphic(graphic);

    return sld;
}
 
Example 16
Source File: DefaultSymbols.java    From sldeditor with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Creates a new line symbol.
 *
 * @return the styled layer descriptor
 */
public static StyledLayerDescriptor createNewLine() {
    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 = createDefaultLineSymbolizer();

    rule.symbolizers().add(line);

    return sld;
}
 
Example 17
Source File: DefaultSymbols.java    From sldeditor with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Creates the new raster symbol.
 *
 * @return the styled layer descriptor
 */
public static StyledLayerDescriptor createNewRaster() {
    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);

    RasterSymbolizer raster = createDefaultRasterSymbolizer();

    rule.symbolizers().add(raster);

    return sld;
}
 
Example 18
Source File: SLDExternalImagesTest.java    From sldeditor with GNU General Public License v3.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 19
Source File: DefaultSymbols.java    From sldeditor with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Creates a new polygon symbol.
 *
 * @return the styled layer descriptor
 */
public static StyledLayerDescriptor createNewPolygon() {
    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 = createDefaultPolygonSymbolizer();

    rule.symbolizers().add(polygon);

    return sld;
}
 
Example 20
Source File: SLDExternalImagesTest.java    From sldeditor with GNU General Public License v3.0 2 votes vote down vote up
/**
 * 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;
}