/** * Create a line style with given color and line width * * @param lineColor color of lines * @param width width of lines * @return a new Style instance */ public static Style createLineStyle(Color lineColor, float width) { Stroke stroke = sf.createStroke(ff.literal(lineColor), ff.literal(width)); return wrapSymbolizers(sf.createLineSymbolizer(stroke, null)); }
return wrapSymbolizers(lineSym); null); return wrapSymbolizers(lineSym, textSym);
/** * Create a polygon style with the given colors and opacity. * * @param outlineColor color of polygon outlines * @param fillColor color for the fill * @param opacity proportional opacity (0 to 1) * @return a new Style instance */ public static Style createPolygonStyle(Color outlineColor, Color fillColor, float opacity) { Stroke stroke = sf.createStroke(ff.literal(outlineColor), ff.literal(1.0f)); Fill fill = Fill.NULL; if (fillColor != null) { fill = sf.createFill(ff.literal(fillColor), ff.literal(opacity)); } return wrapSymbolizers(sf.createPolygonSymbolizer(stroke, fill, null)); }
return wrapSymbolizers(polySym); null); return wrapSymbolizers(polySym, textSym);
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); }
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 testGEOT3111() throws Exception { FilterFactory2 ff2 = CommonFactoryFinder.getFilterFactory2(null); StyleFactory sf = CommonFactoryFinder.getStyleFactory(null); Symbolizer sym = sf.createPolygonSymbolizer( Stroke.NULL, sf.createFill(ff2.literal(Color.CYAN)), null); Style style = SLD.wrapSymbolizers(sym); MapContent mc = new MapContent(); mc.addLayer(new FeatureLayer(fs, style)); StreamingRenderer renderer = new StreamingRenderer(); renderer.setMapContent(mc); renderer.setJava2DHints(new RenderingHints(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON)); RendererBaseTest.showRender("GEOT-3111", renderer, TIME, bounds); } }
return wrapSymbolizers(pointSym); null); return wrapSymbolizers(pointSym, textSym);
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); } }
/** * Create a line style with given color and line width * * @param lineColor color of lines * @param width width of lines * * @return a new Style instance */ public static Style createLineStyle(Color lineColor, float width) { Stroke stroke = sf.createStroke(ff.literal(lineColor), ff.literal(width)); return wrapSymbolizers( sf.createLineSymbolizer(stroke, null) ); }
/** * Creates the rgb style. * * @param reader the reader * @param raster the raster * @return the style */ private Style createRGBStyle(AbstractGridCoverage2DReader reader, WritableRaster raster) { RasterSymbolizer sym = sf.getDefaultRasterSymbolizer(); GridCoverage2D cov = null; try { cov = reader.read(null); } catch (IOException giveUp) { throw new RuntimeException(giveUp); } // We need at least three bands to create an RGB style int numBands = cov.getNumSampleDimensions(); if (numBands < 3) { createRGBImageSymbol(sym, cov, raster); } else { createRGBChannelSymbol(sym, cov, numBands); } return SLD.wrapSymbolizers(sym); }
/** * 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); }
/** * Create a line style with given color, line width and optional labels * * @param lineColor color of lines * @param width width of lines * * @param labelField name of the feature field (attribute) to use for labelling; * mauy be {@code null} for no labels * * @param labelFont GeoTools Font object to use for labelling; if {@code null} * and {@code labelField} is not {@code null} the default font will be * used * * @return a new Style instance */ public static Style createLineStyle(Color lineColor, float width, String labelField, Font labelFont) { Stroke stroke = sf.createStroke(ff.literal(lineColor), ff.literal(width)); LineSymbolizer lineSym = sf.createLineSymbolizer(stroke, null); if (labelField == null) { return wrapSymbolizers( lineSym ); } else { Font font = (labelFont == null ? sf.getDefaultFont() : labelFont); Fill labelFill = sf.createFill(ff.literal(Color.BLACK)); TextSymbolizer textSym = sf.createTextSymbolizer( labelFill, new Font[]{font}, null, ff.property(labelField), null, null); return wrapSymbolizers( lineSym, textSym ); } }
sym.setChannelSelection(sel); return SLD.wrapSymbolizers(sym);
/** * Create a polygon style with the given colors and opacity. * * @param outlineColor color of polygon outlines * @param fillColor color for the fill * @param opacity proportional opacity (0 to 1) * * @return a new Style instance */ public static Style createPolygonStyle(Color outlineColor, Color fillColor, float opacity) { Stroke stroke = sf.createStroke(ff.literal(outlineColor), ff.literal(1.0f)); Fill fill = Fill.NULL; if (fillColor != null) { fill = sf.createFill(ff.literal(fillColor), ff.literal(opacity)); } return wrapSymbolizers( sf.createPolygonSymbolizer(stroke, fill, null) ); }
return wrapSymbolizers( polySym ); labelFill, new Font[]{font}, null, ff.property(labelField), null, null); return wrapSymbolizers( polySym, textSym );
return wrapSymbolizers( pointSym ); labelFill, new Font[]{font}, null, ff.property(labelField), placement, null); return wrapSymbolizers( pointSym, textSym );