Search in sources :

Example 91 with FeatureTypeStyle

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

the class VendorOptionFTSFactoryTest method testVendorOptionFTSFactory.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.featuretypestyle.VendorOptionFTSFactory#VendorOptionFTSFactory(java.lang.Class)}.
 */
@Test
public void testVendorOptionFTSFactory() {
    VendorOptionFTSFactory obj = new VendorOptionFTSFactory(FeatureTypeStyleDetails.class);
    int expectedNoOfVO = 4;
    assertEquals(expectedNoOfVO, obj.getVendorOptionList().size());
    List<VendorOptionPresent> vendorOptionsPresentList = new ArrayList<VendorOptionPresent>();
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
    obj.getMinimumVersion(null, fts, vendorOptionsPresentList);
    assertEquals(0, vendorOptionsPresentList.size());
    // Valid string
    String expectedValue = "exclude,0.12";
    fts.getOptions().put(FeatureTypeStyle.COMPOSITE, expectedValue);
    obj.getMinimumVersion(null, fts, vendorOptionsPresentList);
    assertEquals(1, vendorOptionsPresentList.size());
    assertEquals(expectedNoOfVO, obj.getVendorOptionInfoList().size());
    assertEquals(1, obj.getVendorOptionList(VOGeoServerFTSComposite.class.getName()).size());
    GraphicPanelFieldManager fieldMgr = new GraphicPanelFieldManager(FeatureTypeStyleDetails.class);
    obj.getFieldDataManager(fieldMgr);
    obj.populate(fts);
    obj.updateSymbol(fts);
}
Also used : VendorOptionPresent(com.sldeditor.common.vendoroption.minversion.VendorOptionPresent) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) ArrayList(java.util.ArrayList) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) VOGeoServerFTSComposite(com.sldeditor.ui.detail.vendor.geoserver.featuretypestyle.VOGeoServerFTSComposite) VendorOptionFTSFactory(com.sldeditor.ui.detail.vendor.geoserver.featuretypestyle.VendorOptionFTSFactory) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Example 92 with FeatureTypeStyle

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

the class CreateInternalDataSource method internal_determineGeometryType.

/**
 * Internal determine geometry type.
 *
 * @param sld the sld
 * @return the geometry type enum
 */
protected GeometryTypeEnum internal_determineGeometryType(StyledLayerDescriptor sld) {
    GeometryTypeEnum geometryType = GeometryTypeEnum.UNKNOWN;
    if (sld != null) {
        List<StyledLayer> styledLayerList = sld.layers();
        int pointCount = 0;
        int lineCount = 0;
        int polygonCount = 0;
        int rasterCount = 0;
        for (StyledLayer styledLayer : styledLayerList) {
            List<Style> styleList = null;
            if (styledLayer instanceof NamedLayerImpl) {
                NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;
                styleList = namedLayerImpl.styles();
            } else if (styledLayer instanceof UserLayerImpl) {
                UserLayerImpl userLayerImpl = (UserLayerImpl) styledLayer;
                styleList = userLayerImpl.userStyles();
            }
            if (styleList != null) {
                for (Style style : styleList) {
                    for (FeatureTypeStyle fts : style.featureTypeStyles()) {
                        for (Rule rule : fts.rules()) {
                            for (org.opengis.style.Symbolizer symbolizer : rule.symbolizers()) {
                                if (symbolizer instanceof PointSymbolizer) {
                                    pointCount++;
                                } else if (symbolizer instanceof LineSymbolizer) {
                                    lineCount++;
                                } else if (symbolizer instanceof PolygonSymbolizer) {
                                    polygonCount++;
                                } else if (symbolizer instanceof RasterSymbolizer) {
                                    rasterCount++;
                                }
                            }
                        }
                    }
                }
            }
        }
        if (polygonCount > 0) {
            geometryType = GeometryTypeEnum.POLYGON;
        } else if (lineCount > 0) {
            geometryType = GeometryTypeEnum.LINE;
        } else if (pointCount > 0) {
            geometryType = GeometryTypeEnum.POINT;
        } else if (rasterCount > 0) {
            geometryType = GeometryTypeEnum.RASTER;
        }
    }
    return geometryType;
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) StyledLayer(org.geotools.styling.StyledLayer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) NamedLayerImpl(org.geotools.styling.NamedLayerImpl) Point(com.vividsolutions.jts.geom.Point) RasterSymbolizer(org.geotools.styling.RasterSymbolizer) UserLayerImpl(org.geotools.styling.UserLayerImpl) 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)

Example 93 with FeatureTypeStyle

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

the class ScalePanelUtils method containsScales.

/**
 * Contains 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();
        if (sld != null) {
            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 ((minScale > 0.0) || (maxScale > 0.0)) {
                                    if (dataList == null) {
                                        dataList = new ArrayList<ScaleSLDData>();
                                    }
                                    ScaleSLDData scaleSLDData = new ScaleSLDData(sld, sldData);
                                    scaleSLDData.setNamedLayer(namedLayerImpl.getName());
                                    scaleSLDData.setFeatureTypeStyle(fts.getName());
                                    scaleSLDData.setStyle(style.getName());
                                    scaleSLDData.setRule(rule);
                                    if (minScale > 0.0) {
                                        scaleSLDData.setMinScale(minScale);
                                    }
                                    if (maxScale > 0.0) {
                                        scaleSLDData.setMaxScale(maxScale);
                                    }
                                    dataList.add(scaleSLDData);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return dataList;
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) 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)

Example 94 with FeatureTypeStyle

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

the class CreateInternalDataSourceTest method testDetermineGeometryType.

/**
 * Test method for
 * {@link com.sldeditor.datasource.impl.CreateInternalDataSource#determineGeometryType(StyledLayerDescriptor)}.
 */
