Package org.mapfish.print.attribute.map
Class MapfishMapContext
- java.lang.Object
-
- org.mapfish.print.attribute.map.MapfishMapContext
-
public final class MapfishMapContext extends java.lang.Object
Utility class that adjusts the bounds and the map size in case a rotation is set. Also it provides anAffineTransform
to render the layer graphics.
-
-
Constructor Summary
Constructors Constructor Description MapfishMapContext(MapBounds bounds, java.awt.Dimension mapSize, double rotation, double dpi, java.lang.Boolean forceLongitudeFirst, boolean dpiSensitiveStyle)
Constructor.MapfishMapContext(MapBounds bounds, java.awt.Dimension mapSize, double dpi, java.lang.Boolean forceLongitudeFirst, boolean dpiSensitiveStyle)
Constructor.MapfishMapContext(MapfishMapContext parent, MapBounds bounds, java.awt.Dimension mapSize, double rotation, double dpi, java.lang.Boolean forceLongitudeFirst, boolean dpiSensitiveStyle)
Constructor.MapfishMapContext(MapfishMapContext parent, MapBounds bounds, java.awt.Dimension mapSize, double dpi, java.lang.Boolean forceLongitudeFirst, boolean dpiSensitiveStyle)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MapBounds
getBounds()
double
getCenterX()
Utility method use to display the center in the report.double
getCenterY()
Utility method use to display the center in the report.double
getDPI()
double
getGeodeticScaleDenominator()
java.awt.Dimension
getMapSize()
java.awt.Rectangle
getPaintArea()
MapfishMapContext
getParentContext()
Get the parent context if there is one.MapfishMapContext
getRootContext()
Return the root context which is this context or the context found by recursively calling parent.getRootContext().MapBounds
getRotatedBounds()
Return the map bounds rotated with the set rotation.MapBounds
getRotatedBounds(java.awt.geom.Rectangle2D.Double paintAreaPrecise, java.awt.Rectangle paintArea)
Return the map bounds rotated with the set rotation.MapBounds
getRotatedBoundsAdjustedForPreciseRotatedMapSize()
Return the map bounds rotated with the set rotation.java.awt.Dimension
getRotatedMapSize()
java.awt.geom.Rectangle2D.Double
getRotatedMapSizePrecise()
double
getRotation()
double
getRotationDegree()
double
getRoundedScaleDenominator()
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.Scale
getScale()
java.awt.geom.AffineTransform
getTransform()
Returns anAffineTransform
taking the rotation into account.java.lang.Boolean
isDpiSensitiveStyle()
java.lang.Boolean
isForceLongitudeFirst()
static java.awt.Dimension
rectangleDoubleToDimension(java.awt.geom.Rectangle2D.Double rectangle)
Round the size of a rectangle with double values.org.geotools.geometry.jts.ReferencedEnvelope
toReferencedEnvelope()
Get the bounds as a referenced envelope.
-
-
-
Constructor Detail
-
MapfishMapContext
public MapfishMapContext(MapBounds bounds, java.awt.Dimension mapSize, double dpi, java.lang.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, java.awt.Dimension mapSize, double rotation, double dpi, java.lang.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, java.awt.Dimension mapSize, double dpi, java.lang.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, java.awt.Dimension mapSize, double rotation, double dpi, java.lang.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 Detail
-
rectangleDoubleToDimension
public static java.awt.Dimension rectangleDoubleToDimension(java.awt.geom.Rectangle2D.Double rectangle)
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
public MapBounds getBounds()
-
getRotatedBounds
public MapBounds getRotatedBounds()
Return the map bounds rotated with the set rotation.- Returns:
- Rotated bounds.
-
getRotatedBounds
public MapBounds getRotatedBounds(java.awt.geom.Rectangle2D.Double paintAreaPrecise, java.awt.Rectangle paintArea)
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
public MapBounds 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
public java.awt.Dimension getMapSize()
-
getScale
public Scale 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}.getRoundedScaleDenominato()
- 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
public java.awt.Dimension getRotatedMapSize()
- Returns:
- The new map size taking the rotation into account.
-
getRotatedMapSizePrecise
public java.awt.geom.Rectangle2D.Double getRotatedMapSizePrecise()
- Returns:
- The new map size taking the rotation into account.
-
getTransform
public java.awt.geom.AffineTransform getTransform()
Returns anAffineTransform
taking the rotation into account.- Returns:
- an affine transformation
-
getDPI
public double getDPI()
-
getPaintArea
public java.awt.Rectangle getPaintArea()
-
isForceLongitudeFirst
@Nullable public java.lang.Boolean isForceLongitudeFirst()
-
isDpiSensitiveStyle
public java.lang.Boolean isDpiSensitiveStyle()
-
toReferencedEnvelope
public org.geotools.geometry.jts.ReferencedEnvelope toReferencedEnvelope()
Get the bounds as a referenced envelope.- Returns:
- bounds as a referenced envelope.
-
getParentContext
@Nullable public MapfishMapContext 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
@Nonnull public MapfishMapContext getRootContext()
Return the root context which is this context or the context found by recursively calling parent.getRootContext().
-
-