public static final class MgrsGrid.Builder extends Object implements AutoCloseable
Creates a MGRS grid with predefined scale ranges and default (customizable) styling.
The default styling is expressed in terms of 3 styles: primary, secondary and tertiary. At a given scale range, the most applicable MGRS grid level is styled with the primary style. Higher MGRS levels are styled with secondary and tertiary styles. For example, when zoomed in really far, 1m MGRS squares are styled with the primary style, 10m squares are styled with the secondary style and 100m squares are styled with the tertiary style.
Constructor and Description |
---|
Builder(MgrsGrid.Builder other) |
Modifier and Type | Method and Description |
---|---|
MgrsGrid |
build()
Returns the MGRS grid.
|
void |
close() |
protected void |
finalize() |
MgrsGrid.Builder |
labelEdgeOffset(double labelEdgeOffset)
This specifies the offset of the label, away from the edges of the view, in device independent pixels.
|
MgrsGrid.Builder |
labelGridOffset(double labelGridOffset)
This specifies the offset of the label, in device independent pixels, away from the grid line to which it is attached.
|
MgrsGrid.Builder |
labelOrientation(GridLabelOrientation labelOrientation)
This specifies the label orientation with respect to the line.
|
MgrsGrid.Builder |
labelPosition(GridLabelPosition labelPosition)
This specifies the label position with respect to the view.
|
MgrsGrid.Builder |
lineLabelPosition(GridLineLabelPosition lineLabelPosition)
This specifies the label position (with respect to the line) to use for the line labels of the current MGRS type/level/interval combination.
|
MgrsGrid.Builder |
primaryLabelStyle(TextStyle labelStyle)
Indicates the primary label style to use for the MGRS grid.
|
MgrsGrid.Builder |
primaryLineStyle(LineStyle lineStyle)
Indicates the primary line style to use for the MGRS grid.
|
MgrsGrid.Builder |
scaleMultiplier(double scaleMultiplier)
Indicates the scale multiplier to use for the MGRS grid scale ranges.
|
MgrsGrid.Builder |
secondaryLabelStyle(TextStyle labelStyle)
Indicates the secondary label style to use for the MGRS grid.
|
MgrsGrid.Builder |
secondaryLineStyle(LineStyle lineStyle)
Indicates the secondary line style to use for the MGRS grid.
|
MgrsGrid.Builder |
tertiaryLabelStyle(TextStyle labelStyle)
Indicates the tertiary label style to use for the MGRS grid.
|
MgrsGrid.Builder |
tertiaryLineStyle(LineStyle lineStyle)
Indicates the tertiary line style to use for the MGRS grid.
|
public Builder(@NotNull MgrsGrid.Builder other)
public void close()
close
in interface AutoCloseable
@NotNull public MgrsGrid build() throws IllegalStateException
IllegalStateException
- when the settings are invalid.MgrsGrid
@NotNull public MgrsGrid.Builder primaryLineStyle(@NotNull LineStyle lineStyle)
lineStyle
- the line style.@NotNull public MgrsGrid.Builder secondaryLineStyle(@NotNull LineStyle lineStyle)
lineStyle
- the line style.@NotNull public MgrsGrid.Builder tertiaryLineStyle(@NotNull LineStyle lineStyle)
lineStyle
- the line style.@NotNull public MgrsGrid.Builder primaryLabelStyle(@NotNull TextStyle labelStyle)
labelStyle
- the label style.@NotNull public MgrsGrid.Builder secondaryLabelStyle(@NotNull TextStyle labelStyle)
labelStyle
- the label style.@NotNull public MgrsGrid.Builder tertiaryLabelStyle(@NotNull TextStyle labelStyle)
labelStyle
- the label style.@NotNull public MgrsGrid.Builder scaleMultiplier(double scaleMultiplier) throws IllegalArgumentException
The value must be within the range [0.1, 10.0]
.
A value larger than 1 makes the grid lines appear later when zooming in. This results in a coarser grid. A value below 1 makes the grid lines appear sooner when zooming in. This results in a finer grid.
scaleMultiplier
- the scale multiplier.IllegalArgumentException
- when an invalid value is passed.@NotNull public MgrsGrid.Builder labelEdgeOffset(double labelEdgeOffset) throws IllegalArgumentException
This is applied to all style settings in the grid.
This is optional. Defaults to 6
.
labelEdgeOffset
- the edge offset value. Must be >= 0.IllegalArgumentException
- when an invalid value is passed.MgrsGridSetting.Builder#labelEdgeOffset
@NotNull public MgrsGrid.Builder labelGridOffset(double labelGridOffset) throws IllegalArgumentException
This is applied to all style settings in the grid.
This is optional. Defaults to 3
.
labelGridOffset
- the grid offset value. Must be >= 0.IllegalArgumentException
- when an invalid value is passed.MgrsGridSetting.Builder#labelGridOffset
@NotNull public MgrsGrid.Builder lineLabelPosition(@NotNull GridLineLabelPosition lineLabelPosition)
They can for example be placed at the left or at the right of the line.
This is applied to all style settings in the grid.
This is optional. Defaults to AboveOrLeft
.
lineLabelPosition
- the line label position.MgrsGridSetting.Builder#lineLabelPosition
@NotNull public MgrsGrid.Builder labelOrientation(@NotNull GridLabelOrientation labelOrientation)
This is applied to all style settings in the grid.
This is optional. Defaults to AlongLine
.
labelOrientation
- the label orientation.MgrsGridSetting.Builder#labelOrientation
@NotNull public MgrsGrid.Builder labelPosition(@NotNull GridLabelPosition labelPosition)
They can for example be placed at the left or at the right edge of the view. For example, when a label is placed at the east or south side of a line, it is placed at the left or lower edge of the view when using a rectangular projection like Mercator.
This is applied to all style settings in the grid.
This is optional. Defaults to WestAndSouth
.
labelPosition
- the label position.MgrsGridSetting.Builder#labelPosition