Class ScalebarGraphic
java.lang.Object
org.mapfish.print.processor.map.scalebar.ScalebarGraphic
Creates a scalebar graphic.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static String
createLabelText
(DistanceUnit scaleUnit, double value, DistanceUnit intervalUnit) Format the label text.protected static int
getBarSize
(ScaleBarRenderSettings settings) Get the bar size.protected static int
getLabelDistance
(ScaleBarRenderSettings settings) Get the label distance..protected static Dimension
getMaxLabelSize
(ScaleBarRenderSettings settings) Get the maximum width and height of the labels.protected static double
getNearestNiceValue
(double value, DistanceUnit scaleUnit, boolean lockUnits) Reduce the given value to the nearest smaller 1 significant digit number starting with 1, 2 or 5.protected static Dimension
getSize
(ScalebarAttribute.ScalebarAttributeValues scalebarParams, ScaleBarRenderSettings settings, Dimension maxLabelSize) Get the size of the painting area required to draw the scalebar with labels.final URI
render
(MapfishMapContext mapContext, ScalebarAttribute.ScalebarAttributeValues scalebarParams, File tempFolder, Template template) Render the scalebar.
-
Constructor Details
-
ScalebarGraphic
public ScalebarGraphic()
-
-
Method Details
-
getSize
protected static Dimension getSize(ScalebarAttribute.ScalebarAttributeValues scalebarParams, ScaleBarRenderSettings settings, Dimension maxLabelSize) Get the size of the painting area required to draw the scalebar with labels.- Parameters:
scalebarParams
- Parameters for the scalebar.settings
- Parameters for rendering the scalebar.maxLabelSize
- The max. size of the labels.
-
getMaxLabelSize
Get the maximum width and height of the labels.- Parameters:
settings
- Parameters for rendering the scalebar.
-
createLabelText
protected static String createLabelText(DistanceUnit scaleUnit, double value, DistanceUnit intervalUnit) Format the label text.- Parameters:
scaleUnit
- The unit used for the scalebar.value
- The scale value.intervalUnit
- The scaled unit for the intervals.
-
getNearestNiceValue
protected static double getNearestNiceValue(double value, DistanceUnit scaleUnit, boolean lockUnits) Reduce the given value to the nearest smaller 1 significant digit number starting with 1, 2 or 5.- Parameters:
value
- the value to find a nice number for.scaleUnit
- the unit of the value.lockUnits
- if set, the values are not scaled to a "nicer" unit.
-
getBarSize
Get the bar size.- Parameters:
settings
- Parameters for rendering the scalebar.
-
getLabelDistance
Get the label distance..- Parameters:
settings
- Parameters for rendering the scalebar.
-
render
public final URI render(MapfishMapContext mapContext, ScalebarAttribute.ScalebarAttributeValues scalebarParams, File tempFolder, Template template) throws IOException, ParserConfigurationException Render the scalebar.- Parameters:
mapContext
- The context of the map for which the scalebar is created.scalebarParams
- The scalebar parameters.tempFolder
- The directory in which the graphic file is created.template
- The template that contains the scalebar processor- Throws:
IOException
ParserConfigurationException
-