use of org.geotools.styling.Rule 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.Rule 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.Rule 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);
}
use of org.geotools.styling.Rule in project sldeditor by robward-scisys.
the class LineSymbolizerDetailsTest method testLineSymbolizerDetails.
/**
* Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#LineSymbolizerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
* Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
* Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
* Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#getFieldDataManager()}.
* Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#isDataPresent()}.
* Test method for {@link com.sldeditor.ui.detail.LineSymbolizerDetails#preLoadSymbol()}.
*/
@Test
public void testLineSymbolizerDetails() {
LineSymbolizerDetails panel = new LineSymbolizerDetails();
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 expectedNameFTSValue = "feature type style test value";
fts.setName(expectedNameFTSValue);
style.featureTypeStyles().add(fts);
Rule rule = DefaultSymbols.createNewRule();
String expectedRuleValue = "rule test value";
rule.setName(expectedRuleValue);
LineSymbolizer symbolizer = DefaultSymbols.createDefaultLineSymbolizer();
String expectedNameValue = "symbolizer test value";
symbolizer.setName(expectedNameValue);
rule.symbolizers().add(symbolizer);
fts.rules().add(rule);
sld.layers().add(namedLayer);
SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
SelectedSymbol.getInstance().setStyledLayer(namedLayer);
SelectedSymbol.getInstance().setStyle(style);
SelectedSymbol.getInstance().setFeatureTypeStyle(fts);
SelectedSymbol.getInstance().setRule(rule);
SelectedSymbol.getInstance().setSymbolizer(symbolizer);
panel.populate(SelectedSymbol.getInstance());
GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
assertNotNull(fieldDataManager);
panel.dataChanged(null);
FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
assertNull(nameField);
assertTrue(panel.isDataPresent());
// Reset to default value
panel.preLoadSymbol();
}
use of org.geotools.styling.Rule in project sldeditor by robward-scisys.
the class PointSymbolizerDetailsTest method testPointSymbolizerDetails.
/**
* Test method for {@link com.sldeditor.ui.detail.PointSymbolizerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
* Test method for {@link com.sldeditor.ui.detail.PointSymbolizerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
* Test method for {@link com.sldeditor.ui.detail.PointSymbolizerDetails#getFieldDataManager()}.
* Test method for {@link com.sldeditor.ui.detail.PointSymbolizerDetails#isDataPresent()}.
* Test method for {@link com.sldeditor.ui.detail.PointSymbolizerDetails#preLoadSymbol()}.
* Test method for {@link com.sldeditor.ui.detail.PointSymbolizerDetails#PointSymbolizerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
*/
@Test
public void testPointSymbolizerDetails() {
SelectedSymbol.destroyInstance();
PointSymbolizerDetails panel = new PointSymbolizerDetails();
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 expectedNameFTSValue = "feature type style test value";
fts.setName(expectedNameFTSValue);
style.featureTypeStyles().add(fts);
Rule rule = DefaultSymbols.createNewRule();
String expectedRuleValue = "rule test value";
rule.setName(expectedRuleValue);
PointSymbolizer symbolizer = DefaultSymbols.createDefaultPointSymbolizer();
String expectedNameValue = "symbolizer test value";
symbolizer.setName(expectedNameValue);
rule.symbolizers().add(symbolizer);
fts.rules().add(rule);
sld.layers().add(namedLayer);
SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
SelectedSymbol.getInstance().setStyledLayer(namedLayer);
SelectedSymbol.getInstance().setStyle(style);
SelectedSymbol.getInstance().setFeatureTypeStyle(fts);
SelectedSymbol.getInstance().setRule(rule);
SelectedSymbol.getInstance().setSymbolizer(symbolizer);
panel.populate(SelectedSymbol.getInstance());
GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
assertNotNull(fieldDataManager);
panel.dataChanged(null);
FieldConfigString descriptionField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.DESCRIPTION);
assertNull(descriptionField);
assertTrue(panel.isDataPresent());
// Reset to default value
panel.preLoadSymbol();
}
Aggregations