use of com.sldeditor.ui.detail.config.base.GroupConfigInterface 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 com.sldeditor.ui.detail.config.base.GroupConfigInterface in project sldeditor by robward-scisys.
the class UserLayerDetails method updateSymbol.
/**
* Update symbol.
*
* @param changedField the changed field
*/
private void updateSymbol(FieldIdEnum changedField) {
if (!Controller.getInstance().isPopulating()) {
UserLayer userLayer = getStyleFactory().createUserLayer();
String name = fieldConfigVisitor.getText(FieldIdEnum.NAME);
userLayer.setName(name);
// Feature type constraints
List<FeatureTypeConstraint> ftcList = fieldConfigVisitor.getFeatureTypeConstraint(FieldIdEnum.LAYER_FEATURE_CONSTRAINTS);
if ((ftcList != null) && !ftcList.isEmpty()) {
FeatureTypeConstraint[] ftcArray = new FeatureTypeConstraint[ftcList.size()];
userLayer.setLayerFeatureConstraints(ftcList.toArray(ftcArray));
}
// Source
GroupConfigInterface group = getGroup(GroupIdEnum.USER_LAYER_SOURCE);
if (group != null) {
MultiOptionGroup userLayerSourceGroup = (MultiOptionGroup) group;
OptionGroup selectedOption = userLayerSourceGroup.getSelectedOptionGroup();
switch(selectedOption.getId()) {
case REMOTE_OWS_OPTION:
{
RemoteOWS remoteOWS = new RemoteOWSImpl();
String service = fieldConfigVisitor.getText(FieldIdEnum.REMOTE_OWS_SERVICE);
remoteOWS.setService(service);
String onlineResource = fieldConfigVisitor.getText(FieldIdEnum.REMOTE_OWS_ONLINERESOURCE);
remoteOWS.setOnlineResource(onlineResource);
userLayer.setRemoteOWS(remoteOWS);
}
break;
case INLINE_FEATURE_OPTION:
{
String inlineFeatures = fieldConfigVisitor.getText(FieldIdEnum.INLINE_FEATURE);
if ((inlineFeatures != null) && (!inlineFeatures.isEmpty())) {
InlineFeatureUtils.setInlineFeatures(userLayer, inlineFeatures);
}
}
break;
default:
break;
}
}
StyledLayer existingStyledLayer = SelectedSymbol.getInstance().getStyledLayer();
if (existingStyledLayer instanceof UserLayerImpl) {
UserLayerImpl existingUserLayer = (UserLayerImpl) existingStyledLayer;
for (Style style : existingUserLayer.userStyles()) {
userLayer.addUserStyle(style);
}
}
SelectedSymbol.getInstance().replaceStyledLayer(userLayer);
// reduces creation of datasources
if (changedField != null) {
if (changedField == FieldIdEnum.INLINE_FEATURE) {
DataSourceInterface dataSource = DataSourceFactory.getDataSource();
if (dataSource != null) {
dataSource.updateUserLayers();
}
}
}
this.fireUpdateSymbol();
}
}
use of com.sldeditor.ui.detail.config.base.GroupConfigInterface 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);
}
}
}
}
}
use of com.sldeditor.ui.detail.config.base.GroupConfigInterface in project sldeditor by robward-scisys.
the class VOGeoServerTextSymbolizer2 method populate.
/**
* Populate.
*
* @param textSymbolizer the text symbolizer
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.detail.vendor.geoserver.VendorOptionInterface#populate(org.geotools.styling.TextSymbolizer)
*/
@Override
public void populate(TextSymbolizer textSymbolizer) {
if (textSymbolizer instanceof TextSymbolizer2) {
TextSymbolizer2 textSymbol2 = (TextSymbolizer2) textSymbolizer;
fieldConfigVisitor.populateField(FieldIdEnum.VO_TEXTSYMBOLIZER_2_FEATURE_DESCRIPTION, textSymbol2.getFeatureDescription());
fieldConfigVisitor.populateField(FieldIdEnum.VO_TEXTSYMBOLIZER_2_SNIPPET, textSymbol2.getSnippet());
OtherText otherText = textSymbol2.getOtherText();
String target = null;
Expression text = null;
if (otherText != null) {
target = otherText.getTarget();
text = otherText.getText();
}
GroupConfigInterface group = getGroup(GroupIdEnum.VO_TEXTSYMBOLIZER_2_OTHERTEXT);
if (group != null) {
group.enable(otherText != null);
}
fieldConfigVisitor.populateTextField(FieldIdEnum.VO_TEXTSYMBOLIZER_2_OTHERTEXT_TARGET, target);
fieldConfigVisitor.populateField(FieldIdEnum.VO_TEXTSYMBOLIZER_2_OTHERTEXT_TEXT, text);
Graphic graphic = textSymbol2.getGraphic();
boolean enableFill = false;
boolean enableStroke = false;
if (graphic == null) {
graphic = getStyleFactory().createDefaultGraphic();
graphic.setSize(getFilterFactory().literal(10.0));
Mark mark = getStyleFactory().createMark();
graphic.graphicalSymbols().add(mark);
}
Expression fillColour = getFilterFactory().literal(DefaultSymbols.defaultColour());
Expression fillOpacity = getFilterFactory().literal(DefaultSymbols.defaultColourOpacity());
Expression strokeColour = getFilterFactory().literal(DefaultSymbols.defaultColour());
Expression strokeOpacity = getFilterFactory().literal(DefaultSymbols.defaultColourOpacity());
Expression strokeLineWidth = null;
List<GraphicalSymbol> graphicalSymbolList = graphic.graphicalSymbols();
if (!graphicalSymbolList.isEmpty()) {
GraphicalSymbol symbol = graphicalSymbolList.get(0);
symbolTypeFactory.setValue(TextSymbolizer2.class, this.fieldConfigManager, graphic, symbol);
if (symbol instanceof Mark) {
Mark mark = (Mark) symbol;
Fill fill = mark.getFill();
if (fill != null) {
enableFill = true;
fillColour = fill.getColor();
fillOpacity = fill.getOpacity();
}
Stroke stroke = mark.getStroke();
if (stroke != null) {
enableStroke = true;
strokeColour = stroke.getColor();
strokeOpacity = stroke.getOpacity();
strokeLineWidth = stroke.getWidth();
}
}
}
Expression expSize = graphic.getSize();
Expression expRotation = graphic.getRotation();
fieldConfigVisitor.populateField(FieldIdEnum.VO_TEXTSYMBOLIZER_2_SIZE, expSize);
fieldConfigVisitor.populateField(FieldIdEnum.VO_TEXTSYMBOLIZER_2_ANGLE, expRotation);
fieldConfigVisitor.populateField(FieldIdEnum.VO_TEXTSYMBOLIZER_2_FILL_COLOUR, fillColour);
fieldConfigVisitor.populateField(FieldIdEnum.VO_TEXTSYMBOLIZER_2_FILL_OPACITY, fillOpacity);
fieldConfigVisitor.populateField(FieldIdEnum.VO_TEXTSYMBOLIZER_2_STROKE_FILL_COLOUR, strokeColour);
fieldConfigVisitor.populateField(FieldIdEnum.VO_TEXTSYMBOLIZER_2_STROKE_OPACITY, strokeOpacity);
fieldConfigVisitor.populateField(FieldIdEnum.VO_TEXTSYMBOLIZER_2_STROKE_FILL_WIDTH, strokeLineWidth);
GroupConfigInterface fillGroup = getGroup(GroupIdEnum.VO_TEXTSYMBOLIZER_2_FILL);
if (fillGroup != null) {
fillGroup.enable(enableFill);
}
GroupConfigInterface strokeGroup = getGroup(GroupIdEnum.VO_TEXTSYMBOLIZER_2_STROKE);
if (strokeGroup != null) {
group.enable(enableStroke);
}
group = getGroup(GroupIdEnum.VO_TEXTSYMBOLIZER_2_GRAPHIC);
if (group != null) {
group.enable(textSymbol2.getGraphic() != null);
}
}
}
use of com.sldeditor.ui.detail.config.base.GroupConfigInterface in project sldeditor by robward-scisys.
the class VOGeoServerTextSymbolizer2 method setSymbolTypeVisibility.
/**
* Sets the symbol type visibility.
*
* @param panelId the panel id
* @param selectedItem the selected item
*/
private void setSymbolTypeVisibility(Class<?> panelId, String selectedItem) {
Map<GroupIdEnum, Boolean> groupList = fieldEnableState.getGroupIdList(panelId.getName(), selectedItem);
for (GroupIdEnum groupId : groupList.keySet()) {
boolean groupEnabled = groupList.get(groupId);
GroupConfigInterface groupConfig = fieldConfigManager.getGroup(getPanelId(), groupId);
if (groupConfig != null) {
groupConfig.setGroupStateOverride(groupEnabled);
} else {
ConsoleManager.getInstance().error(this, "Failed to find group : " + groupId.toString());
}
}
Map<FieldIdEnum, Boolean> fieldList = fieldEnableState.getFieldIdList(panelId.getName(), selectedItem);
for (FieldIdEnum fieldId : fieldList.keySet()) {
boolean fieldEnabled = fieldList.get(fieldId);
FieldConfigBase fieldConfig = fieldConfigManager.get(fieldId);
if (fieldConfig != null) {
CurrentFieldState fieldState = fieldConfig.getFieldState();
fieldState.setFieldEnabled(fieldEnabled);
fieldConfig.setFieldState(fieldState);
} else {
ConsoleManager.getInstance().error(this, "Failed to find field : " + fieldId.toString());
}
}
}
Aggregations