use of org.geotools.styling.PolygonSymbolizerImpl 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();
}
use of org.geotools.styling.PolygonSymbolizerImpl 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.PolygonSymbolizerImpl in project sldeditor by robward-scisys.
the class SelectedSymbolTest method getGraphic.
/**
* Gets the graphic.
*
* @param symbolizer the symbolizer
* @return the graphic
*/
private Graphic getGraphic(Symbolizer symbolizer) {
Graphic graphic = null;
if (symbolizer instanceof PointSymbolizerImpl) {
PointSymbolizer pointSymbolizer = (PointSymbolizer) symbolizer;
graphic = pointSymbolizer.getGraphic();
} else if (symbolizer instanceof PolygonSymbolizerImpl) {
PolygonSymbolizer polygonSymbolizer = (PolygonSymbolizer) symbolizer;
if (polygonSymbolizer != null) {
Fill fill = polygonSymbolizer.getFill();
if (fill != null) {
graphic = fill.getGraphicFill();
}
}
}
return graphic;
}
use of org.geotools.styling.PolygonSymbolizerImpl in project sldeditor by robward-scisys.
the class SymbolizerDetailsPanel method getMinimumVersion.
/**
* Gets the minimum version vendor option present in the SLD.
*
* @param parentObj the parent obj
* @param sldObj the sld obj
* @param vendorOptionsPresentList the vendor options present list
*/
public void getMinimumVersion(Object parentObj, Object sldObj, List<VendorOptionPresent> vendorOptionsPresentList) {
Class<?> parentClass = null;
Class<?> classSelected = sldObj.getClass();
if (sldObj instanceof StyledLayerDescriptor) {
// No parent
} else if (sldObj instanceof StyledLayer) {
parentClass = StyledLayerDescriptor.class;
} else if (sldObj instanceof Style) {
parentClass = StyledLayer.class;
} else if (sldObj instanceof FeatureTypeStyle) {
parentClass = Style.class;
} else if (sldObj instanceof Rule) {
parentClass = FeatureTypeStyle.class;
} else if (sldObj instanceof Symbolizer) {
parentClass = Rule.class;
}
internal_getMinimumVersion(parentObj, sldObj, vendorOptionsPresentList, parentClass, classSelected);
if (sldObj instanceof PointSymbolizerImpl) {
PointSymbolizerImpl pointSymbolizer = (PointSymbolizerImpl) sldObj;
parentClass = PointSymbolizerImpl.class;
classSelected = FillImpl.class;
internal_getMinimumVersion(pointSymbolizer, pointSymbolizer.getGraphic(), vendorOptionsPresentList, parentClass, classSelected);
} else if (sldObj instanceof LineSymbolizerImpl) {
LineSymbolizerImpl lineSymbolizer = (LineSymbolizerImpl) sldObj;
parentClass = LineSymbolizerImpl.class;
classSelected = StrokeImpl.class;
internal_getMinimumVersion(lineSymbolizer, lineSymbolizer.getStroke(), vendorOptionsPresentList, parentClass, classSelected);
} else if (sldObj instanceof PolygonSymbolizerImpl) {
PolygonSymbolizerImpl polygonSymbolizer = (PolygonSymbolizerImpl) sldObj;
parentClass = PolygonSymbolizerImpl.class;
classSelected = FillImpl.class;
internal_getMinimumVersion(polygonSymbolizer, polygonSymbolizer.getFill(), vendorOptionsPresentList, parentClass, classSelected);
classSelected = StrokeImpl.class;
internal_getMinimumVersion(polygonSymbolizer, polygonSymbolizer.getStroke(), vendorOptionsPresentList, parentClass, classSelected);
} else if (sldObj instanceof TextSymbolizerImpl) {
TextSymbolizerImpl textSymbolizer = (TextSymbolizerImpl) sldObj;
parentClass = Rule.class;
classSelected = TextSymbolizerImpl.class;
internal_getMinimumVersion(parentObj, textSymbolizer, vendorOptionsPresentList, parentClass, classSelected);
} else if (sldObj instanceof RasterSymbolizerImpl) {
RasterSymbolizerImpl rasterSymbolizer = (RasterSymbolizerImpl) sldObj;
parentClass = Rule.class;
classSelected = RasterSymbolizerImpl.class;
internal_getMinimumVersion(parentObj, rasterSymbolizer, vendorOptionsPresentList, parentClass, classSelected);
}
}
Aggregations