org.geotools.renderer.j2d
Class RenderingContext

java.lang.Object
  extended byorg.geotools.renderer.j2d.RenderingContext
All Implemented Interfaces:
RenderingContext

Deprecated. Replaced by org.geotools.display.canvas.RenderingContext as part of the port of J2D-renderer to the new GO-1 based API. Note that it is not possible to mix J2D-renderer classes with GO-1 rendering engine. Migration from J2D-renderer to the GO-1 API will requires the replacement of all deprecated classes together. Because the new GO-1 rendering engine is a work in progress, see GEOT-776 in order to determine if enough functionalites have been ported for yours need.

public final class RenderingContext
extends java.lang.Object
implements RenderingContext

Informations relatives to a rendering in progress. A RenderingContext object is automatically created by Renderer.paint(java.awt.Graphics2D, java.awt.geom.AffineTransform, java.awt.Rectangle) at rendering time. Then the renderer iterates over layers and invokes RenderedLayer.paint(org.geotools.renderer.j2d.RenderingContext) for each of them. The rendering context is disposed once the rendering is completed. RenderingContext contains the following informations:

A rendering usually imply the following transformations (names are coordinate systems and arrows are transforms):

layerCS       mapCS       textCS       deviceCS

Version:
$Id: RenderingContext.java 17890 2006-02-06 08:46:14Z desruisseaux $
Author:
Martin Desruisseaux
See Also:
Renderer.paint(java.awt.Graphics2D, java.awt.geom.AffineTransform, java.awt.Rectangle), RenderedLayer.paint(org.geotools.renderer.j2d.RenderingContext)

Field Summary
 CoordinateSystem deviceCS
          Deprecated. Renamed as org.geotools.display.canvas.RenderingContext#deviceCRS.
 CoordinateSystem mapCS
          Deprecated. Renamed as org.geotools.display.canvas.RenderingContext#objectiveCRS.
 CoordinateSystem textCS
          Deprecated. Renamed as org.geotools.display.canvas.RenderingContext#displayCRS.
 
Method Summary
 void addPaintedArea(java.awt.Shape area)
          Deprecated. Declares that an area in graphics coordinates has been painted.
 void addPaintedArea(java.awt.Shape area, CoordinateSystem cs)
          Deprecated. Declares that an area has been painted.
 java.awt.geom.AffineTransform getAffineTransform(CoordinateSystem sourceCS, CoordinateSystem targetCS)
          Deprecated. Returns an affine transform between two coordinate systems.
 java.awt.Graphics2D getGraphics()
          Deprecated. Returns the graphics where painting occurs.
 MathTransform getMathTransform(CoordinateSystem sourceCS, CoordinateSystem targetCS)
          Deprecated. Returns a transform between two coordinate systems.
 java.awt.Shape getPaintingArea(CoordinateSystem cs)
          Deprecated. Returns the painting area in the specified coordinate system.
 float getScale()
          Deprecated. Returns the scale factor, or Float.NaN if the scale is unknow.
 boolean isPrinting()
          Deprecated. Returns true if the map is printed instead of painted on screen.
 void setCoordinateSystem(CoordinateSystem cs)
          Deprecated. Renamed as org.geotools.display.canvas.RenderingContext#setGraphicsCRS.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mapCS

public final CoordinateSystem mapCS
Deprecated. Renamed as org.geotools.display.canvas.RenderingContext#objectiveCRS.

The "real world" coordinate system for rendering. This is the coordinate system for what the user will see on the screen. Data from all RenderedLayers will be projected in this coordinate system before to be rendered. Units are usually "real world" metres.

This coordinate system is usually set once for a given Renderer and do not change anymore, except if the user want to change the projection see on screen.

See Also:
textCS, setCoordinateSystem(org.geotools.cs.CoordinateSystem)

textCS

public final CoordinateSystem textCS
Deprecated. Renamed as org.geotools.display.canvas.RenderingContext#displayCRS.

The Java2D coordinate system. Each "unit" is a dot (about 1/72 of inch). x values increase toward the right of the screen and y values increase toward the bottom of the screen. This coordinate system is appropriate for rendering text and labels.

This coordinate system may be different between two different renderings, especially if the zoom (or map scale) has changed since the last rendering.

See Also:
mapCS, deviceCS, setCoordinateSystem(org.geotools.cs.CoordinateSystem)

deviceCS

public final CoordinateSystem deviceCS
Deprecated. Renamed as org.geotools.display.canvas.RenderingContext#deviceCRS.

The device coordinate system. Each "unit" is a pixel of device-dependent size. When rendering on screen, this coordinate system is often identical to textCS, except if only a clipped area of the widget is in process of being rendered. When rendering on printer or some other devices, it depends of the device's resolution. This coordinate system is rarely used.

See Also:
textCS, setCoordinateSystem(org.geotools.cs.CoordinateSystem)
Method Detail

getGraphics

public final java.awt.Graphics2D getGraphics()
Deprecated. 
Returns the graphics where painting occurs. This graphics is initialized with an affine transform appropriate for rendering geographic features in the mapCS coordinate system. The affine transform can be changed in a convenient way with setCoordinateSystem(org.geotools.cs.CoordinateSystem).


getPaintingArea

public java.awt.Shape getPaintingArea(CoordinateSystem cs)
                               throws org.opengis.referencing.operation.TransformException
Deprecated. 
Returns the painting area in the specified coordinate system. If the coordinate system is textCS, then this method will usually returns the widget's bounds (Component.getBounds()).

