Class TLcdXYGridStyle

java.lang.Object
com.luciad.view.map.TLcdXYGridStyle

public final class TLcdXYGridStyle 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.

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 methods like lineColor, lineWidth, labelColor, ... The label text formatting can be customized using the format method. 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.

Example

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.


 TLcdXYGridStyle style = TLcdXYGridStyle.newBuilder()
   .body(100000.0)
     .interval(START_SCALE_100000, START_SCALE_10000).lineColor(primaryLineColor)
     .interval(START_SCALE_10000, START_SCALE_1000).lineColor(secondaryLineColor)
     .interval(START_SCALE_1000, MAX_ZOOMED_IN).lineColor(tertiaryLineColor)
   .label(100000.0)
     .interval(START_SCALE_100000, START_SCALE_10000).labelColor(primaryTextColor)
     .interval(START_SCALE_10000, START_SCALE_1000).labelColor(secondaryTextColor)
     .interval(START_SCALE_1000, MAX_ZOOMED_IN).labelColor(tertiaryTextColor)
   .body(10000.0)
     .interval(START_SCALE_10000, START_SCALE_1000).lineColor(primaryLineColor)
     .interval(START_SCALE_1000, START_SCALE_100).lineColor(secondaryLineColor)
     .interval(START_SCALE_100, MAX_ZOOMED_IN).lineColor(tertiaryLineColor)
   .label(10000.0)
     .interval(START_SCALE_10000, START_SCALE_1000).labelColor(primaryTextColor).format(numberFormat)
     .interval(START_SCALE_1000, START_SCALE_100).labelColor(secondaryTextColor).format(numberFormat)
     .interval(START_SCALE_100, MAX_ZOOMED_IN).labelColor(tertiaryTextColor).format(numberFormat)
   ...
   .build();
 
Since:
2016.0
  • Method Details

    • newBuilder

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

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