Package org.mapfish.print.attribute.map
Class MapfishMapContext
java.lang.Object
org.mapfish.print.attribute.map.MapfishMapContext
Utility class that adjusts the bounds and the map size in case a rotation is set. Also, it
provides an
AffineTransform
to render the layer graphics.-
Constructor Summary
ConstructorsConstructorDescriptionMapfishMapContext
(MapBounds bounds, Dimension mapSize, double rotation, double dpi, Boolean forceLongitudeFirst, boolean dpiSensitiveStyle) Constructor.MapfishMapContext
(MapBounds bounds, Dimension mapSize, double dpi, Boolean forceLongitudeFirst, boolean dpiSensitiveStyle) Constructor.MapfishMapContext
(MapfishMapContext parent, MapBounds bounds, Dimension mapSize, double rotation, double dpi, Boolean forceLongitudeFirst, boolean dpiSensitiveStyle) Constructor.MapfishMapContext
(MapfishMapContext parent, MapBounds bounds, Dimension mapSize, double dpi, Boolean forceLongitudeFirst, boolean dpiSensitiveStyle) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiondouble
Utility method use to display the center in the report.double
Utility method use to display the center in the report.double
getDPI()
double
Get the parent context if there is one.Return the root context which is this context or the context found by recursively calling parent.getRootContext().Return the map bounds rotated with the set rotation.getRotatedBounds
(Rectangle2D.Double paintAreaPrecise, Rectangle paintArea) Return the map bounds rotated with the set rotation.Return the map bounds rotated with the set rotation.double
double
double
Get a nicely rounded scale for to use for displaying the map scale.double
getRoundedScaleDenominator
(boolean geodetic) Get a nicely rounded scale for to use for displaying the map scale.getScale()
Returns anAffineTransform
taking the rotation into account.static Dimension
rectangleDoubleToDimension
(Rectangle2D.Double rectangle) Round the size of a rectangle with double values.org.geotools.geometry.jts.ReferencedEnvelope
Get the bounds as a referenced envelope.
-
Constructor Details
-
MapfishMapContext
public MapfishMapContext(MapBounds bounds, Dimension mapSize, double dpi, Boolean forceLongitudeFirst, boolean dpiSensitiveStyle) Constructor.- Parameters:
bounds
- the map boundsmapSize
- the map sizedpi
- the dpi of the printed mapforceLongitudeFirst
- If true then force longitude coordinates as the first coordinate.dpiSensitiveStyle
- Scale the vector styles?
-
MapfishMapContext
public MapfishMapContext(MapBounds bounds, Dimension mapSize, double rotation, double dpi, Boolean forceLongitudeFirst, boolean dpiSensitiveStyle) Constructor.- Parameters:
bounds
- the map boundsmapSize
- the map sizerotation
- the rotationdpi
- the dpi of the printed mapforceLongitudeFirst
- If true then force longitude coordinates as the first coordinate.dpiSensitiveStyle
- Scale the vector styles?
-
MapfishMapContext
public MapfishMapContext(MapfishMapContext parent, MapBounds bounds, Dimension mapSize, double dpi, Boolean forceLongitudeFirst, boolean dpiSensitiveStyle) Constructor.- Parameters:
parent
- the context that this context is derived frombounds
- the map boundsmapSize
- the map sizedpi
- the dpi of the printed mapforceLongitudeFirst
- If true then force longitude coordinates as the first coordinate.dpiSensitiveStyle
- Scale the vector styles?
-
MapfishMapContext
public MapfishMapContext(MapfishMapContext parent, MapBounds bounds, Dimension mapSize, double rotation, double dpi, Boolean forceLongitudeFirst, boolean dpiSensitiveStyle) Constructor.- Parameters:
parent
- the context that this context is derived frombounds
- the map boundsmapSize
- the map sizerotation
- the rotationdpi
- the dpi of the printed mapforceLongitudeFirst
- If true then force longitude coordinates as the first coordinate.dpiSensitiveStyle
- Scale the vector styles?
-
-
Method Details
-
rectangleDoubleToDimension
Round the size of a rectangle with double values.- Parameters:
rectangle
- The rectangle.
-
getRotation
public double getRotation()- Returns:
- The rotation in radians.
-
getRotationDegree
public double getRotationDegree()- Returns:
- The rotation in degree.
-
getBounds
-
getRotatedBounds
Return the map bounds rotated with the set rotation.- Returns:
- Rotated bounds.
-
getRotatedBounds
Return the map bounds rotated with the set rotation. The bounds are adapted to rounding changes of the size of the paint area.- Parameters:
paintAreaPrecise
- The exact size of the paint area.paintArea
- The rounded size of the paint area.- Returns:
- Rotated bounds.
-
getRotatedBoundsAdjustedForPreciseRotatedMapSize
Return the map bounds rotated with the set rotation. The bounds are adapted to rounding changes of the size of the set paint area.- Returns:
- Rotated bounds.
-
getMapSize
-
getScale
-
getGeodeticScaleDenominator
public double getGeodeticScaleDenominator() -
getRoundedScaleDenominator
public double getRoundedScaleDenominator()Get a nicely rounded scale for to use for displaying the map scale.One of the output parameters of the
CreateMapProcessor
is 'mapContext' which can be accessed in a template. If the scale is required in the template then it can be accessed via:$P{mapContext}.getRoundedScaleDenominator()
-
getRoundedScaleDenominator
public double getRoundedScaleDenominator(boolean geodetic) Get a nicely rounded scale for to use for displaying the map scale.One of the output parameters of the
CreateMapProcessor
is 'mapContext' which can be accessed in a template. If the scale is required in the template then it can be accessed via:$P{mapContext}.getRoundedScaleDenominator()
- Parameters:
geodetic
- Get geodetic scale
-
getCenterX
public double getCenterX()Utility method use to display the center in the report.- Returns:
- the center X
-
getCenterY
public double getCenterY()Utility method use to display the center in the report.- Returns:
- the center Y
-
getRotatedMapSize
- Returns:
- The new map size taking the rotation into account.
-
getRotatedMapSizePrecise
- Returns:
- The new map size taking the rotation into account.
-
getTransform
Returns anAffineTransform
taking the rotation into account.- Returns:
- an affine transformation
-
getDPI
public double getDPI() -
getPaintArea
-
isForceLongitudeFirst
-
isDpiSensitiveStyle
-
toReferencedEnvelope
public org.geotools.geometry.jts.ReferencedEnvelope toReferencedEnvelope()Get the bounds as a referenced envelope.- Returns:
- bounds as a referenced envelope.
-
getParentContext
Get the parent context if there is one. A parent context is the context that this context is derived from. Normally there are some parameters that have been changed for this context from the parent. An example of when there might be a parent is when the child has been rotated and has a bounds to envelope the original bounds. It can be useful in some cases to be able to access the parent (and original bounds).- Returns:
- the parent context or null if there is no parent.
-
getRootContext
Return the root context which is this context or the context found by recursively calling parent.getRootContext().
-