use of com.sldeditor.ui.detail.config.base.MultiOptionGroup 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.MultiOptionGroup 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.MultiOptionGroup in project sldeditor by robward-scisys.
the class ReadPanelConfig method parseGroup.
/**
* Parses the group if fields.
*
* @param localisationClass the localisation class
* @param panelId the panel id
* @param xmlGroupObj the xml group object
* @return the group config
*/
private GroupConfig parseGroup(Class<?> localisationClass, Class<?> panelId, XMLGroupConfig xmlGroupObj) {
GroupConfig groupConfig = new GroupConfig();
groupConfig.setId(xmlGroupObj.getId());
groupConfig.setLabel(groupTitle(getLocalisedText(localisationClass, xmlGroupObj.getLabel())));
groupConfig.setShowLabel(xmlGroupObj.getShowLabel());
groupConfig.setOptional(xmlGroupObj.getOption());
for (Object obj : xmlGroupObj.getFieldList()) {
if (obj instanceof XMLFieldConfigData) {
addField(localisationClass, panelId, groupConfig, (XMLFieldConfigData) obj);
} else if (obj instanceof XMLGroupConfig) {
GroupConfig subGroup = parseGroup(localisationClass, panelId, (XMLGroupConfig) obj);
groupConfig.addGroup(subGroup);
} else if (obj instanceof XMLMultiOptionGroup) {
MultiOptionGroup subGroup = parseMultiOptionGroup(localisationClass, panelId, (XMLMultiOptionGroup) obj);
groupConfig.addGroup(subGroup);
} else if (obj instanceof XMLFieldConfigVendorOption) {
XMLFieldConfigVendorOption vendorOption = (XMLFieldConfigVendorOption) obj;
FieldIdEnum id = vendorOption.getId();
String label = null;
boolean valueOnly = true;
FieldConfigCommonData commonData = new FieldConfigCommonData(panelId, id, label, valueOnly);
List<VendorOptionInterface> veList = null;
veList = vendorOptionFactory.getVendorOptionList(vendorOption.getClazz());
if ((veList == null) || veList.isEmpty()) {
ConsoleManager.getInstance().error(this, Localisation.getField(FieldConfigBase.class, "FieldConfigVendorOption.missingVendorOptionClass") + vendorOption.getClazz());
}
FieldConfigVendorOption placeHolder = new FieldConfigVendorOption(commonData, veList);
groupConfig.addField(placeHolder);
}
}
return groupConfig;
}
use of com.sldeditor.ui.detail.config.base.MultiOptionGroup in project sldeditor by robward-scisys.
the class ReadPanelConfig method parseMultiOptionGroup.
/**
* Parses the multi option group.
*
* @param localisationClass the localisation class
* @param panelId the panel id
* @param xmlMultiGroupObj the xml multi group obj
* @return the multi option group
*/
private MultiOptionGroup parseMultiOptionGroup(Class<?> localisationClass, Class<?> panelId, XMLMultiOptionGroup xmlMultiGroupObj) {
MultiOptionGroup multiOptionGroupConfig = new MultiOptionGroup();
multiOptionGroupConfig.setId(xmlMultiGroupObj.getId());
multiOptionGroupConfig.setLabel(getLocalisedText(localisationClass, xmlMultiGroupObj.getLabel()));
multiOptionGroupConfig.setShowLabel(xmlMultiGroupObj.getShowLabel());
multiOptionGroupConfig.setOptional(xmlMultiGroupObj.getOption());
List<XMLOptionGroup> optionGroupList = xmlMultiGroupObj.getOptionGroup();
for (XMLOptionGroup xmlOptionGroup : optionGroupList) {
OptionGroup optionGroup = new OptionGroup();
optionGroup.setId(xmlOptionGroup.getId());
optionGroup.setLabel(getLocalisedText(localisationClass, xmlOptionGroup.getLabel()));
optionGroup.setShowLabel(xmlOptionGroup.getShowLabel());
List<XMLGroupConfig> xmlGroupConfigList = xmlOptionGroup.getGroup();
if (xmlGroupConfigList != null) {
for (XMLGroupConfig xmlGroupConfig : xmlGroupConfigList) {
GroupConfig groupConfig = parseGroup(localisationClass, panelId, xmlGroupConfig);
optionGroup.addGroup(groupConfig);
}
}
multiOptionGroupConfig.addGroup(optionGroup);
}
return multiOptionGroupConfig;
}
use of com.sldeditor.ui.detail.config.base.MultiOptionGroup in project sldeditor by robward-scisys.
the class VOGeoServerFTSSortBy method updateSymbol.
/*
* (non-Javadoc)
*
* @see
* com.sldeditor.ui.detail.vendor.geoserver.VendorOptionInterface#updateSymbol(org.geotools.
* styling.FeatureTypeStyle)
*/
@Override
public void updateSymbol(FeatureTypeStyle featureTypeStyle) {
Map<String, String> options = featureTypeStyle.getOptions();
MultiOptionGroup groupPanel = (MultiOptionGroup) getGroup(GroupIdEnum.VO_FTS_SORTBY_MULTIOPTION);
if (groupPanel.isPanelEnabled()) {
if (groupPanel.getSelectedOptionGroup().getId() == GroupIdEnum.VO_FTS_SORTBY_MULTIOPTION_SORTBY_OPTION) {
String value = fieldConfigVisitor.getText(FieldIdEnum.VO_FTS_SORTBY_MULTIOPTION_SORTBY_LIST);
options.put(FeatureTypeStyle.SORT_BY, value);
} else {
String property = fieldConfigVisitor.getText(FieldIdEnum.VO_FTS_SORTBY_MULTIOPTION_SORTBY_GROUP_PROPERTIES);
if (property != null) {
options.put(FeatureTypeStyle.SORT_BY_GROUP, property);
} else {
options.remove(FeatureTypeStyle.SORT_BY_GROUP);
}
}
} else {
options.remove(FeatureTypeStyle.SORT_BY);
options.remove(FeatureTypeStyle.SORT_BY_GROUP);
}
}
Aggregations