Class AbstractGCellRenderer

All Implemented Interfaces:
GComponent, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, SwingConstants
Direct Known Subclasses:
GListCellRenderer, GTableCellRenderer

public abstract class AbstractGCellRenderer extends GDHtmlLabel
A common base class for list and table renderer objects, unifying the Ghidra look and feel.

It allows (but default-disables) HTML content, automatically paints alternating row background colors, and highlights the drop target in a drag-n-drop operation.

The preferred method to change the font used by this renderer is setBaseFontId(String). If you would like this renderer to use a monospaced font, then, as an alternative to creating a font ID, you can instead override getDefaultFont() to return this class's fixedWidthFont. Also, the fixed width font of this class is based on the default font set when calling setBaseFontId(String), so it stays up-to-date with theme changes.

See Also:
  • Field Details

    • systemAlternateRowColors

      protected static boolean systemAlternateRowColors
    • focusBorder

      protected Border focusBorder
    • noFocusBorder

      protected Border noFocusBorder
    • defaultFont

      protected Font defaultFont
    • fixedWidthFont

      protected Font fixedWidthFont
    • boldFont

      protected Font boldFont
    • italicFont

      protected Font italicFont
    • dropRow

      protected int dropRow
  • Constructor Details

    • AbstractGCellRenderer

      public AbstractGCellRenderer()
  • Method Details

    • setShouldAlternateRowBackgroundColors

      public void setShouldAlternateRowBackgroundColors(boolean alternate)
    • shouldAlternateRowBackgroundColor

      public boolean shouldAlternateRowBackgroundColor()
      Return whether or not the renderer should alternate row background colors.

      A renderer is unable to override an enforcing DISABLE_ALTERNATING_ROW_COLORS_PROPERTY system property -- if the property has disabled alternating colors (i.e., set to 'true'), this method returns false. If the property is false, individual renderers may assert control over alternating row colors.

      Returns:
      True if the rows may be painted in alternate background colors, false otherwise
      See Also:
      • DISABLE_ALTERNATING_ROW_COLORS_PROPERTY
    • getAlternatingBackgroundColor

      protected Color getAlternatingBackgroundColor(JComponent parent, int row)
      Returns the background color appropriate for the given component. This may vary depending upon the current OS.
      Parameters:
      parent - The parent being rendered -- likely a list or table.
      row - The row being rendered.
      Returns:
      the color
    • setBaseFontId

      public void setBaseFontId(String fontId)
      Sets this renderer's theme font id. This will be used to load the base font and to create the derived fonts, such as bold and fixed width.
      Parameters:
      fontId - the font id
      See Also:
    • setFont

      public void setFont(Font f)
      Overrides:
      setFont in class JComponent
    • checkForInvalidSetFont

      protected void checkForInvalidSetFont(Font f)
    • setBold

      protected void setBold()
      Sets the font of this renderer to be bold until the next time that getTableCellRenderer() is called, as it resets the font to the default font on each pass.
      See Also:
    • setItalic

      protected void setItalic()
      Sets the font of this renderer to be italic until the next time that getTableCellRenderer() is called, as it resets the font to the default font on each pass.
      See Also:
    • getDefaultFont

      protected Font getDefaultFont()
    • getFixedWidthFont

      public Font getFixedWidthFont()
    • getBoldFont

      public Font getBoldFont()
    • getItalicFont

      public Font getItalicFont()
    • setDropRow

      public void setDropRow(int dropRow)
      Sets the row where DnD would perform drop operation.
      Parameters:
      dropRow - the drop row
    • getNoFocusBorder

      protected Border getNoFocusBorder()
    • getDefaultBackgroundColor

      protected Color getDefaultBackgroundColor()
    • getBackgroundColorForRow

      protected Color getBackgroundColorForRow(int row)
    • getErrorForegroundColor

      protected Color getErrorForegroundColor(boolean isSelected)
    • getUneditableForegroundColor

      protected Color getUneditableForegroundColor(boolean isSelected)
    • invalidate

      public void invalidate()
      See DefaultTableCellRenderer class header javadoc for more info.
      Overrides:
      invalidate in class Container
    • superValidate

      protected void superValidate()
    • validate

      public void validate()
      See DefaultTableCellRenderer class header javadoc for more info.
      Overrides:
      validate in class Container
    • revalidate

      public void revalidate()
      See DefaultTableCellRenderer class header javadoc for more info.
      Overrides:
      revalidate in class JComponent
    • repaint

      public void repaint(long tm, int x, int y, int width, int height)
      See DefaultTableCellRenderer class header javadoc for more info.
      Overrides:
      repaint in class JComponent
    • repaint

      public void repaint(Rectangle r)
      See DefaultTableCellRenderer class header javadoc for more info.
      Overrides:
      repaint in class JComponent
    • repaint

      public void repaint()
      See DefaultTableCellRenderer class header javadoc for more info.
      Overrides:
      repaint in class Component
    • firePropertyChange

      protected void firePropertyChange(String property, Object oldValue, Object newValue)
      See DefaultTableCellRenderer class header javadoc for more info.
      Overrides:
      firePropertyChange in class Component
    • firePropertyChange

      public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
      See DefaultTableCellRenderer class header javadoc for more info.
      Overrides:
      firePropertyChange in class JComponent
    • setForeground

      public void setForeground(Color fg)
      Overrides this method to ensure that the new foreground color is not a GColorUIResource. Some Look and Feels will ignore color values that extend UIResource, choosing instead their own custom painting behavior. By not using a UIResource, we prevent the Look and Feel from overriding this renderer's color value.
      Overrides:
      setForeground in class JComponent
      Parameters:
      fg - the new foreground color
    • setBackground

      public void setBackground(Color bg)
      Overrides this method to ensure that the new background color is not a GColorUIResource. Some Look and Feels will ignore color values that extend UIResource, choosing instead their own custom painting behavior. By not using a UIResource, we prevent the Look and Feel from overriding this renderer's color value.
      Overrides:
      setBackground in class JComponent
      Parameters:
      bg - the new background color