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);
}
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;
}
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;
}
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));
}
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);
}
Aggregations