use of org.geotools.styling.Fill in project sldeditor by robward-scisys.
the class PolygonFillDetails method updateSymbol.
/**
* Update symbol.
*/
private void updateSymbol() {
if (!Controller.getInstance().isPopulating()) {
if (symbolizer instanceof PolygonSymbolizer) {
PolygonSymbolizerImpl newPolygonSymbolizer = (PolygonSymbolizerImpl) symbolizer;
GraphicFill graphicFill = getGraphicFill();
Fill fill = symbolTypeFactory.getFill(graphicFill, this.fieldConfigManager);
Expression expOpacity = fieldConfigVisitor.getExpression(FieldIdEnum.OVERALL_OPACITY);
// If field is not enabled it returns null
if ((fill != null) && (expOpacity != null)) {
fill.setOpacity(expOpacity);
}
newPolygonSymbolizer.setFill(fill);
if (vendorOptionFillFactory != null) {
vendorOptionFillFactory.updateSymbol(newPolygonSymbolizer);
}
}
this.fireUpdateSymbol();
}
}
use of org.geotools.styling.Fill 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.geotools.styling.Fill 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.geotools.styling.Fill in project sldeditor by robward-scisys.
the class FieldConfigTTF 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;
Expression fillColourOpacity = null;
Fill fill = getStyleFactory().fill(graphicFill, fillColour, fillColourOpacity);
return fill;
}
use of org.geotools.styling.Fill 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;
}
Aggregations