Class Legend2D.Specs
Object
Specs
- Enclosing class:
Legend2D
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 Summary
FieldsModifier and TypeFieldDescriptionfinal booleanFlag indicating that gradient values should be formatted as percentages.final String[]Labels for discrete legend entries.final double[]Marker values to annotate on gradient legends.final doubleThe maximum value for gradient legends.final doubleThe minimum value for gradient legends.final Legend2D.ModeThe legend mode.private static final String[]Shared empty label array for legends without discrete entries.private static final double[]Shared empty marker array for legends without annotations.private static final Legend2D.SpecsSingleton legend specs representing the absence of a legend. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateSpecs(Legend2D.Mode mode, double min, double max, double[] markers, boolean inPercent, String[] labels) Create semantic legend data. -
Method Summary
Modifier and TypeMethodDescriptionstatic Legend2D.SpecsCreate continuous-trait legend specs.static Legend2D.SpecsdensityGradient(double max) Create density-gradient legend specs.static Legend2D.SpecsdiscreteTrait(String[] labels) Create discrete legend specs.static Legend2D.SpecsfitnessGradient(double min, double max, double[] markers) Create fitness-gradient legend specs.static Legend2D.Specsnone()Get the empty legend specs.
-
Field Details
-
NO_MARKERS
private static final double[] NO_MARKERSShared empty marker array for legends without annotations. -
NO_LABELS
Shared empty label array for legends without discrete entries. -
NONE
Singleton legend specs representing the absence of a legend. -
mode
The legend mode. -
min
public final double minThe minimum value for gradient legends. -
max
public final double maxThe maximum value for gradient legends. -
markers
public final double[] markersMarker values to annotate on gradient legends. -
inPercent
public final boolean inPercentFlag indicating that gradient values should be formatted as percentages. -
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 modemin- minimum gradient valuemax- maximum gradient valuemarkers- marker annotations for gradient legendsinPercent-trueif gradient values should be formatted as percentageslabels- labels for discrete legend entries
-
-
Method Details
-
none
-
discreteTrait
Create discrete legend specs.- Parameters:
labels- labels for discrete entries- Returns:
- legend specs
-
continuousTrait
Create continuous-trait legend specs.- Returns:
- legend specs
-
fitnessGradient
Create fitness-gradient legend specs.- Parameters:
min- minimum fitness valuemax- maximum fitness valuemarkers- marker values- Returns:
- legend specs
-
densityGradient
Create density-gradient legend specs.- Parameters:
max- maximum density or frequency value- Returns:
- legend specs
-