Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Memory Analyzer (MAT) » Creating a query plugin with graphs
Creating a query plugin with graphs [message #8505] Thu, 15 January 2009 16:47 Go to next message
Andrew Johnson is currently offline Andrew JohnsonFriend
Messages: 123
Registered: July 2009
Senior Member
It seems quite easy to create a query with a separate plugin, using
existing extension points, using something like this.

@Name("Test query")
@Category("Java Basics")
@Help("Finds out what is wrong.\n\n")
public class TestQuery implements IQuery {
@Argument
public ISnapshot snapshot;

public IResult execute(IProgressListener listener) throws Exception {
SectionSpec result = new SectionSpec("Testing");
return result;
}
}
}

<plugin>
<extension
point="org.eclipse.mat.report.query">
<query
impl="com.xyz.TestQuery">
</query>
</extension>
</plugin>

The PieFactory seems a quick way of creating graphs, but is internal to
the org.eclipse.mat.api plugin. What's the recommended way to create pie
charts?
Re: Creating a query plugin with graphs [message #8536 is a reply to message #8505] Fri, 16 January 2009 08:43 Go to previous messageGo to next message
Andreas Buchen is currently offline Andreas BuchenFriend
Messages: 113
Registered: July 2009
Senior Member
Hi Andrew,

you're right: the PieFactory could and should be made available to ease
create simple pie charts. For now has been restricted, because I created
it "on the go" and I am not quite sure if it is THE api that makes sense.

Why don't you go ahead, and use the PieFactory? Let me know if it works
for you and we will add it the the public API.


A query could look like this:


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();
}

}



This would be the change necessary:


Index: src/org/eclipse/mat/inspections/util/PieFactory.java
============================================================ =======
--- src/org/eclipse/mat/inspections/util/PieFactory.java (revision 194)
+++ src/org/eclipse/mat/inspections/util/PieFactory.java (working copy)
@@ -24,7 +24,9 @@
import org.eclipse.mat.util.HTMLUtils;
import org.eclipse.mat.util.Units;

-
+/**
+ * @since 0.7
+ */
public class PieFactory
{
private ISnapshot snapshot;
Index: META-INF/MANIFEST.MF
============================================================ =======
--- META-INF/MANIFEST.MF (revision 205)
+++ META-INF/MANIFEST.MF (working copy)
@@ -6,6 +6,7 @@
Bundle-Vendor: Eclipse.org
Export-Package:
org.eclipse.mat.inspections.osgi;x-friends:="org.eclipse.mat.ui ",
org.eclipse.mat.inspections.osgi.model;x-friends:="org.eclipse.mat.ui ",
+ org.eclipse.mat.inspections.util,
org.eclipse.mat.internal.snapshot;x-friends:="org.eclipse.mat.ui ",
org.eclipse.mat.snapshot,
org.eclipse.mat.snapshot.extension,





Cheers,

Andreas.
Re: Creating a query plugin with graphs [message #8598 is a reply to message #8536] Tue, 20 January 2009 15:17 Go to previous message
Andreas Buchen is currently offline Andreas BuchenFriend
Messages: 113
Registered: July 2009
Senior Member
Hi Andrew,

I submitted the code. However, I moved the PieFactory to some other public
package. Let me know if you have comments on this one.

Andreas.
Previous Topic:MAT not showing entire HEAP ?
Next Topic:MAT demonstration example
Goto Forum:
  


Current Time: Fri Nov 28 14:58:20 GMT 2014

Powered by FUDForum. Page generated in 0.02211 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software