use of org.geotools.styling.UserLayer in project sldeditor by robward-scisys.
the class SLDExternalImages method externalGraphicSymbolVisitor.
/**
* Find the SLD graphical symbols.
*
* @param resourceLocator the resource locator
* @param sld the sld
* @param externalImageList the external image list
* @param process the process
*/
private static void externalGraphicSymbolVisitor(URL resourceLocator, StyledLayerDescriptor sld, List<String> externalImageList, ProcessGraphicSymbolInterface process) {
if (sld == null) {
return;
}
if (process == null) {
return;
}
for (StyledLayer styledLayer : sld.layers()) {
List<Style> styles = null;
if (styledLayer instanceof NamedLayer) {
NamedLayerImpl namedLayer = (NamedLayerImpl) styledLayer;
styles = namedLayer.styles();
} else if (styledLayer instanceof UserLayer) {
UserLayerImpl userLayer = (UserLayerImpl) styledLayer;
styles = userLayer.userStyles();
}
if (styles != null) {
for (Style style : styles) {
for (FeatureTypeStyle fts : style.featureTypeStyles()) {
for (Rule rule : fts.rules()) {
for (Symbolizer symbolizer : rule.symbolizers()) {
if (symbolizer instanceof PointSymbolizer) {
PointSymbolizer point = (PointSymbolizer) symbolizer;
if (point.getGraphic() != null) {
process.processGraphicalSymbol(resourceLocator, point.getGraphic().graphicalSymbols(), externalImageList);
}
} else if (symbolizer instanceof LineSymbolizer) {
LineSymbolizer line = (LineSymbolizer) symbolizer;
updateStroke(resourceLocator, line.getStroke(), externalImageList, process);
} else if (symbolizer instanceof PolygonSymbolizer) {
PolygonSymbolizer polygon = (PolygonSymbolizer) symbolizer;
updateStroke(resourceLocator, polygon.getStroke(), externalImageList, process);
updateFill(resourceLocator, polygon.getFill(), externalImageList, process);
}
}
}
}
}
}
}
}
use of org.geotools.styling.UserLayer in project sldeditor by robward-scisys.
the class UserLayerDetails method updateSymbol.
/**
* Update symbol.
*
* @param changedField the changed field
*/
private void updateSymbol(FieldIdEnum changedField) {
if (!Controller.getInstance().isPopulating()) {
UserLayer userLayer = getStyleFactory().createUserLayer();
String name = fieldConfigVisitor.getText(FieldIdEnum.NAME);
userLayer.setName(name);
// Feature type constraints
List<FeatureTypeConstraint> ftcList = fieldConfigVisitor.getFeatureTypeConstraint(FieldIdEnum.LAYER_FEATURE_CONSTRAINTS);
if ((ftcList != null) && !ftcList.isEmpty()) {
FeatureTypeConstraint[] ftcArray = new FeatureTypeConstraint[ftcList.size()];
userLayer.setLayerFeatureConstraints(ftcList.toArray(ftcArray));
}
// Source
GroupConfigInterface group = getGroup(GroupIdEnum.USER_LAYER_SOURCE);
if (group != null) {
MultiOptionGroup userLayerSourceGroup = (MultiOptionGroup) group;
OptionGroup selectedOption = userLayerSourceGroup.getSelectedOptionGroup();
switch(selectedOption.getId()) {
case REMOTE_OWS_OPTION:
{
RemoteOWS remoteOWS = new RemoteOWSImpl();
String service = fieldConfigVisitor.getText(FieldIdEnum.REMOTE_OWS_SERVICE);
remoteOWS.setService(service);
String onlineResource = fieldConfigVisitor.getText(FieldIdEnum.REMOTE_OWS_ONLINERESOURCE);
remoteOWS.setOnlineResource(onlineResource);
userLayer.setRemoteOWS(remoteOWS);
}
break;
case INLINE_FEATURE_OPTION:
{
String inlineFeatures = fieldConfigVisitor.getText(FieldIdEnum.INLINE_FEATURE);
if ((inlineFeatures != null) && (!inlineFeatures.isEmpty())) {
InlineFeatureUtils.setInlineFeatures(userLayer, inlineFeatures);
}
}
break;
default:
break;
}
}
StyledLayer existingStyledLayer = SelectedSymbol.getInstance().getStyledLayer();
if (existingStyledLayer instanceof UserLayerImpl) {
UserLayerImpl existingUserLayer = (UserLayerImpl) existingStyledLayer;
for (Style style : existingUserLayer.userStyles()) {
userLayer.addUserStyle(style);
}
}
SelectedSymbol.getInstance().replaceStyledLayer(userLayer);
// reduces creation of datasources
if (changedField != null) {
if (changedField == FieldIdEnum.INLINE_FEATURE) {
DataSourceInterface dataSource = DataSourceFactory.getDataSource();
if (dataSource != null) {
dataSource.updateUserLayers();
}
}
}
this.fireUpdateSymbol();
}
}
use of org.geotools.styling.UserLayer in project sldeditor by robward-scisys.
the class FieldConfigInlineFeature method setTestValue.
/**
* Sets the test string value.
*
* @param fieldId the field id
* @param testValue the test value
*/
@Override
public void setTestValue(FieldIdEnum fieldId, String testValue) {
UserLayer userLayer = DefaultSymbols.createNewUserLayer();
InlineFeatureUtils.setInlineFeatures(userLayer, testValue);
populateField(userLayer);
}
use of org.geotools.styling.UserLayer in project sldeditor by robward-scisys.
the class MapRender method renderSymbol.
/**
* Render symbol.
*
* @param mapContent the map content
* @param styledLayer the styled layer
* @param style the style
*/
private void renderSymbol(MapContent mapContent, StyledLayer styledLayer, Style style) {
for (Layer layer : mapContent.layers()) {
mapContent.removeLayer(layer);
}
switch(geometryType) {
case RASTER:
{
GridReaderLayer gridLayer = new GridReaderLayer(gridCoverage, (org.geotools.styling.Style) style);
mapContent.addLayer(gridLayer);
mapContent.getViewport().setBounds(gridLayer.getBounds());
if (gridCoverage != null) {
mapPane.setDisplayArea(gridCoverage.getOriginalEnvelope());
}
}
break;
case POINT:
case LINE:
case POLYGON:
{
FeatureSource<SimpleFeatureType, SimpleFeature> tmpFeatureList = null;
if (styledLayer instanceof UserLayer) {
if (userLayerFeatureListMap != null) {
tmpFeatureList = userLayerFeatureListMap.get(styledLayer);
}
} else {
tmpFeatureList = featureList;
}
if (tmpFeatureList != null) {
mapContent.addLayer(new FeatureLayer(tmpFeatureList, (org.geotools.styling.Style) style));
try {
mapPane.setDisplayArea(tmpFeatureList.getBounds());
} catch (IOException e) {
ConsoleManager.getInstance().exception(this, e);
}
}
}
break;
default:
break;
}
wmsEnvVarValues.setMapBounds(mapBounds);
EnvironmentVariableManager.getInstance().setWMSEnvVarValues(wmsEnvVarValues);
}
use of org.geotools.styling.UserLayer in project sldeditor by robward-scisys.
the class UserLayerDetailsTest method testUserLayerDetails.
/**
* Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#UserLayerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
* Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
* Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
* Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#getFieldDataManager()}.
* Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#isDataPresent()}.
* Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#preLoadSymbol()}.
*/
@Test
public void testUserLayerDetails() {
UserLayerDetails panel = new UserLayerDetails();
panel.populate(null);
// Set up test data
StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
SelectedSymbol.getInstance().createNewSLD(sld);
UserLayer userLayer = DefaultSymbols.createNewUserLayer();
String expectedUserValue = "user layer test value";
userLayer.setName(expectedUserValue);
userLayer.addUserStyle(DefaultSymbols.createNewStyle());
sld.layers().add(userLayer);
SelectedSymbol.getInstance().addNewStyledLayer(userLayer);
SelectedSymbol.getInstance().setStyledLayer(userLayer);
panel.populate(SelectedSymbol.getInstance());
panel.dataChanged(null);
GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
assertNotNull(fieldDataManager);
panel.dataChanged(FieldIdEnum.INLINE_FEATURE);
FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
assertTrue(expectedUserValue.compareTo(nameField.getStringValue()) == 0);
assertTrue(panel.isDataPresent());
// Reset to default value
panel.preLoadSymbol();
assertTrue("".compareTo(nameField.getStringValue()) == 0);
}
Aggregations