Class PiePlot<K extends java.lang.Comparable<K>>

    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        For serialization.
        See Also:
        Constant Field Values
      • DEFAULT_INTERIOR_GAP

        public static final double DEFAULT_INTERIOR_GAP
        The default interior gap.
        See Also:
        Constant Field Values
      • MAX_INTERIOR_GAP

        public static final double MAX_INTERIOR_GAP
        The maximum interior gap (currently 40%).
        See Also:
        Constant Field Values
      • DEFAULT_START_ANGLE

        public static final double DEFAULT_START_ANGLE
        The default starting angle for the pie chart.
        See Also:
        Constant Field Values
      • DEFAULT_LABEL_FONT

        public static final java.awt.Font DEFAULT_LABEL_FONT
        The default section label font.
      • DEFAULT_LABEL_PAINT

        public static final java.awt.Paint DEFAULT_LABEL_PAINT
        The default section label paint.
      • DEFAULT_LABEL_BACKGROUND_PAINT

        public static final java.awt.Paint DEFAULT_LABEL_BACKGROUND_PAINT
        The default section label background paint.
      • DEFAULT_LABEL_OUTLINE_PAINT

        public static final java.awt.Paint DEFAULT_LABEL_OUTLINE_PAINT
        The default section label outline paint.
      • DEFAULT_LABEL_OUTLINE_STROKE

        public static final java.awt.Stroke DEFAULT_LABEL_OUTLINE_STROKE
        The default section label outline stroke.
      • DEFAULT_LABEL_SHADOW_PAINT

        public static final java.awt.Paint DEFAULT_LABEL_SHADOW_PAINT
        The default section label shadow paint.
      • DEFAULT_MINIMUM_ARC_ANGLE_TO_DRAW

        public static final double DEFAULT_MINIMUM_ARC_ANGLE_TO_DRAW
        The default minimum arc angle to draw.
        See Also:
        Constant Field Values
      • dataset

        private PieDataset<K extends java.lang.Comparable<K>> dataset
        The dataset for the pie chart.
      • pieIndex

        private int pieIndex
        The pie index (used by the MultiplePiePlot class).
      • interiorGap

        private double interiorGap
        The amount of space left around the outside of the pie plot, expressed as a percentage of the plot area width and height.
      • circular

        private boolean circular
        Flag determining whether to draw an ellipse or a perfect circle.
      • startAngle

        private double startAngle
        The starting angle.
      • direction

        private Rotation direction
        The direction for the pie segments.
      • sectionPaintMap

        private PaintMap sectionPaintMap
        The section paint map.
      • defaultSectionPaint

        private transient java.awt.Paint defaultSectionPaint
        The default section paint (fallback).
      • autoPopulateSectionPaint

        private boolean autoPopulateSectionPaint
        A flag that controls whether or not the section paint is auto-populated from the drawing supplier.
      • sectionOutlinesVisible

        private boolean sectionOutlinesVisible
        A flag that controls whether or not an outline is drawn for each section in the plot.
      • sectionOutlinePaintMap

        private PaintMap sectionOutlinePaintMap
        The section outline paint map.
      • defaultSectionOutlinePaint

        private transient java.awt.Paint defaultSectionOutlinePaint
        The default section outline paint (fallback).
      • autoPopulateSectionOutlinePaint

        private boolean autoPopulateSectionOutlinePaint
        A flag that controls whether or not the section outline paint is auto-populated from the drawing supplier.
      • sectionOutlineStrokeMap

        private StrokeMap sectionOutlineStrokeMap
        The section outline stroke map.
      • defaultSectionOutlineStroke

        private transient java.awt.Stroke defaultSectionOutlineStroke
        The default section outline stroke (fallback).
      • autoPopulateSectionOutlineStroke

        private boolean autoPopulateSectionOutlineStroke
        A flag that controls whether or not the section outline stroke is auto-populated from the drawing supplier.
      • shadowPaint

        private transient java.awt.Paint shadowPaint
        The shadow paint.
      • shadowXOffset

        private double shadowXOffset
        The x-offset for the shadow effect.
      • shadowYOffset

        private double shadowYOffset
        The y-offset for the shadow effect.
      • explodePercentages

        private java.util.Map<K extends java.lang.Comparable<K>,​java.lang.Double> explodePercentages
        The percentage amount to explode each pie section.
      • labelFont

        private java.awt.Font labelFont
        The font used to display the section labels.
      • labelPaint

        private transient java.awt.Paint labelPaint
        The color used to draw the section labels.
      • labelBackgroundPaint

        private transient java.awt.Paint labelBackgroundPaint
        The color used to draw the background of the section labels. If this is null, the background is not filled.
      • labelOutlinePaint

        private transient java.awt.Paint labelOutlinePaint
        The paint used to draw the outline of the section labels (null permitted).
      • labelOutlineStroke

        private transient java.awt.Stroke labelOutlineStroke
        The stroke used to draw the outline of the section labels (null permitted).
      • labelShadowPaint

        private transient java.awt.Paint labelShadowPaint
        The paint used to draw the shadow for the section labels (null permitted).
      • simpleLabels

        private boolean simpleLabels
        A flag that controls whether simple or extended labels are used.
      • labelPadding

        private RectangleInsets labelPadding
        The padding between the labels and the label outlines. This is not allowed to be null.
      • simpleLabelOffset

        private RectangleInsets simpleLabelOffset
        The simple label offset.
      • maximumLabelWidth

        private double maximumLabelWidth
        The maximum label width as a percentage of the plot width.
      • labelGap

        private double labelGap
        The gap between the labels and the link corner, as a percentage of the plot width.
      • labelLinksVisible

        private boolean labelLinksVisible
        A flag that controls whether or not the label links are drawn.
      • labelLinkMargin

        private double labelLinkMargin
        The link margin.
      • labelLinkPaint

        private transient java.awt.Paint labelLinkPaint
        The paint used for the label linking lines.
      • labelLinkStroke

        private transient java.awt.Stroke labelLinkStroke
        The stroke used for the label linking lines.
      • legendLabelToolTipGenerator

        private PieSectionLabelGenerator legendLabelToolTipGenerator
        A tool tip generator for the legend.
      • legendLabelURLGenerator

        private PieURLGenerator legendLabelURLGenerator
        A URL generator for the legend items (optional).
      • ignoreNullValues

        private boolean ignoreNullValues
        A flag that controls whether null values are ignored.
      • ignoreZeroValues

        private boolean ignoreZeroValues
        A flag that controls whether zero values are ignored.
      • legendItemShape

        private transient java.awt.Shape legendItemShape
        The legend item shape.
      • minimumArcAngleToDraw

        private double minimumArcAngleToDraw
        The smallest arc angle that will get drawn (this is to avoid a bug in various Java implementations that causes the JVM to crash). See this link for details: http://www.jfree.org/phpBB2/viewtopic.php?t=2707 ...and this bug report in the Java Bug Parade: http://developer.java.sun.com/developer/bugParade/bugs/4836495.html
      • shadowGenerator

        private ShadowGenerator shadowGenerator
        The shadow generator for the plot (null permitted).
      • localizationResources

        protected static java.util.ResourceBundle localizationResources
        The resourceBundle for the localization.
      • DEBUG_DRAW_INTERIOR

        static final boolean DEBUG_DRAW_INTERIOR
        This debug flag controls whether or not an outline is drawn showing the interior of the plot region. This is drawn as a lightGray rectangle showing the padding provided by the 'interiorGap' setting.
        See Also:
        Constant Field Values
      • DEBUG_DRAW_LINK_AREA

        static final boolean DEBUG_DRAW_LINK_AREA
        This debug flag controls whether or not an outline is drawn showing the link area (in blue) and link ellipse (in yellow). This controls where the label links have 'elbow' points.
        See Also:
        Constant Field Values
      • DEBUG_DRAW_PIE_AREA

        static final boolean DEBUG_DRAW_PIE_AREA
        This debug flag controls whether or not an outline is drawn showing the pie area (in green).
        See Also:
        Constant Field Values
    • Constructor Detail

      • PiePlot

        public PiePlot()
        Creates a new plot. The dataset is initially set to null.
      • PiePlot

        public PiePlot​(PieDataset<K> dataset)
        Creates a plot that will draw a pie chart for the specified dataset.
        Parameters:
        dataset - the dataset (null permitted).
    • Method Detail

      • getPieIndex

        public int getPieIndex()
        Returns the pie index (this is used by the MultiplePiePlot class to track subplots).
        Returns:
        The pie index.
        See Also:
        setPieIndex(int)
      • setPieIndex

        public void setPieIndex​(int index)
        Sets the pie index (this is used by the MultiplePiePlot class to track subplots).
        Parameters:
        index - the index.
        See Also:
        getPieIndex()
      • getStartAngle

        public double getStartAngle()
        Returns the start angle for the first pie section. This is measured in degrees starting from 3 o'clock and measuring anti-clockwise.
        Returns:
        The start angle.
        See Also:
        setStartAngle(double)
      • setStartAngle

        public void setStartAngle​(double angle)
        Sets the starting angle and sends a PlotChangeEvent to all registered listeners. The initial default value is 90 degrees, which corresponds to 12 o'clock. A value of zero corresponds to 3 o'clock... this is the encoding used by Java's Arc2D class.
        Parameters:
        angle - the angle (in degrees).
        See Also:
        getStartAngle()
      • getDirection

        public Rotation getDirection()
        Returns the direction in which the pie sections are drawn (clockwise or anti-clockwise).
        Returns:
        The direction (never null).
        See Also:
        setDirection(Rotation)
      • setDirection

        public void setDirection​(Rotation direction)
        Sets the direction in which the pie sections are drawn and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        direction - the direction (null not permitted).
        See Also:
        getDirection()
      • getInteriorGap

        public double getInteriorGap()
        Returns the interior gap, measured as a percentage of the available drawing space.
        Returns:
        The gap (as a percentage of the available drawing space).
        See Also:
        setInteriorGap(double)
      • setInteriorGap

        public void setInteriorGap​(double percent)
        Sets the interior gap and sends a PlotChangeEvent to all registered listeners. This controls the space between the edges of the pie plot and the plot area itself (the region where the section labels appear).
        Parameters:
        percent - the gap (as a percentage of the available drawing space).
        See Also:
        getInteriorGap()
      • isCircular

        public boolean isCircular()
        Returns a flag indicating whether the pie chart is circular, or stretched into an elliptical shape.
        Returns:
        A flag indicating whether the pie chart is circular.
        See Also:
        setCircular(boolean)
      • setCircular

        public void setCircular​(boolean flag)
        A flag indicating whether the pie chart is circular, or stretched into an elliptical shape.
        Parameters:
        flag - the new value.
        See Also:
        isCircular()
      • setCircular

        public void setCircular​(boolean circular,
                                boolean notify)
        Sets the circular attribute and, if requested, sends a PlotChangeEvent to all registered listeners.
        Parameters:
        circular - the new value of the flag.
        notify - notify listeners?
        See Also:
        isCircular()
      • getIgnoreNullValues

        public boolean getIgnoreNullValues()
        Returns the flag that controls whether null values in the dataset are ignored.
        Returns:
        A boolean.
        See Also:
        setIgnoreNullValues(boolean)
      • setIgnoreNullValues

        public void setIgnoreNullValues​(boolean flag)
        Sets a flag that controls whether null values are ignored, and sends a PlotChangeEvent to all registered listeners. At present, this only affects whether or not the key is presented in the legend.
        Parameters:
        flag - the flag.
        See Also:
        getIgnoreNullValues(), setIgnoreZeroValues(boolean)
      • getIgnoreZeroValues

        public boolean getIgnoreZeroValues()
        Returns the flag that controls whether zero values in the dataset are ignored.
        Returns:
        A boolean.
        See Also:
        setIgnoreZeroValues(boolean)
      • setIgnoreZeroValues

        public void setIgnoreZeroValues​(boolean flag)
        Sets a flag that controls whether zero values are ignored, and sends a PlotChangeEvent to all registered listeners. This only affects whether or not a label appears for the non-visible pie section.
        Parameters:
        flag - the flag.
        See Also:
        getIgnoreZeroValues(), setIgnoreNullValues(boolean)
      • lookupSectionPaint

        protected java.awt.Paint lookupSectionPaint​(java.lang.Comparable key)
        Returns the paint for the specified section. This is equivalent to lookupSectionPaint(section, getAutoPopulateSectionPaint()).
        Parameters:
        key - the section key.
        Returns:
        The paint for the specified section.
        See Also:
        lookupSectionPaint(Comparable, boolean)
      • lookupSectionPaint

        protected java.awt.Paint lookupSectionPaint​(java.lang.Comparable key,
                                                    boolean autoPopulate)
        Returns the paint for the specified section. The lookup involves these steps:
        Parameters:
        key - the section key.
        autoPopulate - a flag that controls whether the drawing supplier is used to auto-populate the section paint settings.
        Returns:
        The paint.
      • getSectionKey

        protected K getSectionKey​(int section)
        Returns a key for the specified section. The preferred way of doing this now is to link the attributes directly to the section key (there are new methods for this, starting from version 1.0.3).
        Parameters:
        section - the section index.
        Returns:
        The key.
      • getSectionPaint

        public java.awt.Paint getSectionPaint​(java.lang.Comparable key)
        Returns the paint associated with the specified key, or null if there is no paint associated with the key.
        Parameters:
        key - the key (null not permitted).
        Returns:
        The paint associated with the specified key, or null.
        Throws:
        java.lang.IllegalArgumentException - if key is null.
        See Also:
        setSectionPaint(Comparable, Paint)
      • setSectionPaint

        public void setSectionPaint​(java.lang.Comparable key,
                                    java.awt.Paint paint)
        Sets the paint associated with the specified key, and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        key - the key (null not permitted).
        paint - the paint.
        Throws:
        java.lang.IllegalArgumentException - if key is null.
        See Also:
        getSectionPaint(Comparable)
      • clearSectionPaints

        public void clearSectionPaints​(boolean notify)
        Clears the section paint settings for this plot and, if requested, sends a PlotChangeEvent to all registered listeners. Be aware that if the autoPopulateSectionPaint flag is set, the section paints may be repopulated using the same colours as before.
        Parameters:
        notify - notify listeners?
        See Also:
        autoPopulateSectionPaint
      • getDefaultSectionPaint

        public java.awt.Paint getDefaultSectionPaint()
        Returns the default section paint. This is used when no other paint is defined, which is rare. The default value is Color.GRAY.
        Returns:
        The paint (never null).
        See Also:
        setDefaultSectionPaint(Paint)
      • setDefaultSectionPaint

        public void setDefaultSectionPaint​(java.awt.Paint paint)
        Sets the default section paint and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        paint - the paint (null not permitted).
        See Also:
        getDefaultSectionPaint()
      • getAutoPopulateSectionPaint

        public boolean getAutoPopulateSectionPaint()
        Returns the flag that controls whether or not the section paint is auto-populated by the lookupSectionPaint(Comparable) method.
        Returns:
        A boolean.
      • setAutoPopulateSectionPaint

        public void setAutoPopulateSectionPaint​(boolean auto)
        Sets the flag that controls whether or not the section paint is auto-populated by the lookupSectionPaint(Comparable) method, and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        auto - auto-populate?
      • getSectionOutlinesVisible

        public boolean getSectionOutlinesVisible()
        Returns the flag that controls whether or not the outline is drawn for each pie section.
        Returns:
        The flag that controls whether or not the outline is drawn for each pie section.
        See Also:
        setSectionOutlinesVisible(boolean)
      • setSectionOutlinesVisible

        public void setSectionOutlinesVisible​(boolean visible)
        Sets the flag that controls whether or not the outline is drawn for each pie section, and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        visible - the flag.
        See Also:
        getSectionOutlinesVisible()
      • lookupSectionOutlinePaint

        protected java.awt.Paint lookupSectionOutlinePaint​(java.lang.Comparable key)
        Returns the outline paint for the specified section. This is equivalent to lookupSectionPaint(section, getAutoPopulateSectionOutlinePaint()).
        Parameters:
        key - the section key.
        Returns:
        The paint for the specified section.
        See Also:
        lookupSectionOutlinePaint(Comparable, boolean)
      • lookupSectionOutlinePaint

        protected java.awt.Paint lookupSectionOutlinePaint​(java.lang.Comparable key,
                                                           boolean autoPopulate)
        Returns the outline paint for the specified section. The lookup involves these steps:
        Parameters:
        key - the section key.
        autoPopulate - a flag that controls whether the drawing supplier is used to auto-populate the section outline paint settings.
        Returns:
        The paint.
      • getSectionOutlinePaint

        public java.awt.Paint getSectionOutlinePaint​(java.lang.Comparable key)
        Returns the outline paint associated with the specified key, or null if there is no paint associated with the key.
        Parameters:
        key - the key (null not permitted).
        Returns:
        The paint associated with the specified key, or null.
        Throws:
        java.lang.IllegalArgumentException - if key is null.
        See Also:
        setSectionOutlinePaint(Comparable, Paint)
      • setSectionOutlinePaint

        public void setSectionOutlinePaint​(java.lang.Comparable key,
                                           java.awt.Paint paint)
        Sets the outline paint associated with the specified key, and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        key - the key (null not permitted).
        paint - the paint.
        Throws:
        java.lang.IllegalArgumentException - if key is null.
        See Also:
        getSectionOutlinePaint(Comparable)
      • clearSectionOutlinePaints

        public void clearSectionOutlinePaints​(boolean notify)
        Clears the section outline paint settings for this plot and, if requested, sends a PlotChangeEvent to all registered listeners. Be aware that if the autoPopulateSectionPaint flag is set, the section paints may be repopulated using the same colours as before.
        Parameters:
        notify - notify listeners?
        See Also:
        autoPopulateSectionOutlinePaint
      • getDefaultSectionOutlinePaint

        public java.awt.Paint getDefaultSectionOutlinePaint()
        Returns the default section paint. This is used when no other paint is available.
        Returns:
        The paint (never null).
        See Also:
        setDefaultSectionOutlinePaint(Paint)
      • setDefaultSectionOutlinePaint

        public void setDefaultSectionOutlinePaint​(java.awt.Paint paint)
        Sets the default section paint.
        Parameters:
        paint - the paint (null not permitted).
        See Also:
        getDefaultSectionOutlinePaint()
      • getAutoPopulateSectionOutlinePaint

        public boolean getAutoPopulateSectionOutlinePaint()
        Returns the flag that controls whether or not the section outline paint is auto-populated by the lookupSectionOutlinePaint(Comparable) method.
        Returns:
        A boolean.
      • setAutoPopulateSectionOutlinePaint

        public void setAutoPopulateSectionOutlinePaint​(boolean auto)
        Sets the flag that controls whether or not the section outline paint is auto-populated by the lookupSectionOutlinePaint(Comparable) method, and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        auto - auto-populate?
      • lookupSectionOutlineStroke

        protected java.awt.Stroke lookupSectionOutlineStroke​(java.lang.Comparable key)
        Returns the outline stroke for the specified section. This is equivalent to lookupSectionOutlineStroke(section, getAutoPopulateSectionOutlineStroke()).
        Parameters:
        key - the section key.
        Returns:
        The stroke for the specified section.
        See Also:
        lookupSectionOutlineStroke(Comparable, boolean)
      • lookupSectionOutlineStroke

        protected java.awt.Stroke lookupSectionOutlineStroke​(java.lang.Comparable key,
                                                             boolean autoPopulate)
        Returns the outline stroke for the specified section. The lookup involves these steps:
        Parameters:
        key - the section key.
        autoPopulate - a flag that controls whether the drawing supplier is used to auto-populate the section outline stroke settings.
        Returns:
        The stroke.
      • getSectionOutlineStroke

        public java.awt.Stroke getSectionOutlineStroke​(java.lang.Comparable key)
        Returns the outline stroke associated with the specified key, or null if there is no stroke associated with the key.
        Parameters:
        key - the key (null not permitted).
        Returns:
        The stroke associated with the specified key, or null.
        Throws:
        java.lang.IllegalArgumentException - if key is null.
        See Also:
        setSectionOutlineStroke(Comparable, Stroke)
      • setSectionOutlineStroke

        public void setSectionOutlineStroke​(java.lang.Comparable key,
                                            java.awt.Stroke stroke)
        Sets the outline stroke associated with the specified key, and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        key - the key (null not permitted).
        stroke - the stroke.
        Throws:
        java.lang.IllegalArgumentException - if key is null.
        See Also:
        getSectionOutlineStroke(Comparable)
      • clearSectionOutlineStrokes

        public void clearSectionOutlineStrokes​(boolean notify)
        Clears the section outline stroke settings for this plot and, if requested, sends a PlotChangeEvent to all registered listeners. Be aware that if the autoPopulateSectionPaint flag is set, the section paints may be repopulated using the same colours as before.
        Parameters:
        notify - notify listeners?
        See Also:
        autoPopulateSectionOutlineStroke
      • getDefaultSectionOutlineStroke

        public java.awt.Stroke getDefaultSectionOutlineStroke()
        Returns the default section stroke. This is used when no other stroke is available.
        Returns:
        The stroke (never null).
        See Also:
        setDefaultSectionOutlineStroke(Stroke)
      • setDefaultSectionOutlineStroke

        public void setDefaultSectionOutlineStroke​(java.awt.Stroke stroke)
        Sets the default section stroke.
        Parameters:
        stroke - the stroke (null not permitted).
        See Also:
        getDefaultSectionOutlineStroke()
      • getAutoPopulateSectionOutlineStroke

        public boolean getAutoPopulateSectionOutlineStroke()
        Returns the flag that controls whether or not the section outline stroke is auto-populated by the lookupSectionOutlinePaint(Comparable) method.
        Returns:
        A boolean.
      • setAutoPopulateSectionOutlineStroke

        public void setAutoPopulateSectionOutlineStroke​(boolean auto)
        Sets the flag that controls whether or not the section outline stroke is auto-populated by the lookupSectionOutlineStroke(Comparable) method, and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        auto - auto-populate?
      • getShadowPaint

        public java.awt.Paint getShadowPaint()
        Returns the shadow paint.
        Returns:
        The paint (possibly null).
        See Also:
        setShadowPaint(Paint)
      • setShadowPaint

        public void setShadowPaint​(java.awt.Paint paint)
        Sets the shadow paint and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        paint - the paint (null permitted).
        See Also:
        getShadowPaint()
      • getShadowXOffset

        public double getShadowXOffset()
        Returns the x-offset for the shadow effect.
        Returns:
        The offset (in Java2D units).
        See Also:
        setShadowXOffset(double)
      • setShadowXOffset

        public void setShadowXOffset​(double offset)
        Sets the x-offset for the shadow effect and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        offset - the offset (in Java2D units).
        See Also:
        getShadowXOffset()
      • getShadowYOffset

        public double getShadowYOffset()
        Returns the y-offset for the shadow effect.
        Returns:
        The offset (in Java2D units).
        See Also:
        setShadowYOffset(double)
      • setShadowYOffset

        public void setShadowYOffset​(double offset)
        Sets the y-offset for the shadow effect and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        offset - the offset (in Java2D units).
        See Also:
        getShadowYOffset()
      • getExplodePercent

        public double getExplodePercent​(K key)
        Returns the amount that the section with the specified key should be exploded.
        Parameters:
        key - the key (null not permitted).
        Returns:
        The amount that the section with the specified key should be exploded.
        Throws:
        java.lang.IllegalArgumentException - if key is null.
        See Also:
        setExplodePercent(Comparable, double)
      • setExplodePercent

        public void setExplodePercent​(K key,
                                      double percent)
        Sets the amount that a pie section should be exploded and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        key - the section key (null not permitted).
        percent - the explode percentage (0.30 = 30 percent).
        See Also:
        getExplodePercent(Comparable)
      • getMaximumExplodePercent

        public double getMaximumExplodePercent()
        Returns the maximum explode percent.
        Returns:
        The percent.
      • getLabelGap

        public double getLabelGap()
        Returns the gap between the edge of the pie and the labels, expressed as a percentage of the plot width.
        Returns:
        The gap (a percentage, where 0.05 = five percent).
        See Also:
        setLabelGap(double)
      • setLabelGap

        public void setLabelGap​(double gap)
        Sets the gap between the edge of the pie and the labels (expressed as a percentage of the plot width) and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        gap - the gap (a percentage, where 0.05 = five percent).
        See Also:
        getLabelGap()
      • getMaximumLabelWidth

        public double getMaximumLabelWidth()
        Returns the maximum label width as a percentage of the plot width.
        Returns:
        The width (a percentage, where 0.20 = 20 percent).
        See Also:
        setMaximumLabelWidth(double)
      • setMaximumLabelWidth

        public void setMaximumLabelWidth​(double width)
        Sets the maximum label width as a percentage of the plot width and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        width - the width (a percentage, where 0.20 = 20 percent).
        See Also:
        getMaximumLabelWidth()
      • getLabelLinksVisible

        public boolean getLabelLinksVisible()
        Returns the flag that controls whether or not label linking lines are visible.
        Returns:
        A boolean.
        See Also:
        setLabelLinksVisible(boolean)
      • setLabelLinksVisible

        public void setLabelLinksVisible​(boolean visible)
        Sets the flag that controls whether or not label linking lines are visible and sends a PlotChangeEvent to all registered listeners. Please take care when hiding the linking lines - depending on the data values, the labels can be displayed some distance away from the corresponding pie section.
        Parameters:
        visible - the flag.
        See Also:
        getLabelLinksVisible()
      • getLabelLinkMargin

        public double getLabelLinkMargin()
        Returns the margin (expressed as a percentage of the width or height) between the edge of the pie and the link point.
        Returns:
        The link margin (as a percentage, where 0.05 is five percent).
        See Also:
        setLabelLinkMargin(double)
      • setLabelLinkMargin

        public void setLabelLinkMargin​(double margin)
        Sets the link margin and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        margin - the margin.
        See Also:
        getLabelLinkMargin()
      • getLabelLinkPaint

        public java.awt.Paint getLabelLinkPaint()
        Returns the paint used for the lines that connect pie sections to their corresponding labels.
        Returns:
        The paint (never null).
        See Also:
        setLabelLinkPaint(Paint)
      • setLabelLinkPaint

        public void setLabelLinkPaint​(java.awt.Paint paint)
        Sets the paint used for the lines that connect pie sections to their corresponding labels, and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        paint - the paint (null not permitted).
        See Also:
        getLabelLinkPaint()
      • getLabelLinkStroke

        public java.awt.Stroke getLabelLinkStroke()
        Returns the stroke used for the label linking lines.
        Returns:
        The stroke.
        See Also:
        setLabelLinkStroke(Stroke)
      • setLabelLinkStroke

        public void setLabelLinkStroke​(java.awt.Stroke stroke)
        Sets the link stroke and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        stroke - the stroke.
        See Also:
        getLabelLinkStroke()
      • getLabelLinkDepth

        protected double getLabelLinkDepth()
        Returns the distance that the end of the label link is embedded into the plot, expressed as a percentage of the plot's radius.

        This method is overridden in the RingPlot class to resolve bug 2121818.
        Returns:
        0.10.
      • getLabelFont

        public java.awt.Font getLabelFont()
        Returns the section label font.
        Returns:
        The font (never null).
        See Also:
        setLabelFont(Font)
      • setLabelFont

        public void setLabelFont​(java.awt.Font font)
        Sets the section label font and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        font - the font (null not permitted).
        See Also:
        getLabelFont()
      • getLabelPaint

        public java.awt.Paint getLabelPaint()
        Returns the section label paint.
        Returns:
        The paint (never null).
        See Also:
        setLabelPaint(Paint)
      • setLabelPaint

        public void setLabelPaint​(java.awt.Paint paint)
        Sets the section label paint and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        paint - the paint (null not permitted).
        See Also:
        getLabelPaint()
      • getLabelBackgroundPaint

        public java.awt.Paint getLabelBackgroundPaint()
        Returns the section label background paint.
        Returns:
        The paint (possibly null).
        See Also:
        setLabelBackgroundPaint(Paint)
      • setLabelBackgroundPaint

        public void setLabelBackgroundPaint​(java.awt.Paint paint)
        Sets the section label background paint and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        paint - the paint (null permitted).
        See Also:
        getLabelBackgroundPaint()
      • getLabelOutlinePaint

        public java.awt.Paint getLabelOutlinePaint()
        Returns the section label outline paint.
        Returns:
        The paint (possibly null).
        See Also:
        setLabelOutlinePaint(Paint)
      • setLabelOutlinePaint

        public void setLabelOutlinePaint​(java.awt.Paint paint)
        Sets the section label outline paint and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        paint - the paint (null permitted).
        See Also:
        getLabelOutlinePaint()
      • getLabelOutlineStroke

        public java.awt.Stroke getLabelOutlineStroke()
        Returns the section label outline stroke.
        Returns:
        The stroke (possibly null).
        See Also:
        setLabelOutlineStroke(Stroke)
      • setLabelOutlineStroke

        public void setLabelOutlineStroke​(java.awt.Stroke stroke)
        Sets the section label outline stroke and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        stroke - the stroke (null permitted).
        See Also:
        getLabelOutlineStroke()
      • getLabelShadowPaint

        public java.awt.Paint getLabelShadowPaint()
        Returns the section label shadow paint.
        Returns:
        The paint (possibly null).
        See Also:
        setLabelShadowPaint(Paint)
      • setLabelShadowPaint

        public void setLabelShadowPaint​(java.awt.Paint paint)
        Sets the section label shadow paint and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        paint - the paint (null permitted).
        See Also:
        getLabelShadowPaint()
      • setLabelPadding

        public void setLabelPadding​(RectangleInsets padding)
        Sets the padding between each label and its outline and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        padding - the padding (null not permitted).
        See Also:
        getLabelPadding()
      • getSimpleLabels

        public boolean getSimpleLabels()
        Returns the flag that controls whether simple or extended labels are displayed on the plot.
        Returns:
        A boolean.
      • setSimpleLabels

        public void setSimpleLabels​(boolean simple)
        Sets the flag that controls whether simple or extended labels are displayed on the plot, and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        simple - the new flag value.
      • setSimpleLabelOffset

        public void setSimpleLabelOffset​(RectangleInsets offset)
        Sets the offset for the simple labels and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        offset - the offset (null not permitted).
        See Also:
        getSimpleLabelOffset()
      • getLabelDistributor

        public AbstractPieLabelDistributor getLabelDistributor()
        Returns the object responsible for the vertical layout of the pie section labels.
        Returns:
        The label distributor (never null).
      • setLabelDistributor

        public void setLabelDistributor​(AbstractPieLabelDistributor distributor)
        Sets the label distributor and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        distributor - the distributor (null not permitted).
      • getToolTipGenerator

        public PieToolTipGenerator getToolTipGenerator()
        Returns the tool tip generator, an object that is responsible for generating the text items used for tool tips by the plot. If the generator is null, no tool tips will be created.
        Returns:
        The generator (possibly null).
        See Also:
        setToolTipGenerator(PieToolTipGenerator)
      • setToolTipGenerator

        public void setToolTipGenerator​(PieToolTipGenerator generator)
        Sets the tool tip generator and sends a PlotChangeEvent to all registered listeners. Set the generator to null if you don't want any tool tips.
        Parameters:
        generator - the generator (null permitted).
        See Also:
        getToolTipGenerator()
      • setURLGenerator

        public void setURLGenerator​(PieURLGenerator generator)
        Sets the URL generator and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        generator - the generator (null permitted).
        See Also:
        getURLGenerator()
      • getMinimumArcAngleToDraw

        public double getMinimumArcAngleToDraw()
        Returns the minimum arc angle that will be drawn. Pie sections for an angle smaller than this are not drawn, to avoid a JDK bug.
        Returns:
        The minimum angle.
        See Also:
        setMinimumArcAngleToDraw(double)
      • getLegendItemShape

        public java.awt.Shape getLegendItemShape()
        Returns the shape used for legend items.
        Returns:
        The shape (never null).
        See Also:
        setLegendItemShape(Shape)
      • setLegendItemShape

        public void setLegendItemShape​(java.awt.Shape shape)
        Sets the shape used for legend items and sends a PlotChangeEvent to all registered listeners.
        Parameters:
        shape - the shape (null not permitted).
        See Also:
        getLegendItemShape()
      • getShadowGenerator

        public ShadowGenerator getShadowGenerator()
        Returns the shadow generator for the plot, if any.
        Returns:
        The shadow generator (possibly null).
      • setShadowGenerator

        public void setShadowGenerator​(ShadowGenerator generator)
        Sets the shadow generator for the plot and sends a PlotChangeEvent to all registered listeners. Note that this is a bitmap drop-shadow generation facility and is separate from the vector based show option that is controlled via the setShadowPaint(java.awt.Paint) method.
        Parameters:
        generator - the generator (null permitted).
      • handleMouseWheelRotation

        public void handleMouseWheelRotation​(int rotateClicks)
        Handles a mouse wheel rotation (this method is intended for use by the MouseWheelHandler class).
        Parameters:
        rotateClicks - the number of rotate clicks on the the mouse wheel.
      • initialise

        public PiePlotState initialise​(java.awt.Graphics2D g2,
                                       java.awt.geom.Rectangle2D plotArea,
                                       PiePlot<?> plot,
                                       java.lang.Integer index,
                                       PlotRenderingInfo info)
        Initialises the drawing procedure. This method will be called before the first item is rendered, giving the plot an opportunity to initialise any state information it wants to maintain.
        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).
      • draw

        public void draw​(java.awt.Graphics2D g2,
                         java.awt.geom.Rectangle2D area,
                         java.awt.geom.Point2D anchor,
                         PlotState parentState,
                         PlotRenderingInfo info)
        Draws the plot on a Java 2D graphics device (such as the screen or a printer).
        Specified by:
        draw in class Plot
        Parameters:
        g2 - the graphics device.
        area - the area within which the plot should be drawn.
        anchor - the anchor point (null permitted).
        parentState - the state from the parent plot, if there is one.
        info - collects info about the drawing (null permitted).
      • drawPie

        protected void drawPie​(java.awt.Graphics2D g2,
                               java.awt.geom.Rectangle2D plotArea,
                               PlotRenderingInfo info)
        Draws the pie.
        Parameters:
        g2 - the graphics device.
        plotArea - the plot area.
        info - chart rendering info.
      • drawItem

        protected void drawItem​(java.awt.Graphics2D g2,
                                int section,
                                java.awt.geom.Rectangle2D dataArea,
                                PiePlotState state,
                                int currentPass)
        Draws a single data item.
        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.
      • drawSimpleLabels

        protected void drawSimpleLabels​(java.awt.Graphics2D g2,
                                        java.util.List<K> keys,
                                        double totalValue,
                                        java.awt.geom.Rectangle2D plotArea,
                                        java.awt.geom.Rectangle2D pieArea,
                                        PiePlotState state)
        Draws the pie section labels in the simple form.
        Parameters:
        g2 - the graphics device.
        keys - the section keys.
        totalValue - the total value for all sections in the pie.
        plotArea - the plot area.
        pieArea - the area containing the pie.
        state - the plot state.
      • drawLabels

        protected void drawLabels​(java.awt.Graphics2D g2,
                                  java.util.List<K> keys,
                                  double totalValue,
                                  java.awt.geom.Rectangle2D plotArea,
                                  java.awt.geom.Rectangle2D linkArea,
                                  PiePlotState state)
        Draws the labels for the pie sections.
        Parameters:
        g2 - the graphics device.
        keys - the keys.
        totalValue - the total value.
        plotArea - the plot area.
        linkArea - the link area.
        state - the state.
      • drawLeftLabels

        protected void drawLeftLabels​(KeyedValues<K> leftKeys,
                                      java.awt.Graphics2D g2,
                                      java.awt.geom.Rectangle2D plotArea,
                                      java.awt.geom.Rectangle2D linkArea,
                                      float maxLabelWidth,
                                      PiePlotState state)
        Draws the left labels.
        Parameters:
        leftKeys - a collection of keys and angles (to the middle of the section, in degrees) for the sections on the left side of the plot.
        g2 - the graphics device.
        plotArea - the plot area.
        linkArea - the link area.
        maxLabelWidth - the maximum label width.
        state - the state.
      • drawRightLabels

        protected void drawRightLabels​(KeyedValues<K> keys,
                                       java.awt.Graphics2D g2,
                                       java.awt.geom.Rectangle2D plotArea,
                                       java.awt.geom.Rectangle2D linkArea,
                                       float maxLabelWidth,
                                       PiePlotState state)
        Draws the right labels.
        Parameters:
        keys - the keys.
        g2 - the graphics device.
        plotArea - the plot area.
        linkArea - the link area.
        maxLabelWidth - the maximum label width.
        state - the state.
      • getPlotType

        public java.lang.String getPlotType()
        Returns a short string describing the type of plot.
        Specified by:
        getPlotType in class Plot
        Returns:
        The plot type.
      • getArcBounds

        protected java.awt.geom.Rectangle2D getArcBounds​(java.awt.geom.Rectangle2D unexploded,
                                                         java.awt.geom.Rectangle2D exploded,
                                                         double angle,
                                                         double extent,
                                                         double explodePercent)
        Returns a rectangle that can be used to create a pie section (taking into account the amount by which the pie section is 'exploded').
        Parameters:
        unexploded - the area inside which the unexploded pie sections are drawn.
        exploded - the area inside which the exploded pie sections are drawn.
        angle - the start angle.
        extent - the extent of the arc.
        explodePercent - the amount by which the pie section is exploded.
        Returns:
        A rectangle that can be used to create a pie section.
      • drawLeftLabel

        protected void drawLeftLabel​(java.awt.Graphics2D g2,
                                     PiePlotState state,
                                     PieLabelRecord record)
        Draws a section label on the left side of the pie chart.
        Parameters:
        g2 - the graphics device.
        state - the state.
        record - the label record.
      • drawRightLabel

        protected void drawRightLabel​(java.awt.Graphics2D g2,
                                      PiePlotState state,
                                      PieLabelRecord record)
        Draws a section label on the right side of the pie chart.
        Parameters:
        g2 - the graphics device.
        state - the state.
        record - the label record.
      • getArcCenter

        protected java.awt.geom.Point2D getArcCenter​(PiePlotState state,
                                                     K key)
        Returns the center for the specified section. Checks to see if the section is exploded and recalculates the new center if so.
        Parameters:
        state - PiePlotState
        key - section key.
        Returns:
        The center for the specified section.
      • lookupSectionPaint

        protected java.awt.Paint lookupSectionPaint​(K key,
                                                    PiePlotState state)
        Returns the paint for the specified section. This is equivalent to lookupSectionPaint(section). Checks to see if the user set the Paint to be of type RadialGradientPaint and if so it adjusts the center and radius to match the Pie.
        Parameters:
        key - the section key.
        state - PiePlotState.
        Returns:
        The paint for the specified section.
      • equals

        public boolean equals​(java.lang.Object obj)
        Tests this plot for equality with an arbitrary object. Note that the plot's dataset is NOT included in the test for equality.
        Overrides:
        equals in class Plot
        Parameters:
        obj - the object to test against (null permitted).
        Returns:
        true or false.
      • hashCode

        public int hashCode()
        Generates a hashcode. Note that, as with the equals method, the dataset is NOT included in the hashcode.
        Overrides:
        hashCode in class Plot
        Returns:
        the hashcode
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Returns a clone of the plot.
        Specified by:
        clone in interface PublicCloneable
        Overrides:
        clone in class Plot
        Returns:
        A clone.
        Throws:
        java.lang.CloneNotSupportedException - if some component of the plot does not support cloning.
      • writeObject

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

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