use of org.geotools.styling.PointSymbolizer in project sldeditor by robward-scisys.
the class SLDTreeTools method addNewMarker.
/**
* Adds the new marker symbolizer.
*/
public void addNewMarker() {
if (symbolTree == null) {
return;
}
// Store current state of the SLD before the add
Object oldValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
PointSymbolizer newPointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer();
DefaultMutableTreeNode ruleNode = getRuleTreeNode();
SelectedSymbol.getInstance().addSymbolizerToRule(newPointSymbolizer);
DefaultMutableTreeNode newNode = sldTree.addObject(ruleNode, newPointSymbolizer, true);
// Select the item just added
if (newNode != null) {
sldTree.addObject(newNode, SLDTreeLeafFactory.getInstance().getFill(newPointSymbolizer), true);
SLDTreeManager.getInstance().rebuildTree((SLDTree) sldTree);
TreePath newPath = getPath(newNode);
symbolTree.setSelectionPath(newPath);
// Store current state of the SLD after the add
Object newValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
UndoManager.getInstance().addUndoEvent(new UndoEvent(sldTree.getUndoObject(), getClass().getName(), oldValueObj, newValueObj));
}
}
use of org.geotools.styling.PointSymbolizer in project sldeditor by robward-scisys.
the class SLDTreeTools method addArrow.
/**
* Adds the arrow.
*
* @param isSourceArrow the is source arrow
*/
private void addArrow(boolean isSourceArrow) {
if (symbolTree == null) {
return;
}
// Store current state of the SLD before the add
Object oldValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
PointSymbolizer pointSymbolizer = DefaultSymbols.createArrow(isSourceArrow);
DefaultMutableTreeNode ruleNode = getRuleTreeNode();
SelectedSymbol.getInstance().addSymbolizerToRule(pointSymbolizer);
DefaultMutableTreeNode newNode = sldTree.addObject(ruleNode, pointSymbolizer, true);
// Select the item just added
if (newNode != null) {
sldTree.addObject(newNode, SLDTreeLeafFactory.getInstance().getFill(pointSymbolizer), true);
SLDTreeManager.getInstance().rebuildTree((SLDTree) sldTree);
// Re-render the symbol
if (renderList != null) {
for (RenderSymbolInterface render : renderList) {
render.renderSymbol();
}
}
// Store current state of the SLD after the add
Object newValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
UndoManager.getInstance().addUndoEvent(new UndoEvent(sldTree.getUndoObject(), getClass().getName(), oldValueObj, newValueObj));
}
}
use of org.geotools.styling.PointSymbolizer 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.PointSymbolizer in project sldeditor by robward-scisys.
the class SLDExternalImagesTest method createTestPoint.
/**
* Creates the test point.
*
* @param url the url
* @return the styled layer descriptor
*/
private StyledLayerDescriptor createTestPoint(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);
PointSymbolizer point = styleFactory.createPointSymbolizer();
rule.symbolizers().add(point);
Graphic graphic = createGraphic(url, styleFactory);
point.setGraphic(graphic);
return sld;
}
use of org.geotools.styling.PointSymbolizer in project sldeditor by robward-scisys.
the class SLDUtilsTest method testCreateSLDFromStringFile.
@Test
public void testCreateSLDFromStringFile() {
StyleWrapper wrapper = new StyleWrapper();
SLDData sldData = new SLDData(wrapper, expectedSld);
String filename = "D:/tmp/test.sld";
File file = new File(filename);
sldData.setSLDFile(file);
StyledLayerDescriptor sld = SLDUtils.createSLDFromString(null);
assertNull(sld);
sld = SLDUtils.createSLDFromString(sldData);
StyledLayer[] styledLayers = sld.getStyledLayers();
NamedLayer namedLayer = (NamedLayer) styledLayers[0];
Style[] actualStyles = namedLayer.getStyles();
PointSymbolizer pointSymbolizer = (PointSymbolizer) actualStyles[0].featureTypeStyles().get(0).rules().get(0).symbolizers().get(0);
MarkImpl mark = (MarkImpl) pointSymbolizer.getGraphic().graphicalSymbols().get(0);
assertEquals("circle", mark.getWellKnownName().toString());
// Check resource locator
try {
URL url = file.getParentFile().toURI().toURL();
String actualResourceLocator = sldData.getResourceLocator().toExternalForm();
String expectedResourcelocator = url.toExternalForm();
assertTrue(expectedResourcelocator.compareTo(actualResourceLocator) == 0);
} catch (MalformedURLException e) {
e.printStackTrace();
fail();
}
}
Aggregations