Search in sources :

Example 11 with MultiOptionGroup

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();
    }
}
Also used : Fill(org.opengis.style.Fill) Displacement(org.geotools.styling.Displacement) Font(org.geotools.styling.Font) OptionGroup(com.sldeditor.ui.detail.config.base.OptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) AnchorPoint(org.geotools.styling.AnchorPoint) LabelPlacement(org.geotools.styling.LabelPlacement) Expression(org.opengis.filter.expression.Expression) TextSymbolizer(org.geotools.styling.TextSymbolizer) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) Halo(org.geotools.styling.Halo)

Example 12 with MultiOptionGroup

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();
    }
}
Also used : RemoteOWS(org.geotools.styling.RemoteOWS) StyledLayer(org.geotools.styling.StyledLayer) RemoteOWSImpl(org.geotools.styling.RemoteOWSImpl) DataSourceInterface(com.sldeditor.datasource.DataSourceInterface) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) OptionGroup(com.sldeditor.ui.detail.config.base.OptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) UserLayerImpl(org.geotools.styling.UserLayerImpl) Style(org.geotools.styling.Style) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) UserLayer(org.geotools.styling.UserLayer) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup)

Example 13 with MultiOptionGroup

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;
}
Also used : XMLMultiOptionGroup(com.sldeditor.common.xml.ui.XMLMultiOptionGroup) XMLFieldConfigVendorOption(com.sldeditor.common.xml.ui.XMLFieldConfigVendorOption) XMLFieldConfigString(com.sldeditor.common.xml.ui.XMLFieldConfigString) XMLGroupConfig(com.sldeditor.common.xml.ui.XMLGroupConfig) XMLFieldConfigVendorOption(com.sldeditor.common.xml.ui.XMLFieldConfigVendorOption) GroupConfig(com.sldeditor.ui.detail.config.base.GroupConfig) XMLGroupConfig(com.sldeditor.common.xml.ui.XMLGroupConfig) XMLFieldConfigData(com.sldeditor.common.xml.ui.XMLFieldConfigData) List(java.util.List) ArrayList(java.util.ArrayList) FieldList(com.sldeditor.common.xml.ui.XMLFieldConfigEnumValue.FieldList) XMLFieldConfigEnumValueList(com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueList) XMLMultiOptionGroup(com.sldeditor.common.xml.ui.XMLMultiOptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum)

Example 14 with MultiOptionGroup

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;
}
Also used : XMLMultiOptionGroup(com.sldeditor.common.xml.ui.XMLMultiOptionGroup) OptionGroup(com.sldeditor.ui.detail.config.base.OptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) XMLOptionGroup(com.sldeditor.common.xml.ui.XMLOptionGroup) XMLGroupConfig(com.sldeditor.common.xml.ui.XMLGroupConfig) GroupConfig(com.sldeditor.ui.detail.config.base.GroupConfig) XMLGroupConfig(com.sldeditor.common.xml.ui.XMLGroupConfig) XMLMultiOptionGroup(com.sldeditor.common.xml.ui.XMLMultiOptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) XMLOptionGroup(com.sldeditor.common.xml.ui.XMLOptionGroup)

Example 15 with MultiOptionGroup

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);
    }
}
Also used : MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup)

Aggregations

MultiOptionGroup (com.sldeditor.ui.detail.config.base.MultiOptionGroup)23 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)18 OptionGroup (com.sldeditor.ui.detail.config.base.OptionGroup)10 ChannelSelection (org.geotools.styling.ChannelSelection)8 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)7 Test (org.junit.Test)6 Expression (org.opengis.filter.expression.Expression)6 RasterSymbolizerDetails (com.sldeditor.ui.detail.RasterSymbolizerDetails)5 GroupConfig (com.sldeditor.ui.detail.config.base.GroupConfig)5 Box (javax.swing.Box)5 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)5 ContrastEnhancement (org.geotools.styling.ContrastEnhancement)4 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)3 GroupIdEnum (com.sldeditor.common.xml.ui.GroupIdEnum)3 XMLGroupConfig (com.sldeditor.common.xml.ui.XMLGroupConfig)3 XMLMultiOptionGroup (com.sldeditor.common.xml.ui.XMLMultiOptionGroup)3 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)3 SelectedChannelType (org.geotools.styling.SelectedChannelType)3 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)2 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)2