Parameters:
cs - The coordinate system.
Returns:
The painting area.
Throws:
org.opengis.referencing.operation.TransformException

setCoordinateSystem

public void setCoordinateSystem(CoordinateSystem cs)
                         throws org.opengis.referencing.operation.TransformException
Deprecated. Renamed as org.geotools.display.canvas.RenderingContext#setGraphicsCRS.

Set the coordinate system in use for rendering in Graphics2D. Invoking this method do not alter the current renderer's coordinate system. It is only a convenient way to set the Graphics2D's affine transform, for example in order to alternate rendering mode between geographic features and texts. The specified coordinate system (argument cs) should be one of mapCS, textCS or deviceCS fields. Other coordinate systems may work, but most of them will thrown an exception.

Parameters:
cs - The graphics coordinate system. Should be mapCS, textCS or deviceCS.
Throws:
org.opengis.referencing.operation.TransformException - if this method failed to find an affine transform from the specified coordinate system to the device coordinate system (deviceCS).
See Also:
getGraphics(), getAffineTransform(org.geotools.cs.CoordinateSystem, org.geotools.cs.CoordinateSystem), Graphics2D.setTransform(java.awt.geom.AffineTransform)

getAffineTransform

public java.awt.geom.AffineTransform getAffineTransform(CoordinateSystem sourceCS,
                                                        CoordinateSystem targetCS)
                                                 throws CannotCreateTransformException
Deprecated. 
Returns an affine transform between two coordinate systems. This method is equivalents to the following pseudo-code, except for the exception to be thrown if the transform is not an instance of AffineTransform.
 return (AffineTransform) getMathTransform(sourceCS, targetCS);
 

Parameters:
sourceCS - The source coordinate system.
targetCS - The target coordinate system.
Returns:
An affine transform from sourceCS to targetCS.
Throws:
CannotCreateTransformException - if the transform can't be created or is not affine.
See Also:
getMathTransform(org.geotools.cs.CoordinateSystem, org.geotools.cs.CoordinateSystem), Renderer.getRenderingHint(java.awt.RenderingHints.Key), Hints.COORDINATE_TRANSFORMATION_FACTORY

getMathTransform

public MathTransform getMathTransform(CoordinateSystem sourceCS,
                                      CoordinateSystem targetCS)
                               throws CannotCreateTransformException
Deprecated. 
Returns a transform between two coordinate systems. If a Hints.COORDINATE_TRANSFORMATION_FACTORY has been provided to the Renderer, then the specified CoordinateTransformationFactory will be used. The arguments are usually (but not necessarily) one of the following pairs:

Parameters:
sourceCS - The source coordinate system.
targetCS - The target coordinate system.
Returns:
A transform from sourceCS to targetCS.
Throws:
CannotCreateTransformException - if the transformation can't be created.
See Also:
getAffineTransform(org.geotools.cs.CoordinateSystem, org.geotools.cs.CoordinateSystem), Renderer.getRenderingHint(java.awt.RenderingHints.Key), Hints.COORDINATE_TRANSFORMATION_FACTORY

isPrinting

public boolean isPrinting()
Deprecated. 
Returns true if the map is printed instead of painted on screen. When printing, layers like RenderedGridCoverage should block until all data are available instead of painting only available data and invokes RenderedLayer.repaint() later.

Specified by:
isPrinting in interface RenderingContext

addPaintedArea

public void addPaintedArea(java.awt.Shape area)
Deprecated. 
Declares that an area in graphics coordinates has been painted. The coordinate system for area should be the same than the one just used for painting in the graphics handler, which depends of the affine transform currently set. This method is equivalents to addPaintedArea(area, null).

Parameters:
area - A bounding shape of the area just painted. This shape may be approximative, as long as it completely encloses the painted area. Simple shape with fast contains(...) and intersects(...) methods are encouraged. The coordinate system is infered from the current graphics state.
See Also:
Graphics2D.getTransform(), addPaintedArea(Shape, CoordinateSystem)

getScale

public float getScale()
Deprecated. 
Returns the scale factor, or Float.NaN if the scale is unknow. The scale factor is usually smaller than 1. For example for a 1:1000 scale, the scale factor will be 0.001. This scale factor takes in account the physical size of the rendering device (e.g. the screen size) if such information is available. Note that this scale can't be more accurate than the information supplied by the underlying system.

Specified by:
getScale in interface RenderingContext
Returns:
The rendering scale factor as a number between 0 and 1, or Float.NaN.
See Also:
Renderer.getScale()

addPaintedArea

public void addPaintedArea(java.awt.Shape area,
                           CoordinateSystem cs)
                    throws org.opengis.referencing.operation.TransformException
Deprecated. 
Declares that an area has been painted. This method should be invoked from RenderedLayer.paint(org.geotools.renderer.j2d.RenderingContext) at rendering time. The Renderer uses this information in order to determine which layers need to be repainted when a screen area is damaged. If addPaintedArea(...) methods are never invoked from a particular RenderedLayer, then the renderer will assume that the painted area is unknow and conservatively repaint the full layer during subsequent rendering.

Parameters:
area - A bounding shape of the area just painted, in cs coordinate system. This shape may be approximative, as long as it completely encloses the painted area. Simple shape with fast contains(...) and intersects(...) methods are encouraged.
cs - The coordinate system for area, or null to infer it from the current graphics state.
Throws:
org.opengis.referencing.operation.TransformException - if area coordinates can't be transformed.


Copyright © GeoTools. All Rights Reserved.