Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Grunberg2011-12-08 17:15:59 -0500
committerRoland Grunberg2011-12-20 11:13:37 -0500
commit911dbd07b1e1b7e78e6e3cc5d48173b1682b6ee3 (patch)
tree26ed32d615393210eed2ebc1316ef8a3e0d056e0 /valgrind
parentde9a25f317bb69a35e8e07a36dd1c35a128d82b1 (diff)
downloadorg.eclipse.linuxtools-911dbd07b1e1b7e78e6e3cc5d48173b1682b6ee3.tar.gz
org.eclipse.linuxtools-911dbd07b1e1b7e78e6e3cc5d48173b1682b6ee3.tar.xz
org.eclipse.linuxtools-911dbd07b1e1b7e78e6e3cc5d48173b1682b6ee3.zip
Render data and begin making chart look similar to the BIRT rendered one.
Diffstat (limited to 'valgrind')
-rw-r--r--valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/ChartEditor.java51
-rw-r--r--valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/HeapChart.java11
2 files changed, 57 insertions, 5 deletions
diff --git a/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/ChartEditor.java b/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/ChartEditor.java
index dcf6bd986f..49a436e981 100644
--- a/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/ChartEditor.java
+++ b/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/ChartEditor.java
@@ -13,12 +13,21 @@ package org.eclipse.linuxtools.internal.valgrind.massif.birt;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.ImageLoader;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.EditorPart;
import org.swtchart.Chart;
+import org.swtchart.ILineSeries;
+import org.swtchart.ILineSeries.PlotSymbolType;
+import org.swtchart.ISeries.SeriesType;
public class ChartEditor extends EditorPart {
protected Chart control;
@@ -58,6 +67,48 @@ public class ChartEditor extends EditorPart {
public void createPartControl(Composite parent) {
ChartEditorInput input = (ChartEditorInput) getEditorInput();
control = new Chart(parent, SWT.FILL);
+
+ Color color = new Color(Display.getDefault(), 255, 128, 128);
+
+ control.setBackground(color);
+ control.setBackgroundInPlotArea(color);
+
+ // titles
+ control.getTitle().setText("Valgrind Title");
+ control.getAxisSet().getXAxis(0).getTitle().setText(input.getChart().xUnits);
+ control.getAxisSet().getYAxis(0).getTitle().setText(input.getChart().yUnits);
+
+ // series
+ ILineSeries lsUseful = (ILineSeries) control.getSeriesSet().createSeries(SeriesType.LINE, "line 1");
+ lsUseful.setYSeries(input.getChart().dataUseful);
+ lsUseful.setSymbolType(PlotSymbolType.DIAMOND);
+
+ ILineSeries lsExtra = (ILineSeries) control.getSeriesSet().createSeries(SeriesType.LINE, "line 2");
+ lsExtra.setYSeries(input.getChart().dataExtra);
+ lsExtra.setSymbolType(PlotSymbolType.DIAMOND);
+
+ if (input.getChart().dataStacks != null){
+ ILineSeries lsStack = (ILineSeries) control.getSeriesSet().createSeries(SeriesType.LINE, "line 3");
+ lsStack.setYSeries(input.getChart().dataStacks);
+ lsStack.setSymbolType(PlotSymbolType.DIAMOND);
+ }
+
+ ILineSeries lsTotal = (ILineSeries) control.getSeriesSet().createSeries(SeriesType.LINE, "line 4");
+ lsTotal.setYSeries(input.getChart().dataTotal);
+ lsTotal.setSymbolType(PlotSymbolType.DIAMOND);
+
+ // adjust axes
+ control.getAxisSet().adjustRange();
+
+ /*Display dsp = Display.getCurrent();
+ GC gc = new GC(control);
+ Image img = new Image(dsp, 640, 480);
+ gc.copyArea(img, 0, 0);
+ gc.dispose();
+ ImageLoader imageLoader = new ImageLoader();
+ imageLoader.data = new ImageData[] {img.getImageData()};
+ imageLoader.save("/home/rgrunber/Desktop/test.jpg",SWT.IMAGE_JPEG);*/
+
}
public Chart getControl() {
diff --git a/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/HeapChart.java b/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/HeapChart.java
index 86d136fce9..80e77fe2ca 100644
--- a/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/HeapChart.java
+++ b/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/HeapChart.java
@@ -78,22 +78,23 @@ public class HeapChart extends ChartWithAxesImpl {
protected String xUnits;
protected String yUnits;
+ protected double [] time, dataUseful, dataExtra, dataStacks, dataTotal;
public HeapChart(MassifSnapshot[] snapshots) {
TimeUnit timeUnit = snapshots[0].getUnit();
long xScaling = getXScaling(snapshots, timeUnit);
long yScaling = getYScaling(snapshots);
- double[] time = new double[snapshots.length];
- double[] dataUseful = new double[snapshots.length];
- double[] dataExtra = new double[snapshots.length];
- double[] dataStacks = null;
+ time = new double[snapshots.length];
+ dataUseful = new double[snapshots.length];
+ dataExtra = new double[snapshots.length];
+ dataStacks = null;
boolean isStack = isStackProfiled(snapshots);
if (isStack) {
dataStacks = new double[snapshots.length];
}
- double[] dataTotal = new double[snapshots.length];
+ dataTotal = new double[snapshots.length];
for (int i = 0; i < snapshots.length; i++) {
time[i] = snapshots[i].getTime() / xScaling;
dataUseful[i] = snapshots[i].getHeapBytes() / yScaling;

Back to the top