use of org.opengis.style.GraphicalSymbol in project sldeditor by robward-scisys.
the class PolygonFillDetails method getGraphicFill.
/**
* Gets the graphic fill.
*
* @return the graphic fill
*/
private GraphicFill getGraphicFill() {
GroupConfigInterface fillGroup = getGroup(GroupIdEnum.FILL);
boolean hasFill = fillGroup.isPanelEnabled();
GroupConfigInterface strokeGroup = getGroup(GroupIdEnum.STROKE);
boolean hasStroke = (strokeGroup == null) ? false : strokeGroup.isPanelEnabled();
Expression opacity = null;
Expression size = fieldConfigVisitor.getExpression(FieldIdEnum.SIZE);
Expression rotation = fieldConfigVisitor.getExpression(FieldIdEnum.ANGLE);
Expression symbolType = fieldConfigVisitor.getExpression(FieldIdEnum.SYMBOL_TYPE);
//
// Anchor point
//
AnchorPoint anchorPoint = null;
GroupConfigInterface anchorPointPanel = getGroup(GroupIdEnum.ANCHORPOINT);
if (anchorPointPanel.isPanelEnabled()) {
anchorPoint = (AnchorPoint) getStyleFactory().anchorPoint(fieldConfigVisitor.getExpression(FieldIdEnum.ANCHOR_POINT_H), fieldConfigVisitor.getExpression(FieldIdEnum.ANCHOR_POINT_V));
// default so it doesn't appear in the SLD
if (DetailsUtilities.isSame(defaultAnchorPoint, anchorPoint)) {
anchorPoint = null;
}
}
//
// Displacement
//
Displacement displacement = null;
GroupConfigInterface displacementPanel = getGroup(GroupIdEnum.DISPLACEMENT);
if (displacementPanel.isPanelEnabled()) {
displacement = getStyleFactory().displacement(fieldConfigVisitor.getExpression(FieldIdEnum.DISPLACEMENT_X), fieldConfigVisitor.getExpression(FieldIdEnum.DISPLACEMENT_Y));
// it doesn't appear in the SLD
if (DetailsUtilities.isSame(defaultDisplacement, displacement)) {
displacement = null;
}
}
List<GraphicalSymbol> symbols = symbolTypeFactory.getValue(this.fieldConfigManager, symbolType, hasFill, hasStroke, selectedFillPanelId);
GraphicFill graphicFill = getStyleFactory().graphicFill(symbols, opacity, size, rotation, anchorPoint, displacement);
return graphicFill;
}
use of org.opengis.style.GraphicalSymbol 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.opengis.style.GraphicalSymbol in project sldeditor by robward-scisys.
the class FieldConfigWKT method getValue.
/**
* Gets the value.
*
* @param fieldConfigManager the field config manager
* @param symbolType the symbol type
* @param fillEnabled the fill enabled
* @param strokeEnabled the stroke enabled
* @return the value
*/
@Override
public List<GraphicalSymbol> getValue(GraphicPanelFieldManager fieldConfigManager, Expression symbolType, boolean fillEnabled, boolean strokeEnabled) {
List<GraphicalSymbol> symbolList = new ArrayList<GraphicalSymbol>();
if (fieldConfigManager != null) {
Expression wellKnownName = null;
if (getConfigField() != null) {
wellKnownName = getConfigField().getExpression();
if (wellKnownName != null) {
Stroke stroke = null;
Fill fill = null;
// Stroke colour
FieldConfigBase field = null;
if (strokeEnabled) {
Expression expStrokeColour = null;
Expression expStrokeColourOpacity = null;
field = fieldConfigManager.get(this.strokeFieldConfig.getColour());
if (field != null) {
if (field instanceof FieldConfigColour) {
FieldConfigColour colourField = (FieldConfigColour) field;
expStrokeColour = colourField.getColourExpression();
}
}
// Stroke width
Expression strokeWidth = null;
field = fieldConfigManager.get(this.strokeFieldConfig.getWidth());
if (field != null) {
strokeWidth = field.getExpression();
}
// Opacity
field = fieldConfigManager.get(this.strokeFieldConfig.getOpacity());
if (field != null) {
expStrokeColourOpacity = field.getExpression();
}
stroke = getStyleFactory().createStroke(expStrokeColour, strokeWidth, expStrokeColourOpacity);
}
// Fill colour
if (fillEnabled) {
Expression expFillColour = null;
Expression expFillColourOpacity = null;
field = fieldConfigManager.get(this.fillFieldConfig.getColour());
if (field != null) {
if (field instanceof FieldConfigColour) {
FieldConfigColour colourField = (FieldConfigColour) field;
expFillColour = colourField.getColourExpression();
}
}
// Opacity
field = fieldConfigManager.get(this.fillFieldConfig.getOpacity());
if (field != null) {
expFillColourOpacity = field.getExpression();
}
fill = getStyleFactory().createFill(expFillColour, expFillColourOpacity);
}
Expression symbolSize = null;
field = fieldConfigManager.get(FieldIdEnum.STROKE_SYMBOL_SIZE);
if (field != null) {
symbolSize = field.getExpression();
}
Expression rotation = null;
Mark mark = getStyleFactory().createMark(wellKnownName, stroke, fill, symbolSize, rotation);
symbolList.add(mark);
}
}
}
return symbolList;
}
use of org.opengis.style.GraphicalSymbol in project sldeditor by robward-scisys.
the class FieldConfigMarker method getFill.
/**
* Gets the fill.
*
* @param graphicFill the graphic fill
* @param fieldConfigManager the field config manager
* @return the fill
*/
@Override
public Fill getFill(GraphicFill graphicFill, GraphicPanelFieldManager fieldConfigManager) {
if (fieldConfigManager == null) {
return null;
}
Expression fillColour = null;
FieldConfigBase field = fieldConfigManager.get(fillFieldConfig.getColour());
if (field != null) {
if ((field instanceof FieldConfigColour) && field.isEnabled()) {
fillColour = ((FieldConfigColour) field).getColourExpression();
}
}
Expression fillColourOpacity = null;
field = fieldConfigManager.get(fillFieldConfig.getOpacity());
if (field != null) {
fillColourOpacity = field.getExpression();
}
GraphicFill _graphicFill = null;
Expression _fillColour = fillColour;
Expression _fillColourOpacity = fillColourOpacity;
if (graphicFill != null) {
List<GraphicalSymbol> symbolList = graphicFill.graphicalSymbols();
if ((symbolList != null) && (!symbolList.isEmpty())) {
GraphicalSymbol symbol = symbolList.get(0);
Mark mark = (Mark) symbol;
if (mark.getWellKnownName() != null) {
_graphicFill = graphicFill;
_fillColour = null;
_fillColourOpacity = null;
}
}
}
Fill fill = getStyleFactory().fill(_graphicFill, _fillColour, _fillColourOpacity);
return fill;
}
use of org.opengis.style.GraphicalSymbol in project sldeditor by robward-scisys.
the class FieldConfigFilename method getValue.
/**
* Gets the value.
*
* @param fieldConfigManager the field config manager
* @param symbolType the symbol type
* @param fillEnabled the fill enabled
* @param strokeEnabled the stroke enabled
* @return the value
*/
@Override
public List<GraphicalSymbol> getValue(GraphicPanelFieldManager fieldConfigManager, Expression symbolType, boolean fillEnabled, boolean strokeEnabled) {
List<GraphicalSymbol> symbols = null;
if (externalGraphicPanel != null) {
ExternalGraphic extGraphic = externalGraphicPanel.getSymbol();
symbols = SelectedSymbol.getInstance().getSymbolList(extGraphic);
}
return symbols;
}
Aggregations