use of org.geotools.styling.NamedLayer in project sldeditor by robward-scisys.
the class DefaultSymbols method createNewRaster.
/**
* Creates the new raster symbol.
*
* @return the styled layer descriptor
*/
public static StyledLayerDescriptor createNewRaster() {
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);
RasterSymbolizer raster = createDefaultRasterSymbolizer();
rule.symbolizers().add(raster);
return sld;
}
use of org.geotools.styling.NamedLayer in project sldeditor by robward-scisys.
the class NewRasterSLD method create.
/**
* Creates the symbol.
*
* @return the styled layer descriptor
*/
/* (non-Javadoc)
* @see com.sldeditor.create.NewSLDInterface#create()
*/
@Override
public StyledLayerDescriptor create() {
StyledLayerDescriptor sld = getStyleFactory().createStyledLayerDescriptor();
NamedLayer namedLayer = getStyleFactory().createNamedLayer();
sld.addStyledLayer(namedLayer);
Style style = getStyleFactory().createStyle();
namedLayer.addStyle(style);
List<FeatureTypeStyle> ftsList = style.featureTypeStyles();
FeatureTypeStyle fts = getStyleFactory().createFeatureTypeStyle();
ftsList.add(fts);
Rule rule = getStyleFactory().createRule();
fts.rules().add(rule);
RasterSymbolizer raster = DefaultSymbols.createDefaultRasterSymbolizer();
rule.symbolizers().add(raster);
return sld;
}
use of org.geotools.styling.NamedLayer in project sldeditor by robward-scisys.
the class SLDTreeTools method removeItem.
/**
* Removes the item.
*/
public void removeItem() {
if (symbolTree == null) {
return;
}
TreePath path = symbolTree.getSelectionPath();
if (path == null) {
return;
}
DefaultMutableTreeNode lastNode = (DefaultMutableTreeNode) path.getLastPathComponent();
Object obj = lastNode.getUserObject();
// CHECKSTYLE:OFF
Object oldValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
if (obj instanceof NamedLayer) {
SelectedSymbol.getInstance().removeUserNamedLayer((NamedLayer) obj);
removeTreeNode(lastNode);
} else if (obj instanceof UserLayer) {
SelectedSymbol.getInstance().removeUserNamedLayer((UserLayer) obj);
removeTreeNode(lastNode);
} else if (obj instanceof Style) {
SelectedSymbol.getInstance().removeStyle((Style) obj);
removeTreeNode(lastNode);
} else if (obj instanceof FeatureTypeStyle) {
SelectedSymbol.getInstance().removeFeatureTypeStyle((FeatureTypeStyle) obj);
removeTreeNode(lastNode);
} else if (obj instanceof Rule) {
SelectedSymbol.getInstance().removeRule((Rule) obj);
removeTreeNode(lastNode);
} else if (obj instanceof Symbolizer) {
DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) lastNode.getParent();
if (parentNode != null) {
if (parentNode.getUserObject() instanceof RasterSymbolizer) {
SelectedSymbol.getInstance().removeRasterImageOutline((RasterSymbolizer) parentNode.getUserObject());
} else {
SelectedSymbol.getInstance().removeSymbolizer((Symbolizer) obj);
}
removeTreeNode(lastNode);
}
} else {
return;
}
SLDTreeManager.getInstance().rebuildTree((SLDTree) sldTree);
// Re-render the symbol
if (renderList != null) {
for (RenderSymbolInterface render : renderList) {
render.renderSymbol();
}
}
Object newValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
UndoManager.getInstance().addUndoEvent(new UndoEvent(sldTree.getUndoObject(), getClass().getName(), oldValueObj, newValueObj));
}
use of org.geotools.styling.NamedLayer in project sldeditor by robward-scisys.
the class SLDTreeTools method addNewThing.
/**
* Adds the new thing.
*
* @param hint the hint when the are multiple possibilities
*/
public void addNewThing(Class<?> hint) {
if (symbolTree == null) {
return;
}
TreePath path = symbolTree.getSelectionPath();
if (path == null) {
return;
}
DefaultMutableTreeNode lastNode = (DefaultMutableTreeNode) path.getLastPathComponent();
DefaultMutableTreeNode newNode = null;
Object obj = lastNode.getUserObject();
// Store current state of the SLD before the add
Object oldValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
if (obj instanceof String) {
StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
SelectedSymbol.getInstance().createNewSLD(sld);
if (hint == NamedLayer.class) {
NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
newNode = sldTree.addObject(lastNode, namedLayer, true);
} else if (hint == UserLayer.class) {
UserLayer userLayer = DefaultSymbols.createNewUserLayer();
SelectedSymbol.getInstance().addNewStyledLayer(userLayer);
newNode = sldTree.addObject(lastNode, userLayer, true);
}
} else if (obj instanceof StyledLayerDescriptor) {
if (hint == NamedLayer.class) {
NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
newNode = sldTree.addObject(lastNode, namedLayer, true);
} else if (hint == UserLayer.class) {
UserLayer userLayer = DefaultSymbols.createNewUserLayer();
SelectedSymbol.getInstance().addNewStyledLayer(userLayer);
newNode = sldTree.addObject(lastNode, userLayer, true);
}
} else if (obj instanceof NamedLayer) {
Style style = DefaultSymbols.createNewStyle();
SelectedSymbol.getInstance().addNewStyle(style);
newNode = sldTree.addObject(lastNode, style, true);
} else if (obj instanceof UserLayer) {
Style style = DefaultSymbols.createNewStyle();
SelectedSymbol.getInstance().addNewStyle(style);
newNode = sldTree.addObject(lastNode, style, true);
} else if (obj instanceof Style) {
FeatureTypeStyle featureTypeStyle = DefaultSymbols.createNewFeatureTypeStyle();
SelectedSymbol.getInstance().addNewFeatureTypeStyle(featureTypeStyle);
newNode = sldTree.addObject(lastNode, featureTypeStyle, true);
} else if (obj instanceof FeatureTypeStyle) {
Rule rule = DefaultSymbols.createNewRule();
SelectedSymbol.getInstance().addNewRule(rule);
newNode = sldTree.addObject(lastNode, rule, true);
}
// Select the item just added
if (newNode != null) {
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.NamedLayer 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;
}
Aggregations