org.geotools.styling.FeatureTypeStyle Java Examples

The following examples show how to use org.geotools.styling.FeatureTypeStyle. 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
/**
 * Sets the feature type style.
 *
 * @param fts the new feature type style
 */
public void setFeatureTypeStyle(FeatureTypeStyle fts) {
    symbolData.resetData();
    this.symbolData.setFeatureTypeStyle(fts);

    updateInternalData(SelectedSymbolMask.SymbolMaskEnum.E_FEATURE_TYPE_STYLE);

    if (this.symbolData.getFeatureTypeStyle() == null) {
        logger.debug("FeatureTypeStyle cleared");
    } else {
        logger.debug(
                String.format(
                        "Selected feature type style : %s (FTS %d)",
                        this.symbolData.getFeatureTypeStyle().getName(),
                        this.symbolData.getSelectedFTSIndex()));
    }
}
 
Example #2
Source File: RenderSymbol.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets the render style.
 *
 * @param selectedSymbol the selected symbol
 * @return the render style
 */
public Style getRenderStyle(SelectedSymbol selectedSymbol) {
    List<StyledLayer> styledLayerList = selectedSymbol.getSld().layers();

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

        for (Style style : styleList) {
            FeatureTypeStyle ftsToRender = selectedSymbol.getFeatureTypeStyle();
            Rule ruleToRender = selectedSymbol.getRule();

            // Check to see if style contains the rule to render
            if (shouldRenderSymbol(style, ftsToRender, ruleToRender)) {
                return renderSymbol(style, ftsToRender, ruleToRender, renderOptions);
            }
        }
    }
    return null;
}
 
Example #3
Source File: FeatureLayerConfigurationPersistencyTest.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings({"deprecation"})
private static Style createStyle() {
    StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory(null);
    FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(null);
    PolygonSymbolizer symbolizer = styleFactory.createPolygonSymbolizer();
    Fill fill = styleFactory.createFill(
            filterFactory.literal("#FFAA00"),
            filterFactory.literal(0.5)
    );
    symbolizer.setFill(fill);
    Rule rule = styleFactory.createRule();
    rule.setSymbolizers(new Symbolizer[]{symbolizer});
    FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
    fts.setRules(new Rule[]{rule});

    Style style = styleFactory.createStyle();
    style.addFeatureTypeStyle(fts);
    return style;
}
 
Example #4
Source File: DistributedRenderCallback.java    From geowave with Apache License 2.0 6 votes vote down vote up
private static FeatureTypeStyle getDirectRasterStyle(
    final String geometryPropertyName,
    final Expression transformation) {
  final StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory();
  final FeatureTypeStyle style = styleFactory.createFeatureTypeStyle();
  final Rule rule = styleFactory.createRule();
  rule.setName("distributed render - direct raster");
  rule.setTitle("Distributed Render - Direct Raster");

  final RasterSymbolizer symbolizer = styleFactory.createRasterSymbolizer();
  symbolizer.setGeometryPropertyName(geometryPropertyName);
  rule.symbolizers().add(symbolizer);
  style.rules().add(rule);
  style.setTransformation(transformation);
  return style;
}
 
Example #5
Source File: RenderSymbol.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Should render symbol.
 *
 * @param style the style
 * @param ruleToRender the rule to render
 * @return true, if successful
 */
private boolean shouldRenderSymbol(
        Style style, FeatureTypeStyle ftsToRender, Rule ruleToRender) {

    if (ruleToRender == null) {
        return true;
    }

    for (FeatureTypeStyle fts : style.featureTypeStyles()) {
        if (fts == ftsToRender) {
            for (Rule rule : fts.rules()) {
                if (rule == ruleToRender) {
                    return true;
                }
            }
        }
    }

    return false;
}
 
Example #6
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 #7
Source File: VOGeoServerFTSRuleEvaluation.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void populate(FeatureTypeStyle featureTypeStyle) {
    Map<String, String> options = featureTypeStyle.getOptions();

    String compositeBaseString = options.get(FeatureTypeStyle.KEY_EVALUATION_MODE);

    String value = DEFAULT_COMPOSITE_RULE_EVALUATION;

    if ((compositeBaseString != null)
            && (compositeBaseString.equals(FeatureTypeStyle.VALUE_EVALUATION_MODE_ALL)
                    || compositeBaseString.equals(
                            FeatureTypeStyle.VALUE_EVALUATION_MODE_FIRST))) {
        value = compositeBaseString;
    }

    fieldConfigVisitor.populateComboBoxField(FieldIdEnum.VO_FTS_RULE_EVALUATION_OPTION, value);

    GroupConfigInterface groupPanel = getGroup(GroupIdEnum.VO_FTS_RULE_EVALUATION);
    groupPanel.enable(compositeBaseString != null);
}
 
