Class GridParam


  • public final class GridParam
    extends AbstractLayerParams
    Parameters relevant to creating Grid layers.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DEFAULT_GRID_COLOR  
      static java.lang.String DEFAULT_HALO_COLOR  
      static int DEFAULT_HALO_RADIUS  
      static int DEFAULT_INDENT  
      static java.lang.String DEFAULT_LABEL_COLOR  
      static int DEFAULT_POINTS_IN_GRID_LINE  
      static java.lang.String DEFAULT_UNIT_FORMAT
      Grid label default format pattern for the unit (if valueFormat is used).
      GridFontParam font
      Configuration for the font of the grid labels.
      java.lang.String formatDecimalSeparator
      The character used to separate the decimal part (for example ",").
      java.lang.String formatGroupingSeparator
      The character used for the thousands separator (for example "'").
      java.lang.String gridColor
      The color of the grid points or lines.
      GridType gridType
      The type of grid to render.
      java.lang.String haloColor
      The color of the halo around grid label text.
      double haloRadius
      The size of the halo around the Grid Labels.
      double horizontalYOffset
      Apply an Y offset to horizontal grid line labels, relative to the horizontal grid lines.
      int indent
      The number of pixels to indent the grid labels from the end of the map.
      java.lang.String labelColor
      The color of the grid label text.
      java.lang.String labelFormat
      The formatting string used to format the label (for example "%1.2f %s").
      java.lang.String labelProjection
      The projection code to use for the labels.
      java.lang.Boolean longitudeFirst
      By default the normal axis order as specified in EPSG code will be used when parsing projections.
      int[] numberOfLines
      The x,y number of grid lines.
      double[] origin
      The x,y point of grid origin.
      int pointsInLine
      The number of points that will be in the grid line (if the gridType is LINES).
      java.lang.Boolean renderAsSvg
      Indicates if the layer is rendered as SVG.
      boolean rotateLabels
      If true (the default), the labels will be rotated to follow the lines they belong to.
      double[] spacing
      The x,y spacing between grid lines.
      java.lang.String style
      The style name of a style to apply to the features during rendering.
      java.lang.String unitFormat
      The formatting string used to format the unit part of a label (for example " %s").
      java.lang.String valueFormat
      The formatting string used to format the decimal part of a label (for example "###,###").
      double verticalXOffset
      Apply an X offset to the vertical grid line labels, relative to the vertical grid lines.
    • Constructor Summary

      Constructors 
      Constructor Description
      GridParam()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.geotools.api.referencing.operation.MathTransform calculateLabelTransform​(org.geotools.api.referencing.crs.CoordinateReferenceSystem mapCrs)
      Determine which math transform to use when creating the coordinate of the label.
      java.lang.String calculateLabelUnit​(org.geotools.api.referencing.crs.CoordinateReferenceSystem mapCrs)
      Determine which unit to use when creating grid labels.
      GridLabelFormat getGridLabelFormat()  
      void postConstruct()
      Initialize default values and validate that config is correct.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_UNIT_FORMAT

        public static final java.lang.String DEFAULT_UNIT_FORMAT
        Grid label default format pattern for the unit (if valueFormat is used).
        See Also:
        Constant Field Values
      • DEFAULT_POINTS_IN_GRID_LINE

        public static final int DEFAULT_POINTS_IN_GRID_LINE
        See Also:
        Constant Field Values
      • DEFAULT_HALO_COLOR

        public static final java.lang.String DEFAULT_HALO_COLOR
        See Also:
        Constant Field Values
      • DEFAULT_LABEL_COLOR

        public static final java.lang.String DEFAULT_LABEL_COLOR
        See Also:
        Constant Field Values
      • DEFAULT_GRID_COLOR

        public static final java.lang.String DEFAULT_GRID_COLOR
        See Also:
        Constant Field Values
      • gridType

        public GridType gridType
        The type of grid to render.

        Can be LINES or POINTS. Default is LINES.

      • spacing

        public double[] spacing
        The x,y spacing between grid lines.

        Either spacing or numberOfLines

        If spacing is defined then origin must also be defined

      • origin

        public double[] origin
        The x,y point of grid origin.

        This is required if spacing is defined.

      • numberOfLines

        public int[] numberOfLines
        The x,y number of grid lines.

        The x is the number of lines that run vertically along the page.

      • style

        public java.lang.String style
        The style name of a style to apply to the features during rendering. The style name must map to a style in the template or the configuration objects.

        If no style is defined then the default grid style will be used. The default will depend if the type is point or line and will respect gridColor and haloColor and haloRadius. If gridType is GridType.POINTS then the style will be crosses with a haloRadius sized halo around the cross. If GridType.LINES then the style will be a dashed line with no halo.

      • renderAsSvg

        public java.lang.Boolean renderAsSvg
        Indicates if the layer is rendered as SVG.

        (will default to Configuration.defaultToSvg).

      • pointsInLine

        public int pointsInLine
        The number of points that will be in the grid line (if the gridType is LINES). If the line will be curved (for certain projections) then the more points the smoother the curve.

        The default number of points is 10000.

      • haloRadius

        public double haloRadius
        The size of the halo around the Grid Labels. The default is 1.
      • haloColor

        public java.lang.String haloColor
        The color of the halo around grid label text. The color is defined the same as colors in CSS. Default is white ("#FFF")
      • labelColor

        public java.lang.String labelColor
        The color of the grid label text. Default is dark gray ("#444")
      • gridColor

        public java.lang.String gridColor
        The color of the grid points or lines. Default is gray ("gray")
      • font

        public GridFontParam font
        Configuration for the font of the grid labels. The default is the default system font.
      • indent

        public int indent
        The number of pixels to indent the grid labels from the end of the map. The default is 5.
      • labelProjection

        public java.lang.String labelProjection
        The projection code to use for the labels. The value should be the string authority:code form identifying the projection. By default it will be the same projection as the map.
      • labelFormat

        public java.lang.String labelFormat
        The formatting string used to format the label (for example "%1.2f %s"). By default the label is formatted according to the unit and label value. For the format syntax, see java.util.Formatter. If labelFormat is set, valueFormat, unitFormat and custom separator characters will be ignored.
      • valueFormat

        public java.lang.String valueFormat
        The formatting string used to format the decimal part of a label (for example "###,###"). This parameter is ignored if labelFormat is set. For the format syntax, see DecimalFormat.
      • unitFormat

        public java.lang.String unitFormat
        The formatting string used to format the unit part of a label (for example " %s"). This parameter is ignored if labelFormat is set. valueFormat must be set to use this parameter. For the format syntax, see java.util.Formatter.
      • formatDecimalSeparator

        public java.lang.String formatDecimalSeparator
        The character used to separate the decimal part (for example ","). This parameter is only used if valueFormat is used. The default is the character of the default locale.
      • formatGroupingSeparator

        public java.lang.String formatGroupingSeparator
        The character used for the thousands separator (for example "'"). This parameter is only used if valueFormat is used. The default is the character of the default locale.
      • longitudeFirst

        public java.lang.Boolean longitudeFirst
        By default the normal axis order as specified in EPSG code will be used when parsing projections. However the requester can override this by explicitly declaring that longitude axis is first.
      • rotateLabels

        public boolean rotateLabels
        If true (the default), the labels will be rotated to follow the lines they belong to. Otherwise they are orientated west to east.
      • verticalXOffset

        public double verticalXOffset
        Apply an X offset to the vertical grid line labels, relative to the vertical grid lines. Defaults to 0.
      • horizontalYOffset

        public double horizontalYOffset
        Apply an Y offset to horizontal grid line labels, relative to the horizontal grid lines. Defaults to 0.
    • Constructor Detail

      • GridParam

        public GridParam()
    • Method Detail

      • postConstruct

        public void postConstruct()
        Initialize default values and validate that config is correct.
      • calculateLabelUnit

        public java.lang.String calculateLabelUnit​(org.geotools.api.referencing.crs.CoordinateReferenceSystem mapCrs)
        Determine which unit to use when creating grid labels.
        Parameters:
        mapCrs - the crs of the map, used if the labelProjection is not defined.
      • calculateLabelTransform

        public org.geotools.api.referencing.operation.MathTransform calculateLabelTransform​(org.geotools.api.referencing.crs.CoordinateReferenceSystem mapCrs)
        Determine which math transform to use when creating the coordinate of the label.
        Parameters:
        mapCrs - the crs of the map, used if the labelProjection is not defined.