Class GridCoverageRenderer
Object
GridCoverageRenderer
A helper class for rendering
GridCoverage objects.- Author:
- Simone Giannecchini, GeoSolutions SAS, Andrea Aime, GeoSolutions SAS, Alessio Fabiani, GeoSolutions SAS
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGridCoverageRenderer(CoordinateReferenceSystem destinationCRS, Envelope envelope, Rectangle screenSize, AffineTransform worldToScreen) Creates a newGridCoverageRendererobject.GridCoverageRenderer(CoordinateReferenceSystem destinationCRS, Envelope envelope, Rectangle screenSize, AffineTransform worldToScreen, RenderingHints newHints) Creates a newGridCoverageRendererobject. -
Method Summary
Modifier and TypeMethodDescriptionbooleanTests if advanced projection handling is enabled (read all areas needed to make up the requested map, cut them to areas where reprojection makes sense, and so on).static booleanisBandsSelectionApplicable(GridCoverageReader reader, RasterSymbolizer symbolizer) Checks if band selection is present, and can be delegated down to the readerbooleanbooleanReturns true if map wrapping is enabled (active only when rendering off aGridCoverage2DReaderand when advanced projection handling has been enabled too)voidpaint(Graphics2D graphics, GridCoverage2D gridCoverage, RasterSymbolizer symbolizer) Paint this grid coverage.voidpaint(Graphics2D graphics, GridCoverage2D gridCoverage, RasterSymbolizer symbolizer, double[] bkgValues) Paint this grid coverage.voidpaint(Graphics2D graphics, GridCoverage2DReader gridCoverageReader, GeneralParameterValue[] readParams, RasterSymbolizer symbolizer, Interpolation interpolation, Color background) Paint the coverage read from the reader (using advanced projection handling).renderImage(GridCoverage2D gridCoverage, RasterSymbolizer symbolizer, double[] bkgValues) Turns the coverage into a rendered image applying the necessary transformations and the symbolizerrenderImage(GridCoverage2D gridCoverage, RasterSymbolizer symbolizer, Interpolation interpolation, Color background, int tileSizeX, int tileSizeY) Turns the coverage into a rendered image applying the necessary transformations and the symbolizerrenderImage(GridCoverage2DReader reader, GeneralParameterValue[] readParams, RasterSymbolizer symbolizer, Interpolation interpolation, Color background, int tileSizeX, int tileSizeY) voidsetAdvancedProjectionHandlingEnabled(boolean enabled) Enables/disables advanced projection handling (read all areas needed to make up the requested map, cut them to areas where reprojection makes sense, and so on).voidsetOversample(boolean oversample) static RasterSymbolizersetupSymbolizerForBandsSelection(RasterSymbolizer symbolizer) Takes into account that the band selection has been delegated down to the reader by producing a new channel selectionvoidsetWrapEnabled(boolean wrapEnabled) Enables/disable map wrapping (active only when rendering off aGridCoverage2DReaderand when advanced projection handling has been enabled too)
-
Field Details
-
PARENT_COVERAGE_PROPERTY
- See Also:
-
PADDING
Hint's KEY specifying a custom padding -
KEY_COMPOSITING
- See Also:
-
-
Constructor Details
-
GridCoverageRenderer
public GridCoverageRenderer(CoordinateReferenceSystem destinationCRS, Envelope envelope, Rectangle screenSize, AffineTransform worldToScreen) throws TransformException, NoninvertibleTransformException Creates a newGridCoverageRendererobject.- Parameters:
destinationCRS- the CRS of theGridCoverage2Dto render.envelope- delineating the area to be rendered.screenSize- at which we want to render the sourceGridCoverage2D.worldToScreen- if notnulland if it contains a rotation, this Affine Transform is used directly to convert from world coordinates to screen coordinates. Otherwise, a standardGridToEnvelopeMapperis used to calculate the affine transform.- Throws:
TransformExceptionNoninvertibleTransformException
-
GridCoverageRenderer
public GridCoverageRenderer(CoordinateReferenceSystem destinationCRS, Envelope envelope, Rectangle screenSize, AffineTransform worldToScreen, RenderingHints newHints) throws TransformException, NoninvertibleTransformException Creates a newGridCoverageRendererobject.- Parameters:
destinationCRS- the CRS of theGridCoverage2Dto render.envelope- delineating the area to be rendered.screenSize- at which we want to render the sourceGridCoverage2D.worldToScreen- if notnulland if it contains a rotation, this Affine Transform is used directly to convert from world coordinates to screen coordinates. Otherwise, a standardGridToEnvelopeMapperis used to calculate the affine transform.newHints-RenderingHintsto control this rendering process.- Throws:
TransformExceptionNoninvertibleTransformException
-
-
Method Details
-
isOversample
public boolean isOversample() -
setOversample
public void setOversample(boolean oversample) -
setWrapEnabled
public void setWrapEnabled(boolean wrapEnabled) Enables/disable map wrapping (active only when rendering off aGridCoverage2DReaderand when advanced projection handling has been enabled too) -
isWrapEnabled
public boolean isWrapEnabled()Returns true if map wrapping is enabled (active only when rendering off aGridCoverage2DReaderand when advanced projection handling has been enabled too) -
setAdvancedProjectionHandlingEnabled
public void setAdvancedProjectionHandlingEnabled(boolean enabled) Enables/disables advanced projection handling (read all areas needed to make up the requested map, cut them to areas where reprojection makes sense, and so on). Works only when rendering off aGridCoverage2DReader. -
isAdvancedProjectionHandlingEnabled
public boolean isAdvancedProjectionHandlingEnabled()Tests if advanced projection handling is enabled (read all areas needed to make up the requested map, cut them to areas where reprojection makes sense, and so on). Works only when rendering off aGridCoverage2DReader. -
renderImage
public RenderedImage renderImage(GridCoverage2D gridCoverage, RasterSymbolizer symbolizer, double[] bkgValues) throws Exception Turns the coverage into a rendered image applying the necessary transformations and the symbolizerBuilds a (RenderedImage, AffineTransform) pair that can be used for rendering onto a
Graphics2Dor as the basis to build a final image. Will return null if there is nothing to render.- Returns:
- The transformed image, or null if the coverage does not lie within the rendering bounds
- Throws:
Exception
-
renderImage
public RenderedImage renderImage(GridCoverage2D gridCoverage, RasterSymbolizer symbolizer, Interpolation interpolation, Color background, int tileSizeX, int tileSizeY) throws FactoryException, TransformException, NoninvertibleTransformException Turns the coverage into a rendered image applying the necessary transformations and the symbolizer- Returns:
- The transformed image, or null if the coverage does not lie within the rendering bounds
- Throws:
FactoryExceptionTransformExceptionNoninvertibleTransformException
-
renderImage
public RenderedImage renderImage(GridCoverage2DReader reader, GeneralParameterValue[] readParams, RasterSymbolizer symbolizer, Interpolation interpolation, Color background, int tileSizeX, int tileSizeY) throws FactoryException, TransformException, NoninvertibleTransformException, IOException -
paint
public void paint(Graphics2D graphics, GridCoverage2D gridCoverage, RasterSymbolizer symbolizer) throws Exception Paint this grid coverage. The caller must ensure thatgraphicshas an affine transform mapping "real world" coordinates in the coordinate system given by- Parameters:
graphics- theGraphics2Dcontext in which to paint.- Throws:
UnsupportedOperationException- if the transformation from grid to coordinate system in the GridCoverage is not an AffineTransformException
-
paint
public void paint(Graphics2D graphics, GridCoverage2D gridCoverage, RasterSymbolizer symbolizer, double[] bkgValues) throws Exception Paint this grid coverage. The caller must ensure thatgraphicshas an affine transform mapping "real world" coordinates in the coordinate system given by#getCoordinateSystem.- Parameters:
graphics- theGraphics2Dcontext in which to paint.- Throws:
UnsupportedOperationException- if the transformation from grid to coordinate system in the GridCoverage is not an AffineTransformException
-
paint
public void paint(Graphics2D graphics, GridCoverage2DReader gridCoverageReader, GeneralParameterValue[] readParams, RasterSymbolizer symbolizer, Interpolation interpolation, Color background) throws Exception Paint the coverage read from the reader (using advanced projection handling). The caller must ensure thatgraphicshas an affine transform mapping "real world" coordinates in the coordinate system given by#getCoordinateSystem.- Parameters:
graphics- theGraphics2Dcontext in which to paint.- Throws:
UnsupportedOperationException- if the transformation from grid to coordinate system in the GridCoverage is not an AffineTransformException
-
setupSymbolizerForBandsSelection
Takes into account that the band selection has been delegated down to the reader by producing a new channel selection -
isBandsSelectionApplicable
public static boolean isBandsSelectionApplicable(GridCoverageReader reader, RasterSymbolizer symbolizer) Checks if band selection is present, and can be delegated down to the reader
-