Class PieChart

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class PieChart extends JComponent
Component which draws a 2D pie chart with a drop shadow, based on supplied data.
See Also:
  • Constructor Details

    • PieChart

      public PieChart(int[] dist, Color... colors)
      Constructs a pie chart with the given initial distribution and colors.
      Parameters:
      dist - the numerical values to be represented in the pie. it is assumed that the sum of these numbers equals 100% of the pie.
      colors - The colors that should be used to paint each of the pie slices, positionally corresponding to the values in the first argument.
      Throws:
      IllegalArgumentException - If the length of the first parameter does not equal the second.
      NullPointerException - if either argument is null
      See Also:
  • Method Details

    • setValue

      public void setValue(int[] dist, Color... c)
      Sets the pie chart to the given distribution and corresponding colors.
      Parameters:
      dist - the numerical values to be represented in the pie. it is assumed that the sum of these numbers equals 100% of the pie.
      c - The colors that should be used to paint each of the pie slices, positionally corresponding to the values in the first argument.
      Throws:
      IllegalArgumentException - If the length of the first parameter does not equal the second.
      NullPointerException - if either argument is null
    • paintComponent

      protected void paintComponent(Graphics g)
      Overrides:
      paintComponent in class JComponent