public void render( Graphics2D g2d, IProgressMonitor monitor ) throws RenderException {
try {
final IRenderContext currentContext = getContext();
currentContext.setStatus(ILayer.WAIT);
CoordinateReferenceSystem destinationCRS = currentContext.getCRS();
// the bounds of the visible area in world coordinates
// get the envelope and the screen extent
Envelope envelope = getRenderBounds();
if (envelope == null || envelope.isNull()) {
envelope = context.getImageBounds();
}
Point upperLeft = currentContext.worldToPixel(new Coordinate(envelope.getMinX(), envelope.getMinY()));
Point bottomRight = currentContext.worldToPixel(new Coordinate(envelope.getMaxX(), envelope.getMaxY()));
Rectangle screenSize = new Rectangle(upperLeft);
screenSize.add(bottomRight);
final IGeoResource resource = getContext().getGeoResource();
if (resource == null || !resource.canResolve(JGrassMapGeoResource.class)) {
return;
}
JGrassMapGeoResource grassMapGeoResource = resource.resolve(JGrassMapGeoResource.class, monitor);
JGrassRegion fileWindow = new JGrassRegion(grassMapGeoResource.getFileWindow());
JGrassMapsetGeoResource parent = (JGrassMapsetGeoResource) grassMapGeoResource.parent(new NullProgressMonitor());
CoordinateReferenceSystem grassCrs = parent.getLocationCrs();
JGrassRegion screenDrawWindow = new JGrassRegion(envelope.getMinX(), envelope.getMaxX(), envelope.getMinY(),
envelope.getMaxY(), fileWindow.getRows(), fileWindow.getCols());
// to intersect with the data window, we transform the screen window
JGrassRegion reprojectedScreenDrawWindow = screenDrawWindow;