Class JSparklinesArrayListBarChartTableCellRenderer

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

public class JSparklinesArrayListBarChartTableCellRenderer
extends JLabel
implements TableCellRenderer
Table cell renderer displaying JSparklines plots consisting of numbers as a stacked bar chart. Supported input: ArrrayListDataPoints objects. Other object types are rendered using the DefaultTableCellRenderer.
Author:
Harald Barsnes
See Also:
Serialized Form
  • Constructor Details

    • JSparklinesArrayListBarChartTableCellRenderer

      public JSparklinesArrayListBarChartTableCellRenderer​(org.jfree.chart.plot.PlotOrientation plotOrientation, Double maxValue, ArrayList<Color> colors, JSparklinesArrayListBarChartTableCellRenderer.ValueDisplayType valueDisplayType)
      Creates a new JSparkLinesTableCellRenderer.
      Parameters:
      plotOrientation - the orientation of the plot
      maxValue - the maximum value to be plotted, used to make sure that all plots in the same column has the same maximum value and are thus comparable
      colors - the colors to use for the plot
      valueDisplayType - the value to display in the table
    • JSparklinesArrayListBarChartTableCellRenderer

      public JSparklinesArrayListBarChartTableCellRenderer​(org.jfree.chart.plot.PlotOrientation plotOrientation, Double maxValue, ArrayList<Color> colors, Color fillColor, JSparklinesArrayListBarChartTableCellRenderer.ValueDisplayType valueDisplayType)
      Creates a new JSparkLinesTableCellRenderer.
      Parameters:
      plotOrientation - the orientation of the plot
      maxValue - the maximum value to be plotted, used to make sure that all plots in the same column has the same maximum value and are thus comparable
      colors - the colors to use for the plot
      fillColor - the color used to fill the rest of the chart up to the max value (set to null if no filling should be used)
      valueDisplayType - the value to display in the table
    • JSparklinesArrayListBarChartTableCellRenderer

      @Deprecated public JSparklinesArrayListBarChartTableCellRenderer​(org.jfree.chart.plot.PlotOrientation plotOrientation, Double maxValue, ArrayList<Color> colors, boolean showFirstNumber)
      Deprecated.
      use the constructor with the ValueDisplayType instead
      Creates a new JSparkLinesTableCellRenderer.
      Parameters:
      plotOrientation - the orientation of the plot
      maxValue - the maximum value to be plotted, used to make sure that all plots in the same column has the same maximum value and are thus comparable
      colors - the colors to use for the plot
      showFirstNumber - if true, the first value is shown when showing the values, false shows the sum
    • JSparklinesArrayListBarChartTableCellRenderer

      @Deprecated public JSparklinesArrayListBarChartTableCellRenderer​(org.jfree.chart.plot.PlotOrientation plotOrientation, Double maxValue, ArrayList<Color> colors, Color fillColor, boolean showFirstNumber)
      Deprecated.
      use the constructor with the ValueDisplayType instead
      Creates a new JSparkLinesTableCellRenderer.
      Parameters:
      plotOrientation - the orientation of the plot
      maxValue - the maximum value to be plotted, used to make sure that all plots in the same column has the same maximum value and are thus comparable
      colors - the colors to use for the plot
      fillColor - the color used to fill the rest of the chart up to the max value (set to null if no filling should be used)
      showFirstNumber - if true, the first value is shown when showing the values, false shows the sum
  • Method Details

    • 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 chart.
      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, DecimalFormat numberFormat)
      If true the number will be shown together with the bar chart in the cell. False only display the chart.
      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
      numberFormat - the decimal format to use when showing the numbers
    • 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 chart.
      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.
    • showNumberAndChart

      public void showNumberAndChart​(boolean showNumberAndChart, int widthOfLabel, Font font, int horizontalAlignement, DecimalFormat numberFormat)
      If true the number will be shown together with the bar chart in the cell. False only display the chart.
      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.
      numberFormat - the decimal format to use when showing the numbers
    • 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
    • showFirstNumber

      @Deprecated public void showFirstNumber​(boolean showFirstNumber)
      Deprecated.
      use the ValueDisplayType enum instead
      If true, the first number is shown as the value. Otherwise the total value is shown.
      Parameters:
      showFirstNumber - the showFirstNumber to set
    • setValueDisplayType

      public void setValueDisplayType​(JSparklinesArrayListBarChartTableCellRenderer.ValueDisplayType valueDisplayType)
      Set the current value display type.
      Parameters:
      valueDisplayType - the value display type
    • getTableCellRendererComponent

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

      public void addReferenceLine​(String label, double value, float lineWidth, Color lineColor)
      Add a reference line at a given data value.
      Parameters:
      label - the label for the reference
      value - the reference line value
      lineWidth - the line width, has to non-negative
      lineColor - the line color
    • addReferenceLine

      public void addReferenceLine​(ReferenceLine referenceLine)
      Add a reference line at a given data value.
      Parameters:
      referenceLine - the reference line
    • removeReferenceLine

      public void removeReferenceLine​(String label)
      Removes the reference line with the given label. Does nothing if no reference with the given label is found.
      Parameters:
      label - the reference to remove
    • removeAllReferenceLines

      public void removeAllReferenceLines()
      Removes all the reference lines.
    • getAllReferenceLines

      public HashMap<String,​ReferenceLine> getAllReferenceLines()
      Returns all the references lines as a hashmap, with the labels as the keys.
      Returns:
      hashmap of all reference lines
    • addReferenceArea

      public void addReferenceArea​(String label, double start, double end, Color areaColor, float alpha)
      Add a reference area.
      Parameters:
      label - the label for the reference area
      start - the start of the reference area
      end - the end of the reference area
      areaColor - the color of the reference area
      alpha - the alpha level of the reference area, range: 0.0 to 1.0
    • addReferenceArea

      public void addReferenceArea​(ReferenceArea referenceArea)
      Add a reference area.
      Parameters:
      referenceArea - the reference area
    • removeReferenceArea

      public void removeReferenceArea​(String label)
      Removes the reference area with the given label. Does nothing if no reference with the given label is found.
      Parameters:
      label - the reference to remove
    • removeAllReferenceAreas

      public void removeAllReferenceAreas()
      Removes all the reference areas.
    • getAllReferenceAreas

      public HashMap<String,​ReferenceArea> getAllReferenceAreas()
      Returns all the references areas as a hashmap, with the labels as the keys.
      Returns:
      hashmap of all reference areas
    • setMaxValue

      public void setMaxValue​(double maxValue)
      Set the maximum value.
      Parameters:
      maxValue - the maximum value
    • getColors

      public ArrayList<Color> getColors()
      Get the colors used for the chart.
      Returns:
      the color used for the chart
    • setColors

      public void setColors​(ArrayList<Color> colors)
      Set the colors used for the chart.
      Parameters:
      colors - the colors to set
    • getPlotOrientation

      public org.jfree.chart.plot.PlotOrientation getPlotOrientation()
      Get the current plot orientation.
      Returns:
      the current plot orientation
    • setPlotOrientation

      public void setPlotOrientation​(org.jfree.chart.plot.PlotOrientation plotOrientation)
      Set the plot orientation.
      Parameters:
      plotOrientation - the new plot orientation
    • getChartPanel

      public org.jfree.chart.ChartPanel getChartPanel()
      Returns a reference to the chart panel.
      Returns:
      the chart panel.
    • setBackgroundColor

      public void setBackgroundColor​(Color color)
      Set the background color. If not set the background color of the given row will be used.
      Parameters:
      color - the new background color
    • getMaxValue

      public double getMaxValue()
      Returns the maximum value.
      Returns:
      the maxValue