use of org.geotools.styling.Symbolizer 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.Symbolizer in project sldeditor by robward-scisys.
the class SLDTreeTools method setButtonState.
/**
* Sets the buttons state.
*
* @param parentNode the parent node
* @param selectedNode the new button state
* @param currentGeometryType the current geometry type
*/
public void setButtonState(DefaultMutableTreeNode parentNode, DefaultMutableTreeNode selectedNode, GeometryTypeEnum currentGeometryType) {
boolean addButtonEnabled = true;
boolean removeButtonEnabled = true;
boolean addNamedLayerButtonEnabled = false;
boolean addUserLayerButtonEnabled = false;
boolean showMoveButtons = true;
boolean hasMoreThan1Item = false;
boolean isFirstSelected = false;
boolean isLastSelected = false;
boolean showLineArrowButtons = false;
symbolizerButtonState.setGeometryType(currentGeometryType);
Object obj = null;
Object parentObj = null;
if (selectedNode != null) {
obj = selectedNode.getUserObject();
if (parentNode != null) {
parentObj = parentNode.getUserObject();
}
if (obj instanceof StyledLayerDescriptor) {
addNamedLayerButtonEnabled = true;
addUserLayerButtonEnabled = true;
addButtonEnabled = false;
} else if (obj instanceof StyledLayer) {
if (parentObj != null) {
StyledLayerDescriptor sld = (StyledLayerDescriptor) parentObj;
hasMoreThan1Item = sld.layers().size() > 1;
isFirstSelected = (obj == sld.layers().get(0));
isLastSelected = (obj == sld.layers().get(sld.layers().size() - 1));
}
} else if (obj instanceof Style) {
if (parentObj instanceof NamedLayerImpl) {
NamedLayerImpl namedLayer = (NamedLayerImpl) parentObj;
hasMoreThan1Item = namedLayer.styles().size() > 1;
isFirstSelected = (obj == namedLayer.styles().get(0));
isLastSelected = (obj == namedLayer.styles().get(namedLayer.styles().size() - 1));
}
} else if (obj instanceof FeatureTypeStyle) {
if (parentObj != null) {
Style style = (Style) parentObj;
hasMoreThan1Item = style.featureTypeStyles().size() > 1;
isFirstSelected = (obj == style.featureTypeStyles().get(0));
isLastSelected = (obj == style.featureTypeStyles().get(style.featureTypeStyles().size() - 1));
}
} else if (obj instanceof Rule) {
symbolizerButtonState.showSymbolizerButtons();
addButtonEnabled = false;
if (parentObj != null) {
FeatureTypeStyle fts = (FeatureTypeStyle) parentObj;
hasMoreThan1Item = fts.rules().size() > 1;
isFirstSelected = (obj == fts.rules().get(0));
isLastSelected = (obj == fts.rules().get(fts.rules().size() - 1));
}
} else if (obj instanceof Symbolizer) {
symbolizerButtonState.showSymbolizerButtons();
addButtonEnabled = false;
if (parentObj instanceof Rule) {
Rule rule = (Rule) parentObj;
hasMoreThan1Item = rule.symbolizers().size() > 1;
isFirstSelected = (obj == rule.symbolizers().get(0));
isLastSelected = (obj == rule.symbolizers().get(rule.symbolizers().size() - 1));
}
showLineArrowButtons = (obj instanceof LineSymbolizer);
} else {
addButtonEnabled = false;
removeButtonEnabled = false;
showMoveButtons = false;
}
}
btnAddNamedLayerButton.setVisible(addNamedLayerButtonEnabled);
btnAddUserLayerButton.setVisible(addUserLayerButtonEnabled);
btnAddButton.setVisible(addButtonEnabled);
// All symbolizer types are allowed be added to an SLD
boolean allSymbolizer = symbolizerButtonState.isMarkerVisible(parentObj, obj) || symbolizerButtonState.isLineVisible(parentObj, obj) || symbolizerButtonState.isPolygonVisible(parentObj, obj) || symbolizerButtonState.isRasterVisible(parentObj, obj);
btnNewMarker.setVisible(allSymbolizer);
btnNewLine.setVisible(allSymbolizer);
btnNewImageOutlineLine.setVisible(symbolizerButtonState.isImageOutlineLineVisible(parentObj, obj));
btnNewPolygon.setVisible(allSymbolizer);
btnNewImageOutlinePolygon.setVisible(symbolizerButtonState.isImageOutlinePolygonVisible(parentObj, obj));
btnNewRaster.setVisible(allSymbolizer);
btnNewText.setVisible(symbolizerButtonState.isTextVisible(parentObj, obj));
btnRemoveMarker.setVisible(removeButtonEnabled);
// Up / down buttons
btnMoveUp.setVisible(showMoveButtons);
btnMoveUp.setEnabled(hasMoreThan1Item && !isFirstSelected);
btnMoveDown.setVisible(showMoveButtons);
btnMoveDown.setEnabled(hasMoreThan1Item && !isLastSelected);
btnSourceArrowButton.setVisible(showLineArrowButtons);
btnDestArrowButton.setVisible(showLineArrowButtons);
}
use of org.geotools.styling.Symbolizer in project sldeditor by robward-scisys.
the class SLDTreeTools method getRuleTreeNode.
/**
* Gets the rule tree node.
*
* @return the rule tree node
*/
private DefaultMutableTreeNode getRuleTreeNode() {
if (symbolTree != null) {
TreePath path = symbolTree.getSelectionPath();
DefaultMutableTreeNode lastNode = (DefaultMutableTreeNode) path.getLastPathComponent();
Object obj = lastNode.getUserObject();
if (obj instanceof Symbolizer) {
return (DefaultMutableTreeNode) lastNode.getParent();
} else if (obj instanceof Rule) {
return lastNode;
}
}
return rootNode;
}
use of org.geotools.styling.Symbolizer in project sldeditor by robward-scisys.
the class FillTreeItem method itemSelected.
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.tree.item.SLDTreeItemInterface#itemSelected(javax.swing.tree.DefaultMutableTreeNode, java.lang.Object)
*/
@Override
public void itemSelected(DefaultMutableTreeNode node, Object userObject) {
SelectedSymbol selectedSymbol = SelectedSymbol.getInstance();
// Individual symbol selected
if (node != null) {
DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent();
if ((parent != null) && (parent.getUserObject() instanceof Symbolizer)) {
Symbolizer symbolizer = (Symbolizer) parent.getUserObject();
selectedSymbol.setSymbolizer(symbolizer);
}
}
}
use of org.geotools.styling.Symbolizer in project sldeditor by robward-scisys.
the class SLDEditorBufferedImageLegendGraphicBuilder method cloneSymbolizer.
/**
* Clones the given (Point)Symbolizer.
*
* @param symbolizer symbolizer to clone
* @return cloned Symbolizer
*/
private Symbolizer cloneSymbolizer(Symbolizer symbolizer) {
DuplicatingStyleVisitor duplicator = new DuplicatingStyleVisitor();
symbolizer.accept(duplicator);
return (Symbolizer) duplicator.getCopy();
}
Aggregations