Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Grunberg2012-02-29 17:08:25 -0500
committerRoland Grunberg2012-02-29 17:08:25 -0500
commitb568797b35e703514c9fc6b33417c4270425e334 (patch)
tree76d39bf5ced6969f4d5ab253c1cee88f661d127e /valgrind
parente34e6f99a6561f536c04544bb9e0d8e00f24ab93 (diff)
parent3fff3043f670f5068a5fcd33079df9d365020398 (diff)
downloadorg.eclipse.linuxtools-b568797b35e703514c9fc6b33417c4270425e334.tar.gz
org.eclipse.linuxtools-b568797b35e703514c9fc6b33417c4270425e334.tar.xz
org.eclipse.linuxtools-b568797b35e703514c9fc6b33417c4270425e334.zip
Merge branch 'feature/valgrind/no-birt'
Conflicts: valgrind/org.eclipse.linuxtools.valgrind.test-feature/feature.xml
Diffstat (limited to 'valgrind')
-rw-r--r--valgrind/org.eclipse.linuxtools.valgrind-feature/feature.xml6
-rw-r--r--valgrind/org.eclipse.linuxtools.valgrind.massif.tests/META-INF/MANIFEST.MF10
-rw-r--r--valgrind/org.eclipse.linuxtools.valgrind.massif.tests/src/org/eclipse/linuxtools/internal/valgrind/massif/tests/ChartExportTest.java22
-rw-r--r--valgrind/org.eclipse.linuxtools.valgrind.massif.tests/src/org/eclipse/linuxtools/internal/valgrind/massif/tests/ChartTests.java30
-rw-r--r--valgrind/org.eclipse.linuxtools.valgrind.massif/META-INF/MANIFEST.MF30
-rw-r--r--valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/MassifViewPart.java13
-rw-r--r--valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/ChartControl.java259
-rw-r--r--valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/ChartEditor.java211
-rw-r--r--valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/ChartPNG.java77
-rw-r--r--valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/ChartSVG.java133
-rw-r--r--valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/HeapChart.java265
-rw-r--r--valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/messages.properties2
12 files changed, 335 insertions, 723 deletions
diff --git a/valgrind/org.eclipse.linuxtools.valgrind-feature/feature.xml b/valgrind/org.eclipse.linuxtools.valgrind-feature/feature.xml
index 0b3bff656b..ecf9092bbe 100644
--- a/valgrind/org.eclipse.linuxtools.valgrind-feature/feature.xml
+++ b/valgrind/org.eclipse.linuxtools.valgrind-feature/feature.xml
@@ -37,12 +37,6 @@
<import plugin="org.eclipse.linuxtools.profiling.launch"/>
<import plugin="org.eclipse.ui.console"/>
<import plugin="org.eclipse.ui.ide"/>
- <import plugin="org.eclipse.birt.chart.device.swt" version="2.3.1" match="greaterOrEqual"/>
- <import plugin="org.eclipse.birt.chart.device.extension" version="2.3.1" match="greaterOrEqual"/>
- <import plugin="org.eclipse.birt.chart.engine" version="2.3.1" match="greaterOrEqual"/>
- <import plugin="org.eclipse.birt.chart.engine.extension" version="2.3.1" match="greaterOrEqual"/>
- <import plugin="org.eclipse.birt.chart.device.svg" version="2.3.1" match="greaterOrEqual"/>
- <import plugin="org.eclipse.birt.core" version="2.3.1" match="greaterOrEqual"/>
<import plugin="org.eclipse.cdt.debug.ui"/>
<import plugin="org.eclipse.emf.common"/>
<import plugin="org.eclipse.emf.ecore"/>
diff --git a/valgrind/org.eclipse.linuxtools.valgrind.massif.tests/META-INF/MANIFEST.MF b/valgrind/org.eclipse.linuxtools.valgrind.massif.tests/META-INF/MANIFEST.MF
index 6c6dbce1ab..715f6dc25c 100644
--- a/valgrind/org.eclipse.linuxtools.valgrind.massif.tests/META-INF/MANIFEST.MF
+++ b/valgrind/org.eclipse.linuxtools.valgrind.massif.tests/META-INF/MANIFEST.MF
@@ -13,11 +13,7 @@ Require-Bundle: org.eclipse.ui,
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
-Import-Package: org.eclipse.birt.chart.computation,
- org.eclipse.birt.chart.event,
- org.eclipse.birt.chart.model,
- org.eclipse.birt.core.exception,
- org.eclipse.cdt.core.model,
+Import-Package: org.eclipse.cdt.core.model,
org.eclipse.cdt.debug.core,
org.eclipse.core.resources,
org.eclipse.debug.core,
@@ -34,7 +30,7 @@ Import-Package: org.eclipse.birt.chart.computation,
org.eclipse.linuxtools.internal.valgrind.ui,
org.eclipse.linuxtools.profiling.tests,
org.eclipse.linuxtools.valgrind.launch,
- org.eclipse.linuxtools.valgrind.ui,
org.eclipse.ui,
- org.eclipse.ui.texteditor
+ org.eclipse.ui.texteditor,
+ org.swtchart
Export-Package: org.eclipse.linuxtools.internal.valgrind.massif.tests
diff --git a/valgrind/org.eclipse.linuxtools.valgrind.massif.tests/src/org/eclipse/linuxtools/internal/valgrind/massif/tests/ChartExportTest.java b/valgrind/org.eclipse.linuxtools.valgrind.massif.tests/src/org/eclipse/linuxtools/internal/valgrind/massif/tests/ChartExportTest.java
index a370a4fbcf..92c66ce77f 100644
--- a/valgrind/org.eclipse.linuxtools.valgrind.massif.tests/src/org/eclipse/linuxtools/internal/valgrind/massif/tests/ChartExportTest.java
+++ b/valgrind/org.eclipse.linuxtools.valgrind.massif.tests/src/org/eclipse/linuxtools/internal/valgrind/massif/tests/ChartExportTest.java
@@ -12,30 +12,30 @@ package org.eclipse.linuxtools.internal.valgrind.massif.tests;
import java.io.File;
-import org.eclipse.birt.chart.model.Chart;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.linuxtools.internal.valgrind.massif.birt.ChartEditorInput;
-import org.eclipse.linuxtools.internal.valgrind.massif.birt.ChartSVG;
+import org.eclipse.linuxtools.internal.valgrind.massif.birt.ChartPNG;
+import org.eclipse.linuxtools.internal.valgrind.massif.birt.HeapChart;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.PlatformUI;
public class ChartExportTest extends AbstractMassifTest {
- private IPath svgPath;
+ private IPath pngPath;
@Override
protected void setUp() throws Exception {
super.setUp();
proj = createProjectAndBuild("alloctest"); //$NON-NLS-1$
- svgPath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
- assertNotNull(svgPath);
- svgPath = svgPath.append("alloctest").append("chart.svg"); //$NON-NLS-1$ //$NON-NLS-2$
+ pngPath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
+ assertNotNull(pngPath);
+ pngPath = pngPath.append("alloctest").append("chart.png"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Override
protected void tearDown() throws Exception {
- File chartFile = svgPath.toFile();
+ File chartFile = pngPath.toFile();
if (chartFile.exists()) {
chartFile.delete();
}
@@ -50,12 +50,12 @@ public class ChartExportTest extends AbstractMassifTest {
IEditorInput input = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorInput();
if (input instanceof ChartEditorInput) {
- Chart chart = ((ChartEditorInput) input).getChart();
+ HeapChart chart = ((ChartEditorInput) input).getChart();
- ChartSVG svg = new ChartSVG(chart, ((ChartEditorInput) input).getView());
- svg.renderSVG(svgPath);
+ ChartPNG png = new ChartPNG(chart);
+ png.renderPNG(pngPath);
- File chartFile = svgPath.toFile();
+ File chartFile = pngPath.toFile();
assertTrue(chartFile.exists());
assertTrue(chartFile.length() > 0);
} else {
diff --git a/valgrind/org.eclipse.linuxtools.valgrind.massif.tests/src/org/eclipse/linuxtools/internal/valgrind/massif/tests/ChartTests.java b/valgrind/org.eclipse.linuxtools.valgrind.massif.tests/src/org/eclipse/linuxtools/internal/valgrind/massif/tests/ChartTests.java
index 1253b087b9..b7cc012612 100644
--- a/valgrind/org.eclipse.linuxtools.valgrind.massif.tests/src/org/eclipse/linuxtools/internal/valgrind/massif/tests/ChartTests.java
+++ b/valgrind/org.eclipse.linuxtools.valgrind.massif.tests/src/org/eclipse/linuxtools/internal/valgrind/massif/tests/ChartTests.java
@@ -12,8 +12,6 @@ package org.eclipse.linuxtools.internal.valgrind.massif.tests;
import java.util.Arrays;
-import org.eclipse.birt.chart.computation.DataPointHints;
-import org.eclipse.birt.chart.event.WrappedStructureSource;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
@@ -27,20 +25,23 @@ import org.eclipse.linuxtools.internal.valgrind.massif.MassifHeapTreeNode;
import org.eclipse.linuxtools.internal.valgrind.massif.MassifLaunchConstants;
import org.eclipse.linuxtools.internal.valgrind.massif.MassifSnapshot;
import org.eclipse.linuxtools.internal.valgrind.massif.MassifViewPart;
-import org.eclipse.linuxtools.internal.valgrind.massif.birt.ChartControl;
import org.eclipse.linuxtools.internal.valgrind.massif.birt.ChartEditor;
import org.eclipse.linuxtools.internal.valgrind.massif.birt.ChartEditorInput;
import org.eclipse.linuxtools.internal.valgrind.massif.birt.ChartLocationsDialog;
import org.eclipse.linuxtools.internal.valgrind.massif.birt.HeapChart;
+import org.eclipse.linuxtools.internal.valgrind.massif.birt.Messages;
import org.eclipse.linuxtools.internal.valgrind.ui.ValgrindUIPlugin;
import org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.PlatformUI;
+import org.swtchart.Chart;
+import org.swtchart.ILineSeries;
public class ChartTests extends AbstractMassifTest {
@Override
@@ -96,19 +97,16 @@ public class ChartTests extends AbstractMassifTest {
IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (part instanceof ChartEditor) {
- ChartControl control = ((ChartEditor) part).getControl();
- Event event = new Event();
- event.button = 1;
- event.count = 1;
- event.widget = control;
- MouseEvent mEvent = new MouseEvent(event);
- DataPointHints source = new DataPointHints(null, null, null, null, null, null, null, null, null, 4, null, 0, null);
- control.callback(mEvent, new WrappedStructureSource(source), null);
-
- TableViewer viewer = ((MassifViewPart) view.getDynamicView()).getTableViewer();
- MassifSnapshot[] snapshots = (MassifSnapshot[]) viewer.getInput();
- MassifSnapshot snapshot = (MassifSnapshot) ((StructuredSelection) viewer.getSelection()).getFirstElement();
- assertEquals(4, Arrays.asList(snapshots).indexOf(snapshot));
+ Chart control = ((ChartEditor) part).getControl();
+ ILineSeries lsTotal = (ILineSeries) control.getSeriesSet().getSeries(Messages.getString("HeapChart.Total_Heap"));
+ Point p1 = lsTotal.getPixelCoordinates(4);
+
+ HeapChart heapChart = ((ChartEditorInput) ((ChartEditor)part).getEditorInput()).getChart();
+ int x = control.getAxisSet().getXAxis(0).getPixelCoordinate(heapChart.time[4]);
+ int y = control.getAxisSet().getYAxis(0).getPixelCoordinate(heapChart.dataTotal[4]);
+
+ assertEquals(x, p1.x);
+ assertEquals(y, p1.y);
} else {
fail();
}
diff --git a/valgrind/org.eclipse.linuxtools.valgrind.massif/META-INF/MANIFEST.MF b/valgrind/org.eclipse.linuxtools.valgrind.massif/META-INF/MANIFEST.MF
index c510724e27..a1998e0c06 100644
--- a/valgrind/org.eclipse.linuxtools.valgrind.massif/META-INF/MANIFEST.MF
+++ b/valgrind/org.eclipse.linuxtools.valgrind.massif/META-INF/MANIFEST.MF
@@ -6,32 +6,11 @@ Bundle-Version: 0.10.0.qualifier
Bundle-Activator: org.eclipse.linuxtools.internal.valgrind.massif.MassifPlugin
Bundle-Vendor: %Bundle-Vendor.0
Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.birt.chart.device.swt;bundle-version="2.3.1",
- org.eclipse.birt.chart.device.extension;bundle-version="2.3.1",
- org.eclipse.birt.chart.engine;bundle-version="2.3.1",
- org.eclipse.birt.chart.engine.extension;bundle-version="2.3.1",
- org.eclipse.birt.chart.device.svg;bundle-version="2.3.1"
+ org.eclipse.core.runtime
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
-Import-Package: org.eclipse.birt.chart.device,
- org.eclipse.birt.chart.exception,
- org.eclipse.birt.chart.factory,
- org.eclipse.birt.chart.model,
- org.eclipse.birt.chart.model.attribute,
- org.eclipse.birt.chart.model.attribute.impl,
- org.eclipse.birt.chart.model.component,
- org.eclipse.birt.chart.model.component.impl,
- org.eclipse.birt.chart.model.data,
- org.eclipse.birt.chart.model.data.impl,
- org.eclipse.birt.chart.model.impl,
- org.eclipse.birt.chart.model.layout,
- org.eclipse.birt.chart.model.type,
- org.eclipse.birt.chart.model.type.impl,
- org.eclipse.birt.chart.util,
- org.eclipse.birt.core.exception,
- org.eclipse.cdt.debug.core,
+Import-Package: org.eclipse.cdt.debug.core,
org.eclipse.cdt.debug.ui,
org.eclipse.cdt.launch,
org.eclipse.core.resources,
@@ -47,6 +26,7 @@ Import-Package: org.eclipse.birt.chart.device,
org.eclipse.linuxtools.valgrind.core,
org.eclipse.linuxtools.valgrind.launch,
org.eclipse.linuxtools.valgrind.ui,
- org.eclipse.ui
+ org.eclipse.ui,
+ org.swtchart
Export-Package: org.eclipse.linuxtools.internal.valgrind.massif,
- org.eclipse.linuxtools.internal.valgrind.massif.birt;uses:="org.eclipse.swt.events,org.eclipse.swt.widgets,org.eclipse.birt.chart.model"
+ org.eclipse.linuxtools.internal.valgrind.massif.birt;uses:="org.eclipse.swt.events,org.eclipse.swt.widgets"
diff --git a/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/MassifViewPart.java b/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/MassifViewPart.java
index 2857f23861..12623dbc4b 100644
--- a/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/MassifViewPart.java
+++ b/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/MassifViewPart.java
@@ -33,7 +33,7 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.linuxtools.internal.valgrind.massif.MassifSnapshot.SnapshotType;
import org.eclipse.linuxtools.internal.valgrind.massif.birt.ChartEditorInput;
-import org.eclipse.linuxtools.internal.valgrind.massif.birt.ChartSVG;
+import org.eclipse.linuxtools.internal.valgrind.massif.birt.ChartPNG;
import org.eclipse.linuxtools.internal.valgrind.massif.birt.HeapChart;
import org.eclipse.linuxtools.valgrind.ui.IValgrindToolView;
import org.eclipse.swt.SWT;
@@ -248,10 +248,10 @@ public class MassifViewPart extends ViewPart implements IValgrindToolView {
@Override
public void run() {
ChartEditorInput currentInput = getChartInput(pid);
- String path = getChartSavePath(currentInput.getName() + ".svg"); //$NON-NLS-1$
+ String path = getChartSavePath(currentInput.getName() + ".png"); //$NON-NLS-1$
if (path != null) {
- ChartSVG renderer = new ChartSVG(currentInput.getChart(), MassifViewPart.this);
- renderer.renderSVG(Path.fromOSString(path));
+ ChartPNG renderer = new ChartPNG(currentInput.getChart());
+ renderer.renderPNG(Path.fromOSString(path));
}
}
};
@@ -287,16 +287,15 @@ public class MassifViewPart extends ViewPart implements IValgrindToolView {
FileDialog dialog = new FileDialog(parent, SWT.SAVE);
dialog.setText(Messages.getString("MassifViewPart.Save_chart_dialog_title")); //$NON-NLS-1$
dialog.setOverwrite(true);
- dialog.setFilterExtensions(new String[] { ".svg" }); //$NON-NLS-1$
+ dialog.setFilterExtensions(new String[] { ".png" }); //$NON-NLS-1$
dialog.setFileName(defaultName);
return dialog.open();
}
protected void createChart(MassifSnapshot[] snapshots) {
- HeapChart chart = new HeapChart(snapshots);
String title = chartName + " [PID: " + pid + "]"; //$NON-NLS-1$//$NON-NLS-2$
- chart.getTitle().getLabel().getCaption().setValue(title);
+ HeapChart chart = new HeapChart(snapshots, title);
String name = getInputName(title);
ChartEditorInput input = new ChartEditorInput(chart, this, name, pid);
diff --git a/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/ChartControl.java b/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/ChartControl.java
deleted file mode 100644
index c837d73357..0000000000
--- a/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/ChartControl.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/***********************************************************************
- * Copyright (c) 2004, 2005 Actuate Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Actuate Corporation - initial API and implementation
- * Elliott Baron <ebaron@redhat.com> - Modified implementation
- ***********************************************************************/
-package org.eclipse.linuxtools.internal.valgrind.massif.birt;
-
-import org.eclipse.birt.chart.computation.DataPointHints;
-import org.eclipse.birt.chart.device.ICallBackNotifier;
-import org.eclipse.birt.chart.device.IDeviceRenderer;
-import org.eclipse.birt.chart.event.WrappedStructureSource;
-import org.eclipse.birt.chart.exception.ChartException;
-import org.eclipse.birt.chart.factory.GeneratedChartState;
-import org.eclipse.birt.chart.factory.Generator;
-import org.eclipse.birt.chart.factory.RunTimeContext;
-import org.eclipse.birt.chart.model.Chart;
-import org.eclipse.birt.chart.model.attribute.Bounds;
-import org.eclipse.birt.chart.model.attribute.CallBackValue;
-import org.eclipse.birt.chart.model.attribute.impl.BoundsImpl;
-import org.eclipse.birt.chart.util.PluginSettings;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.window.Window;
-import org.eclipse.linuxtools.internal.valgrind.massif.MassifSnapshot;
-import org.eclipse.linuxtools.internal.valgrind.massif.MassifViewPart;
-import org.eclipse.linuxtools.valgrind.ui.ValgrindUIConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-
-public class ChartControl extends Canvas implements PaintListener, ControlListener, ICallBackNotifier {
-
- private transient boolean bIsPainting = false;
- private transient Image buffer;
- private static int X_OFFSET = 3;
- private static int Y_OFFSET = 3;
-
- protected Chart cm = null;
- protected GeneratedChartState state = null;
- protected IDeviceRenderer deviceRenderer = null;
- private boolean needsGeneration = true;
- private MassifViewPart view;
-
- public ChartControl(Composite parent, Chart chart, MassifViewPart view, int style) {
- super(parent, SWT.BORDER);
- this.view = view;
- cm = chart;
- setLayoutData(new GridData(GridData.FILL_BOTH));
- setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
-
- try {
- deviceRenderer = PluginSettings.instance().getDevice("dv.SWT"); //$NON-NLS-1$
- deviceRenderer.setProperty(IDeviceRenderer.UPDATE_NOTIFIER, this);
-
- addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- deviceRenderer.dispose();
- }
- });
-
- addPaintListener(this);
- addControlListener(this);
- } catch (ChartException e) {
- e.printStackTrace();
- }
- }
-
- public void callback(Object event, Object source, CallBackValue value) {
- // give Valgrind view focus
- showView();
- MouseEvent mEvent = (MouseEvent) event;
-
- DataPointHints point = ((DataPointHints)((WrappedStructureSource)source).getSource());
- // select the corresponding snapshot in the TableViewer
- TableViewer viewer = view.getTableViewer();
- view.setTopControl(viewer.getControl());
-
- MassifSnapshot snapshot = (MassifSnapshot) viewer.getElementAt(point.getIndex());
-
- switch (mEvent.count) {
- case 1: // single click
- viewer.setSelection(new StructuredSelection(snapshot));
- break;
- case 2: // double click
- if (snapshot.isDetailed()) {
- ChartLocationsDialog dialog = new ChartLocationsDialog(getShell());
- dialog.setInput(snapshot);
-
- if (dialog.open() == Window.OK) {
- dialog.openEditorForResult();
- }
- }
- }
- }
-
- public Chart getDesignTimeModel() {
- return cm;
- }
-
- public Chart getRunTimeModel() {
- return state.getChartModel();
- }
-
- public Object peerInstance() {
- return this;
- }
-
- public void regenerateChart() {
- needsGeneration = true;
- redraw();
- }
-
- public void repaintChart() {
- redraw();
- }
-
- public void paintControl(PaintEvent pe) {
- if (bIsPainting) {
- return;
- }
- Throwable paintError = null;
-
- Rectangle re = getClientArea();
- final Rectangle adjustedRe = new Rectangle(0, 0, re.width, re.height);
-
- if (adjustedRe.width - 2 * X_OFFSET <= 0
- || adjustedRe.height - 2 * Y_OFFSET <= 0) {
- if (buffer != null && !buffer.isDisposed()) {
- buffer.dispose();
- buffer = null;
- }
- return;
- }
-
- if (cm == null) {
- buffer = null;
- } else {
- bIsPainting = true;
- Image oldBuffer = null;
- if (buffer == null) {
- buffer = new Image(Display.getDefault(), adjustedRe);
- } else {
- Rectangle ore = buffer.getBounds();
-
- oldBuffer = buffer;
-
- if (!adjustedRe.equals(ore)) {
- buffer = new Image(Display.getDefault(), adjustedRe);
- }
- }
-
- GC gcImage = new GC(buffer);
-
- // fill default background as white.
- gcImage.setForeground(Display.getDefault().getSystemColor(
- SWT.COLOR_WHITE));
- gcImage.fillRectangle(buffer.getBounds());
-
- Bounds bo = BoundsImpl.create(X_OFFSET, Y_OFFSET,
- adjustedRe.width - 2 * X_OFFSET, adjustedRe.height - 2
- * Y_OFFSET);
-
- try {
- deviceRenderer.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, gcImage);
-
- bo.scale(72d / deviceRenderer.getDisplayServer()
- .getDpiResolution()); // convert to points
-
- // generate and render the cart
- Generator gr = Generator.instance();
- if (needsGeneration) {
- needsGeneration = false;
- RunTimeContext rtc = new RunTimeContext();
-
- state = gr.build(deviceRenderer
- .getDisplayServer(), cm, bo, null, rtc, null);
-
- }
- gr.render(deviceRenderer, state);
- if (paintError != null) {
- buffer = oldBuffer;
- }
- if (oldBuffer != null && oldBuffer != buffer) {
- oldBuffer.dispose();
- }
- GC gc = pe.gc;
- if (buffer != null) {
- gc.drawImage(buffer, 0, 0);
- }
- } catch (Exception ex) {
- paintError = ex;
- } finally {
- gcImage.dispose();
- }
- bIsPainting = false;
- }
-
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.swt.events.ControlListener#controlMoved(org.eclipse.swt.events
- * .ControlEvent)
- */
- public void controlMoved(ControlEvent e) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.swt.events.ControlListener#controlResized(org.eclipse.swt
- * .events.ControlEvent)
- */
- public void controlResized(ControlEvent e) {
- needsGeneration = true;
- redraw();
- }
-
- /**
- * Shows the Valgrind view in the active page and gives it focus.
- */
- public void showView() {
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- try {
- IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- activePage.showView(ValgrindUIConstants.VIEW_ID);
- } catch (PartInitException e) {
- e.printStackTrace();
- }
- }
- });
- }
-}
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 882db4a580..60ae9f5815 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
@@ -10,20 +10,41 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.valgrind.massif.birt;
-import org.eclipse.birt.chart.model.Chart;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.linuxtools.internal.valgrind.massif.MassifSnapshot;
+import org.eclipse.linuxtools.valgrind.ui.ValgrindUIConstants;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Point;
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.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.EditorPart;
+import org.swtchart.Chart;
+import org.swtchart.IAxis;
+import org.swtchart.IAxisSet;
+import org.swtchart.ILineSeries;
+import org.swtchart.ILineSeries.PlotSymbolType;
+import org.swtchart.ISeries.SeriesType;
+import org.swtchart.ITitle;
+import org.swtchart.LineStyle;
+import org.swtchart.Range;
public class ChartEditor extends EditorPart {
- protected ChartControl control;
+ protected Chart control;
@Override
public void doSave(IProgressMonitor monitor) {
@@ -58,29 +79,193 @@ public class ChartEditor extends EditorPart {
@Override
public void createPartControl(Composite parent) {
- Composite top = new Composite(parent, SWT.NONE);
- top.setLayout(new GridLayout());
- top.setLayoutData(new GridData(GridData.FILL_BOTH));
- ChartEditorInput input = (ChartEditorInput) getEditorInput();
- Chart chart = input.getChart();
- control = new ChartControl(top, chart, input.getView(), SWT.NONE);
+ final ChartEditorInput input = (ChartEditorInput) getEditorInput();
+ final HeapChart heapChart = input.getChart();
+ control = new Chart(parent, SWT.FILL);
+ heapChart.setChartControl(control);
+
+ final Color LIGHTYELLOW = new Color(Display.getDefault(), 255, 255, 225);
+ final Color WHITE = new Color(Display.getDefault(), 255, 255, 255);
+ final Color BLACK = new Color(Display.getDefault(), 0, 0, 0);
+ final Color RED = new Color(Display.getDefault(), 255, 0, 0);
+ final Color ORANGE = new Color(Display.getDefault(), 255, 165, 0);
+ final Color GREEN = new Color(Display.getDefault(), 0, 255, 0);
+ final Color DARK_BLUE = new Color(Display.getDefault(), 64, 128, 128);
+ final int TICK_GAP = 40;
+
+ control.setBackground(WHITE);
+ control.setBackgroundInPlotArea(LIGHTYELLOW);
+
+ FontData fd = JFaceResources.getDialogFont().getFontData()[0];
+ fd.setStyle(SWT.BOLD);
+
+ Font font = new Font(Display.getDefault(), fd);
+ fd.setHeight(fd.getHeight() + 2);
+ Font titleFont = new Font(Display.getDefault(), fd);
+
+ ITitle title = control.getTitle();
+ title.setFont(titleFont);
+ title.setForeground(BLACK);
+ title.setText(heapChart.title);
+
+ IAxis xAxis = control.getAxisSet().getXAxis(0);
+ xAxis.getGrid().setStyle(LineStyle.NONE);
+ xAxis.getTick().setForeground(BLACK);
+ ITitle xTitle = xAxis.getTitle();
+ xTitle.setFont(font);
+ xTitle.setForeground(BLACK);
+ xTitle.setText(heapChart.xUnits);
+
+ IAxis yAxis = control.getAxisSet().getYAxis(0);
+ yAxis.getGrid().setStyle(LineStyle.SOLID);
+ yAxis.getTick().setForeground(BLACK);
+ yAxis.getTick().setTickMarkStepHint(TICK_GAP);
+ ITitle yTitle = yAxis.getTitle();
+ yTitle.setFont(font);
+ yTitle.setText(heapChart.yUnits);
+ yTitle.setForeground(BLACK);
+
+ control.getLegend().setPosition(SWT.BOTTOM);
+
+ // data
+ final ILineSeries lsUseful = (ILineSeries) control.getSeriesSet().
+ createSeries(SeriesType.LINE, Messages.getString("HeapChart.Useful_Heap")); //$NON-NLS-1$);
+ lsUseful.setXSeries(heapChart.time);
+ lsUseful.setYSeries(heapChart.dataUseful);
+ lsUseful.setSymbolType(PlotSymbolType.DIAMOND);
+ lsUseful.setSymbolColor(RED);
+ lsUseful.setLineColor(RED);
+
+ final ILineSeries lsExtra = (ILineSeries) control.getSeriesSet().
+ createSeries(SeriesType.LINE, Messages.getString("HeapChart.Extra_Heap")); //$NON-NLS-1$);
+ lsExtra.setXSeries(heapChart.time);
+ lsExtra.setYSeries(heapChart.dataExtra);
+ lsExtra.setSymbolType(PlotSymbolType.DIAMOND);
+ lsExtra.setSymbolColor(ORANGE);
+ lsExtra.setLineColor(ORANGE);
+
+ if (heapChart.dataStacks != null){
+ final ILineSeries lsStack = (ILineSeries) control.getSeriesSet().
+ createSeries(SeriesType.LINE, Messages.getString("HeapChart.Stacks")); //$NON-NLS-1$);
+ lsStack.setXSeries(heapChart.time);
+ lsStack.setYSeries(heapChart.dataStacks);
+ lsStack.setSymbolType(PlotSymbolType.DIAMOND);
+ lsStack.setSymbolColor(DARK_BLUE);
+ lsStack.setLineColor(DARK_BLUE);
+ }
+
+ final ILineSeries lsTotal = (ILineSeries) control.getSeriesSet().
+ createSeries(SeriesType.LINE, Messages.getString("HeapChart.Total_Heap")); //$NON-NLS-1$);
+ lsTotal.setXSeries(heapChart.time);
+ lsTotal.setYSeries(heapChart.dataTotal);
+ lsTotal.setSymbolType(PlotSymbolType.DIAMOND);
+ lsTotal.setSymbolColor(GREEN);
+ lsTotal.setLineColor(GREEN);
+
+ // adjust axes
+ control.getAxisSet().adjustRange();
+
+ IAxisSet axisSet = control.getAxisSet();
+ Range xRange = axisSet.getXAxis(0).getRange();
+ Range yRange = axisSet.getYAxis(0).getRange();
+
+ double xExtra = 0.05 * (xRange.upper - xRange.lower);
+ double yExtra = 0.05 * (yRange.upper - yRange.lower);
+
+ axisSet.getXAxis(0).setRange(new Range(xRange.lower, xRange.upper + xExtra));
+ axisSet.getYAxis(0).setRange(new Range(yRange.lower, yRange.upper + yExtra));
+
+ // listeners
+ control.getPlotArea().addMouseListener(new MouseListener() {
+
+ public void mouseUp(MouseEvent e) {
+ // TODO Auto-generated method stub
+ }
+
+ public void mouseDown(MouseEvent e) {
+ showView();
+ TableViewer viewer = input.getView().getTableViewer();
+ input.getView().setTopControl(viewer.getControl());
+
+ Point p = new Point(e.x, e.y);
+
+ int closest = 0;
+ double d1, d2, d3, currMin;
+ double globalMin = Double.MAX_VALUE;
+ for (int i = 0; i < heapChart.time.length; i++){
+ // get distance from click event to data points for the given index
+ d1 = distance(lsUseful.getPixelCoordinates(i), p);
+ d2 = distance(lsExtra.getPixelCoordinates(i), p);
+ d3 = distance(lsTotal.getPixelCoordinates(i), p);
+ // find the closest data point to the click event
+ currMin = Math.min(Math.min(d1, d2), d3);
+ if (currMin < globalMin){
+ closest = i;
+ globalMin = currMin;
+ }
+ }
+
+ MassifSnapshot snapshot = (MassifSnapshot) viewer.getElementAt(closest);
+ viewer.setSelection(new StructuredSelection(snapshot));
+
+ if (e.count == 2 && snapshot.isDetailed()) {
+ ChartLocationsDialog dialog = new ChartLocationsDialog(Display.getCurrent().getActiveShell());
+ dialog.setInput(snapshot);
+
+ if (dialog.open() == Window.OK) {
+ dialog.openEditorForResult();
+ }
+ }
+
+ }
+
+ public void mouseDoubleClick(MouseEvent e) {
+ // TODO Auto-generated method stub
+ }
+
+ });
+
}
- public ChartControl getControl() {
+ public Chart getControl() {
return control;
}
-
+
@Override
public void setFocus() {
if (control != null) {
control.setFocus();
}
}
-
+
@Override
public void dispose() {
super.dispose();
control.dispose();
}
+
+ /**
+ * Shows the Valgrind view in the active page and gives it focus.
+ */
+ public void showView() {
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ try {
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ activePage.showView(ValgrindUIConstants.VIEW_ID);
+ } catch (PartInitException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+
+ /**
+ * Calculate Euclidean distance between two points (R2).
+ */
+ private double distance (Point p1, Point p2) {
+ return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
+ }
+
}
diff --git a/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/ChartPNG.java b/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/ChartPNG.java
new file mode 100644
index 0000000000..4c83e9b3ce
--- /dev/null
+++ b/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/ChartPNG.java
@@ -0,0 +1,77 @@
+/***********************************************************************
+ * Copyright (c) 2004, 2005 Actuate Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Actuate Corporation - initial API and implementation
+ * Elliott Baron <ebaron@redhat.com> - Modified implementation
+ ***********************************************************************/
+package org.eclipse.linuxtools.internal.valgrind.massif.birt;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.linuxtools.valgrind.ui.ValgrindUIConstants;
+import org.eclipse.swt.SWT;
+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.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
+public class ChartPNG {
+
+ protected HeapChart cm = null;
+
+ public ChartPNG(HeapChart chart) {
+ cm = chart;
+ }
+
+ public void renderPNG(IPath pngPath) {
+ Composite comp = cm.getChartControl();
+ Display dsp = Display.getCurrent();
+ GC gc = new GC(comp);
+ Image img = new Image(dsp, comp.getSize().x, comp.getSize().y);
+ gc.copyArea(img, 0, 0);
+ gc.dispose();
+ ImageLoader imageLoader = new ImageLoader();
+ imageLoader.data = new ImageData[] {img.getImageData()};
+ imageLoader.save(pngPath.toOSString(), SWT.IMAGE_PNG);
+ }
+
+ public HeapChart getDesignTimeModel() {
+ return cm;
+ }
+
+ public Object peerInstance() {
+ return this;
+ }
+
+ public void regenerateChart() {
+ }
+
+ public void repaintChart() {
+ }
+
+ /**
+ * Shows the Valgrind view in the active page and gives it focus.
+ */
+ public void showView() {
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ try {
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ activePage.showView(ValgrindUIConstants.VIEW_ID);
+ } catch (PartInitException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+
+}
diff --git a/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/ChartSVG.java b/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/ChartSVG.java
deleted file mode 100644
index f52d3fbbe6..0000000000
--- a/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/birt/ChartSVG.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/***********************************************************************
- * Copyright (c) 2004, 2005 Actuate Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Actuate Corporation - initial API and implementation
- * Elliott Baron <ebaron@redhat.com> - Modified implementation
- ***********************************************************************/
-package org.eclipse.linuxtools.internal.valgrind.massif.birt;
-
-import org.eclipse.birt.chart.computation.DataPointHints;
-import org.eclipse.birt.chart.device.ICallBackNotifier;
-import org.eclipse.birt.chart.device.IDeviceRenderer;
-import org.eclipse.birt.chart.event.WrappedStructureSource;
-import org.eclipse.birt.chart.exception.ChartException;
-import org.eclipse.birt.chart.factory.GeneratedChartState;
-import org.eclipse.birt.chart.factory.Generator;
-import org.eclipse.birt.chart.factory.RunTimeContext;
-import org.eclipse.birt.chart.model.Chart;
-import org.eclipse.birt.chart.model.attribute.Bounds;
-import org.eclipse.birt.chart.model.attribute.CallBackValue;
-import org.eclipse.birt.chart.model.attribute.impl.BoundsImpl;
-import org.eclipse.birt.chart.util.PluginSettings;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.linuxtools.internal.valgrind.massif.MassifSnapshot;
-import org.eclipse.linuxtools.internal.valgrind.massif.MassifViewPart;
-import org.eclipse.linuxtools.valgrind.ui.ValgrindUIConstants;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-
-public class ChartSVG implements ICallBackNotifier {
-
- protected Chart cm = null;
- protected GeneratedChartState state = null;
- protected IDeviceRenderer deviceRenderer = null;
-
- private MassifViewPart view;
-
- public ChartSVG(Chart chart, MassifViewPart view) {
- this.view = view;
- cm = chart;
- }
-
- public void renderSVG(IPath svgPath) {
- try {
- RunTimeContext rtc = new RunTimeContext();
-
- deviceRenderer = PluginSettings.instance().getDevice("dv.SVG"); //$NON-NLS-1$
- Generator gr = Generator.instance();
- Bounds bo = BoundsImpl.create(0, 0, 800, 600);
- state = gr.build(deviceRenderer.getDisplayServer(), cm, bo, null,
- rtc, null);
- deviceRenderer.setProperty(IDeviceRenderer.FILE_IDENTIFIER, svgPath
- .toOSString());
- deviceRenderer.setProperty(IDeviceRenderer.UPDATE_NOTIFIER, this);
-
- gr.render(deviceRenderer, state);
- } catch (ChartException e) {
- e.printStackTrace();
- }
- }
-
- public void callback(Object event, Object source, CallBackValue value) {
- // give Valgrind view focus
- showView();
- MouseEvent mEvent = (MouseEvent) event;
-
- DataPointHints point = ((DataPointHints)((WrappedStructureSource)source).getSource());
- // select the corresponding snapshot in the TableViewer
- TableViewer viewer = view.getTableViewer();
- view.setTopControl(viewer.getControl());
-
- MassifSnapshot snapshot = (MassifSnapshot) viewer.getElementAt(point.getIndex());
-
- switch (mEvent.count) {
- case 1: // single click
- viewer.setSelection(new StructuredSelection(snapshot));
- break;
- case 2: // double click
-// if (snapshot.isDetailed()) {
-// ChartLocationsDialog dialog = new ChartLocationsDialog(getShell());
-// dialog.setInput(snapshot);
-//
-// if (dialog.open() == Window.OK) {
-// dialog.openEditorForResult();
-// }
-// }
- }
- }
-
- public Chart getDesignTimeModel() {
- return cm;
- }
-
- public Chart getRunTimeModel() {
- return state.getChartModel();
- }
-
- public Object peerInstance() {
- return this;
- }
-
- public void regenerateChart() {
- }
-
- public void repaintChart() {
- }
-
- /**
- * Shows the Valgrind view in the active page and gives it focus.
- */
- public void showView() {
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- try {
- IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- activePage.showView(ValgrindUIConstants.VIEW_ID);
- } catch (PartInitException e) {
- e.printStackTrace();
- }
- }
- });
- }
-
-}
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..1e5639f67b 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
@@ -11,45 +11,11 @@
***********************************************************************/
package org.eclipse.linuxtools.internal.valgrind.massif.birt;
-import org.eclipse.birt.chart.model.attribute.ActionType;
-import org.eclipse.birt.chart.model.attribute.AxisType;
-import org.eclipse.birt.chart.model.attribute.ChartDimension;
-import org.eclipse.birt.chart.model.attribute.FontDefinition;
-import org.eclipse.birt.chart.model.attribute.IntersectionType;
-import org.eclipse.birt.chart.model.attribute.Marker;
-import org.eclipse.birt.chart.model.attribute.MarkerType;
-import org.eclipse.birt.chart.model.attribute.Orientation;
-import org.eclipse.birt.chart.model.attribute.Position;
-import org.eclipse.birt.chart.model.attribute.TickStyle;
-import org.eclipse.birt.chart.model.attribute.TriggerCondition;
-import org.eclipse.birt.chart.model.attribute.impl.CallBackValueImpl;
-import org.eclipse.birt.chart.model.attribute.impl.ColorDefinitionImpl;
-import org.eclipse.birt.chart.model.component.Axis;
-import org.eclipse.birt.chart.model.component.Series;
-import org.eclipse.birt.chart.model.component.impl.SeriesImpl;
-import org.eclipse.birt.chart.model.data.BaseSampleData;
-import org.eclipse.birt.chart.model.data.DataFactory;
-import org.eclipse.birt.chart.model.data.NumberDataSet;
-import org.eclipse.birt.chart.model.data.OrthogonalSampleData;
-import org.eclipse.birt.chart.model.data.SampleData;
-import org.eclipse.birt.chart.model.data.SeriesDefinition;
-import org.eclipse.birt.chart.model.data.Trigger;
-import org.eclipse.birt.chart.model.data.impl.ActionImpl;
-import org.eclipse.birt.chart.model.data.impl.NumberDataSetImpl;
-import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl;
-import org.eclipse.birt.chart.model.data.impl.TriggerImpl;
-import org.eclipse.birt.chart.model.impl.ChartWithAxesImpl;
-import org.eclipse.birt.chart.model.layout.Legend;
-import org.eclipse.birt.chart.model.layout.Plot;
-import org.eclipse.birt.chart.model.type.LineSeries;
-import org.eclipse.birt.chart.model.type.impl.LineSeriesImpl;
-import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.linuxtools.internal.valgrind.massif.MassifSnapshot;
import org.eclipse.linuxtools.internal.valgrind.massif.MassifSnapshot.TimeUnit;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.widgets.Composite;
-public class HeapChart extends ChartWithAxesImpl {
+public class HeapChart {
private static String[] byteUnits = { Messages.getString("HeapChart.B"), //$NON-NLS-1$
Messages.getString("HeapChart.KiB"), //$NON-NLS-1$
@@ -76,24 +42,28 @@ public class HeapChart extends ChartWithAxesImpl {
protected static final int SCALING_THRESHOLD = 20;
+ protected String title;
protected String xUnits;
protected String yUnits;
+ public double [] time, dataUseful, dataExtra, dataStacks, dataTotal;
+ private Composite chartControl;
- public HeapChart(MassifSnapshot[] snapshots) {
+ public HeapChart(MassifSnapshot[] snapshots, String title) {
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;
+ this.title = title;
+ 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;
@@ -104,209 +74,6 @@ public class HeapChart extends ChartWithAxesImpl {
}
}
- initialize();
- setDimension(ChartDimension.TWO_DIMENSIONAL_LITERAL);
- setType("Line Chart"); //$NON-NLS-1$
- setSubType("Overlay"); //$NON-NLS-1$
-
- Font font = JFaceResources.getDialogFont();
- FontData fd = font.getFontData()[0];
-
- // Title
- FontDefinition titleFont = getTitle().getLabel().getCaption().getFont();
- titleFont.setName(fd.getName());
- titleFont.setSize(fd.getHeight() + 2);
-
- // Plot
- getBlock().setBackground(ColorDefinitionImpl.WHITE());
- Plot p = getPlot();
- p.getClientArea().setBackground(
- ColorDefinitionImpl.create(255, 255, 225));
-
- // X-Axis
- Axis xAxisPrimary = getPrimaryBaseAxes()[0];
- xAxisPrimary.setType(AxisType.LINEAR_LITERAL);
- xAxisPrimary.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL);
- xAxisPrimary.getOrigin().setType(IntersectionType.VALUE_LITERAL);
- xAxisPrimary.getTitle().getCaption().setValue(xUnits);
- xAxisPrimary.getTitle().setVisible(true);
-
- FontDefinition xAxisFont = xAxisPrimary.getTitle().getCaption()
- .getFont();
- xAxisFont.setName(fd.getName());
- xAxisFont.setSize(fd.getHeight());
-
- xAxisFont = xAxisPrimary.getLabel().getCaption().getFont();
- xAxisFont.setName(fd.getName());
- xAxisFont.setSize(fd.getHeight());
-
- // Y-Axis
- Axis yAxisPrimary = getPrimaryOrthogonalAxis(xAxisPrimary);
- yAxisPrimary.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL);
- yAxisPrimary.getMajorGrid().getLineAttributes().setVisible(true);
- yAxisPrimary.getTitle().getCaption().setValue(yUnits);
- yAxisPrimary.getTitle().setVisible(true);
-
- FontDefinition yAxisFont = yAxisPrimary.getTitle().getCaption()
- .getFont();
- yAxisFont.setName(fd.getName());
- yAxisFont.setSize(fd.getHeight());
-
- yAxisFont = yAxisPrimary.getLabel().getCaption().getFont();
- yAxisFont.setName(fd.getName());
- yAxisFont.setSize(fd.getHeight());
-
- // // Z-Axis
- // Axis zAxis = AxisImpl.create(Axis.ANCILLARY_BASE);
- // zAxis.setType(AxisType.LINEAR_LITERAL);
- // zAxis.setLabelPosition(Position.BELOW_LITERAL);
- // zAxis.setTitlePosition(Position.BELOW_LITERAL);
- // zAxis.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL);
- // zAxis.setOrientation(Orientation.HORIZONTAL_LITERAL);
- // xAxisPrimary.getAncillaryAxes().add(zAxis);
-
- // Legend
- Legend legend = getLegend();
- legend.setPosition(Position.BELOW_LITERAL);
- legend.setOrientation(Orientation.HORIZONTAL_LITERAL);
-
- FontDefinition legendFont = legend.getText().getFont();
- legendFont.setName(fd.getName());
- legendFont.setSize(fd.getHeight());
-
- // Data Set
- NumberDataSet mainValues = NumberDataSetImpl.create(time);
- NumberDataSet orthoValues1 = NumberDataSetImpl.create(dataUseful);
- NumberDataSet orthoValues2 = NumberDataSetImpl.create(dataExtra);
- NumberDataSet orthoValuesS = null;
- if (isStack) {
- orthoValuesS = NumberDataSetImpl.create(dataStacks);
- }
- NumberDataSet orthoValues3 = NumberDataSetImpl.create(dataTotal);
-
- SampleData sd = DataFactory.eINSTANCE.createSampleData();
- BaseSampleData sdBase = DataFactory.eINSTANCE.createBaseSampleData();
- sdBase.setDataSetRepresentation("");//$NON-NLS-1$
- sd.getBaseSampleData().add(sdBase);
-
- OrthogonalSampleData sdOrthogonal1 = DataFactory.eINSTANCE
- .createOrthogonalSampleData();
- sdOrthogonal1.setDataSetRepresentation("");//$NON-NLS-1$
- sdOrthogonal1.setSeriesDefinitionIndex(0);
- sd.getOrthogonalSampleData().add(sdOrthogonal1);
-
- OrthogonalSampleData sdOrthogonal2 = DataFactory.eINSTANCE
- .createOrthogonalSampleData();
- sdOrthogonal2.setDataSetRepresentation("");//$NON-NLS-1$
- sdOrthogonal2.setSeriesDefinitionIndex(1);
- sd.getOrthogonalSampleData().add(sdOrthogonal2);
-
- if (isStack) {
- OrthogonalSampleData sdOrthogonalS = DataFactory.eINSTANCE
- .createOrthogonalSampleData();
- sdOrthogonalS.setDataSetRepresentation("");//$NON-NLS-1$
- sdOrthogonalS.setSeriesDefinitionIndex(2);
- sd.getOrthogonalSampleData().add(sdOrthogonalS);
- }
-
- OrthogonalSampleData sdOrthogonal3 = DataFactory.eINSTANCE
- .createOrthogonalSampleData();
- sdOrthogonal3.setDataSetRepresentation("");//$NON-NLS-1$
- sdOrthogonal3.setSeriesDefinitionIndex(isStack ? 3 : 2);
- sd.getOrthogonalSampleData().add(sdOrthogonal3);
-
- setSampleData(sd);
-
- // X-Series
- Series seCategory = SeriesImpl.create();
- seCategory.setDataSet(mainValues);
- SeriesDefinition sdX = SeriesDefinitionImpl.create();
- xAxisPrimary.getSeriesDefinitions().add(sdX);
- sdX.getSeries().add(seCategory);
-
- // Y-Series
- LineSeries ls1 = (LineSeries) LineSeriesImpl.create();
- ls1.setDataSet(orthoValues1);
- ls1.getLineAttributes().setColor(ColorDefinitionImpl.CREAM());
- for (int i = 0; i < ls1.getMarkers().size(); i++) {
- Marker marker = (Marker) ls1.getMarkers().get(i);
- marker.setType(MarkerType.DIAMOND_LITERAL);
- }
-
- ls1.setPaletteLineColor(true);
- ls1.setSeriesIdentifier(Messages.getString("HeapChart.Useful_Heap")); //$NON-NLS-1$
- ls1.getTriggers().add(getClickTrigger(ls1));
- ls1.getTriggers().add(getDblClickTrigger(ls1));
-
- // Y-Series
- LineSeries ls2 = (LineSeries) LineSeriesImpl.create();
- ls2.setDataSet(orthoValues2);
- ls2.getLineAttributes().setColor(ColorDefinitionImpl.CREAM());
- for (int i = 0; i < ls2.getMarkers().size(); i++) {
- Marker marker = (Marker) ls2.getMarkers().get(i);
- marker.setType(MarkerType.DIAMOND_LITERAL);
- }
- ls2.setPaletteLineColor(true);
- ls2.setSeriesIdentifier(Messages.getString("HeapChart.Extra_Heap")); //$NON-NLS-1$
- ls2.getTriggers().add(getClickTrigger(ls2));
- ls2.getTriggers().add(getDblClickTrigger(ls2));
-
- // Y-Series
- LineSeries lsS = null;
- if (isStack) {
- lsS = (LineSeries) LineSeriesImpl.create();
- lsS.setDataSet(orthoValuesS);
- lsS.getLineAttributes().setColor(ColorDefinitionImpl.CREAM());
- for (int i = 0; i < lsS.getMarkers().size(); i++) {
- Marker marker = (Marker) lsS.getMarkers().get(i);
- marker.setType(MarkerType.DIAMOND_LITERAL);
- }
- lsS.setPaletteLineColor(true);
- lsS.setSeriesIdentifier(Messages.getString("HeapChart.Stacks")); //$NON-NLS-1$
- lsS.getTriggers().add(getClickTrigger(lsS));
- lsS.getTriggers().add(getDblClickTrigger(lsS));
- }
-
- // Y-Series
- LineSeries ls3 = (LineSeries) LineSeriesImpl.create();
- ls3.setDataSet(orthoValues3);
- ls3.getLineAttributes().setColor(ColorDefinitionImpl.CREAM());
- for (int i = 0; i < ls3.getMarkers().size(); i++) {
- Marker marker = (Marker) ls3.getMarkers().get(i);
- marker.setType(MarkerType.DIAMOND_LITERAL);
- }
- ls3.setPaletteLineColor(true);
- ls3.setSeriesIdentifier(Messages.getString("HeapChart.Total_Heap")); //$NON-NLS-1$
- ls3.getTriggers().add(getClickTrigger(ls3));
- ls3.getTriggers().add(getDblClickTrigger(ls3));
-
- SeriesDefinition sdY = SeriesDefinitionImpl.create();
- sdY.getSeriesPalette().shift(-1);
- yAxisPrimary.getSeriesDefinitions().add(sdY);
- sdY.getSeries().add(ls1);
- sdY.getSeries().add(ls2);
- if (isStack) {
- sdY.getSeries().add(lsS);
- }
- sdY.getSeries().add(ls3);
-
- // // Z-Series
- // SeriesDefinition sdZ = SeriesDefinitionImpl.create();
- // zAxis.getSeriesDefinitions().add(sdZ);
- }
-
- private Trigger getClickTrigger(LineSeries ls) {
- return TriggerImpl.create(TriggerCondition.ONCLICK_LITERAL, ActionImpl
- .create(ActionType.CALL_BACK_LITERAL, CallBackValueImpl
- .create(String.valueOf(ls
- .getSeriesIdentifier()))));
- }
-
- private Trigger getDblClickTrigger(LineSeries ls) {
- return TriggerImpl.create(TriggerCondition.ONDBLCLICK_LITERAL, ActionImpl
- .create(ActionType.CALL_BACK_LITERAL, CallBackValueImpl
- .create(String.valueOf(ls
- .getSeriesIdentifier()))));
}
private boolean isStackProfiled(MassifSnapshot[] snapshots) {
@@ -400,4 +167,12 @@ public class HeapChart extends ChartWithAxesImpl {
return secondUnits;
}
+ public void setChartControl(Composite control) {
+ chartControl = control;
+ }
+
+ public Composite getChartControl (){
+ return chartControl;
+ }
+
}
diff --git a/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/messages.properties b/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/messages.properties
index a920d6c03f..ea833d980f 100644
--- a/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/messages.properties
+++ b/valgrind/org.eclipse.linuxtools.valgrind.massif/src/org/eclipse/linuxtools/internal/valgrind/massif/messages.properties
@@ -31,7 +31,7 @@ MassifToolPage.Remove=Rem&ove
MassifToolPage.time_unit=Time unit:
MassifViewPart.Display_Heap_Allocation=Display Heap Allocation Graph
MassifViewPart.Extra_Heap=Extra Heap (B)
-MassifViewPart.Save_Chart=Save Chart As SVG
+MassifViewPart.Save_Chart=Save Chart As PNG
MassifViewPart.Save_chart_dialog_title=Save Chart
MassifViewPart.Show_Heap_Tree=Show Heap Tree
MassifViewPart.Snapshot=Snapshot

Back to the top