Class RingPlot

All Implemented Interfaces:
Serializable, Cloneable, EventListener, AnnotationChangeListener, AxisChangeListener, MarkerChangeListener, LegendItemSource, PublicCloneable, DatasetChangeListener

public class RingPlot extends PiePlot implements Cloneable, Serializable
A customised pie plot that leaves a hole in the middle.
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For serialization.
      See Also:
    • centerTextMode

      private CenterTextMode centerTextMode
      The center text mode.
    • centerText

      private String centerText
      Text to display in the middle of the chart (used for CenterTextMode.FIXED).
    • centerTextFormatter

      private Format centerTextFormatter
      The formatter used when displaying the first data value from the dataset (CenterTextMode.VALUE).
    • centerTextFont

      private Font centerTextFont
      The font used to display the center text.
    • centerTextColor

      private Color centerTextColor
      The color used to display the center text.
    • separatorsVisible

      private boolean separatorsVisible
      A flag that controls whether or not separators are drawn between the sections of the chart.
    • separatorStroke

      private transient Stroke separatorStroke
      The stroke used to draw separators.
    • separatorPaint

      private transient Paint separatorPaint
      The paint used to draw separators.
    • innerSeparatorExtension

      private double innerSeparatorExtension
      The length of the inner separator extension (as a percentage of the depth of the sections).
    • outerSeparatorExtension

      private double outerSeparatorExtension
      The length of the outer separator extension (as a percentage of the depth of the sections).
    • sectionDepth

      private double sectionDepth
      The depth of the section as a percentage of the diameter.
  • Constructor Details

    • RingPlot

      public RingPlot()
      Creates a new plot with a null dataset.
    • RingPlot

      public RingPlot(PieDataset dataset)
      Creates a new plot for the specified dataset.
      Parameters:
      dataset - the dataset (null permitted).
  • Method Details

    • getCenterTextMode

      public CenterTextMode getCenterTextMode()
      Returns the mode for displaying text in the center of the plot. The default value is CenterTextMode.NONE therefore no text will be displayed by default.
      Returns:
      The mode (never null).
    • setCenterTextMode

      public void setCenterTextMode(CenterTextMode mode)
      Sets the mode for displaying text in the center of the plot and sends a change event to all registered listeners. For CenterTextMode.FIXED, the display text will come from the centerText attribute (see getCenterText()). For CenterTextMode.VALUE, the center text will be the value from the first section in the dataset.
      Parameters:
      mode - the mode (null not permitted).
    • getCenterText

      public String getCenterText()
      Returns the text to display in the center of the plot when the mode is CenterTextMode.FIXED.
      Returns:
      The text (possibly null).
    • setCenterText

      public void setCenterText(String text)
      Sets the text to display in the center of the plot and sends a change event to all registered listeners. If the text is set to null, no text will be displayed.
      Parameters:
      text - the text (null permitted).
    • getCenterTextFormatter

      public Format getCenterTextFormatter()
      Returns the formatter used to format the center text value for the mode CenterTextMode.VALUE. The default value is DecimalFormat("0.00").
      Returns:
      The formatter (never null).
    • setCenterTextFormatter

      public void setCenterTextFormatter(Format formatter)
      Sets the formatter used to format the center text value and sends a change event to all registered listeners.
      Parameters:
      formatter - the formatter (null not permitted).
    • getCenterTextFont

      public Font getCenterTextFont()
      Returns the font used to display the center text. The default value is PiePlot.DEFAULT_LABEL_FONT.
      Returns:
      The font (never null).
    • setCenterTextFont

      public void setCenterTextFont(Font font)
      Sets the font used to display the center text and sends a change event to all registered listeners.
      Parameters:
      font - the font (null not permitted).
    • getCenterTextColor

      public Color getCenterTextColor()
      Returns the color for the center text. The default value is Color.BLACK.
      Returns:
      The color (never null).
    • setCenterTextColor

      public void setCenterTextColor(Color color)
      Sets the color for the center text and sends a change event to all registered listeners.
      Parameters:
      color - the color (null not permitted).
    • getSeparatorsVisible

      public boolean getSeparatorsVisible()
      Returns a flag that indicates whether or not separators are drawn between the sections in the chart.
      Returns:
      A boolean.
      See Also:
    • setSeparatorsVisible

      public void setSeparatorsVisible(boolean visible)
      Sets the flag that controls whether or not separators are drawn between the sections in the chart, and sends a change event to all registered listeners.
      Parameters:
      visible - the flag.
      See Also:
    • getSeparatorStroke

      public Stroke getSeparatorStroke()
      Returns the separator stroke.
      Returns:
      The stroke (never null).
      See Also:
    • setSeparatorStroke

      public void setSeparatorStroke(Stroke stroke)
      Sets the stroke used to draw the separator between sections and sends a change event to all registered listeners.
      Parameters:
      stroke - the stroke (null not permitted).
      See Also:
    • getSeparatorPaint

      public Paint getSeparatorPaint()
      Returns the separator paint.
      Returns:
      The paint (never null).
      See Also:
    • setSeparatorPaint

      public void setSeparatorPaint(Paint paint)
      Sets the paint used to draw the separator between sections and sends a change event to all registered listeners.
      Parameters:
      paint - the paint (null not permitted).
      See Also:
    • getInnerSeparatorExtension

      public double getInnerSeparatorExtension()
      Returns the length of the inner extension of the separator line that is drawn between sections, expressed as a percentage of the depth of the section.
      Returns:
      The inner separator extension (as a percentage).
      See Also:
    • setInnerSeparatorExtension

      public void setInnerSeparatorExtension(double percent)
      Sets the length of the inner extension of the separator line that is drawn between sections, as a percentage of the depth of the sections, and sends a change event to all registered listeners.
      Parameters:
      percent - the percentage.
      See Also:
    • getOuterSeparatorExtension

      public double getOuterSeparatorExtension()
      Returns the length of the outer extension of the separator line that is drawn between sections, expressed as a percentage of the depth of the section.
      Returns:
      The outer separator extension (as a percentage).
      See Also:
    • setOuterSeparatorExtension

      public void setOuterSeparatorExtension(double percent)
      Sets the length of the outer extension of the separator line that is drawn between sections, as a percentage of the depth of the sections, and sends a change event to all registered listeners.
      Parameters:
      percent - the percentage.
      See Also:
    • getSectionDepth

      public double getSectionDepth()
      Returns the depth of each section, expressed as a percentage of the plot radius.
      Returns:
      The depth of each section.
      See Also:
    • setSectionDepth

      public void setSectionDepth(double sectionDepth)
      The section depth is given as percentage of the plot radius. Specifying 1.0 results in a straightforward pie chart.
      Parameters:
      sectionDepth - the section depth.
      See Also:
    • initialise

      public PiePlotState initialise(Graphics2D g2, Rectangle2D plotArea, PiePlot plot, Integer index, PlotRenderingInfo info)
      Initialises the plot state (which will store the total of all dataset values, among other things). This method is called once at the beginning of each drawing.
      Overrides:
      initialise in class PiePlot
      Parameters:
      g2 - the graphics device.
      plotArea - the plot area (null not permitted).
      plot - the plot.
      index - the secondary index (null for primary renderer).
      info - collects chart rendering information for return to caller.
      Returns:
      A state object (maintains state information relevant to one chart drawing).
    • drawItem

      protected void drawItem(Graphics2D g2, int section, Rectangle2D dataArea, PiePlotState state, int currentPass)
      Draws a single data item.
      Overrides:
      drawItem in class PiePlot
      Parameters:
      g2 - the graphics device (null not permitted).
      section - the section index.
      dataArea - the data plot area.
      state - state information for one chart.
      currentPass - the current pass index.
    • getLabelLinkDepth

      protected double getLabelLinkDepth()
      This method overrides the default value for cases where the ring plot is very thin. This fixes bug 2121818.
      Overrides:
      getLabelLinkDepth in class PiePlot
      Returns:
      The label link depth, as a percentage of the plot's radius.
    • equals

      public boolean equals(Object obj)
      Tests this plot for equality with an arbitrary object.
      Overrides:
      equals in class PiePlot
      Parameters:
      obj - the object to test against (null permitted).
      Returns:
      A boolean.
    • writeObject

      private void writeObject(ObjectOutputStream stream) throws IOException
      Provides serialization support.
      Parameters:
      stream - the output stream.
      Throws:
      IOException - if there is an I/O error.
    • readObject

      private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException
      Provides serialization support.
      Parameters:
      stream - the input stream.
      Throws:
      IOException - if there is an I/O error.
      ClassNotFoundException - if there is a classpath problem.