Example #8
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 #9
Source File: Utils.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Create a default point style.
 *
 * @return the created style.
 */
public static Style createPointStyle() {
	final Graphic gr = styleFactory.createDefaultGraphic();
	final Mark mark = styleFactory.getCircleMark();
	mark.setStroke(styleFactory.createStroke(filterFactory.literal(Color.BLUE), filterFactory.literal(1)));
	mark.setFill(styleFactory.createFill(filterFactory.literal(Color.CYAN)));
	gr.graphicalSymbols().clear();
	gr.graphicalSymbols().add(mark);
	gr.setSize(filterFactory.literal(5));
	/*
	 * Setting the geometryPropertyName arg to null signals that we want to draw the default geomettry of features
	 */
	final PointSymbolizer sym = styleFactory.createPointSymbolizer(gr, null);

	final Rule rule = styleFactory.createRule();
	rule.symbolizers().add(sym);
	final FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle(new Rule[] { rule });
	final Style style = styleFactory.createStyle();
	style.featureTypeStyles().add(fts);

	return style;
}
 
Example #10
Source File: SymbolizerFilterVisitorTest.java    From geomajas-project-server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testTransformation() throws IOException{
	SymbolizerFilterVisitor visitor = new SymbolizerFilterVisitor();
	visitor.setIncludeGeometry(true);
	visitor.setIncludeText(true);
	SLDParser parser = new SLDParser(styleFactory);
	parser.setInput(getClass().getResource("heatmap.sld"));
	Style[] styles = parser.readXML();
	Assert.assertEquals(1, styles.length);
	visitor.visit(styles[0]);
	Style copy = (Style) visitor.getCopy();
	FeatureTypeStyle featureTypeStyle = copy.featureTypeStyles().iterator().next();
	Assert.assertNotNull(featureTypeStyle.getTransformation());		
	Rule rule = featureTypeStyle.rules().iterator().next();
	Iterator<Symbolizer> it = rule.symbolizers().iterator();
	Assert.assertTrue(it.next() instanceof RasterSymbolizer);
	Assert.assertFalse(it.hasNext());
}
 
Example #11
Source File: SymbolizerFilterVisitor.java    From geomajas-project-server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Overridden to add transform.
 */
@Override
public void visit(FeatureTypeStyle fts) {

	FeatureTypeStyle copy = new FeatureTypeStyleImpl(
			(FeatureTypeStyleImpl) fts);
	Rule[] rules = fts.getRules();
	int length = rules.length;
	Rule[] rulesCopy = new Rule[length];
	for (int i = 0; i < length; i++) {
		if (rules[i] != null) {
			rules[i].accept(this);
			rulesCopy[i] = (Rule) pages.pop();
		}
	}
	copy.setRules(rulesCopy);
	if (fts.getTransformation() != null) {
		copy.setTransformation(copy(fts.getTransformation()));
	}
	if (STRICT && !copy.equals(fts)) {
		throw new IllegalStateException(
				"Was unable to duplicate provided FeatureTypeStyle:" + fts);
	}
	pages.push(copy);
}
 
Example #12
Source File: SelectedSymbol.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Removes the feature type style.
 *
 * @param ftsToDelete the feature type style to delete
 */
public void removeFeatureTypeStyle(FeatureTypeStyle ftsToDelete) {
    List<FeatureTypeStyle> ftsList = this.symbolData.getStyle().featureTypeStyles();

    int indexFound = -1;
    int index = 0;
    for (FeatureTypeStyle fts : ftsList) {
        if (fts == ftsToDelete) {
            indexFound = index;
            break;
        } else {
            index++;
        }
    }

    if (indexFound > -1) {
        ftsList.remove(indexFound);
    }
}
 
Example #13
Source File: SLDUtils.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Find equivalent rule.
 *
 * @param otherSLD the other SLD
 * @param styledLayerIndex the styled layer index
 * @param styleIndex the style index
 * @param ftsIndex the fts index
 * @param ruleIndex the rule index
 * @return the rule
 */
