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 newGridCoverageRenderer
object.GridCoverageRenderer
(CoordinateReferenceSystem destinationCRS, Envelope envelope, Rectangle screenSize, AffineTransform worldToScreen, RenderingHints newHints) Creates a newGridCoverageRenderer
object. -
Method Summary
Modifier and TypeMethodDescriptionboolean
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).static boolean
isBandsSelectionApplicable
(GridCoverageReader reader, RasterSymbolizer symbolizer) Checks if band selection is present, and can be delegated down to the readerboolean
boolean
Returns true if map wrapping is enabled (active only when rendering off aGridCoverage2DReader
and when advanced projection handling has been enabled too)void
paint
(Graphics2D graphics, GridCoverage2D gridCoverage, RasterSymbolizer symbolizer) Paint this grid coverage.void
paint
(Graphics2D graphics, GridCoverage2D gridCoverage, RasterSymbolizer symbolizer, double[] bkgValues) Paint this grid coverage.void
paint
(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) 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).void
setOversample
(boolean oversample) static RasterSymbolizer
setupSymbolizerForBandsSelection
(RasterSymbolizer symbolizer) Takes into account that the band selection has been delegated down to the reader by producing a new channel selectionvoid
setWrapEnabled
(boolean wrapEnabled) Enables/disable map wrapping (active only when rendering off aGridCoverage2DReader
and 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 newGridCoverageRenderer
object.- Parameters:
destinationCRS
- the CRS of theGridCoverage2D
to render.envelope
- delineating the area to be rendered.screenSize
- at which we want to render the sourceGridCoverage2D
.worldToScreen
- if notnull
and if it contains a rotation, this Affine Transform is used directly to convert from world coordinates to screen coordinates. Otherwise, a standardGridToEnvelopeMapper
is used to calculate the affine transform.- Throws:
TransformException
NoninvertibleTransformException
-
GridCoverageRenderer
public GridCoverageRenderer(CoordinateReferenceSystem destinationCRS, Envelope envelope, Rectangle screenSize, AffineTransform worldToScreen, RenderingHints newHints) throws TransformException, NoninvertibleTransformException Creates a newGridCoverageRenderer
object.- Parameters:
destinationCRS
- the CRS of theGridCoverage2D
to render.envelope
- delineating the area to be rendered.screenSize
- at which we want to render the sourceGridCoverage2D
.worldToScreen
- if notnull
and if it contains a rotation, this Affine Transform is used directly to convert from world coordinates to screen coordinates. Otherwise, a standardGridToEnvelopeMapper
is used to calculate the affine transform.newHints
-RenderingHints
to control this rendering process.- Throws:
TransformException
NoninvertibleTransformException
-
-
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 aGridCoverage2DReader
and when advanced projection handling has been enabled too) -
isWrapEnabled
public boolean isWrapEnabled()Returns true if map wrapping is enabled (active only when rendering off aGridCoverage2DReader
and 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
Graphics2D
or 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:
FactoryException
TransformException
NoninvertibleTransformException
-
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 thatgraphics
has an affine transform mapping "real world" coordinates in the coordinate system given by- Parameters:
graphics
- theGraphics2D
context 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 thatgraphics
has an affine transform mapping "real world" coordinates in the coordinate system given by#getCoordinateSystem
.- Parameters:
graphics
- theGraphics2D
context 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 thatgraphics
has an affine transform mapping "real world" coordinates in the coordinate system given by#getCoordinateSystem
.- Parameters:
graphics
- theGraphics2D
context 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
-