Search in sources :

Example 1 with ShadedReliefImpl

use of org.geotools.styling.ShadedReliefImpl in project sldeditor by robward-scisys.

the class RasterSymbolizerDetails method updateSymbol.

/**
 * Update symbol.
 */
private void updateSymbol() {
    // Contrast enhancement
    Expression gammaValueExpression = fieldConfigVisitor.getExpression(FieldIdEnum.RASTER_CONTRAST_GAMMAVALUE);
    ContrastEnhancement contrastEnhancement = null;
    GroupConfigInterface group = getGroup(GroupIdEnum.RASTER_CONTRAST);
    if (group.isPanelEnabled()) {
        String method = null;
        group = getGroup(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD);
        if (group != null) {
            MultiOptionGroup contrastNormalizeMethodGroup = (MultiOptionGroup) group;
            OptionGroup selectedOption = contrastNormalizeMethodGroup.getSelectedOptionGroup();
            if (selectedOption != null) {
                method = selectedOption.getLabel();
            }
        }
        contrastEnhancement = (ContrastEnhancement) getStyleFactory().contrastEnhancement(gammaValueExpression, method);
    }
    // Colour map
    ColorMap colorMap = fieldConfigVisitor.getColourMap(FieldIdEnum.RASTER_COLOURMAP);
    ValueComboBoxData colourMapType = fieldConfigVisitor.getComboBox(FieldIdEnum.RASTER_COLOURMAP_TYPE);
    colorMap.setType(Integer.valueOf(colourMapType.getKey()));
    // Channel selection
    ChannelSelection channelSelection = null;
    group = getGroup(GroupIdEnum.RASTER_CHANNELSELECTION);
    if (group != null) {
        if (group.isPanelEnabled()) {
            MultiOptionGroup contrastEnhancementGroup = (MultiOptionGroup) group;
            OptionGroup selectedOption = contrastEnhancementGroup.getSelectedOptionGroup();
            if (selectedOption.getId() == GroupIdEnum.RASTER_GREY_CHANNEL_OPTION) {
                // Grey option group
                SelectedChannelType greyChannel = extractContrastEnhancementGroup(GroupIdEnum.RASTER_GREY_CHANNEL, FieldIdEnum.RASTER_RGB_GREY_NAME, GroupIdEnum.RASTER_RGB_CHANNEL_GREY_CONTRAST, FieldIdEnum.RASTER_RGB_CHANNEL_GREY_CONTRAST_GAMMA, GroupIdEnum.RASTER_RGB_CHANNEL_GREY_CONTRAST_METHOD);
                channelSelection = getStyleFactory().channelSelection(greyChannel);
            } else {
                SelectedChannelType redChannel = extractContrastEnhancementGroup(GroupIdEnum.RASTER_RGB_CHANNEL_RED, FieldIdEnum.RASTER_RGB_RED_NAME, GroupIdEnum.RASTER_RGB_CHANNEL_RED_CONTRAST, FieldIdEnum.RASTER_RGB_CHANNEL_RED_CONTRAST_GAMMA, GroupIdEnum.RASTER_RGB_CHANNEL_RED_CONTRAST_METHOD);
                SelectedChannelType greenChannel = extractContrastEnhancementGroup(GroupIdEnum.RASTER_RGB_CHANNEL_GREEN, FieldIdEnum.RASTER_RGB_GREEN_NAME, GroupIdEnum.RASTER_RGB_CHANNEL_GREEN_CONTRAST, FieldIdEnum.RASTER_RGB_CHANNEL_GREEN_CONTRAST_GAMMA, GroupIdEnum.RASTER_RGB_CHANNEL_GREEN_CONTRAST_METHOD);
                SelectedChannelType blueChannel = extractContrastEnhancementGroup(GroupIdEnum.RASTER_RGB_CHANNEL_BLUE, FieldIdEnum.RASTER_RGB_BLUE_NAME, GroupIdEnum.RASTER_RGB_CHANNEL_BLUE_CONTRAST, FieldIdEnum.RASTER_RGB_CHANNEL_BLUE_CONTRAST_GAMMA, GroupIdEnum.RASTER_RGB_CHANNEL_BLUE_CONTRAST_METHOD);
                SelectedChannelType[] channels = new SelectedChannelType[3];
                channels[0] = redChannel;
                channels[1] = greenChannel;
                channels[2] = blueChannel;
                channelSelection = getStyleFactory().createChannelSelection(channels);
            }
        }
    }
    // 
    // Overlap
    // 
    OverlapBehavior overlapBehavior = null;
    group = getGroup(GroupIdEnum.RASTER_OVERLAP);
    if (group.isPanelEnabled()) {
        ValueComboBoxData overlapBehaviorValue = fieldConfigVisitor.getComboBox(FieldIdEnum.RASTER_OVERLAP_BEHAVIOUR);
        overlapBehavior = OverlapBehavior.valueOf(overlapBehaviorValue.getKey());
    }
    // 
    // Shaded relief
    // 
    ShadedRelief shadedRelief = null;
    group = getGroup(GroupIdEnum.RASTER_SHADEDRELIEF);
    if (group.isPanelEnabled()) {
        shadedRelief = new ShadedReliefImpl();
        shadedRelief.setBrightnessOnly(fieldConfigVisitor.getBoolean(FieldIdEnum.RASTER_SHADEDRELIEF_BRIGHTNESS));
        shadedRelief.setReliefFactor(fieldConfigVisitor.getExpression(FieldIdEnum.RASTER_SHADEDRELIEF_FACTOR));
    }
    Symbolizer symbolizer = null;
    StandardData standardData = getStandardData();
    Expression opacityExpression = fieldConfigVisitor.getExpression(FieldIdEnum.RASTER_OPACITY);
    // Geometry field
    Expression geometryField = ExtractGeometryField.getGeometryField(fieldConfigVisitor);
    RasterSymbolizer rasterSymbolizer = (RasterSymbolizer) getStyleFactory().rasterSymbolizer(standardData.name, geometryField, standardData.description, standardData.unit, opacityExpression, channelSelection, overlapBehavior, colorMap, contrastEnhancement, shadedRelief, symbolizer);
    if (vendorOptionRasterFactory != null) {
        vendorOptionRasterFactory.updateSymbol(rasterSymbolizer);
    }
    rasterSymbolizer.setOverlapBehavior(overlapBehavior);
    SelectedSymbol.getInstance().replaceSymbolizer(rasterSymbolizer);
    this.fireUpdateSymbol();
}
Also used : ColorMap(org.geotools.styling.ColorMap) ShadedRelief(org.geotools.styling.ShadedRelief) Symbolizer(org.geotools.styling.Symbolizer) RasterSymbolizer(org.geotools.styling.RasterSymbolizer) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) SelectedChannelType(org.geotools.styling.SelectedChannelType) RasterSymbolizer(org.geotools.styling.RasterSymbolizer) ContrastEnhancement(org.geotools.styling.ContrastEnhancement) OptionGroup(com.sldeditor.ui.detail.config.base.OptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) Expression(org.opengis.filter.expression.Expression) ChannelSelection(org.geotools.styling.ChannelSelection) ShadedReliefImpl(org.geotools.styling.ShadedReliefImpl) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) OverlapBehavior(org.opengis.style.OverlapBehavior)

Aggregations

GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)1 MultiOptionGroup (com.sldeditor.ui.detail.config.base.MultiOptionGroup)1 OptionGroup (com.sldeditor.ui.detail.config.base.OptionGroup)1 ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)1 ChannelSelection (org.geotools.styling.ChannelSelection)1 ColorMap (org.geotools.styling.ColorMap)1 ContrastEnhancement (org.geotools.styling.ContrastEnhancement)1 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)1 SelectedChannelType (org.geotools.styling.SelectedChannelType)1 ShadedRelief (org.geotools.styling.ShadedRelief)1 ShadedReliefImpl (org.geotools.styling.ShadedReliefImpl)1 Symbolizer (org.geotools.styling.Symbolizer)1 Expression (org.opengis.filter.expression.Expression)1 OverlapBehavior (org.opengis.style.OverlapBehavior)1