Class TLspXYGridStyle

java.lang.Object
com.luciad.view.lightspeed.painter.grid.TLspXYGridStyle

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.

How to create a custom grid style

  1. Define grid line spacings. A grid consists of lines with different spacings. For example when zoomed out, grid lines each 100 km can be sufficient. When zooming in, the distance between two consecutive grid lines can be changed to 10 km. These spacings can be configured using the following methods: 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.
  2. Define when grid lines are visible. By default, when defining grid lines with a specific spacing (see previous bullet), grid lines will always be visible. This can be a problem when adding grid lines with a small spacing, because when zoomed out, way too many lines would be visible simultaneously. Better behavior would be to only start showing these detailed lines when zooming in sufficiently. This can be done by using the interval method.
  3. Define the styles. After defining grid lines with a specific spacing, and after specifying when they are visible, we can specify what these grid lines should look like. This can be done using the following methods: 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.

Examples

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();
 

Supported styles

For lines, the following styles are supported:

For labels, the following styles are supported: For overlay components (see TLspXYGridOverlayLabelBuilder), the following styles are supported: On top of that, the text formatting can be controlled.

Since:
2016.0
  • Method Details

    • newBuilder

      public static TLspXYGridStyle.Builder<?> newBuilder()
      Creates a new builder with the default values.
      Returns:
      the new builder.
    • asBuilder

      public TLspXYGridStyle.Builder<?> asBuilder()
      Creates a new builder initialized with all the properties of this style.
      Returns:
      the new builder.