Package org.eclipse.mat.snapshot.query

## Class PieFactory

- java.lang.Object
- - org.eclipse.mat.snapshot.query.PieFactory

    public final class PieFactory
    extends java.lang.Object

Helper class to create pie chart results for heap objects.

Usage:

     public class PieQuery implements IQuery
     {
         @Argument
         public ISnapshot snapshot;

         public IResult execute(IProgressListener listener) throws Exception
         {
             PieFactory f = new PieFactory(snapshot);

             int[] topDominators = snapshot.getImmediateDominatedIds(-1);

             for (int ii = 0; ii < 5 && ii < topDominators.length; ii++)
                 f.addSlice(topDominators[ii]);

             return f.build();
         }

     }

Since:
  0.8

### Constructor Summary

Constructors
`PieFactory​(long pieSize)` Create a pie factory for objects.
`PieFactory​(ISnapshot snapshot)` Create a pie factory for the given snapshot.
`PieFactory​(ISnapshot snapshot, long pieSize)` Create a pie factory for the given snapshot.

### Method Summary

All Methods Instance Methods Concrete Methods
`IResultPie.Slice` `addSlice​(int objectId)` Create and add a new slice for the given object.
`IResultPie.Slice` `addSlice​(int objectId, java.awt.Color color)` Create and add a new slice for the given object.
`IResultPie.Slice` `addSlice​(int objectId, java.lang.String label, long usedHeapSize, long retainedHeapSize)` Create and add a new slice for the given object.
`IResultPie.Slice` `addSlice​(int objectId, java.lang.String label, long usedHeapSize, long retainedHeapSize, java.awt.Color color)` Create and add a new slice for the given object.
`IResultPie.Slice` `addSlice​(IObject object)` Create and add a new slice for the given object.
`IResultPie.Slice` `addSlice​(IObject object, java.awt.Color color)` Create and add a new slice for the given object.
`IResultPie` `build()` Create and return the pie result object.

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### PieFactory

    public PieFactory​(ISnapshot snapshot)

Create a pie factory for the given snapshot. The size of the pie is the total heap size `SnapshotInfo.getUsedHeapSize()`.

Parameters:
  `snapshot` -

#### PieFactory

    public PieFactory​(ISnapshot snapshot,
                      long pieSize)

Create a pie factory for the given snapshot.

Parameters:
  `snapshot` - snapshot containing the objects
  `pieSize` - total size of the pie

#### PieFactory

    public PieFactory​(long pieSize)

Create a pie factory for objects. Objects must be added either via `addSlice(IObject)` or `addSlice(int, String, long, long)` methods.

Parameters:
  `pieSize` - total size of the pie

### Method Detail

#### addSlice

    public IResultPie.Slice addSlice​(int objectId)
                              throws SnapshotException

Create and add a new slice for the given object. The size of the slice is determined by the retained size.

To use this method, one needs to pass a `ISnapshot` to the constructor.

Parameters:
  `objectId` - object id
Returns:
  a new slice
Throws:
  `SnapshotException`

#### addSlice

    public IResultPie.Slice addSlice​(int objectId,
                                     java.awt.Color color)
                              throws SnapshotException

Create and add a new slice for the given object. The size of the slice is determined by the retained size.

To use this method, one needs to pass a `ISnapshot` to the constructor.

Parameters:
  `objectId` - object id
  `color` - Explicit color of the slice
Returns:
  a new slice
Throws:
  `SnapshotException`
Since:
  1.2

#### addSlice

    public IResultPie.Slice addSlice​(IObject object)

Create and add a new slice for the given object. The size of the slice is determined by the retained size.

Parameters:
  `object` -
Returns:
  a new slice

#### addSlice

    public IResultPie.Slice addSlice​(IObject object,
                                     java.awt.Color color)

Create and add a new slice for the given object. The size of the slice is determined by the retained size.

Parameters:
  `object` -
  `color` - Explicit color of the slice
Returns:
  a new slice
Since:
  1.2

#### addSlice

    public IResultPie.Slice addSlice​(int objectId,
                                     java.lang.String label,
                                     long usedHeapSize,
                                     long retainedHeapSize)

Create and add a new slice for the given object.

Parameters:
  `objectId` - object id
  `label` - (optionally) a label describing the object (for display)
  `usedHeapSize` - (optionally) the used heap size (for display)
  `retainedHeapSize` - the retained size which determines the size of the slice
Returns:
  a new slice

#### addSlice

    public IResultPie.Slice addSlice​(int objectId,
                                     java.lang.String label,
                                     long usedHeapSize,
                                     long retainedHeapSize,
                                     java.awt.Color color)

Create and add a new slice for the given object.

Parameters:
  `objectId` - object id
  `label` - (optionally) a label describing the object (for display)
  `usedHeapSize` - (optionally) the used heap size (for display)
  `retainedHeapSize` - the retained size which determines the size of the slice
  `color` - the color to use for the slice
Returns:
  a new slice
Since:
  1.2

#### build

    public IResultPie build()

Create and return the pie result object.

Returns:
  the pie result object