Class JSparklinesIntegerColorTableCellRenderer

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
no.uib.jsparklines.renderers.JSparklinesIntegerColorTableCellRenderer
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, TableCellRenderer

public class JSparklinesIntegerColorTableCellRenderer
extends JPanel
implements TableCellRenderer
Table cell renderer displaying integers as colored equal size bar charts. Supported input: Integer objects. Other object types are rendered using the DefaultTableCellRenderer.
Author:
Harald Barsnes
See Also:
Serialized Form
  • Constructor Details

    • JSparklinesIntegerColorTableCellRenderer

      public JSparklinesIntegerColorTableCellRenderer​(Color defaultColor, HashMap<Integer,​Color> colors)
      Creates a new JSparklinesIntegerColorTableCellRenderer, where all integer cell values are displayed as equal size bars, but using different colors as defined by the colors hash map.
      Parameters:
      defaultColor - the color to use for the bars if an integer without a mapped color is found
      colors - a HashMap with the integer to color mappings
    • JSparklinesIntegerColorTableCellRenderer

      public JSparklinesIntegerColorTableCellRenderer​(Color defaultColor, HashMap<Integer,​Color> colors, HashMap<Integer,​String> tooltips)
      Creates a new JSparklinesIntegerColorTableCellRenderer, where all integer cell values are displayed as equal size bars, but using different colors as defined by the colors hash map.
      Parameters:
      defaultColor - the color to use for the bars if an integer without a mapped color is found
      colors - a HashMap with the integer to color mappings
      tooltips - a HashMap with the integer to tooltip mappings
  • Method Details

    • setBackgroundColor

      public void setBackgroundColor​(Color plotBackgroundColor)
      Set the plot background color.
      Parameters:
      plotBackgroundColor - the plot background color
    • showNumberAndChart

      public void showNumberAndChart​(boolean showNumberAndChart, int widthOfLabel)
      If true the number will be shown together with the bar chart in the cell. False only display the bar chart. This method is not to be confused with the showNumbers-method that only displays the numbers.
      Parameters:
      showNumberAndChart - if true the number and the chart is shown in the cell
      widthOfLabel - the width used to display the label containing the number
    • showNumberAndChart

      public void showNumberAndChart​(boolean showNumberAndChart, int widthOfLabel, Font font, int horizontalAlignement)
      If true the number will be shown together with the bar chart in the cell. False only display the bar chart. This method is not to be confused with the showNumbers-method that only displays the numbers.
      Parameters:
      showNumberAndChart - if true the number and the chart is shown in the cell
      widthOfLabel - the width used to display the label containing the number
      font - the font to use for the label
      horizontalAlignement - the horizontal alignment of the text in the label: one of the following constants defined in SwingConstants: LEFT, CENTER, RIGHT, LEADING or TRAILING.
    • showNumbers

      public void showNumbers​(boolean showNumbers)
      Set if the underlying numbers or the bar charts are to be shown.
      Parameters:
      showNumbers - if true the underlying numbers are shown
    • getTableCellRendererComponent

      public Component getTableCellRendererComponent​(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
      Specified by:
      getTableCellRendererComponent in interface TableCellRenderer
    • getColors

      public HashMap<Integer,​Color> getColors()
      Return the color map.
      Returns:
      the colors
    • setColors

      public void setColors​(HashMap<Integer,​Color> colors)
      Set the color map.
      Parameters:
      colors - the colors to set
    • getTooltips

      public HashMap<Integer,​String> getTooltips()
      Returns the tooltips map.
      Returns:
      the tooltips
    • setTooltips

      public void setTooltips​(HashMap<Integer,​String> tooltips)
      Set the tooltip map.
      Parameters:
      tooltips - the tooltips to set