Search in sources :

Example 6 with ContrastEnhancement

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

the class VOGeoServerContrastEnhancementNormalize method updateSymbol.

/*
     * (non-Javadoc)
     * 
     * @see
     * com.sldeditor.ui.detail.vendor.geoserver.VendorOptionInterface#updateSymbol(org.geotools.
     * styling.RasterSymbolizer)
     */
@Override
public void updateSymbol(RasterSymbolizer rasterSymbolizer) {
    if (parentPanel != null) {
        GroupConfigInterface group = parentPanel.getGroup(GroupIdEnum.RASTER_CHANNELSELECTION);
        if (group != null) {
            if (group.isPanelEnabled()) {
                MultiOptionGroup contrastEnhancementGroup = (MultiOptionGroup) group;
                ChannelSelection channelSelection = rasterSymbolizer.getChannelSelection();
                OptionGroup selectedOption = contrastEnhancementGroup.getSelectedOptionGroup();
                ContrastEnhancement contrastEnhancement = getContrastEnhancement(selectedOption.getId(), channelSelection);
                if (contrastEnhancement != null) {
                    extractNormalizeVendorOption(contrastEnhancement);
                }
            }
        }
    }
}
Also used : OptionGroup(com.sldeditor.ui.detail.config.base.OptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) ContrastEnhancement(org.geotools.styling.ContrastEnhancement) ChannelSelection(org.geotools.styling.ChannelSelection) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup)

Example 7 with ContrastEnhancement

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

the class VOGeoServerContrastEnhancementNormalize method populate.

/*
     * (non-Javadoc)
     * 
     * @see
     * com.sldeditor.ui.detail.vendor.geoserver.VendorOptionInterface#populate(org.geotools.styling.
     * RasterSymbolizer)
     */
@Override
public void populate(RasterSymbolizer rasterSymbolizer) {
    if (rasterSymbolizer != null) {
        ContrastEnhancement contrastEnhancement = getContrastEnhancement(rasterSymbolizer);
        if (contrastEnhancement != null) {
            Map<String, Expression> options = contrastEnhancement.getOptions();
            if ((options != null) && !options.isEmpty()) {
                if (contrastEnhancement.getMethod().equals(ContrastMethod.NORMALIZE)) {
                    String algorithm = options.get(ALGORITHM_OPTION).toString();
                    fieldConfigVisitor.populateComboBoxField(algorithmFieldId, algorithm);
                    int minValue = 0;
                    try {
                        Expression expression = options.get(MIN_VALUE_OPTION);
                        minValue = Integer.valueOf(expression.toString());
                    } catch (Exception e) {
                        // Ignore number format conversions
                        ConsoleManager.getInstance().error(this, "Vendor Option - minValue not valid");
                    }
                    fieldConfigVisitor.populateIntegerField(minValueFieldId, minValue);
                    int maxValue = 0;
                    try {
                        Expression expression = options.get(MAX_VALUE_OPTION);
                        maxValue = Integer.valueOf(expression.toString());
                    } catch (Exception e) {
                        // Ignore number format conversions
                        ConsoleManager.getInstance().error(this, "Vendor Option - maxValue not valid");
                    }
                    fieldConfigVisitor.populateIntegerField(maxValueFieldId, maxValue);
                }
            }
        }
    }
}
Also used : ContrastEnhancement(org.geotools.styling.ContrastEnhancement) Expression(org.opengis.filter.expression.Expression)

Example 8 with ContrastEnhancement

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

the class VOGeoServerContrastEnhancementNormalizeBlueTest method createChannelSelectionError.

/**
 * Creates the channel selection error object.
 *
 * @param styleFactory the style factory
 * @param contrastMethod the contrast method
 * @return the channel selection
 */
private ChannelSelection createChannelSelectionError(StyleFactoryImpl styleFactory, ContrastMethod contrastMethod) {
    ContrastEnhancement contrastEnhancement = (ContrastEnhancement) styleFactory.contrastEnhancement(null, contrastMethod.name());
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    Map<String, Expression> options = contrastEnhancement.getOptions();
    options.put("algorithm", ff.literal("TestStretchToMinimumMaximum"));
    options.put("minValue", ff.literal("1.0"));
    options.put("maxValue", ff.literal("5.0"));
    SelectedChannelType channelType = styleFactory.createSelectedChannelType("channel name", contrastEnhancement);
    SelectedChannelType[] channels = new SelectedChannelType[3];
    channels[0] = channelType;
    channels[1] = channelType;
    channels[2] = channelType;
    ChannelSelection channelSelection = styleFactory.createChannelSelection(channels);
    return channelSelection;
}
Also used : SelectedChannelType(org.geotools.styling.SelectedChannelType) ContrastEnhancement(org.geotools.styling.ContrastEnhancement) Expression(org.opengis.filter.expression.Expression) ChannelSelection(org.geotools.styling.ChannelSelection) FilterFactory(org.opengis.filter.FilterFactory)

