Search in sources :

Example 1 with OverlapBehavior

use of org.opengis.style.OverlapBehavior in project sldeditor by robward-scisys.

the class RasterSymbolizerDetails method updateOverlapBehavior.

/**
 * Update overlap behavior.
 *
 * @return the overlap behavior
 */
private OverlapBehavior updateOverlapBehavior() {
    GroupConfigInterface group;
    OverlapBehavior overlapBehavior = null;
    group = getGroup(GroupIdEnum.RASTER_OVERLAP);
    if (group.isPanelEnabled()) {
        ValueComboBoxData overlapBehaviorValue = fieldConfigVisitor.getComboBox(FieldIdEnum.RASTER_OVERLAP_BEHAVIOUR);
        overlapBehavior = OverlapBehavior.valueOf(overlapBehaviorValue.getKey());
    }
    return overlapBehavior;
}
Also used : GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) OverlapBehavior(org.opengis.style.OverlapBehavior) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Example 2 with OverlapBehavior

use of org.opengis.style.OverlapBehavior in project sldeditor by robward-scisys.

the class RasterSymbolizerDetailsTest method testRasterSymbolizerDetailsColourChannel.

/**
 * Test method for {@link
 * com.sldeditor.ui.detail.RasterSymbolizerDetails#RasterSymbolizerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 * Test method for {@link com.sldeditor.ui.detail.RasterSymbolizerDetails#isDataPresent()}. Test
 * method for {@link
 * com.sldeditor.ui.detail.RasterSymbolizerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
 * Test method for {@link
 * com.sldeditor.ui.detail.RasterSymbolizerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for {@link
 * com.sldeditor.ui.detail.RasterSymbolizerDetails#getFieldDataManager()}. Test method for
 * {@link com.sldeditor.ui.detail.RasterSymbolizerDetails#preLoadSymbol()}.
 */
@Test
public void testRasterSymbolizerDetailsColourChannel() {
    RasterSymbolizerDetails panel = new RasterSymbolizerDetails();
    panel.populate(null);
    // Set up test data
    StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
    SelectedSymbol.getInstance().createNewSLD(sld);
    NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
    String expectedNameLayerValue = "named layer test value";
    namedLayer.setName(expectedNameLayerValue);
    Style style = DefaultSymbols.createNewStyle();
    String expectedNameStyleValue = "style test value";
    style.setName(expectedNameStyleValue);
    namedLayer.addStyle(style);
    FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
    String expectedNameFTSValue = "feature type style test value";
    fts.setName(expectedNameFTSValue);
    style.featureTypeStyles().add(fts);
    Rule rule = DefaultSymbols.createNewRule();
    String expectedRuleValue = "rule test value";
    rule.setName(expectedRuleValue);
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    ContrastEnhancement contrastEnhancement = (ContrastEnhancement) styleFactory.contrastEnhancement(ff.literal(.5), "ramp");
    SelectedChannelType redChannel = styleFactory.createSelectedChannelType("red", contrastEnhancement);
    SelectedChannelType greenChannel = styleFactory.createSelectedChannelType("green", contrastEnhancement);
    SelectedChannelType blueChannel = styleFactory.createSelectedChannelType("blue", contrastEnhancement);
    SelectedChannelType[] channels = new SelectedChannelType[3];
    channels[0] = redChannel;
    channels[1] = greenChannel;
    channels[2] = blueChannel;
    RasterSymbolizer symbolizer = DefaultSymbols.createDefaultRasterSymbolizer();
    symbolizer.setChannelSelection(styleFactory.createChannelSelection(channels));
    String expectedNameValue = "symbolizer test value";
    symbolizer.setName(expectedNameValue);
    OverlapBehavior overlapBehavior = OverlapBehavior.EARLIEST_ON_TOP;
    symbolizer.setOverlapBehavior(overlapBehavior);
    ShadedRelief shadedRelief = styleFactory.createShadedRelief(ff.literal(0.75));
    symbolizer.setShadedRelief(shadedRelief);
    rule.symbolizers().add(symbolizer);
    fts.rules().add(rule);
    sld.layers().add(namedLayer);
    SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyle(style);
    SelectedSymbol.getInstance().setFeatureTypeStyle(fts);
    SelectedSymbol.getInstance().setRule(rule);
    SelectedSymbol.getInstance().setSymbolizer(symbolizer);
    panel.populate(SelectedSymbol.getInstance());
    GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
    assertNotNull(fieldDataManager);
    panel.dataChanged(null);
    FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
    assertNull(nameField);
    assertTrue(panel.isDataPresent());
    // Reset to default value
    panel.preLoadSymbol();
}
Also used : FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) RasterSymbolizerDetails(com.sldeditor.ui.detail.RasterSymbolizerDetails) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) ShadedRelief(org.geotools.styling.ShadedRelief) FilterFactory(org.opengis.filter.FilterFactory) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) SelectedChannelType(org.geotools.styling.SelectedChannelType) RasterSymbolizer(org.geotools.styling.RasterSymbolizer) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) ContrastEnhancement(org.geotools.styling.ContrastEnhancement) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer) OverlapBehavior(org.opengis.style.OverlapBehavior) Test(org.junit.jupiter.api.Test)

