use of org.geotools.styling.MarkImpl in project sldeditor by robward-scisys.
the class FieldConfigTTF method setValue.
/**
* Sets the value.
*
* @param symbolizerType the symbolizer type
* @param fieldConfigManager the field config manager
* @param multiOptionPanel the multi option panel
* @param graphic the graphic
* @param symbol the symbol
*/
@Override
public void setValue(Class<?> symbolizerType, GraphicPanelFieldManager fieldConfigManager, FieldConfigSymbolType multiOptionPanel, Graphic graphic, GraphicalSymbol symbol) {
if (symbol == null) {
return;
}
if (fieldConfigManager == null) {
return;
}
MarkImpl markerSymbol = (MarkImpl) symbol;
FillImpl fill = markerSymbol.getFill();
Expression expFillColour = null;
Expression expFillOpacity = null;
if (fill != null) {
expFillColour = fill.getColor();
if (!isOverallOpacity(symbolizerType)) {
expFillOpacity = fill.getOpacity();
}
}
FieldConfigBase field = fieldConfigManager.get(fillFieldConfig.getColour());
if (field != null) {
field.populate(expFillColour);
}
// Opacity
if (isOverallOpacity(symbolizerType)) {
FieldConfigBase opacity = fieldConfigManager.get(FieldIdEnum.OVERALL_OPACITY);
if (opacity != null) {
opacity.populate(graphic.getOpacity());
}
}
field = fieldConfigManager.get(fillFieldConfig.getOpacity());
if (field != null) {
field.populate(expFillOpacity);
}
Class<?> panelId = getCommonData().getPanelId();
GroupConfigInterface fillGroup = fieldConfigManager.getGroup(panelId, fillFieldConfig.getGroup());
if (fillGroup != null) {
fillGroup.enable(expFillColour != null);
}
if (ttfPanel != null) {
Expression wellKnownNameExpression = markerSymbol.getWellKnownName();
String wellKnownName = null;
if (wellKnownNameExpression != null) {
wellKnownName = wellKnownNameExpression.toString();
}
ttfPanel.populateExpression(wellKnownName);
}
if (multiOptionPanel != null) {
multiOptionPanel.setSelectedItem(TTF_SYMBOL_KEY);
}
}
use of org.geotools.styling.MarkImpl in project sldeditor by robward-scisys.
the class FieldConfigTTF method accept.
/**
* Accept.
*
* @param symbol the symbol
* @return true, if successful
*/
@Override
public boolean accept(GraphicalSymbol symbol) {
if (symbol != null) {
if (symbol instanceof MarkImpl) {
MarkImpl marker = (MarkImpl) symbol;
Expression expression = marker.getWellKnownName();
if (expression instanceof LiteralExpressionImpl) {
LiteralExpressionImpl lExpression = (LiteralExpressionImpl) expression;
Object value = lExpression.getValue();
if (value instanceof String) {
String valueString = (String) value;
if (valueString.startsWith(TTF_PREFIX)) {
return true;
}
}
}
}
}
return false;
}
use of org.geotools.styling.MarkImpl in project sldeditor by robward-scisys.
the class FieldConfigWindBarbs method accept.
/**
* Accept.
*
* @param symbol the symbol
* @return true, if successful
*/
@Override
public boolean accept(GraphicalSymbol symbol) {
if (symbol != null) {
if (symbol instanceof MarkImpl) {
MarkImpl marker = (MarkImpl) symbol;
Expression expression = marker.getWellKnownName();
if (expression instanceof LiteralExpressionImpl) {
LiteralExpressionImpl lExpression = (LiteralExpressionImpl) expression;
Object value = lExpression.getValue();
if (value instanceof String) {
String valueString = (String) value;
if (valueString.startsWith(WINDBARBS_PREFIX)) {
return true;
}
}
}
}
}
return false;
}
use of org.geotools.styling.MarkImpl in project sldeditor by robward-scisys.
the class SLDUtilsTest method testCreateSLDFromStringFile.
@Test
public void testCreateSLDFromStringFile() {
StyleWrapper wrapper = new StyleWrapper();
SLDData sldData = new SLDData(wrapper, expectedSld);
String filename = "D:/tmp/test.sld";
File file = new File(filename);
sldData.setSLDFile(file);
StyledLayerDescriptor sld = SLDUtils.createSLDFromString(null);
assertNull(sld);
sld = SLDUtils.createSLDFromString(sldData);
StyledLayer[] styledLayers = sld.getStyledLayers();
NamedLayer namedLayer = (NamedLayer) styledLayers[0];
Style[] actualStyles = namedLayer.getStyles();
PointSymbolizer pointSymbolizer = (PointSymbolizer) actualStyles[0].featureTypeStyles().get(0).rules().get(0).symbolizers().get(0);
MarkImpl mark = (MarkImpl) pointSymbolizer.getGraphic().graphicalSymbols().get(0);
assertEquals("circle", mark.getWellKnownName().toString());
// Check resource locator
try {
URL url = file.getParentFile().toURI().toURL();
String actualResourceLocator = sldData.getResourceLocator().toExternalForm();
String expectedResourcelocator = url.toExternalForm();
assertTrue(expectedResourcelocator.compareTo(actualResourceLocator) == 0);
} catch (MalformedURLException e) {
e.printStackTrace();
fail();
}
}
use of org.geotools.styling.MarkImpl in project sldeditor by robward-scisys.
the class SLDUtilsTest method testCreateSLDFromStringGeoServer.
@Test
public void testCreateSLDFromStringGeoServer() {
SLDData sldData = new SLDData(null, expectedSld);
String geoserverUrl = "http://localhost:8080/geoserver";
GeoServerConnection connectionData = new GeoServerConnection();
try {
connectionData.setUrl(new URL(geoserverUrl));
} catch (MalformedURLException e) {
e.printStackTrace();
}
sldData.setConnectionData(connectionData);
StyledLayerDescriptor sld = SLDUtils.createSLDFromString(null);
assertNull(sld);
sld = SLDUtils.createSLDFromString(sldData);
StyledLayer[] styledLayers = sld.getStyledLayers();
NamedLayer namedLayer = (NamedLayer) styledLayers[0];
Style[] actualStyles = namedLayer.getStyles();
PointSymbolizer pointSymbolizer = (PointSymbolizer) actualStyles[0].featureTypeStyles().get(0).rules().get(0).symbolizers().get(0);
MarkImpl mark = (MarkImpl) pointSymbolizer.getGraphic().graphicalSymbols().get(0);
assertEquals("circle", mark.getWellKnownName().toString());
// Check resource locator
geoserverUrl = geoserverUrl + "/styles/";
assertTrue(geoserverUrl.compareTo(sldData.getResourceLocator().toExternalForm()) == 0);
}
Aggregations