Example 9 with ContrastEnhancement

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

the class VOGeoServerContrastEnhancementNormalizeGreenTest method createChannelSelection.

/**
 * Creates the channel selection object.
 *
 * @param styleFactory the style factory
 * @param contrastMethod the contrast method
 * @return the channel selection
 */
private ChannelSelection createChannelSelection(StyleFactoryImpl styleFactory, ContrastMethod contrastMethod) {
    ContrastEnhancement contrastEnhancement = (ContrastEnhancement) styleFactory.contrastEnhancement(null, contrastMethod.name());
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    Map<String, Expression> options = contrastEnhancement.getOptions();
    options.put("algorithm", ff.literal("StretchToMinimumMaximum"));
    options.put("minValue", ff.literal("1"));
    options.put("maxValue", ff.literal("5"));
    SelectedChannelType channelType = styleFactory.createSelectedChannelType("channel name", contrastEnhancement);
    SelectedChannelType[] channels = new SelectedChannelType[3];
    channels[0] = channelType;
    channels[1] = channelType;
    channels[2] = channelType;
    ChannelSelection channelSelection = styleFactory.createChannelSelection(channels);
    return channelSelection;
}
Also used : SelectedChannelType(org.geotools.styling.SelectedChannelType) ContrastEnhancement(org.geotools.styling.ContrastEnhancement) Expression(org.opengis.filter.expression.Expression) ChannelSelection(org.geotools.styling.ChannelSelection) FilterFactory(org.opengis.filter.FilterFactory)

Example 10 with ContrastEnhancement

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

the class VOGeoServerContrastEnhancementNormalizeGreenTest method createChannelSelectionError.

/**
 * Creates the channel selection error object.
 *
 * @param styleFactory the style factory
 * @param contrastMethod the contrast method
 * @return the channel selection
 */
private ChannelSelection createChannelSelectionError(StyleFactoryImpl styleFactory, ContrastMethod contrastMethod) {
    ContrastEnhancement contrastEnhancement = (ContrastEnhancement) styleFactory.contrastEnhancement(null, contrastMethod.name());
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    Map<String, Expression> options = contrastEnhancement.getOptions();
    options.put("algorithm", ff.literal("TestStretchToMinimumMaximum"));
    options.put("minValue", ff.literal("1.0"));
    options.put("maxValue", ff.literal("5.0"));
    SelectedChannelType channelType = styleFactory.createSelectedChannelType("channel name", contrastEnhancement);
    SelectedChannelType[] channels = new SelectedChannelType[3];
    channels[0] = channelType;
    channels[1] = channelType;
    channels[2] = channelType;
    ChannelSelection channelSelection = styleFactory.createChannelSelection(channels);
    return channelSelection;
}
Also used : SelectedChannelType(org.geotools.styling.SelectedChannelType) ContrastEnhancement(org.geotools.styling.ContrastEnhancement) Expression(org.opengis.filter.expression.Expression) ChannelSelection(org.geotools.styling.ChannelSelection) FilterFactory(org.opengis.filter.FilterFactory)

Aggregations

ContrastEnhancement (org.geotools.styling.ContrastEnhancement)19 SelectedChannelType (org.geotools.styling.SelectedChannelType)16 ChannelSelection (org.geotools.styling.ChannelSelection)14 Expression (org.opengis.filter.expression.Expression)14 FilterFactory (org.opengis.filter.FilterFactory)12 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)5 MultiOptionGroup (com.sldeditor.ui.detail.config.base.MultiOptionGroup)4 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)4 OptionGroup (com.sldeditor.ui.detail.config.base.OptionGroup)3 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)2 RasterSymbolizerDetails (com.sldeditor.ui.detail.RasterSymbolizerDetails)2 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)2 ColorMap (org.geotools.styling.ColorMap)2 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)2 NamedLayer (org.geotools.styling.NamedLayer)2 Rule (org.geotools.styling.Rule)2 ShadedRelief (org.geotools.styling.ShadedRelief)2 Style (org.geotools.styling.Style)2 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)2 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)2