Example 3 with OverlapBehavior

use of org.opengis.style.OverlapBehavior 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 = updateContrastEnhancement(gammaValueExpression);
    // Colour map
    ColorMap colorMap = updateColourMap();
    // Channel selection
    ChannelSelection channelSelection = updateEnhancementGroup();
    // 
    // Overlap
    // 
    OverlapBehavior overlapBehavior = updateOverlapBehavior();
    // 
    // Shaded relief
    // 
    ShadedRelief shadedRelief = updateShadedRelief();
    Symbolizer symbolizer = null;
    StandardData standardData = getStandardData();
    Expression opacityExpression = fieldConfigVisitor.getExpression(FieldIdEnum.RASTER_OPACITY);
    // Geometry field
    Expression geometryField = ExtractGeometryField.getGeometryField(fieldConfigVisitor);
    RasterSymbolizer rasterSymbolizer = getStyleFactory().rasterSymbolizer(standardData.getName(), geometryField, standardData.getDescription(), (standardData.getUnit() != null) ? standardData.getUnit().getUnit() : null, opacityExpression, channelSelection, overlapBehavior, colorMap, contrastEnhancement, shadedRelief, symbolizer);
    if (vendorOptionRasterFactory != null) {
        vendorOptionRasterFactory.updateSymbol(rasterSymbolizer);
    }
    rasterSymbolizer.setOverlapBehavior(overlapBehavior);
    SelectedSymbol.getInstance().replaceSymbolizer(rasterSymbolizer);
    this.fireUpdateSymbol();
}
Also used : RasterSymbolizer(org.geotools.styling.RasterSymbolizer) ContrastEnhancement(org.geotools.styling.ContrastEnhancement) Expression(org.opengis.filter.expression.Expression) ChannelSelection(org.geotools.styling.ChannelSelection) ColorMap(org.geotools.styling.ColorMap) ShadedRelief(org.geotools.styling.ShadedRelief) Symbolizer(org.geotools.styling.Symbolizer) RasterSymbolizer(org.geotools.styling.RasterSymbolizer) OverlapBehavior(org.opengis.style.OverlapBehavior)

Example 4 with OverlapBehavior

use of org.opengis.style.OverlapBehavior in project sldeditor by robward-scisys.

the class RasterSymbolizerDetails method populateOverlapBehavior.

/**
 * Populate overlap behavior.
 *
 * @param rasterSymbolizer the raster symbolizer
 */
private void populateOverlapBehavior(RasterSymbolizer rasterSymbolizer) {
    OverlapBehavior overlapBehaviour = rasterSymbolizer.getOverlapBehavior();
    GroupConfigInterface group = getGroup(GroupIdEnum.RASTER_OVERLAP);
    if (group != null) {
        group.enable(overlapBehaviour != null);
    }
    if (overlapBehaviour != null) {
        fieldConfigVisitor.populateComboBoxField(FieldIdEnum.RASTER_OVERLAP_BEHAVIOUR, overlapBehaviour.name());
    }
}
Also used : GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) OverlapBehavior(org.opengis.style.OverlapBehavior)

Aggregations

OverlapBehavior (org.opengis.style.OverlapBehavior)4 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)2 ContrastEnhancement (org.geotools.styling.ContrastEnhancement)2 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)2 ShadedRelief (org.geotools.styling.ShadedRelief)2 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)1 RasterSymbolizerDetails (com.sldeditor.ui.detail.RasterSymbolizerDetails)1 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)1 ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)1 ChannelSelection (org.geotools.styling.ChannelSelection)1 ColorMap (org.geotools.styling.ColorMap)1 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)1 NamedLayer (org.geotools.styling.NamedLayer)1 Rule (org.geotools.styling.Rule)1 SelectedChannelType (org.geotools.styling.SelectedChannelType)1 Style (org.geotools.styling.Style)1 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)1 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)1 Symbolizer (org.geotools.styling.Symbolizer)1 Test (org.junit.jupiter.api.Test)1