Java Code Examples for org.geotools.styling.RasterSymbolizer#setShadedRelief()

The following examples show how to use org.geotools.styling.RasterSymbolizer#setShadedRelief() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RuleRenderVisitor.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
public void visit(RasterSymbolizer raster) {
    // CHECKSTYLE:ON
    RasterSymbolizer copy = sf.createRasterSymbolizer();
    copy.setChannelSelection(copy(raster.getChannelSelection()));
    copy.setColorMap(copy(raster.getColorMap()));
    copy.setContrastEnhancement(copy(raster.getContrastEnhancement()));

    copy.setGeometry(copy(raster.getGeometry()));

    copy.setUnitOfMeasure(raster.getUnitOfMeasure());
    copy.setImageOutline(copy(raster.getImageOutline()));
    copy.setOpacity(copy(raster.getOpacity()));
    copy.setOverlap(copy(raster.getOverlap()));
    copy.setShadedRelief(copy(raster.getShadedRelief()));

    if (STRICT && !copy.equals(raster)) {
        throw new IllegalStateException("Was unable to duplicate provided raster:" + raster);
    }
    pages.push(copy);
}
 
Example 2
Source File: RasterSymbolizerDetailsTest.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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();
}