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 Constructor Description 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 Modifier and Type Method Description 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.
-
-
-
Constructor Detail
-
PieFactory
public PieFactory(ISnapshot snapshot)
Create a pie factory for the given snapshot. The size of the pie is the total heap sizeSnapshotInfo.getUsedHeapSize()
.- Parameters:
snapshot
-
-
PieFactory
public PieFactory(ISnapshot snapshot, long pieSize)
Create a pie factory for the given snapshot.- Parameters:
snapshot
- snapshot containing the objectspieSize
- total size of the pie
-
PieFactory
public PieFactory(long pieSize)
Create a pie factory for objects. Objects must be added either viaaddSlice(IObject)
oraddSlice(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 idcolor
- 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 idlabel
- (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 idlabel
- (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 slicecolor
- 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
-
-