use of org.geotools.styling.Displacement in project sldeditor by robward-scisys.
the class StrokeDetails method populateStroke.
/**
* Populate stroke.
*
* @param symbolizerType the symbolizer type
* @param stroke the stroke
*/
private void populateStroke(Class<?> symbolizerType, Stroke stroke) {
Expression expColour = null;
Expression expStrokeColour = null;
Expression expOpacity = null;
Expression expStrokeWidth = null;
Expression expStrokeOffset = null;
Expression expStrokeLineCap = null;
Expression expStrokeLineJoin = null;
Expression expStrokeDashArray = null;
Expression expAnchorPointX = null;
Expression expAnchorPointY = null;
Expression expDisplacementX = null;
Expression expDisplacementY = null;
Expression expGap = null;
Expression expInitialGap = null;
Expression expSymbolSize = null;
Expression expSymbolRotation = null;
if (stroke == null) {
expColour = getFilterFactory().literal("#000000");
expOpacity = getFilterFactory().literal(1.0);
symbolTypeFactory.setSolidFill(fieldConfigManager, expColour, expOpacity);
expStrokeWidth = getFilterFactory().literal(1.0);
expStrokeOffset = getFilterFactory().literal(0.0);
expStrokeLineCap = getFilterFactory().literal("round");
expStrokeLineJoin = getFilterFactory().literal("round");
expStrokeDashArray = getFilterFactory().literal("");
} else {
Graphic graphicFill = stroke.getGraphicFill();
Graphic graphicStroke = stroke.getGraphicStroke();
if ((graphicFill == null) && (graphicStroke == null)) {
expOpacity = stroke.getOpacity();
symbolTypeFactory.setSolidFill(fieldConfigManager, stroke.getColor(), stroke.getOpacity());
}
expOpacity = stroke.getOpacity();
expStrokeWidth = stroke.getWidth();
expStrokeOffset = stroke.getDashOffset();
expStrokeLineCap = stroke.getLineCap();
expStrokeLineJoin = stroke.getLineJoin();
expColour = stroke.getColor();
List<Float> dashesArray = getStrokeDashArray(stroke);
expStrokeDashArray = getFilterFactory().literal(createDashArrayString(dashesArray));
if (graphicStroke != null) {
// Anchor points
AnchorPoint anchorPoint = graphicStroke.getAnchorPoint();
if (anchorPoint != null) {
expAnchorPointX = anchorPoint.getAnchorPointX();
expAnchorPointY = anchorPoint.getAnchorPointY();
} else {
expAnchorPointX = defaultAnchorPoint.getAnchorPointX();
expAnchorPointY = defaultAnchorPoint.getAnchorPointY();
}
// Displacement
Displacement displacement = graphicStroke.getDisplacement();
if (displacement != null) {
expDisplacementX = displacement.getDisplacementX();
expDisplacementY = displacement.getDisplacementY();
} else {
expDisplacementX = defaultDisplacement.getDisplacementX();
expDisplacementY = defaultDisplacement.getDisplacementY();
}
expGap = graphicStroke.getGap();
expInitialGap = graphicStroke.getInitialGap();
expSymbolSize = graphicStroke.getSize();
expSymbolRotation = graphicStroke.getRotation();
List<GraphicalSymbol> graphicSymbolList = graphicStroke.graphicalSymbols();
for (GraphicalSymbol graphicSymbol : graphicSymbolList) {
if (graphicSymbol instanceof MarkImpl) {
MarkImpl mark = (MarkImpl) graphicSymbol;
Mark defaultMark = getStyleFactory().getDefaultMark();
Fill markFill = mark.getFill();
if (markFill != null) {
expColour = markFill.getColor();
}
expStrokeColour = defaultMark.getStroke().getColor();
Stroke markStroke = mark.getStroke();
if (markStroke != null) {
expStrokeColour = markStroke.getColor();
}
} else if (graphicSymbol instanceof ExternalGraphicImpl) {
@SuppressWarnings("unused") ExternalGraphicImpl externalGraphic = (ExternalGraphicImpl) graphicSymbol;
}
symbolTypeFactory.setValue(symbolizerType, this.fieldConfigManager, graphicStroke, graphicSymbol);
}
}
fieldConfigVisitor.populateField(FieldIdEnum.STROKE_WIDTH, expStrokeWidth);
fieldConfigVisitor.populateField(FieldIdEnum.STROKE_OFFSET, expStrokeOffset);
fieldConfigVisitor.populateField(FieldIdEnum.STROKE_LINE_CAP, expStrokeLineCap);
fieldConfigVisitor.populateField(FieldIdEnum.STROKE_LINE_JOIN, expStrokeLineJoin);
fieldConfigVisitor.populateField(FieldIdEnum.STROKE_DASH_ARRAY, expStrokeDashArray);
fieldConfigVisitor.populateField(FieldIdEnum.STROKE_SYMBOL_GAP, expGap);
fieldConfigVisitor.populateField(FieldIdEnum.STROKE_SYMBOL_INITIAL_GAP, expInitialGap);
fieldConfigVisitor.populateField(FieldIdEnum.STROKE_SYMBOL_SIZE, expSymbolSize);
fieldConfigVisitor.populateField(FieldIdEnum.STROKE_SYMBOL_ANGLE, expSymbolRotation);
fieldConfigVisitor.populateField(FieldIdEnum.STROKE_SYMBOL_ANCHOR_POINT_H, expAnchorPointX);
fieldConfigVisitor.populateField(FieldIdEnum.STROKE_SYMBOL_ANCHOR_POINT_V, expAnchorPointY);
fieldConfigVisitor.populateField(FieldIdEnum.STROKE_SYMBOL_DISPLACEMENT_X, expDisplacementX);
fieldConfigVisitor.populateField(FieldIdEnum.STROKE_SYMBOL_DISPLACEMENT_Y, expDisplacementY);
fieldConfigVisitor.populateField(FieldIdEnum.STROKE_FILL_COLOUR, expColour);
fieldConfigVisitor.populateField(FieldIdEnum.STROKE_STROKE_COLOUR, expStrokeColour);
if ((graphicFill == null) && (graphicStroke == null)) {
GroupConfigInterface fillColourGroup = getGroup(GroupIdEnum.FILLCOLOUR);
if (fillColourGroup != null) {
fillColourGroup.enable(true);
}
}
//
// GroupConfigInterface strokeColourGroup = getGroup(GroupIdEnum.STROKECOLOUR);
// if (strokeColourGroup != null) {
// strokeColourGroup.enable(strokeColourEnabled);
// }
}
}
use of org.geotools.styling.Displacement in project sldeditor by robward-scisys.
the class StrokeDetails method getStroke.
/**
* Gets the stroke.
*
* @return the stroke
*/
public Stroke getStroke() {
Expression join = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_LINE_JOIN);
Expression lineCap = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_LINE_CAP);
Expression offset = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_OFFSET);
Expression strokeWidth = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_WIDTH);
ValueComboBoxData symbolTypeValue = fieldConfigVisitor.getComboBox(FieldIdEnum.STROKE_STYLE);
Expression symbolType = null;
if (symbolTypeValue != null) {
symbolType = getFilterFactory().literal(symbolTypeValue.getKey());
}
List<Float> dashList = createDashArray(fieldConfigVisitor.getText(FieldIdEnum.STROKE_DASH_ARRAY));
float[] dashes = convertDashListToArray(dashList);
FieldConfigBase fdmFillColour = fieldConfigManager.get(FieldIdEnum.STROKE_FILL_COLOUR);
FieldConfigColour colourField = (FieldConfigColour) fdmFillColour;
Expression fillColour = colourField.getColourExpression();
Expression opacity = fieldConfigVisitor.getExpression(FieldIdEnum.OVERALL_OPACITY);
boolean isLine = true;
if (symbolTypeValue != null) {
isLine = (symbolTypeValue.getKey().compareTo(SOLID_LINE_KEY) == 0);
}
boolean fillColourEnabled = isPanelEnabled(GroupIdEnum.FILLCOLOUR);
boolean strokeColourEnabled = isPanelEnabled(GroupIdEnum.STROKECOLOUR);
Stroke stroke = null;
if (isLine) {
opacity = fieldConfigVisitor.getExpression(FieldIdEnum.LINE_FILL_OPACITY);
stroke = getStyleFactory().stroke(fillColour, opacity, strokeWidth, join, lineCap, dashes, offset);
} else {
stroke = getStyleFactory().getDefaultStroke();
AnchorPoint anchorPoint = getStyleFactory().anchorPoint(fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_ANCHOR_POINT_H), fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_ANCHOR_POINT_V));
// default so it doesn't appear in the SLD
if (DetailsUtilities.isSame(defaultAnchorPoint, anchorPoint)) {
anchorPoint = null;
}
Displacement displacement = getStyleFactory().displacement(fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_DISPLACEMENT_X), fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_DISPLACEMENT_Y));
// so it doesn't appear in the SLD
if (DetailsUtilities.isSame(defaultDisplacement, displacement)) {
displacement = null;
}
List<GraphicalSymbol> symbols = symbolTypeFactory.getValue(this.fieldConfigManager, symbolType, fillColourEnabled, strokeColourEnabled, selectedFillPanelId);
Expression initalGap = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_INITIAL_GAP);
Expression gap = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_GAP);
Expression rotation = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_ANGLE);
Expression symbolSize = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_SIZE);
GraphicStroke graphicStroke = getStyleFactory().graphicStroke(symbols, opacity, symbolSize, rotation, anchorPoint, displacement, initalGap, gap);
boolean overallOpacity = symbolTypeFactory.isOverallOpacity(PointSymbolizer.class, selectedFillPanelId);
if (overallOpacity) {
stroke.setOpacity(opacity);
}
stroke.setGraphicStroke(graphicStroke);
stroke.setWidth(strokeWidth);
}
return stroke;
}
use of org.geotools.styling.Displacement in project sldeditor by robward-scisys.
the class TextSymbolizerDetails method updateSymbol.
/**
* Update symbol.
*/
private void updateSymbol() {
if (!Controller.getInstance().isPopulating()) {
Expression haloRadius = fieldConfigVisitor.getExpression(FieldIdEnum.HALO_RADIUS);
// Label placement
LabelPlacement labelPlacement = null;
MultiOptionGroup labelPlacementPanel = (MultiOptionGroup) getGroup(GroupIdEnum.PLACEMENT);
OptionGroup labelPlacementOption = labelPlacementPanel.getSelectedOptionGroup();
if (labelPlacementOption.getId() == GroupIdEnum.POINTPLACEMENT) {
AnchorPoint anchor = null;
GroupConfigInterface anchorPointPanel = getGroup(GroupIdEnum.ANCHORPOINT);
if (anchorPointPanel == null) {
String errorMessage = String.format("%s : %s", Localisation.getString(TextSymbolizerDetails.class, "TextSymbol.error1"), GroupIdEnum.ANCHORPOINT);
ConsoleManager.getInstance().error(this, errorMessage);
} else if (anchorPointPanel.isPanelEnabled()) {
Expression anchorPointH = fieldConfigVisitor.getExpression(FieldIdEnum.ANCHOR_POINT_H);
Expression anchorPointV = fieldConfigVisitor.getExpression(FieldIdEnum.ANCHOR_POINT_V);
anchor = (AnchorPoint) getStyleFactory().anchorPoint(anchorPointH, anchorPointV);
}
//
// Displacement
//
Displacement displacement = null;
GroupConfigInterface displacementPanel = getGroup(GroupIdEnum.DISPLACEMENT);
if (displacementPanel == null) {
ConsoleManager.getInstance().error(this, String.format("%s : %s", Localisation.getString(TextSymbolizerDetails.class, "TextSymbol.error1"), GroupIdEnum.DISPLACEMENT));
} else if (displacementPanel.isPanelEnabled()) {
displacement = getStyleFactory().displacement(fieldConfigVisitor.getExpression(FieldIdEnum.DISPLACEMENT_X), fieldConfigVisitor.getExpression(FieldIdEnum.DISPLACEMENT_Y));
}
//
// Rotation
//
Expression rotation = null;
GroupConfigInterface rotationPanel = getGroup(GroupIdEnum.ROTATION);
if (rotationPanel == null) {
ConsoleManager.getInstance().error(this, String.format("%s : %s", Localisation.getString(TextSymbolizerDetails.class, "TextSymbol.error1"), GroupIdEnum.ROTATION));
} else if (rotationPanel.isPanelEnabled()) {
rotation = fieldConfigVisitor.getExpression(FieldIdEnum.ANGLE);
}
labelPlacement = getStyleFactory().pointPlacement(anchor, displacement, rotation);
} else if (labelPlacementOption.getId() == GroupIdEnum.LINEPLACEMENT) {
Expression offset = fieldConfigVisitor.getExpression(FieldIdEnum.PERPENDICULAR_OFFSET);
Expression initialGap = fieldConfigVisitor.getExpression(FieldIdEnum.INITIAL_GAP);
Expression gap = fieldConfigVisitor.getExpression(FieldIdEnum.GAP);
boolean repeated = fieldConfigVisitor.getBoolean(FieldIdEnum.REPEATED);
boolean aligned = fieldConfigVisitor.getBoolean(FieldIdEnum.ALIGN);
boolean generalizedLine = fieldConfigVisitor.getBoolean(FieldIdEnum.GENERALISED_LINE);
labelPlacement = getStyleFactory().linePlacement(offset, initialGap, gap, repeated, aligned, generalizedLine);
}
FieldConfigColour fdmFillColour = (FieldConfigColour) fieldConfigManager.get(FieldIdEnum.FILL_COLOUR);
Expression fillColour = fdmFillColour.getColourExpression();
Expression fillColourOpacity = fieldConfigVisitor.getExpression(FieldIdEnum.TEXT_OPACITY);
Fill fill = getStyleFactory().createFill(fillColour, fillColourOpacity);
FieldConfigColour fdmHaloColour = (FieldConfigColour) fieldConfigManager.get(FieldIdEnum.HALO_COLOUR);
Expression haloFillColour = fdmHaloColour.getColourExpression();
Expression haloFillColourOpacity = fdmHaloColour.getColourOpacityExpression();
Fill haloFill = getStyleFactory().fill(null, haloFillColour, haloFillColourOpacity);
//
// Halo
//
Halo halo = null;
GroupConfigInterface haloPanel = getGroup(GroupIdEnum.HALO);
if (haloPanel.isPanelEnabled()) {
halo = (Halo) getStyleFactory().halo(haloFill, haloRadius);
}
//
// Font
//
Font font = extractFont();
// Any changes made to the font details need to be reflected
// back to the FieldConfigFontPreview field
fieldConfigVisitor.populateFontField(FieldIdEnum.FONT_PREVIEW, font);
StandardData standardData = getStandardData();
Expression label = fieldConfigVisitor.getExpression(FieldIdEnum.LABEL);
Expression geometryField = fieldConfigVisitor.getExpression(FieldIdEnum.GEOMETRY);
String geometryFieldName = null;
Expression defaultGeometryField = getFilterFactory().property(geometryFieldName);
TextSymbolizer textSymbolizer = (TextSymbolizer) getStyleFactory().textSymbolizer(standardData.name, defaultGeometryField, standardData.description, standardData.unit, label, font, labelPlacement, halo, fill);
if ((geometryField != null) && !geometryField.toString().isEmpty()) {
textSymbolizer.setGeometry(geometryField);
}
if (vendorOptionTextFactory != null) {
vendorOptionTextFactory.updateSymbol(textSymbolizer);
}
SelectedSymbol.getInstance().replaceSymbolizer(textSymbolizer);
this.fireUpdateSymbol();
}
}
use of org.geotools.styling.Displacement in project sldeditor by robward-scisys.
the class PointFillDetails method getGraphic.
/**
* Gets the graphic.
*
* @return the graphic
*/
private Graphic getGraphic() {
AnchorPoint anchor = null;
Displacement displacement = null;
Expression symbolType = fieldConfigVisitor.getExpression(FieldIdEnum.SYMBOL_TYPE);
GroupConfigInterface fillGroup = getGroup(GroupIdEnum.FILL);
boolean hasFill = fillGroup.isPanelEnabled();
GroupConfigInterface strokeGroup = getGroup(GroupIdEnum.STROKE);
boolean hasStroke = (strokeGroup == null) ? false : strokeGroup.isPanelEnabled();
Expression opacity = fieldConfigVisitor.getExpression(FieldIdEnum.OVERALL_OPACITY);
Expression size = fieldConfigVisitor.getExpression(FieldIdEnum.SIZE);
Expression rotation = fieldConfigVisitor.getExpression(FieldIdEnum.ANGLE);
//
// Anchor point
//
GroupConfigInterface anchorPointPanel = getGroup(GroupIdEnum.ANCHORPOINT);
if (anchorPointPanel.isPanelEnabled()) {
anchor = (AnchorPoint) getStyleFactory().anchorPoint(fieldConfigVisitor.getExpression(FieldIdEnum.ANCHOR_POINT_H), fieldConfigVisitor.getExpression(FieldIdEnum.ANCHOR_POINT_V));
// so it doesn't appear in the SLD
if (DetailsUtilities.isSame(AnchorPoint.DEFAULT, anchor)) {
anchor = null;
}
}
//
// Displacement
//
GroupConfigInterface displacementPanel = getGroup(GroupIdEnum.DISPLACEMENT);
if (displacementPanel.isPanelEnabled()) {
displacement = getStyleFactory().displacement(fieldConfigVisitor.getExpression(FieldIdEnum.DISPLACEMENT_X), fieldConfigVisitor.getExpression(FieldIdEnum.DISPLACEMENT_Y));
// it doesn't appear in the SLD
if (DetailsUtilities.isSame(Displacement.DEFAULT, displacement)) {
displacement = null;
}
}
List<GraphicalSymbol> symbols = symbolTypeFactory.getValue(fieldConfigManager, symbolType, hasFill, hasStroke, selectedFillPanelId);
boolean overallOpacity = symbolTypeFactory.isOverallOpacity(PointSymbolizer.class, selectedFillPanelId);
Graphic graphic = getStyleFactory().graphic(symbols, null, size, rotation, anchor, displacement);
Expression gap = fieldConfigVisitor.getExpression(FieldIdEnum.GAP);
Expression initialGap = fieldConfigVisitor.getExpression(FieldIdEnum.INITIAL_GAP);
graphic.setInitialGap(initialGap);
graphic.setGap(gap);
if (overallOpacity) {
graphic.setOpacity(opacity);
}
return graphic;
}
use of org.geotools.styling.Displacement in project sldeditor by robward-scisys.
the class PointFillDetails method populate.
/**
* Populate.
*
* @param selectedSymbol the selected symbol
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.iface.PopulateDetailsInterface#populate(com.sldeditor.ui.detail.SelectedSymbol)
*/
@Override
public void populate(SelectedSymbol selectedSymbol) {
Expression expSize = null;
Expression expRotation = null;
Expression expAnchorPointX = null;
Expression expAnchorPointY = null;
Expression expDisplacementX = null;
Expression expDisplacementY = null;
Expression expGap = null;
Expression expInitialGap = null;
PointSymbolizer pointSymbolizer = null;
if (selectedSymbol != null) {
Symbolizer symbolizer = selectedSymbol.getSymbolizer();
if (symbolizer instanceof PointSymbolizerImpl) {
pointSymbolizer = (PointSymbolizer) symbolizer;
Graphic graphic = pointSymbolizer.getGraphic();
if (graphic != null) {
expSize = graphic.getSize();
expRotation = graphic.getRotation();
// Anchor point
AnchorPoint anchorPoint = graphic.getAnchorPoint();
if (anchorPoint != null) {
expAnchorPointX = anchorPoint.getAnchorPointX();
expAnchorPointY = anchorPoint.getAnchorPointY();
} else {
expAnchorPointX = AnchorPoint.DEFAULT.getAnchorPointX();
expAnchorPointY = AnchorPoint.DEFAULT.getAnchorPointY();
}
// Offset
Displacement displacement = graphic.getDisplacement();
if (displacement != null) {
expDisplacementX = displacement.getDisplacementX();
expDisplacementY = displacement.getDisplacementY();
} else {
expDisplacementX = Displacement.DEFAULT.getDisplacementX();
expDisplacementY = Displacement.DEFAULT.getDisplacementY();
}
expGap = graphic.getGap();
expInitialGap = graphic.getInitialGap();
List<GraphicalSymbol> graphicalSymbolList = graphic.graphicalSymbols();
if (!graphicalSymbolList.isEmpty()) {
GraphicalSymbol symbol = graphicalSymbolList.get(0);
symbolTypeFactory.setValue(PointSymbolizer.class, this.fieldConfigManager, graphic, symbol);
}
}
}
}
fieldConfigVisitor.populateField(FieldIdEnum.SIZE, expSize);
fieldConfigVisitor.populateField(FieldIdEnum.ANGLE, expRotation);
fieldConfigVisitor.populateField(FieldIdEnum.ANCHOR_POINT_H, expAnchorPointX);
fieldConfigVisitor.populateField(FieldIdEnum.ANCHOR_POINT_V, expAnchorPointY);
fieldConfigVisitor.populateField(FieldIdEnum.DISPLACEMENT_X, expDisplacementX);
fieldConfigVisitor.populateField(FieldIdEnum.DISPLACEMENT_Y, expDisplacementY);
fieldConfigVisitor.populateField(FieldIdEnum.GAP, expGap);
fieldConfigVisitor.populateField(FieldIdEnum.INITIAL_GAP, expInitialGap);
if (vendorOptionFillFactory != null) {
vendorOptionFillFactory.populate(pointSymbolizer);
}
updateSymbol();
}
Aggregations