Module platform

Class BoxAndWhiskerRenderer

All Implemented Interfaces:
Serializable, Cloneable, LegendItemSource, CategoryItemRenderer, PublicCloneable

public class BoxAndWhiskerRenderer extends AbstractCategoryItemRenderer implements Cloneable, PublicCloneable, Serializable
A box-and-whisker renderer. This renderer requires a BoxAndWhiskerCategoryDataset and is for use with the CategoryPlot class. The example shown here is generated by the BoxAndWhiskerChartDemo1.java program included in the JFreeChart Demo Collection:

BoxAndWhiskerRendererSample.png
See Also:
  • Constructor Details

    • BoxAndWhiskerRenderer

      public BoxAndWhiskerRenderer()
      Default constructor.
  • Method Details

    • getArtifactPaint

      public Paint getArtifactPaint()
      Returns the paint used to color the median and average markers.
      Returns:
      The paint used to draw the median and average markers (never null).
      See Also:
    • setArtifactPaint

      public void setArtifactPaint(Paint paint)
      Sets the paint used to color the median and average markers and sends a RendererChangeEvent to all registered listeners.
      Parameters:
      paint - the paint (null not permitted).
      See Also:
    • getFillBox

      public boolean getFillBox()
      Returns the flag that controls whether or not the box is filled.
      Returns:
      A boolean.
      See Also:
    • setFillBox

      public void setFillBox(boolean flag)
      Sets the flag that controls whether or not the box is filled and sends a RendererChangeEvent to all registered listeners.
      Parameters:
      flag - the flag.
      See Also:
    • getItemMargin

      public double getItemMargin()
      Returns the item margin. This is a percentage of the available space that is allocated to the space between items in the chart.
      Returns:
      The margin.
      See Also:
    • setItemMargin

      public void setItemMargin(double margin)
      Sets the item margin and sends a RendererChangeEvent to all registered listeners.
      Parameters:
      margin - the margin (a percentage).
      See Also:
    • getMaximumBarWidth

      public double getMaximumBarWidth()
      Returns the maximum bar width as a percentage of the available drawing space. Take care with the encoding, for example 0.10 is ten percent.
      Returns:
      The maximum bar width.
      See Also:
    • setMaximumBarWidth

      public void setMaximumBarWidth(double percent)
      Sets the maximum bar width, which is specified as a percentage of the available space for all bars, and sends a RendererChangeEvent to all registered listeners.
      Parameters:
      percent - the maximum bar width (a percentage, where 0.10 is ten percent).
      See Also:
    • isMeanVisible

      public boolean isMeanVisible()
      Returns the flag that controls whether or not the mean indicator is draw for each item.
      Returns:
      A boolean.
      See Also:
    • setMeanVisible

      public void setMeanVisible(boolean visible)
      Sets the flag that controls whether or not the mean indicator is drawn for each item, and sends a RendererChangeEvent to all registered listeners.
      Parameters:
      visible - the new flag value.
      See Also:
    • isMedianVisible

      public boolean isMedianVisible()
      Returns the flag that controls whether or not the median indicator is draw for each item.
      Returns:
      A boolean.
      See Also:
    • setMedianVisible

      public void setMedianVisible(boolean visible)
      Sets the flag that controls whether or not the median indicator is drawn for each item, and sends a RendererChangeEvent to all registered listeners.
      Parameters:
      visible - the new flag value.
      See Also:
    • isMinOutlierVisible

      public boolean isMinOutlierVisible()
      Returns the flag that controls whether or not the minimum outlier is draw for each item.
      Returns:
      A boolean.
      Since:
      1.5.2
      See Also:
    • setMinOutlierVisible

      public void setMinOutlierVisible(boolean visible)
      Sets the flag that controls whether or not the minimum outlier is drawn for each item, and sends a RendererChangeEvent to all registered listeners.
      Parameters:
      visible - the new flag value.
      Since:
      1.5.2
      See Also:
    • isMaxOutlierVisible

      public boolean isMaxOutlierVisible()
      Returns the flag that controls whether or not the maximum outlier is draw for each item.
      Returns:
      A boolean.
      Since:
      1.5.2
      See Also:
    • setMaxOutlierVisible

      public void setMaxOutlierVisible(boolean visible)
      Sets the flag that controls whether or not the maximum outlier is drawn for each item, and sends a RendererChangeEvent to all registered listeners.
      Parameters:
      visible - the new flag value.
      Since:
      1.5.2
      See Also:
    • getUseOutlinePaintForWhiskers

      public boolean getUseOutlinePaintForWhiskers()
      Returns the flag that, if true, causes the whiskers to be drawn using the series outline paint.
      Returns:
      A boolean.
    • setUseOutlinePaintForWhiskers

      public void setUseOutlinePaintForWhiskers(boolean flag)
      Sets the flag that, if true, causes the whiskers to be drawn using the series outline paint, and sends a RendererChangeEvent to all registered listeners.
      Parameters:
      flag - the new flag value.
    • getWhiskerWidth

      public double getWhiskerWidth()
      Returns the width of the whiskers as fraction of the bar width.
      Returns:
      The width of the whiskers.
      See Also:
    • setWhiskerWidth

      public void setWhiskerWidth(double width)
      Sets the width of the whiskers as a fraction of the bar width and sends a RendererChangeEvent to all registered listeners.
      Parameters:
      width - a value between 0 and 1 indicating how wide the whisker is supposed to be compared to the bar.
      See Also:
    • getLegendItem

      public LegendItem getLegendItem(int datasetIndex, int series)
      Returns a legend item for a series.
      Specified by:
      getLegendItem in interface CategoryItemRenderer
      Overrides:
      getLegendItem in class AbstractCategoryItemRenderer
      Parameters:
      datasetIndex - the dataset index (zero-based).
      series - the series index (zero-based).
      Returns:
      The legend item (possibly null).
      See Also:
    • findRangeBounds

      public Range findRangeBounds(CategoryDataset dataset)
      Returns the range of values from the specified dataset that the renderer will require to display all the data.
      Specified by:
      findRangeBounds in interface CategoryItemRenderer
      Overrides:
      findRangeBounds in class AbstractCategoryItemRenderer
      Parameters:
      dataset - the dataset.
      Returns:
      The range.
    • initialise

      public CategoryItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info)
      Initialises the renderer. This method gets called once at the start of the process of drawing a chart.
      Specified by:
      initialise in interface CategoryItemRenderer
      Overrides:
      initialise in class AbstractCategoryItemRenderer
      Parameters:
      g2 - the graphics device.
      dataArea - the area in which the data is to be plotted.
      plot - the plot.
      rendererIndex - the renderer index.
      info - collects chart rendering information for return to caller.
      Returns:
      The renderer state.
    • drawItem

      public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass)
      Draw a single data item.
      Specified by:
      drawItem in interface CategoryItemRenderer
      Parameters:
      g2 - the graphics device.
      state - the renderer state.
      dataArea - the area in which the data is drawn.
      plot - the plot.
      domainAxis - the domain axis.
      rangeAxis - the range axis.
      dataset - the data (must be an instance of BoxAndWhiskerCategoryDataset).
      row - the row index (zero-based).
      column - the column index (zero-based).
      pass - the pass index.
    • drawHorizontalItem

      public void drawHorizontalItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column)
      Draws the visual representation of a single data item when the plot has a horizontal orientation.
      Parameters:
      g2 - the graphics device.
      state - the renderer state.
      dataArea - the area within which the plot is being drawn.
      plot - the plot (can be used to obtain standard color information etc).
      domainAxis - the domain axis.
      rangeAxis - the range axis.
      dataset - the dataset (must be an instance of BoxAndWhiskerCategoryDataset).
      row - the row index (zero-based).
      column - the column index (zero-based).
    • drawVerticalItem

      public void drawVerticalItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column)
      Draws the visual representation of a single data item when the plot has a vertical orientation.
      Parameters:
      g2 - the graphics device.
      state - the renderer state.
      dataArea - the area within which the plot is being drawn.
      plot - the plot (can be used to obtain standard color information etc).
      domainAxis - the domain axis.
      rangeAxis - the range axis.
      dataset - the dataset (must be an instance of BoxAndWhiskerCategoryDataset).
      row - the row index (zero-based).
      column - the column index (zero-based).
    • equals

      public boolean equals(Object obj)
      Tests this renderer for equality with an arbitrary object.
      Overrides:
      equals in class AbstractCategoryItemRenderer
      Parameters:
      obj - the object (null permitted).
      Returns:
      true or false.