1
/***********************************************************************
2
* Copyright (c) 2004, 2005 Actuate Corporation.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* Actuate Corporation - initial API and implementation
10
* Elliott Baron <ebaron@redhat.com> - Modified implementation
11
***********************************************************************/
12
package org.eclipse.linuxtools.internal.valgrind.massif.charting;
14
import org.eclipse.core.runtime.IPath;
15
import org.eclipse.linuxtools.valgrind.ui.ValgrindUIConstants;
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.graphics.GC;
18
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.graphics.ImageData;
20
import org.eclipse.swt.graphics.ImageLoader;
21
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Display;
23
import org.eclipse.ui.IWorkbenchPage;
24
import org.eclipse.ui.PartInitException;
25
import org.eclipse.ui.PlatformUI;
27
public class ChartPNG {
29
protected HeapChart cm = null;
31
public ChartPNG(HeapChart chart) {
35
public void renderPNG(IPath pngPath) {
36
Composite comp = cm.getChartControl();
37
Display dsp = Display.getCurrent();
39
Image img = new Image(dsp, comp.getSize().x + 1, comp.getSize().y + 1);
40
gc.copyArea(img, 0, 0);
42
ImageLoader imageLoader = new ImageLoader();
43
imageLoader.data = new ImageData[] {img.getImageData()};
44
imageLoader.save(pngPath.toOSString(), SWT.IMAGE_PNG);
47
public HeapChart getDesignTimeModel() {
51
public Object peerInstance() {
55
public void regenerateChart() {
58
public void repaintChart() {
62
* Shows the Valgrind view in the active page and gives it focus.
64
public void showView() {
65
Display.getDefault().syncExec(new Runnable() {
68
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
69
activePage.showView(ValgrindUIConstants.VIEW_ID);
70
} catch (PartInitException e) {