Search in sources :

Example 31 with Rule

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

the class SelectedSymbol method updateInternalData.

/**
 * 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;
    }
    StyledLayer[] styledLayers = sld.getStyledLayers();
    if (styledLayers != null) {
        localSymbolData.initialiseSelectedStyledLayerIndex();
        for (StyledLayer styledLayer : styledLayers) {
            localSymbolData.setStyledLayer(styledLayer);
            if (styledLayer == symbolData.getStyledLayer()) {
                this.symbolData.update(localSymbolData);
                return;
            }
            List<Style> styleList = null;
            if ((styledLayer instanceof NamedLayerImpl) && mask.shouldContinue(SelectedSymbolMask.SymbolMaskEnum.E_STYLED_LAYER)) {
                NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;
                styleList = namedLayerImpl.styles();
            } else if ((styledLayer instanceof UserLayerImpl) && mask.shouldContinue(SelectedSymbolMask.SymbolMaskEnum.E_STYLED_LAYER)) {
                UserLayerImpl userLayerImpl = (UserLayerImpl) styledLayer;
                styleList = userLayerImpl.userStyles();
            }
            if (mask.shouldContinue(SelectedSymbolMask.SymbolMaskEnum.E_STYLE) && (styleList != null)) {
                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();
        }
    }
}
Also used : UserLayerImpl(org.geotools.styling.UserLayerImpl) StyledLayer(org.geotools.styling.StyledLayer) NamedLayerImpl(org.geotools.styling.NamedLayerImpl) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) Symbolizer(org.geotools.styling.Symbolizer) RasterSymbolizer(org.geotools.styling.RasterSymbolizer)

Example 32 with Rule

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

the class DefaultSymbols method createNewRule.

/**
 * Creates the new rule.
 *
 * @return the rule
 */
public static Rule createNewRule() {
    Rule rule = styleFactory.createRule();
    rule.setName(Localisation.getString(SLDTreeTools.class, "TreeItem.newRule"));
    return rule;
}
Also used : Rule(org.geotools.styling.Rule) SLDTreeTools(com.sldeditor.ui.tree.SLDTreeTools)

Example 33 with Rule

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

the class DefaultSymbols method createNewLine.

/**
 * 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;
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) LineSymbolizer(org.geotools.styling.LineSymbolizer) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer)

Example 34 with Rule

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

the class DefaultSymbols method createNewPoint.

/**
 * Creates a new point symbol.
 *
 * @return the styled layer descriptor
 */
public static StyledLayerDescriptor createNewPoint() {
    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 = createDefaultPointSymbolizer();
    rule.symbolizers().add(point);
    return sld;
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer)

Example 35 with Rule

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

the class DefaultSymbols method createNewRaster.

/**
 * 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;
}
Also used : RasterSymbolizer(org.geotools.styling.RasterSymbolizer) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer)

Aggregations

Rule (org.geotools.styling.Rule)110 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)65 Style (org.geotools.styling.Style)60 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)51 Test (org.junit.Test)48 NamedLayer (org.geotools.styling.NamedLayer)38 PointSymbolizer (org.geotools.styling.PointSymbolizer)28 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)26 LineSymbolizer (org.geotools.styling.LineSymbolizer)24 Symbolizer (org.geotools.styling.Symbolizer)22 StyledLayer (org.geotools.styling.StyledLayer)19 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)16 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)16 TextSymbolizer (org.geotools.styling.TextSymbolizer)15 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)13 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)11 ArrayList (java.util.ArrayList)11 Filter (org.opengis.filter.Filter)11 UserLayerImpl (org.geotools.styling.UserLayerImpl)10 DataSourceAttributeData (com.sldeditor.datasource.attribute.DataSourceAttributeData)8