Class PieChart2D

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public final class PieChart2D extends Chart2D
A PieChart2D object is an enclosed are with a title, pie sectors, pie labels, and a legend. Changes through its set methods are updated upon next repaint() or getImage() calls.
See Also:
  • Constructor Details

    • PieChart2D

      public PieChart2D()
      Creates a PieChart2D object with its defaults.
  • Method Details

    • setPieChart2DProperties

      public final void setPieChart2DProperties(PieChart2DProperties props)
      Sets the PieChart2DProperties for this PieChart2D.
      Parameters:
      props - The PieChart2DProperties.
    • setDataset

      public final void setDataset(Dataset d)
      Sets the Dataset for this PieChart2D. Pie datasets are expected to be non-negative. If any value is negative, then validate(...) will return false. Rendering still clamps negative values to zero as a defensive fallback and prints a short note to System.out.
      Parameters:
      d - The Dataset.
    • setMultiColorsProperties

      public final void setMultiColorsProperties(MultiColorsProperties props)
      Sets the MultiColorsProperties for this PieChart2D.
      Parameters:
      props - The MultiColorsProperties.
    • setLayoutRatios

      public final void setLayoutRatios(float pieInfoW)
      Sets the allocation of space to each component of a pie chart. There are three components: pieInfo and legend. The pieInfoW needs to be within 0f and 1f. The legendW will be 1f - pieInfoW. Both the pieInfoW and the legendH will be 1f.
      Parameters:
      pieInfoW - The ratio of pieInfo width to total.
    • setPreferredSize

      public final void setPreferredSize(Dimension size)
      Sets a custom preferred size for the chart. This custom size will override the preferred size calculations that normally occurr. If null is passed, the preferred size calculations will be reinstated.
      Specified by:
      setPreferredSize in class Object2D
      Parameters:
      size - The custom preferred size for this chart.
    • getPieChart2DProperties

      public final PieChart2DProperties getPieChart2DProperties()
      Gets the PieChart2DProperties for this PieChart2D.
      Returns:
      The PieChart2DProperties.
    • getDataset

      public final Dataset getDataset()
      Gets the Dataset for this PieChart2D.
      Returns:
      The Dataset.
    • getMultiColorsProperties

      public final MultiColorsProperties getMultiColorsProperties()
      Gets the MultiColorsProperties for this PieChart2D.
      Returns:
      The MultiColorsProperties.
    • getImage

      public final BufferedImage getImage()
      Gets a buffered image of the chart.
      Specified by:
      getImage in class Object2D
      Returns:
      An image of this chart
    • getPreferredSize

      public final Dimension getPreferredSize()
      Gets the preferred size of the chart. The preferred size is within the maximum and minimum sizes of the chart. Much calculation is performed when calling this method.
      Specified by:
      getPreferredSize in class Object2D
      Returns:
      The preferred minimum size of the chart.
    • pack

      public final void pack()
      Causes the object to reinintialize to it's preferred size.
      Specified by:
      pack in class Object2D
    • validate

      public final boolean validate(boolean debug)
      Validates the properties of this object. If debug is true then prints a messages indicating whether each property is valid. Pie datasets containing negative values are considered invalid even though rendering defensively clamps those values to zero. Returns true if all the properties were valid and false otherwise.
      Specified by:
      validate in class Object2D
      Parameters:
      debug - If true then will print status messages.
      Returns:
      If true then valid.
    • paintComponent

      public final void paintComponent(Graphics g)
      Paints the chart. This is provided for the layout manager to call.
      Overrides:
      paintComponent in class JComponent
      Parameters:
      g - The graphics context for calculations and painting.