use of org.geotools.styling.PolygonSymbolizer in project sldeditor by robward-scisys.
the class VOGeoServerTextSymbolizer2Test method testVOGeoServerTextSymbolizer2.
/**
* Test method for
* {@link com.sldeditor.ui.detail.vendor.geoserver.text.VOGeoServerTextSymbolizer2#VOGeoServerTextSymbolizer2(java.lang.Class, com.sldeditor.filter.v2.function.FunctionNameInterface)}.
*/
@Test
public void testVOGeoServerTextSymbolizer2() {
TextSymbolizerDetails panel = new TextSymbolizerDetails();
TextSymbolizer2 textSymbolizer = null;
VOGeoServerTextSymbolizer2 testObj = new VOGeoServerTextSymbolizer2(panel.getClass());
testObj.setParentPanel(panel);
testObj.populate(textSymbolizer);
testObj.updateSymbol(textSymbolizer);
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
textSymbolizer = (TextSymbolizer2) styleFactory.createTextSymbolizer();
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
Literal featureDescription = ff.literal("feature description");
textSymbolizer.setFeatureDescription(featureDescription);
OtherText otherText = new OtherTextImpl();
otherText.setTarget("target");
Literal otherTextExpression = ff.literal("other text");
otherText.setText(otherTextExpression);
textSymbolizer.setOtherText(otherText);
Literal snippet = ff.literal("snippet");
textSymbolizer.setSnippet(snippet);
// Try with marker symbol
Graphic graphic = styleFactory.createDefaultGraphic();
graphic.graphicalSymbols().add(styleFactory.createMark());
textSymbolizer.setGraphic(graphic);
Controller.getInstance().setPopulating(true);
testObj.populate(textSymbolizer);
Controller.getInstance().setPopulating(false);
testObj.updateSymbol(textSymbolizer);
// Try with external graphic
graphic = styleFactory.createDefaultGraphic();
try {
graphic.graphicalSymbols().add(styleFactory.createExternalGraphic(new File("test.png").toURI().toURL(), "png"));
} catch (MalformedURLException e) {
e.printStackTrace();
}
textSymbolizer.setGraphic(graphic);
Controller.getInstance().setPopulating(true);
testObj.populate(textSymbolizer);
Controller.getInstance().setPopulating(false);
testObj.updateSymbol(textSymbolizer);
// Find minimum version with textSymbolizer2 values set
List<VendorOptionPresent> vendorOptionsPresentList = new ArrayList<VendorOptionPresent>();
testObj.getMinimumVersion(null, textSymbolizer, vendorOptionsPresentList);
assertEquals(1, vendorOptionsPresentList.size());
// Find minimum version with no textSymbolizer2 values set
vendorOptionsPresentList.clear();
testObj.getMinimumVersion(null, styleFactory.createTextSymbolizer(), vendorOptionsPresentList);
assertEquals(0, vendorOptionsPresentList.size());
// Get the code coverage values up
testObj.populate(SelectedSymbol.getInstance());
PolygonSymbolizer polygon = null;
testObj.populate(polygon);
testObj.updateSymbol(polygon);
RasterSymbolizer raster = null;
testObj.populate(raster);
testObj.updateSymbol(raster);
testObj.preLoadSymbol();
assertTrue(testObj.isDataPresent());
}
use of org.geotools.styling.PolygonSymbolizer 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.PolygonSymbolizer 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.PolygonSymbolizer 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.PolygonSymbolizer in project sldeditor by robward-scisys.
the class VOGeoServerRandomFill method getMinimumVersion.
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.iface.PopulateDetailsInterface#getMinimumVersion(java.lang.Object,
* java.util.List)
*/
@Override
public void getMinimumVersion(Object parentObj, Object sldObj, List<VendorOptionPresent> vendorOptionsPresentList) {
if (parentObj instanceof PolygonSymbolizer) {
PolygonSymbolizer polygon = (PolygonSymbolizer) parentObj;
Map<String, String> options = polygon.getOptions();
for (FieldIdEnum key : fieldMap.keySet()) {
String vendorOptionAttributeKey = fieldMap.get(key);
if (options.containsKey(vendorOptionAttributeKey)) {
VendorOptionPresent voPresent = new VendorOptionPresent(sldObj, getVendorOptionInfo());
vendorOptionsPresentList.add(voPresent);
}
}
}
}
Aggregations