use of org.geotools.styling.Graphic in project sldeditor by robward-scisys.
the class RuleDetails method updateSymbol.
/**
* Update symbol.
*/
private void updateSymbol() {
if (!Controller.getInstance().isPopulating()) {
StandardData standardData = getStandardData();
double minScale = getMinimumValue(fieldConfigManager.get(FieldIdEnum.MINIMUM_SCALE));
double maxScale = getMaximumValue(fieldConfigManager.get(FieldIdEnum.MAXIMUM_SCALE));
//
// Read filter string
//
String filterText = fieldConfigVisitor.getText(FieldIdEnum.FILTER);
Filter filter = originalFilter;
if (originalFilter == null) {
try {
if (!filterText.isEmpty()) {
filter = CQL.toFilter(filterText);
}
} catch (CQLException e) {
filter = originalFilter;
ConsoleManager.getInstance().exception(this, e);
}
}
//
// Use existing symbolizers
//
org.geotools.styling.Rule existingRule = SelectedSymbol.getInstance().getRule();
if (existingRule != null) {
List<org.geotools.styling.Symbolizer> symbolizerList = existingRule.symbolizers();
org.geotools.styling.Symbolizer[] symbolizerArray = new org.geotools.styling.Symbolizer[symbolizerList.size()];
int index = 0;
for (org.geotools.styling.Symbolizer symbolizer : symbolizerList) {
symbolizerArray[index] = symbolizer;
index++;
}
//
// Legend
//
GraphicLegend existingLegend = existingRule.getLegend();
Graphic[] legendGraphics = null;
if (existingLegend != null) {
int legendGraphicCount = existingLegend.graphicalSymbols().size();
legendGraphics = new Graphic[legendGraphicCount];
index = 0;
for (GraphicalSymbol graphicalSymbol : existingLegend.graphicalSymbols()) {
legendGraphics[index] = (Graphic) graphicalSymbol;
index++;
}
} else {
legendGraphics = new Graphic[0];
}
//
// Else filter
//
boolean isElseFilter = fieldConfigVisitor.getBoolean(FieldIdEnum.ELSE_FILTER);
//
// Create new rule object
//
Rule rule = getStyleFactory().createRule(symbolizerArray, standardData.description, legendGraphics, standardData.name, filter, isElseFilter, maxScale, minScale);
SelectedSymbol.getInstance().replaceRule((org.geotools.styling.Rule) rule);
this.fireUpdateSymbol();
}
}
}
use of org.geotools.styling.Graphic 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.geotools.styling.Graphic in project sldeditor by robward-scisys.
the class SLDExternalImagesTest method createTestPoint.
/**
* Creates the test point.
*
* @param url the url
* @return the styled layer descriptor
*/
private StyledLayerDescriptor createTestPoint(URL url) {
StyleBuilder sb = new StyleBuilder();
StyleFactory styleFactory = sb.getStyleFactory();
StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
NamedLayer namedLayer = styleFactory.createNamedLayer();
sld.addStyledLayer(namedLayer);
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);
PointSymbolizer point = styleFactory.createPointSymbolizer();
rule.symbolizers().add(point);
Graphic graphic = createGraphic(url, styleFactory);
point.setGraphic(graphic);
return sld;
}
use of org.geotools.styling.Graphic in project sldeditor by robward-scisys.
the class SLDExternalImagesTest method createTestPolygon.
/**
* Creates the test polygon.
*
* @param url the url
* @return the styled layer descriptor
*/
private StyledLayerDescriptor createTestPolygon(URL url) {
StyleBuilder sb = new StyleBuilder();
StyleFactory styleFactory = sb.getStyleFactory();
StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
NamedLayer namedLayer = styleFactory.createNamedLayer();
sld.addStyledLayer(namedLayer);
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);
PolygonSymbolizer polygon = styleFactory.createPolygonSymbolizer();
rule.symbolizers().add(polygon);
Graphic graphicFill1 = createGraphic(url, styleFactory);
Graphic graphicFill2 = createGraphic(url, styleFactory);
Graphic graphicStroke = createGraphic(url, styleFactory);
Fill fill = styleFactory.createFill(null, null, null, graphicFill1);
polygon.setFill(fill);
Stroke stroke = styleFactory.createStroke(null, null, null, null, null, null, null, graphicFill2, graphicStroke);
polygon.setStroke(stroke);
return sld;
}
use of org.geotools.styling.Graphic in project sldeditor by robward-scisys.
the class SLDExternalImagesTest method createTestLine.
/**
* Creates the test line.
*
* @param url the url
* @return the styled layer descriptor
*/
private StyledLayerDescriptor createTestLine(URL url) {
StyleBuilder sb = new StyleBuilder();
StyleFactory styleFactory = sb.getStyleFactory();
StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
NamedLayer namedLayer = styleFactory.createNamedLayer();
sld.addStyledLayer(namedLayer);
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);
LineSymbolizer line = styleFactory.createLineSymbolizer();
rule.symbolizers().add(line);
Graphic graphicFill = createGraphic(url, styleFactory);
Graphic graphicStroke = createGraphic(url, styleFactory);
Stroke stroke = styleFactory.createStroke(null, null, null, null, null, null, null, graphicFill, graphicStroke);
line.setStroke(stroke);
return sld;
}
Aggregations