use of org.geotools.styling.FeatureTypeStyle in project sldeditor by robward-scisys.
the class FeatureTypeStyleDetails method updateSymbol.
/**
* Update symbol.
*/
private void updateSymbol() {
if (!Controller.getInstance().isPopulating()) {
StandardData standardData = getStandardData();
Expression transformation = fieldConfigVisitor.getExpression(FieldIdEnum.TRANSFORMATION);
FeatureTypeStyle existingFTS = SelectedSymbol.getInstance().getFeatureTypeStyle();
if (existingFTS != null) {
List<org.opengis.style.Rule> newRuleList = new ArrayList<org.opengis.style.Rule>();
for (org.opengis.style.Rule rule : existingFTS.rules()) {
newRuleList.add(rule);
}
FeatureTypeStyle fts = (FeatureTypeStyle) getStyleFactory().featureTypeStyle(standardData.name, (org.opengis.style.Description) standardData.description, existingFTS.getFeatureInstanceIDs(), existingFTS.featureTypeNames(), existingFTS.semanticTypeIdentifiers(), newRuleList);
if (transformation != null) {
fts.setTransformation(transformation);
}
if (vendorOptionFTSFactory != null) {
vendorOptionFTSFactory.updateSymbol(fts);
}
SelectedSymbol.getInstance().replaceFeatureTypeStyle(fts);
this.fireUpdateSymbol();
}
}
}
use of org.geotools.styling.FeatureTypeStyle in project sldeditor by robward-scisys.
the class VOGeoServerFTSComposite 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 (sldObj instanceof FeatureTypeStyle) {
FeatureTypeStyle fts = (FeatureTypeStyle) sldObj;
Map<String, String> options = fts.getOptions();
if (options.containsKey(FeatureTypeStyle.COMPOSITE)) {
VendorOptionPresent voPresent = new VendorOptionPresent(sldObj, getVendorOptionInfo());
vendorOptionsPresentList.add(voPresent);
}
}
}
use of org.geotools.styling.FeatureTypeStyle in project sldeditor by robward-scisys.
the class VOGeoServerFTSCompositeBase 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 (sldObj instanceof FeatureTypeStyle) {
FeatureTypeStyle fts = (FeatureTypeStyle) sldObj;
Map<String, String> options = fts.getOptions();
if (options.containsKey(FeatureTypeStyle.COMPOSITE_BASE)) {
VendorOptionPresent voPresent = new VendorOptionPresent(sldObj, getVendorOptionInfo());
vendorOptionsPresentList.add(voPresent);
}
}
}
use of org.geotools.styling.FeatureTypeStyle 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.FeatureTypeStyle 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 != null) {
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 != null) {
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);
}
Aggregations