Class GridCoverageRenderer
- Object
-
- GridCoverageRenderer
-
public final class GridCoverageRenderer extends Object
A helper class for renderingGridCoverage
objects.- Author:
- Simone Giannecchini, GeoSolutions SAS, Andrea Aime, GeoSolutions SAS, Alessio Fabiani, GeoSolutions SAS
-
-
Field Summary
Fields Modifier and Type Field Description static String
KEY_COMPOSITING
static Hints.Key
PADDING
Hint's KEY specifying a custom paddingstatic String
PARENT_COVERAGE_PROPERTY
-
Constructor Summary
Constructors Constructor Description GridCoverageRenderer(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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).static boolean
isBandsSelectionApplicable(GridCoverageReader reader, RasterSymbolizer symbolizer)
Checks if band selection is present, and can be delegated down to the readerboolean
isWrapEnabled()
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).RenderedImage
renderImage(GridCoverage2D gridCoverage, RasterSymbolizer symbolizer, double[] bkgValues)
Turns the coverage into a rendered image applying the necessary transformations and the symbolizerRenderedImage
renderImage(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 symbolizerRenderedImage
renderImage(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).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 Detail
-
PARENT_COVERAGE_PROPERTY
public static final String PARENT_COVERAGE_PROPERTY
- See Also:
- Constant Field Values
-
PADDING
public static final Hints.Key PADDING
Hint's KEY specifying a custom padding
-
KEY_COMPOSITING
public static final String KEY_COMPOSITING
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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 Detail
-
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
public static RasterSymbolizer setupSymbolizerForBandsSelection(RasterSymbolizer symbolizer)
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
-
-