private static Rule findEquivalentRule(
        StyledLayerDescriptor otherSLD,
        int styledLayerIndex,
        int styleIndex,
        int ftsIndex,
        int ruleIndex) {
    if (otherSLD != null) {
        List<StyledLayer> styledLayerList = otherSLD.layers();

        try {
            StyledLayer styledLayer = styledLayerList.get(styledLayerIndex);

            List<Style> styleList = getStylesList(styledLayer);

            Style style = styleList.get(styleIndex);
            FeatureTypeStyle fts = style.featureTypeStyles().get(ftsIndex);
            return fts.rules().get(ruleIndex);
        } catch (IndexOutOfBoundsException exception) {
            // Do nothing
        }
    }
    return null;
}
 
Example #14
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 #15
Source File: VOGeoServerFTSSortBy.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void getMinimumVersion(
        Object parentObj, Object sldObj, List<VendorOptionPresent> vendorOptionsPresentList) {
    if (sldObj instanceof FeatureTypeStyle) {
        FeatureTypeStyle fts = (FeatureTypeStyle) sldObj;
        Map<String, String> options = fts.getOptions();

        if (options.containsKey(FeatureTypeStyle.SORT_BY)
                || options.containsKey(FeatureTypeStyle.SORT_BY_GROUP)) {
            VendorOptionPresent voPresent =
                    new VendorOptionPresent(sldObj, getVendorOptionInfo());

            vendorOptionsPresentList.add(voPresent);
        }
    }
}
 
