use of org.geotools.styling.Graphic 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.Graphic in project sldeditor by robward-scisys.
the class DefaultSymbols method createArrow.
/**
* Creates the arrow.
*
* @param angleFunction the angle function
* @param locationFunction the location function
* @param markerSymbol the marker symbol
* @param isSourceArrow the is source arrow
* @return the point symbolizer
*/
private static PointSymbolizer createArrow(FunctionName angleFunction, FunctionName locationFunction, String markerSymbol, boolean isSourceArrow) {
String name = isSourceArrow ? Localisation.getString(SLDTreeTools.class, "TreeItem.sourceArrow") : Localisation.getString(SLDTreeTools.class, "TreeItem.destArrow");
PointSymbolizer pointSymbolizer = createDefaultPointSymbolizer();
pointSymbolizer.setName(name);
Graphic graphic = pointSymbolizer.getGraphic();
graphic.setSize(ff.literal(DEFAULT_ARROW_SIZE));
List<GraphicalSymbol> graphicalSymbolList = graphic.graphicalSymbols();
MarkImpl mark = (MarkImpl) graphicalSymbolList.get(0);
Expression wellKnownName = ff.literal(markerSymbol);
mark.setWellKnownName(wellKnownName);
mark.getFill().setColor(ff.literal(DEFAULT_COLOUR));
// Arrow rotation
List<Expression> rotationArgumentList = new ArrayList<Expression>();
String geometryFieldName = "geom";
DataSourceInterface dsInfo = DataSourceFactory.getDataSource();
if (dsInfo != null) {
geometryFieldName = dsInfo.getGeometryFieldName();
}
rotationArgumentList.add(ff.property(geometryFieldName));
Expression rotation = FunctionManager.getInstance().createExpression(angleFunction, rotationArgumentList);
if (isSourceArrow) {
graphic.setRotation(ff.add(ff.literal(DEGREES_180), rotation));
} else {
graphic.setRotation(rotation);
}
AnchorPoint anchorPoint = styleFactory.anchorPoint(ff.literal(0.5), ff.literal(0.5));
graphic.setAnchorPoint(anchorPoint);
// Set location of the arrow head
List<Expression> endPointArgumentList = new ArrayList<Expression>();
endPointArgumentList.add(ff.property(geometryFieldName));
Expression geometry = FunctionManager.getInstance().createExpression(locationFunction, endPointArgumentList);
pointSymbolizer.setGeometry(geometry);
return pointSymbolizer;
}
use of org.geotools.styling.Graphic in project sldeditor by robward-scisys.
the class RuleRenderVisitor method visit.
/**
* Visit.
*
* @param rule the rule
*/
/*
* (non-Javadoc)
*
* @see org.geotools.styling.visitor.DuplicatingStyleVisitor#visit(org.geotools.styling.Rule)
*/
@SuppressWarnings("deprecation")
@Override
public void visit(Rule rule) {
Rule copy = null;
Symbolizer[] symsCopy = null;
if (!displayOverall) {
if ((symbolizerIndex >= 0) && (symbolizerIndex < rule.getSymbolizers().length)) {
symsCopy = new Symbolizer[1];
symsCopy[0] = copy(rule.getSymbolizers()[symbolizerIndex]);
}
}
// As a catch all copy everything
if (symsCopy == null) {
symsCopy = rule.getSymbolizers();
for (int i = 0; i < symsCopy.length; i++) {
symsCopy[i] = copy(symsCopy[i]);
}
}
Graphic[] legendCopy = rule.getLegendGraphic();
for (int i = 0; i < legendCopy.length; i++) {
legendCopy[i] = copy(legendCopy[i]);
}
Description descCopy = rule.getDescription();
descCopy = copy(descCopy);
copy = sf.createRule();
copy.setSymbolizers(symsCopy);
copy.setDescription(descCopy);
copy.setLegendGraphic(legendCopy);
copy.setName(rule.getName());
Filter filterCopy = null;
copy.setFilter(filterCopy);
copy.setElseFilter(rule.isElseFilter());
if (STRICT && !copy.equals(rule)) {
throw new IllegalStateException("Was unable to duplicate provided Rule:" + rule);
}
pages.push(copy);
}
use of org.geotools.styling.Graphic in project sldeditor by robward-scisys.
the class PointFillDetails method updateSymbol.
/**
* Update symbol.
*/
private void updateSymbol() {
if (!Controller.getInstance().isPopulating()) {
Symbolizer symbolizer = SelectedSymbol.getInstance().getSymbolizer();
if (symbolizer instanceof PointSymbolizer) {
PointSymbolizerImpl newPointSymbolizer = (PointSymbolizerImpl) symbolizer;
Graphic graphic = getGraphic();
newPointSymbolizer.setGraphic(graphic);
}
this.fireUpdateSymbol();
}
}
use of org.geotools.styling.Graphic 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