use of org.geotools.styling.LineSymbolizer in project sldeditor by robward-scisys.
the class LineSymbolizerDetails method populate.
/*
* (non-Javadoc)
*
* @see com.sldeditor.marker.iface.PointMarkerDetailsInterface#populate(com.sldeditor.marker.detail.SelectedSymbol)
*/
@Override
public void populate(SelectedSymbol selectedSymbol) {
if (selectedSymbol != null) {
LineSymbolizer lineSymbolizer = (LineSymbolizer) selectedSymbol.getSymbolizer();
if (lineSymbolizer != null) {
populateStandardData(lineSymbolizer);
fieldConfigVisitor.populateField(FieldIdEnum.PERPENDICULAR_OFFSET, lineSymbolizer.getPerpendicularOffset());
fieldConfigVisitor.populateField(FieldIdEnum.GEOMETRY, lineSymbolizer.getGeometry());
}
}
}
use of org.geotools.styling.LineSymbolizer in project sldeditor by robward-scisys.
the class SLDEditorBufferedImageLegendGraphicBuilder method getSampleShape.
/**
* Returns a <code>java.awt.Shape</code> appropiate to render a legend graphic given the
* symbolizer type and the legend dimensions.
*
* @param symbolizer the Symbolizer for whose type a sample shape will be created
* @param legendWidth the requested width, in output units, of the legend graphic
* @param legendHeight the requested height, in output units, of the legend graphic
*
* @return an appropiate Line2D, Rectangle2D or LiteShape(Point) for the symbolizer, wether it
* is a LineSymbolizer, a PolygonSymbolizer, or a Point ot Text Symbolizer
*
* @throws IllegalArgumentException if an unknown symbolizer impl was passed in.
*/
private LiteShape2 getSampleShape(Symbolizer symbolizer, int legendWidth, int legendHeight) {
LiteShape2 sampleShape;
final float hpad = (legendWidth * LegendUtils.hpaddingFactor);
final float vpad = (legendHeight * LegendUtils.vpaddingFactor);
if (symbolizer instanceof LineSymbolizer) {
Coordinate[] coords = { new Coordinate(hpad, legendHeight - vpad - 1), new Coordinate(legendWidth - hpad - 1, vpad) };
LineString geom = geomFac.createLineString(coords);
try {
this.sampleLine = new LiteShape2(geom, null, null, false);
} catch (Exception e) {
this.sampleLine = null;
}
sampleShape = this.sampleLine;
} else if ((symbolizer instanceof PolygonSymbolizer) || (symbolizer instanceof RasterSymbolizer)) {
final float w = legendWidth - (2 * hpad) - 1;
final float h = legendHeight - (2 * vpad) - 1;
Coordinate[] coords = { new Coordinate(hpad, vpad), new Coordinate(hpad, vpad + h), new Coordinate(hpad + w, vpad + h), new Coordinate(hpad + w, vpad), new Coordinate(hpad, vpad) };
LinearRing shell = geomFac.createLinearRing(coords);
Polygon geom = geomFac.createPolygon(shell, null);
try {
this.sampleRect = new LiteShape2(geom, null, null, false);
} catch (Exception e) {
this.sampleRect = null;
}
sampleShape = this.sampleRect;
} else if (symbolizer instanceof PointSymbolizer || symbolizer instanceof TextSymbolizer) {
Coordinate coord = new Coordinate(legendWidth / 2, legendHeight / 2);
try {
this.samplePoint = new LiteShape2(geomFac.createPoint(coord), null, null, false);
} catch (Exception e) {
this.samplePoint = null;
}
sampleShape = this.samplePoint;
} else {
throw new IllegalArgumentException("Unknown symbolizer: " + symbolizer);
}
return sampleShape;
}
use of org.geotools.styling.LineSymbolizer in project sldeditor by robward-scisys.
the class SLDTreeTools method addNewImageOutlineLine.
/**
* Adds the new image outline line symbolizer.
*/
public void addNewImageOutlineLine() {
if (symbolTree == null) {
return;
}
// Store current state of the SLD before the add
Object oldValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
LineSymbolizer newLineSymbolizer = DefaultSymbols.createDefaultLineSymbolizer();
DefaultMutableTreeNode ruleNode = getRasterTreeNode();
SelectedSymbol.getInstance().addImageOutlineSymbolizerToRaster(newLineSymbolizer);
DefaultMutableTreeNode newNode = sldTree.addObject(ruleNode, newLineSymbolizer, true);
if (newNode != null) {
sldTree.addObject(newNode, SLDTreeLeafFactory.getInstance().getStroke(newLineSymbolizer), true);
SLDTreeManager.getInstance().rebuildTree((SLDTree) sldTree);
// Select the item just added
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.LineSymbolizer 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);
}
use of org.geotools.styling.LineSymbolizer in project sldeditor by robward-scisys.
the class SLDTreeTools method addNewLine.
/**
* Adds the new line symbolizer.
*/
public void addNewLine() {
if (symbolTree == null) {
return;
}
// Store current state of the SLD before the add
Object oldValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
LineSymbolizer newLineSymbolizer = DefaultSymbols.createDefaultLineSymbolizer();
DefaultMutableTreeNode ruleNode = getRuleTreeNode();
SelectedSymbol.getInstance().addSymbolizerToRule(newLineSymbolizer);
DefaultMutableTreeNode newNode = sldTree.addObject(ruleNode, newLineSymbolizer, true);
if (newNode != null) {
sldTree.addObject(newNode, SLDTreeLeafFactory.getInstance().getStroke(newLineSymbolizer), true);
SLDTreeManager.getInstance().rebuildTree((SLDTree) sldTree);
// Select the item just added
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));
}
}
Aggregations