use of org.geotools.styling.LineSymbolizer in project sldeditor by robward-scisys.
the class SLDTree method populateSLD.
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.tree.UpdateTreeStructureInterface#populateSLD()
*/
@Override
public void populateSLD() {
reset();
SelectedSymbol selectedSymbol = SelectedSymbol.getInstance();
if (selectedSymbol != null) {
StyledLayerDescriptor sld = selectedSymbol.getSld();
rootNode.setUserObject(sld);
treeModel.nodeChanged(rootNode);
if (sld != null) {
List<StyledLayer> styledLayerList = sld.layers();
if (styledLayerList != null) {
for (StyledLayer styledLayer : styledLayerList) {
DefaultMutableTreeNode styledLayerTreeNode = null;
List<Style> styleList = null;
if (styledLayer instanceof NamedLayerImpl) {
NamedLayerImpl namedLayerImpl = (NamedLayerImpl) styledLayer;
styleList = namedLayerImpl.styles();
styledLayerTreeNode = addObject(rootNode, namedLayerImpl, true);
} else if (styledLayer instanceof UserLayerImpl) {
UserLayerImpl userLayerImpl = (UserLayerImpl) styledLayer;
styleList = userLayerImpl.userStyles();
styledLayerTreeNode = addObject(rootNode, userLayerImpl, true);
}
if (styleList != null) {
for (Style style : styleList) {
DefaultMutableTreeNode styleTreeNode = addObject(styledLayerTreeNode, style, true);
for (FeatureTypeStyle fts : style.featureTypeStyles()) {
DefaultMutableTreeNode ftsTreeNode = addObject(styleTreeNode, fts, true);
for (Rule rule : fts.rules()) {
DefaultMutableTreeNode ruleTreeNode = addObject(ftsTreeNode, rule, true);
for (Symbolizer symbolizer : rule.symbolizers()) {
DefaultMutableTreeNode symbolizerTreeNode = addObject(ruleTreeNode, symbolizer, true);
if ((symbolizer instanceof PointSymbolizer) || (symbolizer instanceof PolygonSymbolizer)) {
addObject(symbolizerTreeNode, SLDTreeLeafFactory.getInstance().getFill(symbolizer), true);
}
if ((symbolizer instanceof PolygonSymbolizer) || (symbolizer instanceof LineSymbolizer)) {
addObject(symbolizerTreeNode, SLDTreeLeafFactory.getInstance().getStroke(symbolizer), true);
}
if (symbolizer instanceof RasterSymbolizer) {
handleRasterSymbolizer(symbolizer, symbolizerTreeNode);
}
}
}
}
}
}
}
}
}
}
}
use of org.geotools.styling.LineSymbolizer in project sldeditor by robward-scisys.
the class SLDTree method handleRasterSymbolizer.
/**
* Handle raster symbolizer.
*
* @param symbolizer the symbolizer
* @param symbolizerTreeNode the symbolizer tree node
*/
private void handleRasterSymbolizer(Symbolizer symbolizer, DefaultMutableTreeNode symbolizerTreeNode) {
// Handle the image outline symbolizer for raster symbols
Symbolizer outlineSymbolizer = ((RasterSymbolizer) symbolizer).getImageOutline();
if (outlineSymbolizer instanceof LineSymbolizer) {
LineSymbolizer outlineLineSymbolizer = (LineSymbolizer) outlineSymbolizer;
if (outlineLineSymbolizer != null) {
DefaultMutableTreeNode symbolizerImageOutlineLineNode = addObject(symbolizerTreeNode, outlineLineSymbolizer, true);
addObject(symbolizerImageOutlineLineNode, SLDTreeLeafFactory.getInstance().getStroke(outlineLineSymbolizer), true);
}
} else if (outlineSymbolizer instanceof PolygonSymbolizer) {
PolygonSymbolizer outlinePolygonSymbolizer = (PolygonSymbolizer) outlineSymbolizer;
if (outlinePolygonSymbolizer != null) {
DefaultMutableTreeNode symbolizerImageOutlinePolygonNode = addObject(symbolizerTreeNode, outlinePolygonSymbolizer, true);
addObject(symbolizerImageOutlinePolygonNode, SLDTreeLeafFactory.getInstance().getFill(outlinePolygonSymbolizer), true);
addObject(symbolizerImageOutlinePolygonNode, SLDTreeLeafFactory.getInstance().getStroke(outlinePolygonSymbolizer), true);
}
}
}
use of org.geotools.styling.LineSymbolizer in project sldeditor by robward-scisys.
the class SLDExternalImagesTest method createTestLine.
/**
* Creates the test line.
*
* @param url the url
* @return the styled layer descriptor
*/
private StyledLayerDescriptor createTestLine(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);
LineSymbolizer line = styleFactory.createLineSymbolizer();
rule.symbolizers().add(line);
Graphic graphicFill = createGraphic(url, styleFactory);
Graphic graphicStroke = createGraphic(url, styleFactory);
Stroke stroke = styleFactory.createStroke(null, null, null, null, null, null, null, graphicFill, graphicStroke);
line.setStroke(stroke);
return sld;
}
use of org.geotools.styling.LineSymbolizer in project sldeditor by robward-scisys.
the class SelectedSymbolTest method testGetGraphic.
/**
* Test method for {@link com.sldeditor.common.data.SelectedSymbol#getGraphic()}.
*/
@Test
public void testGetGraphic() {
SelectedSymbol.destroyInstance();
SelectedSymbol instance = SelectedSymbol.getInstance();
// CHECKSTYLE:OFF
Rule rule = DefaultSymbols.createNewRule();
FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
Style style = DefaultSymbols.createNewStyle();
NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
PolygonSymbolizer symbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
// CHECKSTYLE:ON
instance.createNewSLD(sld);
instance.setSld(sld);
System.out.println("Select named layer");
instance.addNewStyledLayer(namedLayer);
instance.setStyledLayer(namedLayer);
instance.addNewStyle(style);
instance.setStyle(style);
instance.addNewFeatureTypeStyle(fts);
instance.setFeatureTypeStyle(fts);
instance.addNewRule(rule);
instance.setRule(rule);
instance.addSymbolizerToRule(symbolizer);
instance.setSymbolizer(symbolizer);
Graphic graphic = getGraphic(symbolizer);
assertNull(graphic);
Fill graphicFill = DefaultSymbols.createDefaultGraphicFill();
PolygonSymbolizer newSymbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
newSymbolizer.setFill(graphicFill);
instance.addSymbolizerToRule(newSymbolizer);
instance.setSymbolizer(newSymbolizer);
graphic = getGraphic(newSymbolizer);
assertNotNull(graphic);
assertTrue(instance.hasFill());
assertTrue(instance.hasStroke());
LineSymbolizer lineSymbolizer = DefaultSymbols.createDefaultLineSymbolizer();
instance.addSymbolizerToRule(lineSymbolizer);
instance.setSymbolizer(lineSymbolizer);
graphic = getGraphic(lineSymbolizer);
assertNull(graphic);
assertFalse(instance.hasFill());
assertTrue(instance.hasStroke());
PointSymbolizer pointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer();
instance.addSymbolizerToRule(pointSymbolizer);
instance.setSymbolizer(pointSymbolizer);
graphic = getGraphic(pointSymbolizer);
assertNotNull(graphic);
assertTrue(instance.hasFill());
assertFalse(instance.hasStroke());
}
use of org.geotools.styling.LineSymbolizer in project sldeditor by robward-scisys.
the class SLDTreeLeafFactoryTest method testUpdateStroke.
/**
* Test method for
* {@link com.sldeditor.common.tree.leaf.SLDTreeLeafFactory#updateStroke(boolean, org.opengis.style.Symbolizer)}.
*/
@Test
public void testUpdateStroke() {
assertNull(SLDTreeLeafFactory.getInstance().updateStroke(true, null));
PolygonSymbolizer polygonSymbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
assertEquals(SLDTreeLeafFactory.getInstance().updateStroke(false, polygonSymbolizer), styleFactory.getDefaultStroke());
assertTrue(SLDTreeLeafFactory.getInstance().updateStroke(true, polygonSymbolizer) != null);
PointSymbolizer pointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer();
assertEquals(SLDTreeLeafFactory.getInstance().updateStroke(false, pointSymbolizer), styleFactory.getDefaultStroke());
assertTrue(SLDTreeLeafFactory.getInstance().updateStroke(true, pointSymbolizer) != null);
LineSymbolizer lineSymbolizer = DefaultSymbols.createDefaultLineSymbolizer();
assertEquals(SLDTreeLeafFactory.getInstance().updateStroke(false, lineSymbolizer), styleFactory.getDefaultStroke());
assertEquals(SLDTreeLeafFactory.getInstance().updateStroke(true, lineSymbolizer), styleFactory.getDefaultStroke());
TextSymbolizer textSymbolizer = DefaultSymbols.createDefaultTextSymbolizer();
assertEquals(SLDTreeLeafFactory.getInstance().updateStroke(false, textSymbolizer), styleFactory.getDefaultStroke());
assertEquals(SLDTreeLeafFactory.getInstance().updateStroke(true, textSymbolizer), styleFactory.getDefaultStroke());
}
Aggregations