use of org.geotools.styling.Stroke in project sldeditor by robward-scisys.
the class StrokeDetails method populate.
/**
* Populate.
*
* @param selectedSymbol the selected symbol
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.iface.PopulateDetailsInterface#populate(com.sldeditor.ui.detail.selectedsymbol.SelectedSymbol)
*/
@Override
public void populate(SelectedSymbol selectedSymbol) {
Stroke stroke = null;
if (selectedSymbol != null) {
symbolizer = selectedSymbol.getSymbolizer();
if (symbolizer instanceof PointSymbolizer) {
PointSymbolizer pointSymbolizer = (PointSymbolizer) symbolizer;
Graphic graphic = pointSymbolizer.getGraphic();
List<GraphicalSymbol> graphicalSymbols = graphic.graphicalSymbols();
if (graphicalSymbols.size() > 0) {
GraphicalSymbol symbol = graphicalSymbols.get(0);
if (symbol instanceof MarkImpl) {
MarkImpl markerSymbol = (MarkImpl) symbol;
stroke = markerSymbol.getStroke();
}
}
} else if (symbolizer instanceof LineSymbolizer) {
LineSymbolizer lineSymbol = (LineSymbolizer) symbolizer;
stroke = lineSymbol.getStroke();
} else if (symbolizer instanceof PolygonSymbolizer) {
PolygonSymbolizer polygonSymbol = (PolygonSymbolizer) symbolizer;
stroke = polygonSymbol.getStroke();
}
}
Class<?> symbolizerClass = null;
if (symbolizer != null) {
symbolizerClass = symbolizer.getClass();
}
populateStroke(symbolizerClass, stroke);
}
use of org.geotools.styling.Stroke in project sldeditor by robward-scisys.
the class StrokeDetails method updateSymbol.
/**
* Update symbol.
*/
private void updateSymbol() {
if (!Controller.getInstance().isPopulating()) {
Stroke stroke = getStroke();
if (symbolizer instanceof PointSymbolizer) {
PointSymbolizer pointSymbol = (PointSymbolizer) symbolizer;
Graphic graphic = pointSymbol.getGraphic();
GraphicalSymbol symbol = graphic.graphicalSymbols().get(0);
if (symbol instanceof MarkImpl) {
MarkImpl markerSymbol = (MarkImpl) symbol;
markerSymbol.setStroke(stroke);
SelectedSymbol.getInstance().replaceSymbolizer(pointSymbol);
this.fireUpdateSymbol();
}
} else if (symbolizer instanceof LineSymbolizer) {
LineSymbolizer lineSymbol = (LineSymbolizer) symbolizer;
lineSymbol.setStroke(stroke);
SelectedSymbol.getInstance().replaceSymbolizer(lineSymbol);
this.fireUpdateSymbol();
} else if (symbolizer instanceof PolygonSymbolizer) {
PolygonSymbolizer polygonSymbol = (PolygonSymbolizer) symbolizer;
polygonSymbol.setStroke(stroke);
SelectedSymbol.getInstance().replaceSymbolizer(polygonSymbol);
this.fireUpdateSymbol();
}
}
}
use of org.geotools.styling.Stroke 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.Stroke in project sldeditor by robward-scisys.
the class FieldConfigMarker method getValue.
/**
* Gets the value.
*
* @param fieldConfigManager the field config manager
* @param symbolType the symbol type
* @param fillEnabled the fill enabled
* @param strokeEnabled the stroke enabled
* @return the value
*/
@Override
public List<GraphicalSymbol> getValue(GraphicPanelFieldManager fieldConfigManager, Expression symbolType, boolean fillEnabled, boolean strokeEnabled) {
if ((symbolType == null) || (fieldConfigManager == null)) {
return null;
}
Expression symbolTypeExpression = null;
String symbolTypeName = symbolType.toString();
if (symbolTypeName.compareTo(SOLID_SYMBOL_KEY) != 0) {
symbolTypeExpression = symbolType;
}
Fill fill = null;
Stroke stroke = null;
if (symbolTypeName.startsWith(GEOSERVER_MARKER_PREFIX)) {
Expression strokeColour = null;
FieldConfigBase field = fieldConfigManager.get(fillFieldConfig.getColour());
if (field != null) {
strokeColour = ((FieldConfigColour) field).getColourExpression();
}
Expression strokeColourOpacity = null;
field = fieldConfigManager.get(fillFieldConfig.getOpacity());
if (field != null) {
strokeColourOpacity = field.getExpression();
}
Expression strokeWidth = null;
field = fieldConfigManager.get(fillFieldConfig.getWidth());
if (field != null) {
strokeWidth = field.getExpression();
}
stroke = getStyleFactory().createStroke(strokeColour, strokeWidth, strokeColourOpacity);
} else {
Expression fillColour = null;
FieldConfigBase field = fieldConfigManager.get(fillFieldConfig.getColour());
if (field != null) {
fillColour = ((FieldConfigColour) field).getColourExpression();
}
Expression fillColourOpacity = null;
field = fieldConfigManager.get(fillFieldConfig.getOpacity());
if (field != null) {
fillColourOpacity = field.getExpression();
}
if (fillEnabled) {
fill = getStyleFactory().fill(null, fillColour, fillColourOpacity);
}
if (strokeEnabled) {
Expression strokeColour = null;
field = fieldConfigManager.get(strokeFieldConfig.getColour());
if (field != null) {
strokeColour = ((FieldConfigColour) field).getColourExpression();
}
Expression strokeColourOpacity = null;
field = fieldConfigManager.get(strokeFieldConfig.getOpacity());
if (field != null) {
strokeColourOpacity = field.getExpression();
}
Expression strokeWidth = null;
field = fieldConfigManager.get(strokeFieldConfig.getWidth());
if (field != null) {
strokeWidth = field.getExpression();
}
stroke = getStyleFactory().createStroke(strokeColour, strokeWidth, strokeColourOpacity);
}
}
Mark markerSymbol = getStyleFactory().mark(symbolTypeExpression, fill, stroke);
return SelectedSymbol.getInstance().getSymbolList(markerSymbol);
}
use of org.geotools.styling.Stroke in project sldeditor by robward-scisys.
the class FieldConfigMarker method setValue.
/**
* Sets the value.
*
* @param symbolizerType the symbolizer type
* @param fieldConfigManager the field config manager
* @param multiOptionPanel the multi option panel
* @param graphic the graphic
* @param symbol the symbol
*/
@Override
public void setValue(Class<?> symbolizerType, GraphicPanelFieldManager fieldConfigManager, FieldConfigSymbolType multiOptionPanel, Graphic graphic, GraphicalSymbol symbol) {
if ((symbol != null) && (fieldConfigManager != null)) {
MarkImpl markerSymbol = (MarkImpl) symbol;
Expression wellKnownNameExpression = markerSymbol.getWellKnownName();
if (wellKnownNameExpression instanceof LiteralExpressionImpl) {
LiteralExpressionImpl literal = (LiteralExpressionImpl) wellKnownNameExpression;
FieldConfigBase field = fieldConfigManager.get(symbolSelectionField);
if (field != null) {
field.populate(literal);
}
Expression expFillColour = null;
Expression expFillOpacity = null;
Expression expStrokeColour = null;
Expression expStrokeOpacity = null;
Expression expStrokeWidth = null;
// Which opacity attribute do we use?
if (symbol instanceof MarkImpl) {
MarkImpl markSymbol = (MarkImpl) symbol;
Fill fill = markSymbol.getFill();
if (fill != null) {
expFillColour = fill.getColor();
if (!isOverallOpacity(symbolizerType)) {
expFillOpacity = fill.getOpacity();
}
}
Stroke stroke = markSymbol.getStroke();
if (stroke != null) {
expStrokeColour = stroke.getColor();
if (!isOverallOpacity(symbolizerType)) {
expStrokeOpacity = stroke.getOpacity();
}
expStrokeWidth = stroke.getWidth();
}
}
if (isOverallOpacity(symbolizerType)) {
FieldConfigBase opacity = fieldConfigManager.get(FieldIdEnum.OVERALL_OPACITY);
if (opacity != null) {
opacity.populate(graphic.getOpacity());
}
}
FieldConfigBase opacity = fieldConfigManager.get(fillFieldConfig.getOpacity());
if (opacity != null) {
opacity.populate(expFillOpacity);
}
opacity = fieldConfigManager.get(strokeFieldConfig.getOpacity());
if (opacity != null) {
opacity.populate(expStrokeOpacity);
}
Class<?> panelId = getCommonData().getPanelId();
GroupConfigInterface fillGroup = fieldConfigManager.getGroup(panelId, fillFieldConfig.getGroup());
GroupConfigInterface strokeGroup = fieldConfigManager.getGroup(panelId, strokeFieldConfig.getGroup());
if ((fillGroup == null) || (strokeGroup == null)) {
return;
}
if (literal.toString().startsWith(GEOSERVER_MARKER_PREFIX)) {
fillGroup.enable(expStrokeColour != null);
FieldConfigBase fillColour = fieldConfigManager.get(fillFieldConfig.getColour());
if (fillColour != null) {
fillColour.populate(expStrokeColour);
}
opacity = fieldConfigManager.get(fillFieldConfig.getOpacity());
if (opacity != null) {
opacity.populate(expStrokeOpacity);
}
strokeGroup.enable(false);
} else {
fillGroup.enable(expFillColour != null);
FieldConfigBase fillColour = fieldConfigManager.get(fillFieldConfig.getColour());
if (fillColour != null) {
fillColour.populate(expFillColour);
}
strokeGroup.enable(expStrokeColour != null);
FieldConfigBase strokeColour = fieldConfigManager.get(strokeFieldConfig.getColour());
if (strokeColour != null) {
strokeColour.populate(expStrokeColour);
}
FieldConfigBase strokeWidth = fieldConfigManager.get(FieldIdEnum.STROKE_FILL_WIDTH);
if (strokeWidth != null) {
strokeWidth.populate(expStrokeWidth);
}
}
}
}
}
Aggregations