use of org.geotools.styling.Fill in project sldeditor by robward-scisys.
the class SimpleFillSymbol method convertToFill.
/* (non-Javadoc)
* @see com.sldeditor.convert.esri.symbols.EsriFillSymbolInterface#convertToFill(java.lang.String, com.google.gson.JsonElement, int)
*/
@Override
public List<Symbolizer> convertToFill(String layerName, JsonElement element, int transparency) {
if (element == null)
return null;
JsonObject obj = element.getAsJsonObject();
List<Symbolizer> symbolizerList = new ArrayList<Symbolizer>();
Expression fillColour = getColour(obj.get(SimpleFillSymbolKeys.FILL_COLOUR));
Expression transparencyExpression = getTransparency(transparency);
Fill fill = null;
if (fillColour != null) {
fill = styleFactory.createFill(fillColour, transparencyExpression);
}
PolygonSymbolizer polygon = styleFactory.createPolygonSymbolizer();
polygon.setStroke(null);
polygon.setFill(fill);
symbolizerList.add(polygon);
return symbolizerList;
}
use of org.geotools.styling.Fill in project sldeditor by robward-scisys.
the class SimpleMarkerSymbol method convert.
/**
* Convert.
*
* @param element the element
* @return the graphic marker list
*/
@Override
public List<Graphic> convert(JsonElement element) {
if (element == null)
return null;
JsonObject obj = element.getAsJsonObject();
List<Graphic> markList = new ArrayList<Graphic>();
double angle = getDouble(obj, CommonSymbolKeys.ANGLE);
double outlineSize = getDouble(obj, SimpleMarkerSymbolKeys.OUTLINE_SIZE);
double size = getDouble(obj, CommonSymbolKeys.SIZE);
int style = getInt(obj, CommonSymbolKeys.STYLE);
double xOffset = getDouble(obj, CommonSymbolKeys.X_OFFSET);
double yOffset = getDouble(obj, CommonSymbolKeys.Y_OFFSET);
Expression markerColour = getColour(obj.get(CommonSymbolKeys.COLOUR));
Expression outlineColour = getColour(obj.get(SimpleMarkerSymbolKeys.OUTLINE_COLOUR));
Expression wellKnownName = ff.literal(styleMap.get(style));
Stroke stroke = null;
if (outlineSize > 0.0) {
stroke = styleFactory.createStroke(outlineColour, ff.literal(outlineSize));
}
Fill fill = styleFactory.createFill(markerColour);
Mark mark = styleFactory.createMark(wellKnownName, stroke, fill, ff.literal(size), ff.literal(angle));
Expression expressionOpacity = null;
ExternalGraphic[] externalGraphics = null;
Symbol[] symbols = null;
Mark[] marks = new Mark[1];
marks[0] = mark;
Graphic graphic = styleFactory.createGraphic(externalGraphics, marks, symbols, expressionOpacity, ff.literal(size), ff.literal(angle));
// Set offset
if ((xOffset > 0.0) && (yOffset > 0.0)) {
Displacement displacement = styleFactory.displacement(ff.literal(xOffset), ff.literal(yOffset));
graphic.setDisplacement(displacement);
}
markList.add(graphic);
return markList;
}
use of org.geotools.styling.Fill in project sldeditor by robward-scisys.
the class DefaultSymbols method createDefaultGraphicFill.
/**
* Creates a default graphic fill.
*
* @return the fill
*/
public static Fill createDefaultGraphicFill() {
Graphic graphicFill = styleFactory.createDefaultGraphic();
Expression colour = ff.literal(DEFAULT_FILL_COLOUR);
Expression backgroundColour = null;
Expression opacity = ff.literal(1.0);
Fill fill = styleFactory.createFill(colour, backgroundColour, opacity, graphicFill);
return fill;
}
use of org.geotools.styling.Fill in project sldeditor by robward-scisys.
the class DefaultSymbols method createDefaultPolygonSymbolizer.
/**
* Creates the default polygon symbolizer.
*
* @return the polygon symbolizer
*/
public static PolygonSymbolizer createDefaultPolygonSymbolizer() {
Stroke stroke = styleFactory.createStroke(ff.literal(DEFAULT_LINE_COLOUR), ff.literal(2));
Fill fill = styleFactory.getDefaultFill();
PolygonSymbolizer polygonSymbolizer = styleFactory.createPolygonSymbolizer();
polygonSymbolizer.setStroke(stroke);
polygonSymbolizer.setFill(fill);
return polygonSymbolizer;
}
use of org.geotools.styling.Fill in project sldeditor by robward-scisys.
the class PolygonFillDetails method populate.
/**
* Populate.
*
* @param selectedSymbol the selected symbol
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.iface.PopulateDetailsInterface#populate(com.sldeditor.ui.detail.SelectedSymbol)
*/
@Override
public void populate(SelectedSymbol selectedSymbol) {
Expression expSize = null;
Expression expRotation = null;
Expression expAnchorPointX = null;
Expression expAnchorPointY = null;
Expression expDisplacementX = null;
Expression expDisplacementY = null;
Expression expFillColour = null;
Expression expGap = null;
Expression expInitialGap = null;
Fill fill = null;
Expression expOpacity = null;
symbolizer = null;
if (selectedSymbol != null) {
symbolizer = selectedSymbol.getSymbolizer();
Graphic graphic = null;
if (symbolizer instanceof PointSymbolizerImpl) {
PointSymbolizer pointSymbolizer = (PointSymbolizer) symbolizer;
graphic = pointSymbolizer.getGraphic();
if (graphic != null) {
List<GraphicalSymbol> graphicSymbolList = graphic.graphicalSymbols();
if (!graphicSymbolList.isEmpty()) {
GraphicalSymbol graphicalSymbol = graphicSymbolList.get(0);
if (graphicalSymbol instanceof MarkImpl) {
MarkImpl mark = (MarkImpl) graphicalSymbol;
fill = mark.getFill();
if (fill != null) {
expOpacity = fill.getOpacity();
}
}
}
}
} else if (symbolizer instanceof PolygonSymbolizerImpl) {
PolygonSymbolizer polygonSymbolizer = (PolygonSymbolizer) symbolizer;
if (polygonSymbolizer != null) {
fill = polygonSymbolizer.getFill();
if (fill != null) {
expOpacity = fill.getOpacity();
graphic = fill.getGraphicFill();
}
}
}
if (graphic == null) {
if (fill != null) {
expFillColour = fill.getColor();
}
if (fill == null) {
symbolTypeFactory.setNoFill(this.fieldConfigManager);
} else {
symbolTypeFactory.setSolidFill(this.fieldConfigManager, expFillColour, expOpacity);
}
} else {
expSize = graphic.getSize();
expRotation = graphic.getRotation();
// Anchor point
AnchorPoint anchorPoint = graphic.getAnchorPoint();
if (anchorPoint != null) {
expAnchorPointX = anchorPoint.getAnchorPointX();
expAnchorPointY = anchorPoint.getAnchorPointY();
} else {
expAnchorPointX = defaultAnchorPoint.getAnchorPointX();
expAnchorPointY = defaultAnchorPoint.getAnchorPointY();
}
// Offset
Displacement displacement = graphic.getDisplacement();
if (displacement != null) {
expDisplacementX = displacement.getDisplacementX();
expDisplacementY = displacement.getDisplacementY();
} else {
expDisplacementX = defaultDisplacement.getDisplacementX();
expDisplacementY = defaultDisplacement.getDisplacementY();
}
expGap = graphic.getGap();
expInitialGap = graphic.getInitialGap();
List<GraphicalSymbol> graphicalSymbolList = graphic.graphicalSymbols();
if (!graphicalSymbolList.isEmpty()) {
GraphicalSymbol symbol = graphicalSymbolList.get(0);
symbolTypeFactory.setValue(PolygonSymbolizer.class, this.fieldConfigManager, graphic, symbol);
}
}
}
fieldConfigVisitor.populateField(FieldIdEnum.SIZE, expSize);
fieldConfigVisitor.populateField(FieldIdEnum.ANGLE, expRotation);
fieldConfigVisitor.populateField(FieldIdEnum.ANCHOR_POINT_H, expAnchorPointX);
fieldConfigVisitor.populateField(FieldIdEnum.ANCHOR_POINT_V, expAnchorPointY);
fieldConfigVisitor.populateField(FieldIdEnum.DISPLACEMENT_X, expDisplacementX);
fieldConfigVisitor.populateField(FieldIdEnum.DISPLACEMENT_Y, expDisplacementY);
fieldConfigVisitor.populateField(FieldIdEnum.GAP, expGap);
fieldConfigVisitor.populateField(FieldIdEnum.INITIAL_GAP, expInitialGap);
fieldConfigVisitor.populateField(FieldIdEnum.OVERALL_OPACITY, expOpacity);
if (vendorOptionFillFactory != null) {
if (symbolizer instanceof PolygonSymbolizer) {
vendorOptionFillFactory.populate((PolygonSymbolizer) symbolizer);
}
}
updateSymbol();
}
Aggregations