Class InteractiveLegendOverlay

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
com.arbergashi.charts.ui.legend.InteractiveLegendOverlay
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public final class InteractiveLegendOverlay extends JComponent
TradingView-style interactive legend overlay.

Features:

  • Column layout (name + values)
  • Live values from the current ChartFocus
  • Visibility toggles (click name)
  • Settings action area (right side)

This component deliberately stays lightweight: it renders text/boxes itself and delegates actions via LegendActionListener.

Since:
2025-06-01
Version:
1.0.0
Author:
Arber Gashi
See Also:
  • Constructor Details

  • Method Details

    • setTheme

      public void setTheme(ChartTheme theme)
      Updates the legend theme for colors and typography.
      Parameters:
      theme - chart theme (falls back to default when null)
    • setLegendActionListener

      public void setLegendActionListener(LegendActionListener actions)
      Installs the action handler used for toggle/solo/settings interactions.
      Parameters:
      actions - action listener (may be null to disable interactivity)
    • setFocus

      public void setFocus(ChartFocus focus)
      Updates the focus state used to display live series values.
      Parameters:
      focus - focus payload (null resets to ChartFocus.EMPTY)
    • setVisibilityResolver

      public void setVisibilityResolver(Predicate<String> resolver)
      Sets a resolver callback used to determine whether a series is visible.

      If not set, all series are assumed visible.

    • paintComponent

      protected void paintComponent(Graphics g)
      Overrides:
      paintComponent in class JComponent