@Test
public void testDetermineGeometryType() {
    TestCreateInternalDataSource ds = new TestCreateInternalDataSource();
    assertEquals(GeometryTypeEnum.UNKNOWN, ds.callDetermineGeometryType(null));
    // Create StyledLayerDescriptor
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
    NamedLayer namedLayer = styleFactory.createNamedLayer();
    sld.addStyledLayer(namedLayer);
    UserLayer userLayer = styleFactory.createUserLayer();
    sld.addStyledLayer(userLayer);
    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);
    // Raster
    RasterSymbolizer raster = DefaultSymbols.createDefaultRasterSymbolizer();
    rule.symbolizers().add(raster);
    assertEquals(GeometryTypeEnum.RASTER, ds.callDetermineGeometryType(sld));
    // Polygon
    rule.symbolizers().clear();
    PolygonSymbolizer polygon = DefaultSymbols.createDefaultPolygonSymbolizer();
    rule.symbolizers().add(polygon);
    assertEquals(GeometryTypeEnum.POLYGON, ds.callDetermineGeometryType(sld));
    // Line
    rule.symbolizers().clear();
    LineSymbolizer line = DefaultSymbols.createDefaultLineSymbolizer();
    rule.symbolizers().add(line);
    assertEquals(GeometryTypeEnum.LINE, ds.callDetermineGeometryType(sld));
    // Point
    rule.symbolizers().clear();
    PointSymbolizer point = DefaultSymbols.createDefaultPointSymbolizer();
    rule.symbolizers().add(point);
    assertEquals(GeometryTypeEnum.POINT, ds.callDetermineGeometryType(sld));
    // Add line to point
    rule.symbolizers().add(line);
    assertEquals(GeometryTypeEnum.LINE, ds.callDetermineGeometryType(sld));
    // Add point, line
    rule.symbolizers().clear();
    rule.symbolizers().add(line);
    rule.symbolizers().add(point);
    assertEquals(GeometryTypeEnum.LINE, ds.callDetermineGeometryType(sld));
    // Add polygon, line
    rule.symbolizers().clear();
    rule.symbolizers().add(point);
    rule.symbolizers().add(polygon);
    assertEquals(GeometryTypeEnum.POLYGON, ds.callDetermineGeometryType(sld));
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) RasterSymbolizer(org.geotools.styling.RasterSymbolizer) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) 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) UserLayer(org.geotools.styling.UserLayer) NamedLayer(org.geotools.styling.NamedLayer) Test(org.junit.Test)

Example 95 with FeatureTypeStyle

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

the class FeatureTypeStyleDetailsTest method testFeatureTypeStyleDetails.

/**
 * Test method for {@link com.sldeditor.ui.detail.FeatureTypeStyleDetails#FeatureTypeStyleDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 * Test method for {@link com.sldeditor.ui.detail.FeatureTypeStyleDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
 * Test method for {@link com.sldeditor.ui.detail.FeatureTypeStyleDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for {@link com.sldeditor.ui.detail.FeatureTypeStyleDetails#getFieldDataManager()}.
 * Test method for {@link com.sldeditor.ui.detail.FeatureTypeStyleDetails#isDataPresent()}.
 * Test method for {@link com.sldeditor.ui.detail.FeatureTypeStyleDetails#preLoadSymbol()}.
 */
@Test
public void testFeatureTypeStyleDetails() {
    FeatureTypeStyleDetails panel = new FeatureTypeStyleDetails();
    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 expectedNameValue = "feature type style test value";
    fts.setName(expectedNameValue);
    style.featureTypeStyles().add(fts);
    Rule rule = DefaultSymbols.createNewRule();
    String expectedRuleNameValue = "rule test value";
    rule.setName(expectedRuleNameValue);
    fts.rules().add(rule);
    sld.layers().add(namedLayer);
    SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyle(style);
    SelectedSymbol.getInstance().setFeatureTypeStyle(fts);
    panel.populate(SelectedSymbol.getInstance());
    panel.dataChanged(null);
    GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
    assertNotNull(fieldDataManager);
    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) FeatureTypeStyleDetails(com.sldeditor.ui.detail.FeatureTypeStyleDetails) 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) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Aggregations

FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)110 Style (org.geotools.styling.Style)81 Rule (org.geotools.styling.Rule)65 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)43 Test (org.junit.Test)42 NamedLayer (org.geotools.styling.NamedLayer)38 PointSymbolizer (org.geotools.styling.PointSymbolizer)24 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)22 StyledLayer (org.geotools.styling.StyledLayer)21 LineSymbolizer (org.geotools.styling.LineSymbolizer)20 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)17 Symbolizer (org.geotools.styling.Symbolizer)16 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)15 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)14 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)12 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)12 TextSymbolizer (org.geotools.styling.TextSymbolizer)12 UserLayerImpl (org.geotools.styling.UserLayerImpl)12 ArrayList (java.util.ArrayList)11 LineStyle (org.polymap.core.style.model.feature.LineStyle)11