Class ContextTableCellRenderer

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, SwingConstants, TableCellRenderer

public class ContextTableCellRenderer extends DefaultTableCellRenderer
Custom table cell renderer for token metrics and status columns in the Context TreeTable.

This renderer detects whether a rendered node is a ResourceNode whose active viewport is truncated (i.e. only a partial slice of the resource file is loaded into the AI prompt window). When truncated, token metrics are highlighted in a theme-adaptive warning/orange color provided by SwingAgiConfig.getTruncatedTokenColor().

Look and Feel Adaptability: Supports both Dark and Light Swing themes dynamically, ensuring high contrast and readability on all platforms and desktop environments.

Author:
anahata
See Also:
  • Constructor Details

    • ContextTableCellRenderer

      public ContextTableCellRenderer()
      Constructs a default ContextTableCellRenderer with standard left alignment.
    • ContextTableCellRenderer

      public ContextTableCellRenderer(int horizontalAlignment)
      Constructs a ContextTableCellRenderer with a specific horizontal text alignment.
      Parameters:
      horizontalAlignment - One of the alignment constants defined in SwingConstants (e.g., javax.swing.SwingConstants.RIGHT or javax.swing.SwingConstants.LEFT).
  • Method Details

    • getTableCellRendererComponent

      public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)

      Implementation details: Inspects the target row in the parent JXTreeTable to determine if the node corresponds to a truncated ResourceNode. If truncated, the foreground text color is painted with an adaptive warning/orange color and an explanatory tooltip is attached.

      Specified by:
      getTableCellRendererComponent in interface TableCellRenderer
      Overrides:
      getTableCellRendererComponent in class DefaultTableCellRenderer
      Parameters:
      table - The JTable requesting rendering.
      value - The value of the cell to be rendered.
      isSelected - True if the cell is currently selected in the UI.
      hasFocus - True if the cell currently holds keyboard focus.
      row - The row index of the cell being painted.
      column - The column index of the cell being painted.
      Returns:
      The configured component for rendering.