Example #16
Source File: StyleDetailsTest.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Test method for {@link
 * com.sldeditor.ui.detail.StyleDetails#StyleDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 * Test method for {@link
 * com.sldeditor.ui.detail.StyleDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
 * Test method for {@link
 * com.sldeditor.ui.detail.StyleDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for {@link com.sldeditor.ui.detail.StyleDetails#getFieldDataManager()}. Test
 * method for {@link com.sldeditor.ui.detail.StyleDetails#isDataPresent()}. Test method for
 * {@link com.sldeditor.ui.detail.StyleDetails#preLoadSymbol()}.
 */
@Test
public void testStyleDetails() {
    StyleDetails panel = new StyleDetails();
    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 expectedNameValue = "style test value";
    style.setName(expectedNameValue);
    namedLayer.addStyle(style);
    FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
    style.featureTypeStyles().add(fts);
    sld.layers().add(namedLayer);
    SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyle(style);

    panel.populate(SelectedSymbol.getInstance());
    panel.dataChanged(null);
    GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
    assertNotNull(fieldDataManager);

    FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
    assertTrue(expectedNameValue.compareTo(nameField.getStringValue()) == 0);
    assertTrue(panel.isDataPresent());

    // Reset to default value
    panel.preLoadSymbol();
    assertTrue("".compareTo(nameField.getStringValue()) == 0);
}
 
Example #17
Source File: VOGeoServerLabellingUnderlineTest.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Test method for {@link
 * com.sldeditor.ui.detail.vendor.geoserver.text.VOGeoServerLabellingUnderline#populate(org.geotools.styling.FeatureTypeStyle)}.
 */
@Test
void testPopulateFeatureTypeStyle() {
    VOGeoServerLabellingUnderline testObj =
            new VOGeoServerLabellingUnderline(TextSymbolizerDetails.class);
    FeatureTypeStyle symbol = null;
    testObj.populate(symbol);
}
 
Example #18
Source File: RuleRenderVisitor.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Instantiates a new rule render visitor.
 *
 * @param featureTypeStyle the feature type style
 * @param rule the rule
 * @param symbolizerIndex the symbolizer index
 * @param options the options
 */
public RuleRenderVisitor(
        FeatureTypeStyle featureTypeStyle,
        Rule rule,
        int symbolizerIndex,
        RuleRenderOptions options) {
    this.ftsToRender = featureTypeStyle;
    this.ruleToRender = rule;
    this.symbolizerIndex = symbolizerIndex;
    this.options = options;
}
 
Example #19
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 #20
Source File: StyleGenerator.java    From constellation with Apache License 2.0 5 votes vote down vote up
private static Style createLineStyle() {
    final StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory();
    final FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory();

    // create a partially opaque outline stroke
    final Stroke stroke = styleFactory.createStroke(
            filterFactory.literal(Color.WHITE),
            filterFactory.literal(1),
            filterFactory.literal(.5)
    );

    // create a partially opaque fill
    final Fill fill = styleFactory.createFill(
            filterFactory.literal(Color.RED),
            filterFactory.literal(.25)
    );

    // setting the geometryPropertyName arg to null signals that we want to draw the default geometry of features
    final PolygonSymbolizer sym = styleFactory.createPolygonSymbolizer(stroke, fill, null);

    // make rule
    final Rule rule = styleFactory.createRule();
    rule.symbolizers().add(sym);

    final FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle(new Rule[]{rule});
    final Style style = styleFactory.createStyle();
    style.getDescription().setTitle("Line Style");
    style.featureTypeStyles().add(fts);

    return style;
}
 
Example #21
Source File: StyleGenerator.java    From constellation with Apache License 2.0 5 votes vote down vote up
private static Style createPolygonStyle(final SimpleFeatureCollection features) {
    // get name based rule names
    final List<Rule> ruleList = new ArrayList<>();
    final Set<String> nameSet = new HashSet<>();

    // setup custom rules for polygons
    final SimpleFeatureIterator featureIterator = features.features();
    while (featureIterator.hasNext()) {
        final SimpleFeature feature = featureIterator.next();
        if (nameSet.add((String) feature.getAttribute(ATTRIBUTE))) {
            ruleList.add(makeFillRule(feature));
        }
    }

    // create a partially opaque outline stroke
    final Rule defaultRule = makeFillRule();
    defaultRule.setElseFilter(true);
    defaultRule.setName("Default Rule");
    ruleList.add(defaultRule);

    // Create rule defined style
    final Rule[] rules = ruleList.toArray(new Rule[ruleList.size()]);
    final StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory();
    final FeatureTypeStyle featureTypeStyle = styleFactory.createFeatureTypeStyle(rules);

    final StyleBuilder builder = new StyleBuilder();
    final Style style = builder.createStyle();
    style.getDescription().setTitle("Polygon Style");
    style.featureTypeStyles().add(featureTypeStyle);

    return style;
}
 
Example #22
Source File: SLDUtils.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Find equivalent symbolizer in another SLD.
 *
 * @param otherSLD the other SLD
 * @param styledLayerIndex the styled layer index
 * @param isNamedLayer the is named layer
 * @param styleIndex the style index
 * @param ftsIndex the fts index
 * @param ruleIndex the rule index
 * @param symbolizerIndex the symbolizer index
 * @return the symbolizer
 */
private static Symbolizer findEquivalentSymbolizer(
        StyledLayerDescriptor otherSLD,
        int styledLayerIndex,
        boolean isNamedLayer,
        int styleIndex,
        int ftsIndex,
        int ruleIndex,
        int symbolizerIndex) {
    if (otherSLD != null) {
        List<StyledLayer> styledLayerList = otherSLD.layers();

        if (styledLayerList != null) {

            try {
                StyledLayer styledLayer = styledLayerList.get(styledLayerIndex);

                List<Style> styleList = null;

                if (isNamedLayer) {
                    NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;
                    styleList = namedLayerImpl.styles();
                } else {
                    UserLayerImpl userLayerImpl = (UserLayerImpl) styledLayer;
                    styleList = userLayerImpl.userStyles();
                }

                if (styleList != null) {
                    Style style = styleList.get(styleIndex);
                    FeatureTypeStyle fts = style.featureTypeStyles().get(ftsIndex);
                    Rule rule = fts.rules().get(ruleIndex);
                    return rule.symbolizers().get(symbolizerIndex);
                }
            } catch (IndexOutOfBoundsException exception) {
                // Do nothing
            }
        }
    }
    return null;
}
 
Example #23
Source File: VOGeoServerTextSymbolizer2Test.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Test method for {@link
 * com.sldeditor.ui.detail.vendor.geoserver.text.VOGeoServerTextSymbolizer2#updateSymbol(org.geotools.styling.FeatureTypeStyle)}.
 */
@Test
public void testUpdateSymbolFeatureTypeStyle() {
    TextSymbolizerDetails panel = new TextSymbolizerDetails();
    VOGeoServerTextSymbolizer2 testObj = new VOGeoServerTextSymbolizer2(panel.getClass());
    FeatureTypeStyle style = null;
    testObj.updateSymbol(style);
}
 
Example #24
Source File: VectorLayerFactory.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
public void visit(FeatureTypeStyle fts) {
	Rule[] rules = fts.getRules();

	for (int i = 0; i < rules.length; i++) {
		Rule rule = rules[i];
		rule.accept(this);
	}
	if (fts.getTransformation() != null) {
		visit(fts.getTransformation());
	}
}
 
Example #25
Source File: SelectedSymbol.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds the new feature type style.
 *
 * @param featureTypeStyle the feature type style
 */
public void addNewFeatureTypeStyle(FeatureTypeStyle featureTypeStyle) {
    if (this.symbolData.getStyle() == null) {
        ConsoleManager.getInstance().error(this, "style == null");
    } else {
        List<FeatureTypeStyle> ftsList = this.symbolData.getStyle().featureTypeStyles();

        ftsList.add(featureTypeStyle);
    }
}
 
Example #26
Source File: VOGeoServerFTSSortBy.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void populate(FeatureTypeStyle featureTypeStyle) {
    Map<String, String> options = featureTypeStyle.getOptions();

    String sortByString = options.get(FeatureTypeStyle.SORT_BY);
    String sortByGroupString = null;
    MultiOptionGroup group = (MultiOptionGroup) getGroup(GroupIdEnum.VO_FTS_SORTBY_MULTIOPTION);

    if (sortByString != null) {
        group.setOption(GroupIdEnum.VO_FTS_SORTBY_MULTIOPTION_SORTBY_OPTION);

        fieldConfigVisitor.populateTextField(
                FieldIdEnum.VO_FTS_SORTBY_MULTIOPTION_SORTBY_LIST, sortByString);

    } else {
        sortByGroupString = options.get(FeatureTypeStyle.SORT_BY_GROUP);
        if (sortByGroupString != null) {
            group.setOption(GroupIdEnum.VO_FTS_SORTBY_MULTIOPTION_SORTBY_GROUP_OPTION);

            fieldConfigVisitor.populateTextField(
                    FieldIdEnum.VO_FTS_SORTBY_MULTIOPTION_SORTBY_GROUP_PROPERTIES,
                    sortByGroupString);
        }
    }

    group.enable((sortByString != null) || (sortByGroupString != null));
}
 
Example #27
Source File: VendorOptionFTSFactory.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Update symbol.
 *
 * @param featureTypeStyle the feature type style
 */
public void updateSymbol(FeatureTypeStyle featureTypeStyle) {
    for (VendorOptionInterface vendorOption : vendorOptionList) {
        boolean displayVendorOption =
                VendorOptionManager.getInstance()
                        .isAllowed(vendorOptionVersionsList, vendorOption.getVendorOption());

        if (displayVendorOption) {
            vendorOption.updateSymbol(featureTypeStyle);
        }
    }
}
 
Example #28
Source File: VOGeoServerFTSRuleEvaluation.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void updateSymbol(FeatureTypeStyle featureTypeStyle) {
    Map<String, String> options = featureTypeStyle.getOptions();

    GroupConfigInterface groupPanel = getGroup(GroupIdEnum.VO_FTS_RULE_EVALUATION);
    if (groupPanel.isPanelEnabled()) {
        ValueComboBoxData value =
                fieldConfigVisitor.getComboBox(FieldIdEnum.VO_FTS_RULE_EVALUATION_OPTION);

        options.put(FeatureTypeStyle.KEY_EVALUATION_MODE, value.getKey());
    } else {
        options.remove(FeatureTypeStyle.KEY_EVALUATION_MODE);
    }
}
 
Example #29
Source File: VOGeoServerLabellingTest.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Test method for {@link
 * com.sldeditor.ui.detail.vendor.geoserver.text.VOGeoServerLabelling#updateSymbol(org.geotools.styling.FeatureTypeStyle)}.
 */
@Test
void testUpdateSymbolFeatureTypeStyle() {
    VOGeoServerLabelling testObj = new VOGeoServerLabelling(TextSymbolizerDetails.class);
    FeatureTypeStyle symbolizer = null;
    testObj.updateSymbol(symbolizer);
}
 
Example #30
Source File: SLDs.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the max scale of the default rule, or Double#NaN if none is set
 */
public static double maxScale(final FeatureTypeStyle fts) {
	if (fts == null || fts.rules().size() == 0) { return Double.NaN; }

	final Rule r = fts.rules().get(0);
	return r.getMaxScaleDenominator();
}