use of org.opengis.style.GraphicalSymbol in project sldeditor by robward-scisys.
the class VOGeoServerTextSymbolizer2 method updateSymbol.
/**
* Update symbol.
*
* @param textSymbolizer the text symbolizer
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.detail.vendor.geoserver.VendorOptionInterface#updateSymbol(org.geotools.styling.TextSymbolizer)
*/
@Override
public void updateSymbol(TextSymbolizer textSymbolizer) {
GroupConfigInterface fillGroup = getGroup(GroupIdEnum.VO_TEXTSYMBOLIZER_2_FILL);
GroupConfigInterface strokeGroup = getGroup(GroupIdEnum.VO_TEXTSYMBOLIZER_2_STROKE);
GroupConfigInterface group = null;
if (textSymbolizer instanceof TextSymbolizer2) {
TextSymbolizer2 textSymbol2 = (TextSymbolizer2) textSymbolizer;
Expression featureDescription = fieldConfigVisitor.getExpression(FieldIdEnum.VO_TEXTSYMBOLIZER_2_FEATURE_DESCRIPTION);
if (!featureDescription.toString().isEmpty()) {
textSymbol2.setFeatureDescription(featureDescription);
}
Expression snippet = fieldConfigVisitor.getExpression(FieldIdEnum.VO_TEXTSYMBOLIZER_2_SNIPPET);
if (!snippet.toString().isEmpty()) {
textSymbol2.setSnippet(snippet);
}
// Extract OtherText
OtherText otherText = null;
group = getGroup(GroupIdEnum.VO_TEXTSYMBOLIZER_2_OTHERTEXT);
if (group != null) {
if (group.isPanelEnabled()) {
String target = fieldConfigVisitor.getText(FieldIdEnum.VO_TEXTSYMBOLIZER_2_OTHERTEXT_TARGET);
Expression text = fieldConfigVisitor.getExpression(FieldIdEnum.VO_TEXTSYMBOLIZER_2_OTHERTEXT_TEXT);
if (!target.isEmpty() && !text.toString().isEmpty()) {
otherText = new OtherTextImpl();
otherText.setTarget(target);
otherText.setText(text);
}
}
}
textSymbol2.setOtherText(otherText);
// Graphic
Graphic graphic = null;
group = getGroup(GroupIdEnum.VO_TEXTSYMBOLIZER_2_GRAPHIC);
if (group.isPanelEnabled()) {
Expression symbolType = fieldConfigVisitor.getExpression(FieldIdEnum.VO_TEXTSYMBOLIZER_2_SYMBOL_TYPE);
boolean hasFill = (fillGroup == null) ? false : fillGroup.isPanelEnabled();
boolean hasStroke = (strokeGroup == null) ? false : strokeGroup.isPanelEnabled();
Expression size = fieldConfigVisitor.getExpression(FieldIdEnum.VO_TEXTSYMBOLIZER_2_SIZE);
Expression rotation = fieldConfigVisitor.getExpression(FieldIdEnum.VO_TEXTSYMBOLIZER_2_ANGLE);
List<GraphicalSymbol> symbols = symbolTypeFactory.getValue(fieldConfigManager, symbolType, hasFill, hasStroke, selectedFillPanelId);
AnchorPoint anchor = null;
Displacement displacement = null;
graphic = getStyleFactory().graphic(symbols, null, size, rotation, anchor, displacement);
if (!symbols.isEmpty()) {
boolean overallOpacity = (symbols.get(0) instanceof ExternalGraphic);
if (overallOpacity) {
Expression opacity = fieldConfigVisitor.getExpression(FieldIdEnum.VO_TEXTSYMBOLIZER_2_OVERALL_OPACITY);
graphic.setOpacity(opacity);
}
}
}
textSymbol2.setGraphic(graphic);
}
}
use of org.opengis.style.GraphicalSymbol in project sldeditor by robward-scisys.
the class SLDExternalImagesTest method createGraphic.
/**
* Creates the graphic.
*
* @param url the url
* @param styleFactory the style factory
* @return the graphic
*/
private Graphic createGraphic(URL url, StyleFactory styleFactory) {
List<GraphicalSymbol> symbolList = new ArrayList<GraphicalSymbol>();
ExternalGraphic externalGraphic = styleFactory.createExternalGraphic(url, "image/png");
symbolList.add(externalGraphic);
Graphic graphicFill = styleFactory.graphicFill(symbolList, null, null, null, null, null);
return graphicFill;
}
use of org.opengis.style.GraphicalSymbol in project polymap4-core by Polymap4.
the class StyleModelTest method testSimplePoint.
@Test
public void testSimplePoint() throws Exception {
FeatureStyle fs = repo.newFeatureStyle();
PointStyle style = fs.members().createElement(PointStyle.defaults);
assertTrue(style.visibleIf.get() instanceof ConstantFilter);
style.diameter.createValue(ConstantNumber.defaults(100.0));
style.rotation.createValue(ConstantNumber.defaults(45.0));
style.fill.get().color.createValue(ConstantColor.defaults(0, 0, 0));
style.fill.get().opacity.createValue(ConstantNumber.defaults(0.0));
style.stroke.get().color.createValue(ConstantColor.defaults(100, 100, 100));
style.stroke.get().width.createValue(ConstantNumber.defaults(5.0));
style.stroke.get().opacity.createValue(ConstantNumber.defaults(0.5));
fs.store();
log.info("SLD: " + repo.serializedFeatureStyle(fs.id(), String.class));
Style result = repo.serializedFeatureStyle(fs.id(), Style.class).get();
assertEquals(1, result.featureTypeStyles().size());
FeatureTypeStyle fts = result.featureTypeStyles().get(0);
assertEquals(1, fts.rules().size());
Rule rule = fts.rules().get(0);
assertEquals(0, rule.getMinScaleDenominator(), 0);
assertEquals(Double.POSITIVE_INFINITY, rule.getMaxScaleDenominator(), 0);
assertEquals(1, rule.symbolizers().size());
assertNull(rule.getFilter());
PointSymbolizer sym = (PointSymbolizer) rule.symbolizers().get(0);
assertEqualsLiteral(100.0, sym.getGraphic().getSize());
assertEqualsLiteral(45.0, sym.getGraphic().getRotation());
assertEquals(1, sym.getGraphic().graphicalSymbols().size());
GraphicalSymbol symbol = sym.getGraphic().graphicalSymbols().get(0);
Mark mark = (Mark) symbol;
assertEqualsLiteral(0.0, mark.getFill().getOpacity());
assertEqualsLiteral(0.5, mark.getStroke().getOpacity());
assertEqualsLiteral(5.0, mark.getStroke().getWidth());
}
use of org.opengis.style.GraphicalSymbol in project sldeditor by robward-scisys.
the class SelectedSymbolTest method testGetSymbolList.
/**
* Test method for
* {@link com.sldeditor.common.data.SelectedSymbol#getSymbolList(org.opengis.style.GraphicalSymbol)}.
*/
@Test
public void testGetSymbolList() {
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
Stroke stroke = null;
Fill fill = styleFactory.createFill(ff.literal(DefaultSymbols.defaultColour()));
GraphicalSymbol symbolToAdd = styleFactory.mark(ff.literal("circle"), fill, stroke);
List<GraphicalSymbol> symbolList = SelectedSymbol.getInstance().getSymbolList(symbolToAdd);
assertEquals(1, symbolList.size());
assertEquals(symbolToAdd, symbolList.get(0));
}
use of org.opengis.style.GraphicalSymbol in project sldeditor by robward-scisys.
the class SLDTreeLeafPointTest method testGetFill.
/**
* Test method for
* {@link com.sldeditor.common.tree.leaf.SLDTreeLeafPoint#getFill(org.opengis.style.Symbolizer)}.
*/
@Test
public void testGetFill() {
SLDTreeLeafPoint leaf = new SLDTreeLeafPoint();
assertNull(leaf.getFill(null));
assertNull(leaf.getFill(DefaultSymbols.createDefaultPolygonSymbolizer()));
PointSymbolizer pointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer();
Fill expectedFill = null;
Graphic graphic = pointSymbolizer.getGraphic();
if (graphic != null) {
List<GraphicalSymbol> symbolList = graphic.graphicalSymbols();
if ((symbolList != null) && !symbolList.isEmpty()) {
GraphicalSymbol obj = symbolList.get(0);
if (obj != null) {
if (obj instanceof MarkImpl) {
MarkImpl mark = (MarkImpl) obj;
expectedFill = mark.getFill();
}
}
}
}
assertEquals(expectedFill, leaf.getFill(pointSymbolizer));
}
Aggregations