Enum Class LegendPosition

java.lang.Object
java.lang.Enum<LegendPosition>
com.arbergashi.charts.ui.legend.LegendPosition
All Implemented Interfaces:
Serializable, Comparable<LegendPosition>, Constable

public enum LegendPosition extends Enum<LegendPosition>
Standard positions for overlay legends.

This enum is used by legend overlays to compute their anchor point and apply padding. The default position is typically TOP_LEFT.

Since:
2026-01-01
Version:
1.0.0
Author:
Arber Gashi
  • Enum Constant Details

    • TOP_LEFT

      public static final LegendPosition TOP_LEFT
      Top-left corner of the chart area.
    • TOP_CENTER

      public static final LegendPosition TOP_CENTER
      Top-center of the chart area.
    • TOP_RIGHT

      public static final LegendPosition TOP_RIGHT
      Top-right corner of the chart area.
    • MIDDLE_LEFT

      public static final LegendPosition MIDDLE_LEFT
      Middle-left of the chart area.
    • CENTER

      public static final LegendPosition CENTER
      Center of the chart area. Use with care; may cover data.
    • MIDDLE_RIGHT

      public static final LegendPosition MIDDLE_RIGHT
      Middle-right of the chart area.
    • BOTTOM_LEFT

      public static final LegendPosition BOTTOM_LEFT
      Bottom-left corner of the chart area.
    • BOTTOM_CENTER

      public static final LegendPosition BOTTOM_CENTER
      Bottom-center of the chart area.
    • BOTTOM_RIGHT

      public static final LegendPosition BOTTOM_RIGHT
      Bottom-right corner of the chart area.
  • Method Details

    • values

      public static LegendPosition[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static LegendPosition valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • parse

      public static LegendPosition parse(String raw, LegendPosition fallback)
      Parses common string tokens (used by theme/property-based configuration).
      Parameters:
      raw - string token such as "top-left" or "BOTTOM_RIGHT"
      fallback - fallback when the token is null/blank or cannot be parsed
      Returns:
      parsed position
    • place

      public Rectangle place(Rectangle bounds, Dimension size, Insets padding)
      Computes a legend rectangle anchored within the given bounds.

      The returned rectangle is clamped so it always stays fully inside bounds.

      Parameters:
      bounds - the available area (typically the component bounds)
      size - the preferred legend size
      padding - padding from the edges (applied relative to the anchor)
      Returns:
      legend rectangle, clamped to bounds