Class ScalebarGraphic


  • public class ScalebarGraphic
    extends java.lang.Object
    Creates a scalebar graphic.
    • Constructor Detail

      • ScalebarGraphic

        public ScalebarGraphic()
    • Method Detail

      • getSize

        protected static java.awt.Dimension getSize​(ScalebarAttribute.ScalebarAttributeValues scalebarParams,
                                                    ScaleBarRenderSettings settings,
                                                    java.awt.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

        protected static java.awt.Dimension getMaxLabelSize​(ScaleBarRenderSettings settings)
        Get the maximum width and height of the labels.
        Parameters:
        settings - Parameters for rendering the scalebar.
      • createLabelText

        protected static java.lang.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

        protected static int getBarSize​(ScaleBarRenderSettings settings)
        Get the bar size.
        Parameters:
        settings - Parameters for rendering the scalebar.
      • getLabelDistance

        protected static int getLabelDistance​(ScaleBarRenderSettings settings)
        Get the label distance..
        Parameters:
        settings - Parameters for rendering the scalebar.
      • render

        public final java.net.URI render​(MapfishMapContext mapContext,
                                         ScalebarAttribute.ScalebarAttributeValues scalebarParams,
                                         java.io.File tempFolder,
                                         Template template)
                                  throws java.io.IOException,
                                         javax.xml.parsers.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:
        java.io.IOException
        javax.xml.parsers.ParserConfigurationException