Class PFieldComponentRenderer

All Implemented Interfaces:
Exportable, ImageObserver, MenuContainer, Serializable, Accessible, ListCellRenderer, SwingConstants, TableCellRenderer
Direct Known Subclasses:
PLinkRenderer, PServicesFieldRenderer, PSubFieldComponentRenderer

public class PFieldComponentRenderer extends JLabel implements ListCellRenderer, TableCellRenderer, Exportable
PFieldComponentRenderer is a generic renderer component for PFieldComponent objects. It abstracts out the formatting needed to display these kinds of objects.
Version:
9
Author:
Larry Lynch-Freshner
See Also:
  • Constructor Details

    • PFieldComponentRenderer

      public PFieldComponentRenderer(String format)
      Creates a new instance of the renderer based on the supplied format string.
      Parameters:
      format - the format string to use for rendering
    • PFieldComponentRenderer

      public PFieldComponentRenderer(String format, Locale loc)
      Creates a new instance of the renderer based on the supplied format string and locale info.
      Parameters:
      format - the format string to use for rendering
      loc - the locale to format for
    • PFieldComponentRenderer

      public PFieldComponentRenderer(PFieldComponent parent)
      Creates a new instance of the renderer based on the supplied component.
      Parameters:
      parent - the component to render
    • PFieldComponentRenderer

      public PFieldComponentRenderer(PInfranetMessageFormat fmt)
      Creates a new instance of the renderer based on the supplied format object.
      Parameters:
      fmt - the format to use for rendering
  • Method Details

    • setDisplayFormat

      public void setDisplayFormat(PInfranetMessageFormat format)
      Changes the renderer's format object.
      Parameters:
      format - the format to use for rendering
    • setDisplayFormat

      public void setDisplayFormat(String format)
      Changes the renderer's format string.
      Parameters:
      format - the format to use for rendering
    • setDisplayFormat

      public void setDisplayFormat(String format, Locale loc)
      Changes the renderer's format string.
      Parameters:
      format - the format to use for rendering
      loc - the locale
    • overrideCurrencySymbol

      public void overrideCurrencySymbol(String newSymbol)
      Uses a passed-in currency symbol to override the currency symbol used by the default locale.
      Parameters:
      newSymbol - a String that contains the replacement currency symbol
    • getListCellRendererComponent

      public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
      Gets a renderer for a list cell at a specified position. This is the core of the renderer for lists.
      Specified by:
      getListCellRendererComponent in interface ListCellRenderer
      Parameters:
      list - the list for which to format a row
      value - the value to format
      index - the list position of the value
      isSelected - true if the value is selected; false otherwise
      cellHasFocus - true if the cell has focus; false otherwise
      Returns:
      A renderer for the specified cell.
    • getTableCellRendererComponent

      public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
      Gets a renderer for a specific list cell. This is the core of the renderer for lists.
      Specified by:
      getTableCellRendererComponent in interface TableCellRenderer
      Parameters:
      table - the table for which to format a cell
      value - the value to format
      isSelected - true if the value is selected; false otherwise
      hasFocus - true if the cell has focus; false otherwise
      row - the table row for the value
      column - the table column of the value
      Returns:
      A renderer for the specified cell.
    • setRowBackground

      public void setRowBackground(Color c)
      Specifies the background color for the rows in this component.
      Parameters:
      c - the (unselected) row background color
    • setRowBackground

      public void setRowBackground(Color c1, Color c2)
      Specifies the alternating row color scheme for the component.
      Parameters:
      c1 - the (unselected) row background color for odd rows
      c2 - the (unselected) row background color for even rows
    • getDisplayedData

      public String getDisplayedData(Object value)
    • getFormattedLabel

      protected Component getFormattedLabel(Object value, Color focusColor)
      Gets the formatted label for display.
      Parameters:
      value - the type of component to label
      focusColor - the current border color; if focusColor is null, the label is rendered without borders
      Returns:
      This renderer.
    • setCurrencyFormat

      public void setCurrencyFormat(NumberFormat newFormat)
      Changes the currency format.
      Parameters:
      newformat - the new currency format
    • ignoreFormatingForClass

      public void ignoreFormatingForClass(Class cls)
    • getDataToDisplay

      public String getDataToDisplay(Object o)
      This method is called from the PIASpreadsheet, to display the data appropriately when the table is exported.
      Specified by:
      getDataToDisplay in interface Exportable
      Parameters:
      o - Object
      Returns:
      String