Class AbstractCategoryItemRenderer

java.lang.Object
org.jfree.chart.renderer.AbstractRenderer
org.jfree.chart.renderer.AbstractCategoryItemRenderer
All Implemented Interfaces:
Serializable, Cloneable, CategoryItemRenderer
Direct Known Subclasses:
AreaRenderer, BarRenderer, BoxAndWhiskerRenderer, CategoryStepRenderer, LevelRenderer, LineAndShapeRenderer, MinMaxCategoryRenderer

public abstract class AbstractCategoryItemRenderer
extends AbstractRenderer
implements CategoryItemRenderer, Cloneable, Serializable
An abstract base class that you can use to implement a new CategoryItemRenderer.

When you create a new CategoryItemRenderer you are not required to extend this class, but it makes the job easier.

See Also:
Serialized Form
  • Method Details

    • getPlot

      public CategoryPlot getPlot()
      Returns the plot that the renderer has been assigned to (where null indicates that the renderer is not currently assigned to a plot).
      Specified by:
      getPlot in interface CategoryItemRenderer
      Returns:
      The plot (possibly null).
    • setPlot

      public void setPlot​(CategoryPlot plot)
      Sets the plot that the renderer has been assigned to. This method is usually called by the CategoryPlot, in normal usage you shouldn't need to call this method directly.
      Specified by:
      setPlot in interface CategoryItemRenderer
      Parameters:
      plot - the plot (null not permitted).
    • getLabelGenerator

      public CategoryLabelGenerator getLabelGenerator​(int row, int column)
      Returns the label generator for a data item. This implementation simply passes control to the getSeriesLabelGenerator(int) method. If, for some reason, you want a different generator for individual items, you can override this method.
      Specified by:
      getLabelGenerator in interface CategoryItemRenderer
      Parameters:
      row - the row index (zero based).
      column - the column index (zero based).
      Returns:
      the generator (possibly null).
    • getSeriesLabelGenerator

      public CategoryLabelGenerator getSeriesLabelGenerator​(int series)
      Returns the label generator for a series.
      Specified by:
      getSeriesLabelGenerator in interface CategoryItemRenderer
      Parameters:
      series - the series index (zero based).
      Returns:
      the generator (possibly null).
    • setLabelGenerator

      public void setLabelGenerator​(CategoryLabelGenerator generator)
      Sets the label generator for ALL series and sends a RendererChangeEvent to all registered listeners.
      Specified by:
      setLabelGenerator in interface CategoryItemRenderer
      Parameters:
      generator - the generator (null permitted).
    • setSeriesLabelGenerator

      public void setSeriesLabelGenerator​(int series, CategoryLabelGenerator generator)
      Sets the label generator for a series and sends a RendererChangeEvent to all registered listeners.
      Specified by:
      setSeriesLabelGenerator in interface CategoryItemRenderer
      Parameters:
      series - the series index (zero based).
      generator - the generator (null permitted).
    • getBaseLabelGenerator

      public CategoryLabelGenerator getBaseLabelGenerator()
      Returns the base label generator.
      Specified by:
      getBaseLabelGenerator in interface CategoryItemRenderer
      Returns:
      The generator (possibly null).
    • setBaseLabelGenerator

      public void setBaseLabelGenerator​(CategoryLabelGenerator generator)
      Sets the base label generator and sends a RendererChangeEvent to all registered listeners.
      Specified by:
      setBaseLabelGenerator in interface CategoryItemRenderer
      Parameters:
      generator - the generator (null permitted).
    • getToolTipGenerator

      public CategoryToolTipGenerator getToolTipGenerator​(int row, int column)
      Returns the tool tip generator that should be used for the specified item. This method looks up the generator using the "three-layer" approach outlined in the general description of this interface. You can override this method if you want to return a different generator per item.
      Specified by:
      getToolTipGenerator in interface CategoryItemRenderer
      Parameters:
      row - the row index (zero-based).
      column - the column index (zero-based).
      Returns:
      The generator (possibly null).
    • getToolTipGenerator

      public CategoryToolTipGenerator getToolTipGenerator()
      Returns the tool tip generator that will be used for ALL items in the dataset (the "layer 0" generator).
      Specified by:
      getToolTipGenerator in interface CategoryItemRenderer
      Returns:
      A tool tip generator (possibly null).
    • setToolTipGenerator

      public void setToolTipGenerator​(CategoryToolTipGenerator generator)
      Sets the tool tip generator for ALL series and sends a RendererChangeEvent to all registered listeners.
      Specified by:
      setToolTipGenerator in interface CategoryItemRenderer
      Parameters:
      generator - the generator (null permitted).
    • getSeriesToolTipGenerator

      public CategoryToolTipGenerator getSeriesToolTipGenerator​(int series)
      Returns the tool tip generator for the specified series (a "layer 1" generator).
      Specified by:
      getSeriesToolTipGenerator in interface CategoryItemRenderer
      Parameters:
      series - the series index (zero-based).
      Returns:
      The tool tip generator (possibly null).
    • setSeriesToolTipGenerator

      public void setSeriesToolTipGenerator​(int series, CategoryToolTipGenerator generator)
      Sets the tool tip generator for a series and sends a RendererChangeEvent to all registered listeners.
      Specified by:
      setSeriesToolTipGenerator in interface CategoryItemRenderer
      Parameters:
      series - the series index (zero-based).
      generator - the generator (null permitted).
    • getBaseToolTipGenerator

      public CategoryToolTipGenerator getBaseToolTipGenerator()
      Returns the base tool tip generator (the "layer 2" generator).
      Specified by:
      getBaseToolTipGenerator in interface CategoryItemRenderer
      Returns:
      The tool tip generator (possibly null).
    • setBaseToolTipGenerator

      public void setBaseToolTipGenerator​(CategoryToolTipGenerator generator)
      Sets the base tool tip generator and sends a RendererChangeEvent to all registered listeners.
      Specified by:
      setBaseToolTipGenerator in interface CategoryItemRenderer
      Parameters:
      generator - the generator (null permitted).
    • getItemURLGenerator

      public CategoryURLGenerator getItemURLGenerator​(int row, int column)
      Returns the URL generator for a data item. This method just calls the getSeriesItemURLGenerator method, but you can override this behaviour if you want to.
      Specified by:
      getItemURLGenerator in interface CategoryItemRenderer
      Parameters:
      row - the row index (zero based).
      column - the column index (zero based).
      Returns:
      The URL generator.
    • getSeriesItemURLGenerator

      public CategoryURLGenerator getSeriesItemURLGenerator​(int series)
      Returns the URL generator for a series.
      Specified by:
      getSeriesItemURLGenerator in interface CategoryItemRenderer
      Parameters:
      series - the series index (zero based).
      Returns:
      The URL generator for the series.
    • setItemURLGenerator

      public void setItemURLGenerator​(CategoryURLGenerator generator)
      Sets the item URL generator for ALL series.
      Specified by:
      setItemURLGenerator in interface CategoryItemRenderer
      Parameters:
      generator - the generator.
    • setSeriesItemURLGenerator

      public void setSeriesItemURLGenerator​(int series, CategoryURLGenerator generator)
      Sets the URL generator for a series.
      Specified by:
      setSeriesItemURLGenerator in interface CategoryItemRenderer
      Parameters:
      series - the series index (zero based).
      generator - the generator.
    • getBaseItemURLGenerator

      public CategoryURLGenerator getBaseItemURLGenerator()
      Returns the base item URL generator.
      Specified by:
      getBaseItemURLGenerator in interface CategoryItemRenderer
      Returns:
      The item URL generator.
    • setBaseItemURLGenerator

      public void setBaseItemURLGenerator​(CategoryURLGenerator generator)
      Sets the base item URL generator.
      Specified by:
      setBaseItemURLGenerator in interface CategoryItemRenderer
      Parameters:
      generator - the item URL generator.
    • getRowCount

      public int getRowCount()
      Returns:
      the row count.
    • getColumnCount

      public int getColumnCount()
      Returns:
      the column count.
    • initialise

      public CategoryItemRendererState initialise​(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info)
      Initialises the renderer and returns a state object that will be used for the remainder of the drawing process for a single chart. The state object allows for the fact that the renderer may be used simultaneously by multiple threads (each thread will work with a separate state object).

      Stores a reference to the PlotRenderingInfo object (which might be null), and then sets the useCategoriesPaint flag according to the special case conditions a) there is only one series and b) the categoriesPaint array is not null.

      Specified by:
      initialise in interface CategoryItemRenderer
      Parameters:
      g2 - the graphics device.
      dataArea - the data area.
      plot - the plot.
      rendererIndex - the renderer index.
      info - an object for returning information about the structure of the plot (null permitted).
      Returns:
      the renderer state.
    • getRangeExtent

      public Range getRangeExtent​(CategoryDataset dataset)
      Returns the range of values the renderer requires to display all the items from the specified dataset.
      Specified by:
      getRangeExtent in interface CategoryItemRenderer
      Parameters:
      dataset - the dataset (null permitted).
      Returns:
      The range (or null if the dataset is null or empty).
    • drawBackground

      public void drawBackground​(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea)
      Draws a background for the data area. The default implementation just gets the plot to draw the outline, but some renderers will override this behaviour.
      Specified by:
      drawBackground in interface CategoryItemRenderer
      Parameters:
      g2 - the graphics device.
      plot - the plot.
      dataArea - the data area.
    • drawOutline

      public void drawOutline​(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea)
      Draws an outline for the data area. The default implementation just gets the plot to draw the outline, but some renderers will override this behaviour.
      Specified by:
      drawOutline in interface CategoryItemRenderer
      Parameters:
      g2 - the graphics device.
      plot - the plot.
      dataArea - the data area.
    • drawDomainGridline

      public void drawDomainGridline​(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, double value)
      Draws a grid line against the domain axis.

      Note that this default implementation assumes that the horizontal axis is the domain axis. If this is not the case, you will need to override this method.

      Specified by:
      drawDomainGridline in interface CategoryItemRenderer
      Parameters:
      g2 - the graphics device.
      plot - the plot.
      dataArea - the area for plotting data (not yet adjusted for any 3D effect).
      value - the Java2D value at which the grid line should be drawn.
    • drawRangeGridline

      public void drawRangeGridline​(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Rectangle2D dataArea, double value)
      Draws a grid line against the range axis.
      Specified by:
      drawRangeGridline in interface CategoryItemRenderer
      Parameters:
      g2 - the graphics device.
      plot - the plot.
      axis - the value axis.
      dataArea - the area for plotting data (not yet adjusted for any 3D effect).
      value - the value at which the grid line should be drawn.
    • drawRangeMarker

      public void drawRangeMarker​(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Marker marker, Rectangle2D dataArea)
      Draws a marker for the range axis.
      Specified by:
      drawRangeMarker in interface CategoryItemRenderer
      Parameters:
      g2 - the graphics device (not null).
      plot - the plot (not null).
      axis - the range axis (not null).
      marker - the marker to be drawn (not null).
      dataArea - the area inside the axes (not null).
    • getLegendItem

      public LegendItem getLegendItem​(int datasetIndex, int series)
      Returns a legend item for a series.
      Specified by:
      getLegendItem in interface CategoryItemRenderer
      Parameters:
      datasetIndex - the dataset index (zero-based).
      series - the series index (zero-based).
      Returns:
      the legend item.
    • equals

      public boolean equals​(Object obj)
      Tests this renderer for equality with another object.
      Overrides:
      equals in class AbstractRenderer
      Parameters:
      obj - the object.
      Returns:
      true or false.
    • hashCode

      public int hashCode()
      Returns a hash code for the renderer.
      Overrides:
      hashCode in class AbstractRenderer
      Returns:
      The hash code.
    • getDrawingSupplier

      public DrawingSupplier getDrawingSupplier()
      Returns the drawing supplier from the plot.
      Specified by:
      getDrawingSupplier in class AbstractRenderer
      Returns:
      The drawing supplier (possibly null).
    • clone

      public Object clone() throws CloneNotSupportedException
      Returns an independent copy of the renderer.

      The plot reference is shallow copied.

      Returns:
      A clone.
      Throws:
      CloneNotSupportedException - can be thrown if one of the objects belonging to the renderer does not support cloning (for example, an item label generator).