Class TLcdXYGridStyle.Builder<B extends TLcdXYGridStyle.Builder<B>>
- Enclosing class:
TLcdXYGridStyle
- Since:
- 2016.0
-
Method Summary
Modifier and TypeMethodDescriptionall
(TLcdXYGridStyle aXYStyle) Sets all parameters on the builder based on the given XY style.axes
(EnumSet<TLcdXYGridStyle.Axis> aAxes) This method specifies to which axes the subsequent calls are applied.body
(double aSpacing) This method defines a level for which grid lines, separated by the given spacing, are added.build()
Creates a newTLcdXYGridStyle
from this builder.clampToBounds
(ILcdBounds aBounds) When called with a non-null value, this grid layer will restrict the grid lines to the given bounds.Configures this builder with a default xy grid style.This method specifies the font to use for the current spacing/interval combination.This method specifies the format to use for the labels of the current spacing/interval combination.interval
(double aMinScale, double aMaxScale) This method specifies when grid lines or its labels are visible using an interval of scales.label
(double aSpacing) This method defines a level for which labels of grid lines, separated by the given spacing, are added.labelAntiAliasing
(boolean aAntiAliasing) This method specifies whether to use anti-aliasing during the painting of grid labels.labelColor
(Color aTextColor) This method specifies the label color to use for the current spacing/interval combination.labelHaloColor
(Color aLabelHaloColor) This method specifies the label halo color to use for the current spacing/interval combination.labelHaloThickness
(int aLabelHaloThickness) This method specifies the label halo thickness to use for the current spacing/interval combination.lineAntiAliasing
(boolean aAntiAliasing) This method specifies whether to use anti-aliasing during the painting of grid lines.This method specifies the line color to use for the current spacing/interval combination.lineWidth
(double aLineWidth) This method specifies the line width to use for the current spacing/interval combination.When called with a non-null value, this grid layer will map its origin (0, 0) to the given point on the map.overlay()
After calling this method, all subsequentinterval()
,lineColor()
,labelColor()
, … calls will only apply to all overlay labels.
-
Method Details
-
defaultXYGridStyle
Configures this builder with a default xy grid style.- Returns:
- this builder.
-
clampToBounds
When called with a non-null value, this grid layer will restrict the grid lines to the given bounds. The clamping will happen for all grid lines.- Parameters:
aBounds
- the bounds to which the grid is clamped.- Returns:
- this builder.
-
origin
When called with a non-null value, this grid layer will map its origin (0, 0) to the given point on the map.- Parameters:
aOrigin
- the origin, defined in the reference of the grid.- Returns:
- this builder
- Since:
- 2020.1
-
axes
This method specifies to which axes the subsequent calls are applied. This method can be used anywhere, but its behavior depends on which method is called right after it. Some examples are given below. If this method is never called, the other method calls apply to all axes.
It can be used to specify spacings that are only used on one of the axes. To do this, this method should be called before calling the
body
orlabel
method:// The grid will contain lines with a spacing of
5000.0
,1000.0
and100.0
for the X // axis, and with a spacing of5000.0
,2000.0
and100.0
for the Y axis. TLcdXYGridStyle.Builder builder = TLcdXYGridStyle.newBuilder(); builder.body(5000.0).interval(...)...; builder.axis(EnumSet.of(Axis.X)).body(1000.0).interval(...)...; builder.axis(EnumSet.of(Axis.Y)).body(2000.0).interval(...)...; builder.axis(EnumSet.of(Axis.X, Axis.Y)).body(100.0).interval(...)...;It can be used to specify intervals that are only used on one of the axes. To do this, this method should be called before calling the
interval
method:// The grid will contain lines with a spacing of
1000.0
. For the X axis, these line will be displayed // in the'interval1'
scale interval and in the'interval2'
scale interval for the Y axis. TLcdXYGridStyle.Builder builder = TLcdXYGridStyle.newBuilder(); builder.body(1000); builder.axis(EnumSet.of(Axis.X)).interval(interval1)...; builder.axis(EnumSet.of(Axis.Y)).interval(interval2)...;It can be used to specify styling options that are only used on one of the axes. To do this, this method should be called before one of the style related method (e.g.
lineWidth
,labelColor
,format
, ...):// The grid will contain labels with a spacing of
1000.0
, visible in the given scale'interval'
. // For the X axis, the labels will be formatted differently from the Y axis labels. Both axes will show red labels. TLcdXYGridStyle.Builder builder = TLcdXYGridStyle.newBuilder(); builder.label(1000).interval(interval); builder.labelColor(Color.red); builder.axis(EnumSet.of(Axis.X)).format(formatX); builder.axis(EnumSet.of(Axis.Y)).format(formatY);- Parameters:
aAxes
- the axes for which the subsequent calls are applied.- Returns:
- this builder.
-
body
This method defines a level for which grid lines, separated by the given spacing, are added. This spacing is a double value, expressed in the units of the xy grid reference. When using a spacing with a certain value, grid lines with coordinates that are a multiple of this values are added to the grid. You can for example use a spacing of 100 kilometers by supplying a value of
100000.0
. As a result, grid lines with coordinates of-100000.0
,0.0
,100000.0
,200000.0
, and so on, are added.After calling this method, all subsequent
interval()
,lineColor()
,labelColor()
, … calls will apply to all grid lines with the given spacing. E.g. to all 100000 meter lines.When no subsequent
interval()
or style call is done, a default interval and default styles are chosen. Note that the default interval might not be a good default. Seeinterval()
for more information.For more information on how to use this method, see
TLcdXYGridStyle
.- Parameters:
aSpacing
- the spacing between the grid lines (expressed in the unit of measure of the reference)- Returns:
- this builder
-
label
This method defines a level for which labels of grid lines, separated by the given spacing, are added. This spacing is a double value, expressed in the units of the xy grid reference. When using a spacing with a certain value, labels for grid lines with coordinates that are a multiple of this values are added to the grid. You can for example use a spacing of 100 kilometers by supplying a value of
100000.0
. As a result, labels of grid lines with coordinates of-100000.0
,0.0
,100000.0
,200000.0
, and so on, are added.After calling this method, all subsequent
interval()
,lineColor()
,labelColor()
, … calls will apply to all labels of the grid lines with the given spacing. E.g. to all 100000 meter line labels.When no subsequent
interval()
or style call is done, a default interval and default styles are chosen. Note that the default interval might not be a good default. Seeinterval
for more information.For more information on how to use this method, see
TLcdXYGridStyle
.- Parameters:
aSpacing
- the spacing (expressed in the unit of measure of the grid reference) of the grid lines to which the labels are added- Returns:
- this builder
-
overlay
After calling this method, all subsequent
interval()
,lineColor()
,labelColor()
, … calls will only apply to all overlay labels. See alsoTLcdXYGridOverlayLabelBuilder
.When no subsequent
interval()
or style call is done, a default interval and default styles are chosen.For more information on how to use this method, see
TLcdXYGridStyle
.- Returns:
- this builder
-
interval
This method specifies when grid lines or its labels are visible using an interval of scales. Grid lines or labels will be visible whenever the scale of the view lies within this scale interval. This method should be called after calling one of the
body
,label
oroverlay
methods, so the scale interval will only apply to the lines or labels with the spacing defined in these methods. It is possible to call this method more than once. In that case, the grid lines with a specific spacing or its labels will be visible when the scale of the view is within one of the specified scale intervals. This is especially useful to define different styles at different scales.After calling this method, all subsequent
lineColor()
,labelColor()
, … calls will only apply to the given scale interval. It is possible to define multiple scale intervals for every grid line or label spacing. In order to do this, theinterval
method (and its subsequent calls) can be called multiple times.When not calling this method after calling one of the
body
orlabel
methods, a scale interval from0
(completely zoomed out) toDouble.MAX_VALUE
(completely zoomed in) is used. So if you want to use the same styles for every scale, this method should not be called.Note that it is important to choose realistic scale intervals for each spacing. Not doing this may cause the grid layer to generate too many lines. This could for example happen when displaying grid lines with a spacing of 1 meter, when viewing the whole world. Note that the grid layer will automatically fall back to a less detailed grid level (if available) to avoid OutOfMemoryErrors. This may or may not be the desired behavior though, so it is advised to avoid this problem by using well chosen scale intervals.
When specifying overlapping scale intervals, it's undefined which styles will be used. It is advised to only specify non-overlapping scale intervals for the same (spacing / body or label) combination.
For more information on how to use this method, see
TLcdXYGridStyle
.- Parameters:
aMinScale
- the minimum scale, for example 0.0005 (=50/100000, when 50 pixels correspond to 100000 meters in the view)aMaxScale
- the maximum scale, typicallyDouble.MAX_VALUE
(to make sure grid lines always remain visible when zooming in)- Returns:
- this builder
-
lineWidth
This method specifies the line width to use for the current spacing/interval combination. The given style setting is only applied to grid lines with the spacing defined in a previous
body
call. It is also only used when the view scale lies within the scale interval defined in a previousinterval
call.For an example of how to use this method, see
TLcdXYGridStyle
.This method should be called at least once after calling one of the
body
orinterval
methods. Otherwise, default styling is used.- Parameters:
aLineWidth
- the line width to use.- Returns:
- this builder
-
lineColor
This method specifies the line color to use for the current spacing/interval combination. The given style setting is only applied to grid lines with the spacing defined in a previous
body
call. It is also only used when the view scale lies within the scale interval defined in a previousinterval
call.For an example of how to use this method, see
TLcdXYGridStyle
.This method should be called at least once after calling one of the
body
orinterval
methods. Otherwise, default styling is used.- Parameters:
aLineColor
- the line color to use.- Returns:
- this builder
-
font
This method specifies the font to use for the current spacing/interval combination. The given style setting is only applied to grid lines or labels with the spacing defined in a previous
label
call. It is also only used when the view scale lies within the scale interval defined in a previousinterval
call.For an example of how to use this method, see
TLcdXYGridStyle
.This method should be called at least once after calling one of the
label
orinterval
methods. Otherwise, default styling is used.- Parameters:
aFont
- the font to use.- Returns:
- this builder
-
labelColor
This method specifies the label color to use for the current spacing/interval combination. The given style setting is only applied to grid line labels with the spacing defined in a previous
label
call. It is also only used when the view scale lies within the scale interval defined in a previousinterval
call.For an example of how to use this method, see
TLcdXYGridStyle
.This method should be called at least once after calling one of the
label
orinterval
methods. Otherwise, default styling is used.- Parameters:
aTextColor
- the text color to use.- Returns:
- this builder
-
labelHaloColor
This method specifies the label halo color to use for the current spacing/interval combination. The given style setting is only applied to grid line labels with the spacing defined in a previous
label
call. It is also only used when the view scale lies within the scale interval defined in a previousinterval
call.For an example of how to use this method, see
TLcdXYGridStyle
.This method should be called at least once after calling one of the
label
orinterval
methods. Otherwise, default styling is used.- Parameters:
aLabelHaloColor
- the halo color to use for the label text.- Returns:
- this builder
- See Also:
-
labelHaloThickness
This method specifies the label halo thickness to use for the current spacing/interval combination. The given style setting is only applied to grid line labels with the spacing defined in a previous
label
call. It is also only used when the view scale lies within the scale interval defined in a previousinterval
call.For an example of how to use this method, see
TLcdXYGridStyle
.This method should be called at least once after calling one of the
label
orinterval
methods. Otherwise, default styling is used.- Parameters:
aLabelHaloThickness
- the halo thickness to use for the label text.- Returns:
- this builder
- See Also:
-
lineAntiAliasing
This method specifies whether to use anti-aliasing during the painting of grid lines.
The default is
true
.- Parameters:
aAntiAliasing
-true
to enable anti-aliasing when painting grid lines.- Returns:
- this builder
-
labelAntiAliasing
This method specifies whether to use anti-aliasing during the painting of grid labels.
The default is
true
.- Parameters:
aAntiAliasing
-true
to enable anti-aliasing when painting grid labels.- Returns:
- this builder
-
format
This method specifies the format to use for the labels of the current spacing/interval combination. The given format is only applied to grid labels with the spacing defined in a previous
label
call. It is also only used when the view scale lies within the scale interval defined in a previousinterval
call. This method has no effect for bodies.This method is also used to specify the format used by the overlay labels. The given format is then only applied to the overlay label if
overlay
was called before.For labels, this
Format
should be able to formatdouble
values.TLcdDistanceFormat
can be used for example. For overlay labels, thisFormat
should be able to formatILcdPoint
objects, for exampleGridPointFormat
.- Parameters:
aFormat
- theFormat
used to format the label- Returns:
- this builder.
-
all
Sets all parameters on the builder based on the given XY style.
This is useful for example to create a new style that has almost all properties equal to another style.
- Parameters:
aXYStyle
- the grid style to copy- Returns:
- this styler
-
build
Creates a newTLcdXYGridStyle
from this builder.- Returns:
- a new
TLcdXYGridStyle
-