Class Legend2D.Specs

Object
Specs
Enclosing class:
Legend2D

public static final class Legend2D.Specs extends Object
Semantic legend data prepared by views and consumed by legends for rendering, sizing and hit-testing.

A LegendSpecs instance contains the non-geometric meaning of a legend: its mode, numeric range, marker annotations and optional discrete entry labels. Views compile this information from model and module state and push it into legends. The legend then combines it with local layout state such as bounds, zoom, padding and the active color map.

For gradient legends, min, max, markers and inPercent are relevant. Endpoint labels and gradient tooltip labels are derived by the legend from the numeric range, formatting flag and mode. For discrete legends, labels are used. The Legend2D.Mode.NONE singleton returned by none() disables legend rendering.

  • Field Details

    • NO_MARKERS

      private static final double[] NO_MARKERS
      Shared empty marker array for legends without annotations.
    • NO_LABELS

      private static final String[] NO_LABELS
      Shared empty label array for legends without discrete entries.
    • NONE

      private static final Legend2D.Specs NONE
      Singleton legend specs representing the absence of a legend.
    • mode

      public final Legend2D.Mode mode
      The legend mode.
    • min

      public final double min
      The minimum value for gradient legends.
    • max

      public final double max
      The maximum value for gradient legends.
    • markers

      public final double[] markers
      Marker values to annotate on gradient legends.
    • inPercent

      public final boolean inPercent
      Flag indicating that gradient values should be formatted as percentages.
    • labels

      public final String[] labels
      Labels for discrete legend entries.
  • Constructor Details

    • Specs

      private Specs(Legend2D.Mode mode, double min, double max, double[] markers, boolean inPercent, String[] labels)
      Create semantic legend data.
      Parameters:
      mode - the legend mode
      min - minimum gradient value
      max - maximum gradient value
      markers - marker annotations for gradient legends
      inPercent - true if gradient values should be formatted as percentages
      labels - labels for discrete legend entries
  • Method Details

    • none

      public static Legend2D.Specs none()
      Get the empty legend specs.
      Returns:
      empty legend specs
    • discreteTrait

      public static Legend2D.Specs discreteTrait(String[] labels)
      Create discrete legend specs.
      Parameters:
      labels - labels for discrete entries
      Returns:
      legend specs
    • continuousTrait

      public static Legend2D.Specs continuousTrait()
      Create continuous-trait legend specs.
      Returns:
      legend specs
    • fitnessGradient

      public static Legend2D.Specs fitnessGradient(double min, double max, double[] markers)
      Create fitness-gradient legend specs.
      Parameters:
      min - minimum fitness value
      max - maximum fitness value
      markers - marker values
      Returns:
      legend specs
    • densityGradient

      public static Legend2D.Specs densityGradient(double max)
      Create density-gradient legend specs.
      Parameters:
      max - maximum density or frequency value
      Returns:
      legend specs