public void visit(SelectedChannelType sct) { final SelectedChannelType copy = sf.createSelectedChannelType( sct.getChannelName(), copy(sct.getContrastEnhancement())); if (STRICT && !copy.equals(sct)) { throw new IllegalStateException( "Was unable to duplicate provided SelectedChannelType:" + sct); } pages.push(copy); }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { return styleFactory.createSelectedChannelType( (Expression) node.getChildValue("SourceChannelName"), (ContrastEnhancement) node.getChildValue("ContrastEnhancement")); } }
protected SelectedChannelType copy(SelectedChannelType selectedChannelType) { if (selectedChannelType == null) return null; ContrastEnhancement enhancement = copy(selectedChannelType.getContrastEnhancement()); Expression name = (Expression) selectedChannelType.getChannelName().accept(copyFilter, null); SelectedChannelType copy = sf.createSelectedChannelType(name, enhancement); return copy; }
private RasterSymbolizer buildChannelSelectingSymbolizer(int band) { StyleBuilder sb = new StyleBuilder(); RasterSymbolizer symbolizer = sb.createRasterSymbolizer(); StyleFactory sf = sb.getStyleFactory(); symbolizer.setChannelSelection( sf.createChannelSelection( new SelectedChannelType[] { sf.createSelectedChannelType( String.valueOf(band), (ContrastEnhancement) null) })); return symbolizer; }
private Style createCoverageStyle(String bandName) { StyleFactory sf = CommonFactoryFinder.getStyleFactory(null); FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null); ContrastEnhancement ce = sf.contrastEnhancement(ff.literal(1.0), ContrastMethod.NORMALIZE); SelectedChannelType sct = sf.createSelectedChannelType(bandName, ce); RasterSymbolizer sym = sf.getDefaultRasterSymbolizer(); ChannelSelection sel = sf.channelSelection(sct); sym.setChannelSelection(sel); return SLD.wrapSymbolizers(sym); }
/** * Test SelectedChannelType copy with Expression * * @throws Exception */ @Test public void testSelectedChannelTypeDuplication() throws Exception { final String b1 = "b1"; SelectedChannelType sct = sf.createSelectedChannelType( ff.function("env", ff.literal(b1), ff.literal("1")), sf.createContrastEnhancement()); sct.accept(visitor); SelectedChannelType clone = (SelectedChannelType) visitor.getCopy(); assertEquals(sct, clone); } }
private Style createEnvCoverageStyle(String bandName) { StyleFactory sf = CommonFactoryFinder.getStyleFactory(null); FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null); ContrastEnhancement ce = sf.contrastEnhancement( ff.function("env", ff.literal("gamma"), ff.literal(1)), ContrastMethod.NORMALIZE); SelectedChannelType sct = sf.createSelectedChannelType(bandName, ce); RasterSymbolizer sym = sf.getDefaultRasterSymbolizer(); ChannelSelection sel = sf.channelSelection(sct); sym.setChannelSelection(sel); return SLD.wrapSymbolizers(sym); }
@Test public void testGrayBandSelection() throws Exception { StyleFactory factory = CommonFactoryFinder.getStyleFactory(); RasterSymbolizer r = factory.createRasterSymbolizer(); ChannelSelection sel = factory.channelSelection( factory.createSelectedChannelType( "foo", factory.createContrastEnhancement())); r.setChannelSelection(sel); StringWriter out = new StringWriter(); Ysld.encode(sld(r), out); YamlMap obj = new YamlMap(YamlUtil.getSafeYaml().load(out.toString())); YamlMap channelMap = obj.seq("feature-styles") .map(0) .seq("rules") .map(0) .seq("symbolizers") .map(0) .map("raster") .map("channels"); assertThat(channelMap, yHasEntry("gray")); assertThat(channelMap, not(yHasEntry("red"))); assertThat(channelMap, not(yHasEntry("green"))); assertThat(channelMap, not(yHasEntry("blue"))); assertThat(channelMap.map("gray"), yHasEntry("name", equalTo("foo"))); assertThat(channelMap.map("gray"), not(yHasEntry("contrast-enhancement"))); }
/** * Build a Symbolizer with ENV function ChannelName * * @param envVar * @param band * @return */ private RasterSymbolizer buildEnvChannelSelectingSymbolizer(String envVar, int band) { StyleBuilder sb = new StyleBuilder(); RasterSymbolizer symbolizer = sb.createRasterSymbolizer(); StyleFactory sf = sb.getStyleFactory(); final FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); symbolizer.setChannelSelection( sf.createChannelSelection( new SelectedChannelType[] { sf.createSelectedChannelType( ff.function("env", ff.literal(envVar), ff.literal(band)), (ContrastEnhancement) null) })); return symbolizer; }
ChannelSelection sel = styleFactory.channelSelection( styleFactory.createSelectedChannelType( "foo", styleFactory.createContrastEnhancement(
ChannelSelection sel = styleFactory.channelSelection( styleFactory.createSelectedChannelType( "foo", styleFactory.createContrastEnhancement()), styleFactory.createSelectedChannelType( "bar", styleFactory.createContrastEnhancement(filterFactory.literal(1.2))), styleFactory.createSelectedChannelType( "baz", styleFactory.createContrastEnhancement())); ((org.geotools.styling.ContrastEnhancement)
public void visit(SelectedChannelType sct) { final SelectedChannelType copy = sf.createSelectedChannelType(sct.getChannelName(), copy(sct.getContrastEnhancement())); if (STRICT && !copy.equals(sct)) { throw new IllegalStateException("Was unable to duplicate provided SelectedChannelType:" + sct); } pages.push(copy); }
/** * Test to ensure that updating the channels duplicates the raster sybmolizer with the new rgb * channels */ public void testSetRasterRGBChannels() { RasterSymbolizer rs = sb.createRasterSymbolizer(); Style s = sb.createStyle(rs); SelectedChannelType red = sf.createSelectedChannelType("red", sf.createContrastEnhancement(ff.literal(0.2))); SelectedChannelType green = sf.createSelectedChannelType( "green", sf.createContrastEnhancement(ff.literal(0.4))); SelectedChannelType blue = sf.createSelectedChannelType("blue", sf.createContrastEnhancement(ff.literal(0.7))); SLD.setChannelSelection(s, new SelectedChannelType[] {red, green, blue}, null); assertNull(SLD.rasterSymbolizer(s).getChannelSelection().getGrayChannel()); assertNotNull(SLD.rasterSymbolizer(s).getChannelSelection().getRGBChannels()); SelectedChannelType[] selectedChannels = SLD.rasterSymbolizer(s).getChannelSelection().getRGBChannels(); assertEquals("red", selectedChannels[0].getChannelName().evaluate(null, String.class)); assertEquals("green", selectedChannels[1].getChannelName().evaluate(null, String.class)); assertEquals("blue", selectedChannels[2].getChannelName().evaluate(null, String.class)); assertNotSame(SLD.rasterSymbolizer(s), rs); } }
ChannelSelection sel = factory.channelSelection( factory.createSelectedChannelType( "foo", factory.createContrastEnhancement()), factory.createSelectedChannelType( "bar", factory.createContrastEnhancement()), factory.createSelectedChannelType( "baz", factory.createContrastEnhancement())); r.setChannelSelection(sel);
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { return styleFactory.createSelectedChannelType((String) node.getChildValue( "SourceChannelName"), (ContrastEnhancement) node.getChildValue("ContrastEnhancement")); } }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { return styleFactory.createSelectedChannelType((String) node.getChildValue( "SourceChannelName"), (ContrastEnhancement) node.getChildValue("ContrastEnhancement")); } }
private Style createEnvMinMaxCoverageStyle(String bandName) { StyleFactory sf = CommonFactoryFinder.getStyleFactory(null); FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null); ContrastEnhancement ce = sf.contrastEnhancement(ff.literal(1.0), ContrastMethod.NORMALIZE); ce.addOption("algorithm", ff.literal("StretchToMinimumMaximum")); ce.addOption("minValue", ff.function("env", ff.literal("range_min"), ff.literal(0))); ce.addOption("maxValue", ff.function("env", ff.literal("range_max"), ff.literal(220))); SelectedChannelType sct = sf.createSelectedChannelType(bandName, ce); RasterSymbolizer sym = sf.getDefaultRasterSymbolizer(); ChannelSelection sel = sf.channelSelection(sct); sym.setChannelSelection(sel); return SLD.wrapSymbolizers(sym); } }
protected SelectedChannelType copy(SelectedChannelType selectedChannelType) { if( selectedChannelType == null ) return null; ContrastEnhancement enhancement = copy( selectedChannelType.getContrastEnhancement() ); String name = selectedChannelType.getChannelName(); SelectedChannelType copy = sf.createSelectedChannelType( name, enhancement); return copy; }
/** * Create a Style to display the specified band of the GeoTIFF image * as a greyscale layer. * <p> * This method is a helper for createGreyScale() and is also called directly * by the displayLayers() method when the application first starts. * * @param band the image band to use for the greyscale display * * @return a new Style instance to render the image in greyscale */ private Style createGreyscaleStyle(int band) { ContrastEnhancement ce = sf.createContrastEnhancement(); SelectedChannelType sct = sf.createSelectedChannelType(String.valueOf(band), ce); RasterSymbolizer sym = sf.getDefaultRasterSymbolizer(); ChannelSelection sel = sf.createChannelSelection(new SelectedChannelType[]{sct}); sym.setChannelSelection(sel); sym.setOpacity(new OpacityExp(0.5)); return SLD.wrapSymbolizers(sym); }
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);