Java Code Examples for org.geotools.styling.RasterSymbolizer#setChannelSelection()
The following examples show how to use
org.geotools.styling.RasterSymbolizer#setChannelSelection() .
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 |
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: RasterReader.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Creates the RGB channel symbol. * * @param sym the sym * @param cov the cov * @param numBands the num bands */ private void createRGBChannelSymbol(RasterSymbolizer sym, GridCoverage2D cov, int numBands) { // Get the names of the bands String[] sampleDimensionNames = new String[numBands]; for (int i = 0; i < numBands; i++) { GridSampleDimension dim = cov.getSampleDimension(i); sampleDimensionNames[i] = dim.getDescription().toString(); } final int RED = 0; final int GREEN = 1; final int BLUE = 2; int[] channelNum = {-1, -1, -1}; // We examine the band names looking for "red...", "green...", "blue...". // Note that the channel numbers we record are indexed from 1, not 0. for (int i = 0; i < numBands; i++) { String name = sampleDimensionNames[i].toLowerCase(); if (name != null) { if (name.matches("red.*")) { channelNum[RED] = i + 1; } else if (name.matches("green.*")) { channelNum[GREEN] = i + 1; } else if (name.matches("blue.*")) { channelNum[BLUE] = i + 1; } } } // If we didn't find named bands "red...", "green...", "blue..." // we fall back to using the first three bands in order if (channelNum[RED] < 0 || channelNum[GREEN] < 0 || channelNum[BLUE] < 0) { channelNum[RED] = 1; channelNum[GREEN] = 2; channelNum[BLUE] = 3; } // Now we create a RasterSymbolizer using the selected channels SelectedChannelType[] sct = new SelectedChannelType[cov.getNumSampleDimensions()]; ContrastEnhancement ce = sf.contrastEnhancement(ff.literal(1.0), ContrastMethod.NORMALIZE); for (int i = 0; i < 3; i++) { sct[i] = sf.createSelectedChannelType(String.valueOf(channelNum[i]), ce); } ChannelSelection sel = sf.channelSelection(sct[RED], sct[GREEN], sct[BLUE]); sym.setChannelSelection(sel); }
Example 3
Source File: RasterSymbolizerDetailsTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * 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 testRasterSymbolizerDetailsGreyChannel() { 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); RasterSymbolizer symbolizer = DefaultSymbols.createDefaultRasterSymbolizer(); StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory(); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); ContrastEnhancement contrastEnhancement = (ContrastEnhancement) styleFactory.contrastEnhancement(ff.literal(.5), "ramp"); SelectedChannelType greyChannel = styleFactory.createSelectedChannelType("grey", contrastEnhancement); symbolizer.setChannelSelection(styleFactory.channelSelection(greyChannel)); String expectedNameValue = "symbolizer test value"; symbolizer.setName(expectedNameValue); 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(); }
Example 4
Source File: RasterSymbolizerDetailsTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * 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(); }
Example 5
Source File: VOGeoServerContrastEnhancementNormalizeGreyTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeGrey#VOGeoServerContrastEnhancementNormalizeGrey(java.lang.Class, * com.sldeditor.ui.detail.RasterSymbolizerDetails)}. Test method for {@link * com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeGrey#getContrastEnhancement(com.sldeditor.common.xml.ui.GroupIdEnum, * org.geotools.styling.ChannelSelection)}. */ @Test public void testVOGeoServerContrastEnhancementNormalizeGrey() { RasterSymbolizerDetails panel = new RasterSymbolizerDetails(); VOGeoServerContrastEnhancementNormalizeGrey testObj = new VOGeoServerContrastEnhancementNormalizeGrey(panel.getClass(), panel); RasterSymbolizer rasterSymbolizer = null; testObj.setParentPanel(panel); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory(); rasterSymbolizer = styleFactory.createRasterSymbolizer(); GroupConfigInterface constrastMethodGroup = panel.getGroup(GroupIdEnum.RASTER_RGB_CHANNEL_GREY_CONTRAST_METHOD); assertNotNull(constrastMethodGroup); MultiOptionGroup constrastMethodGroup2 = (MultiOptionGroup) constrastMethodGroup; Box box = Box.createVerticalBox(); constrastMethodGroup2.createUI(panel.getFieldDataManager(), box, panel, panel.getPanelId()); constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_LOGARITHMIC); ChannelSelection channelSelection = createChannelSelection(styleFactory, ContrastMethod.LOGARITHMIC); rasterSymbolizer.setChannelSelection(channelSelection); testObj.populate(rasterSymbolizer); SelectedSymbol.getInstance().setSymbolizer(rasterSymbolizer); Controller.getInstance().setPopulating(true); panel.populate(SelectedSymbol.getInstance()); Controller.getInstance().setPopulating(false); testObj.updateSymbol(rasterSymbolizer); channelSelection = createChannelSelection(styleFactory, ContrastMethod.EXPONENTIAL); rasterSymbolizer.setChannelSelection(channelSelection); constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_EXPONENTIAL); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); channelSelection = createChannelSelection(styleFactory, ContrastMethod.HISTOGRAM); rasterSymbolizer.setChannelSelection(channelSelection); constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_HISTOGRAM); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); channelSelection = createChannelSelection(styleFactory, ContrastMethod.NORMALIZE); constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_NORMALIZE); rasterSymbolizer.setChannelSelection(channelSelection); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); // Error channelSelection = createChannelSelectionError(styleFactory, ContrastMethod.NORMALIZE); rasterSymbolizer.setChannelSelection(channelSelection); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); // Increase code coverage testObj.populate((SelectedSymbol) null); testObj.populate((TextSymbolizer) null); testObj.populate((PolygonSymbolizer) null); testObj.updateSymbol((TextSymbolizer) null); testObj.updateSymbol((PolygonSymbolizer) null); testObj.preLoadSymbol(); assertTrue(testObj.isDataPresent()); testObj.dataChanged(FieldIdEnum.DESCRIPTION); }
Example 6
Source File: VOGeoServerContrastEnhancementNormalizeOverallTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeOverall#VOGeoServerContrastEnhancementNormalizeOverall(java.lang.Class, * com.sldeditor.ui.detail.RasterSymbolizerDetails)}. Test method for {@link * com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeOverall#getContrastEnhancement(com.sldeditor.common.xml.ui.GroupIdEnum, * org.geotools.styling.ChannelSelection)}. */ @Test public void testVOGeoServerContrastEnhancementNormalizeOverall() { RasterSymbolizerDetails panel = new RasterSymbolizerDetails(); VOGeoServerContrastEnhancementNormalizeOverall testObj = new VOGeoServerContrastEnhancementNormalizeOverall(panel.getClass(), panel); RasterSymbolizer rasterSymbolizer = null; testObj.setParentPanel(panel); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory(); rasterSymbolizer = styleFactory.createRasterSymbolizer(); GroupConfigInterface constrastMethodGroup = panel.getGroup(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD); assertNotNull(constrastMethodGroup); MultiOptionGroup constrastMethodGroup2 = (MultiOptionGroup) constrastMethodGroup; Box box = Box.createVerticalBox(); constrastMethodGroup2.createUI(panel.getFieldDataManager(), box, panel, panel.getPanelId()); constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_LOGARITHMIC); ChannelSelection channelSelection = createChannelSelection(styleFactory, ContrastMethod.LOGARITHMIC); rasterSymbolizer.setChannelSelection(channelSelection); testObj.populate(rasterSymbolizer); SelectedSymbol.getInstance().setSymbolizer(rasterSymbolizer); Controller.getInstance().setPopulating(true); panel.populate(SelectedSymbol.getInstance()); Controller.getInstance().setPopulating(false); testObj.updateSymbol(rasterSymbolizer); channelSelection = createChannelSelection(styleFactory, ContrastMethod.EXPONENTIAL); rasterSymbolizer.setChannelSelection(channelSelection); constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_EXPONENTIAL); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); channelSelection = createChannelSelection(styleFactory, ContrastMethod.HISTOGRAM); rasterSymbolizer.setChannelSelection(channelSelection); constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_HISTOGRAM); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); channelSelection = createChannelSelection(styleFactory, ContrastMethod.NORMALIZE); constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_NORMALIZE); rasterSymbolizer.setChannelSelection(channelSelection); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); // Error channelSelection = createChannelSelectionError(styleFactory, ContrastMethod.NORMALIZE); rasterSymbolizer.setChannelSelection(channelSelection); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); // Increase code coverage testObj.populate((SelectedSymbol) null); testObj.populate((TextSymbolizer) null); testObj.populate((PolygonSymbolizer) null); testObj.updateSymbol((TextSymbolizer) null); testObj.updateSymbol((PolygonSymbolizer) null); testObj.preLoadSymbol(); assertTrue(testObj.isDataPresent()); testObj.dataChanged(FieldIdEnum.DESCRIPTION); }
Example 7
Source File: VOGeoServerContrastEnhancementNormalizeGreenTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeGreen#VOGeoServerContrastEnhancementNormalizeGreen(java.lang.Class, * com.sldeditor.ui.detail.RasterSymbolizerDetails)}. Test method for {@link * com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeGreen#getContrastEnhancement(com.sldeditor.common.xml.ui.GroupIdEnum, * org.geotools.styling.ChannelSelection)}. */ @Test public void testVOGeoServerContrastEnhancementNormalizeGreen() { RasterSymbolizerDetails panel = new RasterSymbolizerDetails(); VOGeoServerContrastEnhancementNormalizeGreen testObj = new VOGeoServerContrastEnhancementNormalizeGreen(panel.getClass(), panel); RasterSymbolizer rasterSymbolizer = null; testObj.setParentPanel(panel); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory(); rasterSymbolizer = styleFactory.createRasterSymbolizer(); GroupConfigInterface constrastMethodGroup = panel.getGroup(GroupIdEnum.RASTER_RGB_CHANNEL_GREEN_CONTRAST_METHOD); assertNotNull(constrastMethodGroup); MultiOptionGroup constrastMethodGroup2 = (MultiOptionGroup) constrastMethodGroup; Box box = Box.createVerticalBox(); constrastMethodGroup2.createUI(panel.getFieldDataManager(), box, panel, panel.getPanelId()); constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_LOGARITHMIC); ChannelSelection channelSelection = createChannelSelection(styleFactory, ContrastMethod.LOGARITHMIC); rasterSymbolizer.setChannelSelection(channelSelection); testObj.populate(rasterSymbolizer); SelectedSymbol.getInstance().setSymbolizer(rasterSymbolizer); Controller.getInstance().setPopulating(true); panel.populate(SelectedSymbol.getInstance()); Controller.getInstance().setPopulating(false); testObj.updateSymbol(rasterSymbolizer); channelSelection = createChannelSelection(styleFactory, ContrastMethod.EXPONENTIAL); rasterSymbolizer.setChannelSelection(channelSelection); constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_EXPONENTIAL); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); channelSelection = createChannelSelection(styleFactory, ContrastMethod.HISTOGRAM); rasterSymbolizer.setChannelSelection(channelSelection); constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_HISTOGRAM); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); channelSelection = createChannelSelection(styleFactory, ContrastMethod.NORMALIZE); constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_NORMALIZE); rasterSymbolizer.setChannelSelection(channelSelection); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); // Error channelSelection = createChannelSelectionError(styleFactory, ContrastMethod.NORMALIZE); rasterSymbolizer.setChannelSelection(channelSelection); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); // Increase code coverage testObj.populate((SelectedSymbol) null); testObj.populate((TextSymbolizer) null); testObj.populate((PolygonSymbolizer) null); testObj.updateSymbol((TextSymbolizer) null); testObj.updateSymbol((PolygonSymbolizer) null); testObj.preLoadSymbol(); assertTrue(testObj.isDataPresent()); testObj.dataChanged(FieldIdEnum.DESCRIPTION); }
Example 8
Source File: VOGeoServerContrastEnhancementNormalizeRedTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeRed#VOGeoServerContrastEnhancementNormalizeRed(java.lang.Class, * com.sldeditor.ui.detail.RasterSymbolizerDetails)}. Test method for {@link * com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeRed#getContrastEnhancement(com.sldeditor.common.xml.ui.GroupIdEnum, * org.geotools.styling.ChannelSelection)}. */ @Test public void testVOGeoServerContrastEnhancementNormalizeRed() { RasterSymbolizerDetails panel = new RasterSymbolizerDetails(); VOGeoServerContrastEnhancementNormalizeRed testObj = new VOGeoServerContrastEnhancementNormalizeRed(panel.getClass(), panel); RasterSymbolizer rasterSymbolizer = null; testObj.setParentPanel(panel); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory(); rasterSymbolizer = styleFactory.createRasterSymbolizer(); GroupConfigInterface constrastMethodGroup = panel.getGroup(GroupIdEnum.RASTER_RGB_CHANNEL_RED_CONTRAST_METHOD); assertNotNull(constrastMethodGroup); MultiOptionGroup constrastMethodGroup2 = (MultiOptionGroup) constrastMethodGroup; Box box = Box.createVerticalBox(); constrastMethodGroup2.createUI(panel.getFieldDataManager(), box, panel, panel.getPanelId()); constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_LOGARITHMIC); ChannelSelection channelSelection = createChannelSelection(styleFactory, ContrastMethod.LOGARITHMIC); rasterSymbolizer.setChannelSelection(channelSelection); testObj.populate(rasterSymbolizer); SelectedSymbol.getInstance().setSymbolizer(rasterSymbolizer); Controller.getInstance().setPopulating(true); panel.populate(SelectedSymbol.getInstance()); Controller.getInstance().setPopulating(false); testObj.updateSymbol(rasterSymbolizer); channelSelection = createChannelSelection(styleFactory, ContrastMethod.EXPONENTIAL); rasterSymbolizer.setChannelSelection(channelSelection); constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_EXPONENTIAL); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); channelSelection = createChannelSelection(styleFactory, ContrastMethod.HISTOGRAM); rasterSymbolizer.setChannelSelection(channelSelection); constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_HISTOGRAM); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); channelSelection = createChannelSelection(styleFactory, ContrastMethod.NORMALIZE); constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_NORMALIZE); rasterSymbolizer.setChannelSelection(channelSelection); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); // Error channelSelection = createChannelSelectionError(styleFactory, ContrastMethod.NORMALIZE); rasterSymbolizer.setChannelSelection(channelSelection); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); // Increase code coverage testObj.populate((SelectedSymbol) null); testObj.populate((TextSymbolizer) null); testObj.populate((PolygonSymbolizer) null); testObj.updateSymbol((TextSymbolizer) null); testObj.updateSymbol((PolygonSymbolizer) null); testObj.preLoadSymbol(); assertTrue(testObj.isDataPresent()); testObj.dataChanged(FieldIdEnum.DESCRIPTION); }
Example 9
Source File: VOGeoServerContrastEnhancementNormalizeBlueTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test method for {@link * com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeBlue#VOGeoServerContrastEnhancementNormalizeBlue(java.lang.Class, * com.sldeditor.ui.detail.RasterSymbolizerDetails)}. Test method for {@link * com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeBlue#getContrastEnhancement(com.sldeditor.common.xml.ui.GroupIdEnum, * org.geotools.styling.ChannelSelection)}. */ @Test public void testVOGeoServerContrastEnhancementNormalizeBlue() { RasterSymbolizerDetails panel = new RasterSymbolizerDetails(); VOGeoServerContrastEnhancementNormalizeBlue testObj = new VOGeoServerContrastEnhancementNormalizeBlue(panel.getClass(), panel); RasterSymbolizer rasterSymbolizer = null; testObj.setParentPanel(panel); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory(); rasterSymbolizer = styleFactory.createRasterSymbolizer(); GroupConfigInterface constrastMethodGroup = panel.getGroup(GroupIdEnum.RASTER_RGB_CHANNEL_BLUE_CONTRAST_METHOD); assertNotNull(constrastMethodGroup); MultiOptionGroup constrastMethodGroup2 = (MultiOptionGroup) constrastMethodGroup; Box box = Box.createVerticalBox(); constrastMethodGroup2.createUI(panel.getFieldDataManager(), box, panel, panel.getPanelId()); constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_LOGARITHMIC); ChannelSelection channelSelection = createChannelSelection(styleFactory, ContrastMethod.LOGARITHMIC); rasterSymbolizer.setChannelSelection(channelSelection); testObj.populate(rasterSymbolizer); SelectedSymbol.getInstance().setSymbolizer(rasterSymbolizer); Controller.getInstance().setPopulating(true); panel.populate(SelectedSymbol.getInstance()); Controller.getInstance().setPopulating(false); testObj.updateSymbol(rasterSymbolizer); channelSelection = createChannelSelection(styleFactory, ContrastMethod.EXPONENTIAL); rasterSymbolizer.setChannelSelection(channelSelection); constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_EXPONENTIAL); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); channelSelection = createChannelSelection(styleFactory, ContrastMethod.HISTOGRAM); rasterSymbolizer.setChannelSelection(channelSelection); constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_HISTOGRAM); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); channelSelection = createChannelSelection(styleFactory, ContrastMethod.NORMALIZE); constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_NORMALIZE); rasterSymbolizer.setChannelSelection(channelSelection); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); // Error channelSelection = createChannelSelectionError(styleFactory, ContrastMethod.NORMALIZE); rasterSymbolizer.setChannelSelection(channelSelection); testObj.populate(rasterSymbolizer); testObj.updateSymbol(rasterSymbolizer); // Increase code coverage testObj.populate((SelectedSymbol) null); testObj.populate((TextSymbolizer) null); testObj.populate((PolygonSymbolizer) null); testObj.updateSymbol((TextSymbolizer) null); testObj.updateSymbol((PolygonSymbolizer) null); testObj.preLoadSymbol(); assertTrue(testObj.isDataPresent()); testObj.dataChanged(FieldIdEnum.DESCRIPTION); }