public class TLspXYGridStyle extends Object
Style that can be used for XY grid layers. This style can be used to style the grid lines as well as the labels.
A simple way to use this class is to create a default style, see Builder#defaultXYGridStyle()
. The samples contain a class that builds a style from the ground up. This
sample code can be adjusted according to needs. See samples.lightspeed.grid.XYGridStyleFactory
.
body
and label
. These methods can be called multiple times with different spacings in order to
add grid lines with different spacings. This makes it possible to for example add 100km and 10km grid lines and
labels.interval
method.styles
, customizableStyles
and
format
. They allow for example to specify the line width and color, or the label
font, color and content. Note that it is possible to define multiple styles per grid line at different scales.
This can for example be used to make certain grid lines more prominent when zooming in by specifying multiple
scale intervals with different styles.The following pseudo-code fragment shows how to use this style and its builder. This example shows how to define grid lines and labels with a spacing of 100km and 10km. For each line spacing, there are three intervals in which the lines/labels are visible. Each of these three intervals defines a different style. Because of this, the grid lines and labels will be styled differently, depending on the scale of the view.
TLspXYGridStyle style = TLspXYGridStyle.newBuilder()
.body(100000.0)
.interval(START_SCALE_100000, START_SCALE_10000).customizableStyles(primaryStyles)
.interval(START_SCALE_10000, START_SCALE_1000).customizableStyles(secondaryStyles)
.interval(START_SCALE_1000, MAX_ZOOMED_IN).customizableStyles(tertiaryStyles)
.label(100000.0)
.interval(START_SCALE_100000, START_SCALE_10000).customizableStyles(primaryLabelStyles)
.interval(START_SCALE_10000, START_SCALE_1000).customizableStyles(secondaryLabelStyles)
.interval(START_SCALE_1000, MAX_ZOOMED_IN).customizableStyles(tertiaryLabelStyles)
.body(10000.0)
.interval(START_SCALE_10000, START_SCALE_1000).customizableStyles(primaryStyles)
.interval(START_SCALE_1000, START_SCALE_100).customizableStyles(secondaryStyles)
.interval(START_SCALE_100, MAX_ZOOMED_IN).customizableStyles(tertiaryStyles)
.label(10000.0)
.interval(START_SCALE_10000, START_SCALE_1000).customizableStyles(primaryLabelStyles).format(numberFormat)
.interval(START_SCALE_1000, START_SCALE_100).customizableStyles(secondaryLabelStyles).format(numberFormat)
.interval(START_SCALE_100, MAX_ZOOMED_IN).customizableStyles(tertiaryLabelStyles).format(numberFormat)
.overlay()
.interval(START_SCALE_100000, START_SCALE_10000).customizableStyles(primaryLabelStyles).format(pointFormat)
.interval(START_SCALE_10000, START_SCALE_1000).customizableStyles(secondaryLabelStyles).format(pointFormat)
...
.build();
The following example shows how to configure different spacings / scale intervals for the X and Y axis:
TLspXYGridStyle.Builder> builder = TLspXYGridStyle.newBuilder();
// Configure the X axis to have 3 spacings
builder.axes(EnumSet.of(Axis.X));
builder.body(100.0).interval(MAX_ZOOMED_OUT, 10.0).customizableStyles(primaryStyles);
builder.body(10.0).interval(10.0, 100.0).customizableStyles(primaryStyles);
builder.body(1.0).interval(100.0, MAX_ZOOMED_IN).customizableStyles(primaryStyles);
// Configure the Y axis to only have 1 spacing
builder.axes(EnumSet.of(Axis.Y));
builder.body(1.0).interval(MAX_ZOOMED_OUT, MAX_ZOOMED_IN).customizableStyles(primaryStyles);
TLspXYGridStyle style = builder.build();
For lines, the following styles are supported:
For labels, the following styles are supported: For overlay components (seeTLspXYGridOverlayLabelBuilder
),
the following styles are supported:
On top of that, the text formatting can be controlled.
Modifier and Type | Class and Description |
---|---|
static class |
TLspXYGridStyle.Axis
The axis for which style information can be specified.
|
static class |
TLspXYGridStyle.Builder<B extends TLspXYGridStyle.Builder<B>>
Builder for XY grid styles.
|
static class |
TLspXYGridStyle.LabelPosition
Defines the position of the line labels with respect to the view.
|
static class |
TLspXYGridStyle.LinePosition
Defines where the line labels should be positioned with respect to the line.
|
static class |
TLspXYGridStyle.Orientation
Defines how the labels should be oriented.
|
Modifier and Type | Method and Description |
---|---|
TLspXYGridStyle.Builder<?> |
asBuilder()
Creates a new builder initialized with all the properties of this style.
|
static TLspXYGridStyle.Builder<?> |
newBuilder()
Creates a new builder with the default values.
|
public static TLspXYGridStyle.Builder<?> newBuilder()
public TLspXYGridStyle.Builder<?> asBuilder()