int x = display.getBounds().width;
int y = display.getBounds().height;
shell.setBounds(x/4, y/4, GRAPH_WIDTH, GRAPH_HEIGHT);
shell.setLayout(new FillLayout());
final Canvas canvas = new Canvas(shell, SWT.NONE);
long currentValue = Long.parseLong(data.getValue().toString());
long mValue = getGraphMaxValue(currentValue);
canvas.setData(MAX_VALUE, mValue);
canvas.setData(GRAPH_VALUES, new long[] {0,0,0,0,0,currentValue});
canvas.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
canvas.addPaintListener(new PaintListener()
{
public void paintControl(PaintEvent event)
{
Canvas canvas = (Canvas)event.widget;
int maxX = canvas.getSize().x;
int maxY = canvas.getSize().y;
event.gc.fillRectangle(canvas.getBounds());
event.gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
event.gc.setLineWidth(4);
Object canvasData = canvas.getData(MAX_VALUE);
String str = canvasData.toString();
long maxValue = Long.parseLong(str);
// Set the graph dimensions
event.gc.drawText("0", startX - 40, maxY - startY - 10);
event.gc.drawText("" + maxValue/2, startX - 40, maxY/2);
event.gc.drawText("" + maxValue, startX - 40, startY);
// horizontal line
event.gc.drawLine(startX, maxY - startY, maxX - 60, maxY - startY);
// vertical line
event.gc.drawLine(startX, maxY - startY, startX, startY);
// set graph text
event.gc.drawText(data.getName(), startX - 40, startY - 40);
event.gc.drawText("25 sec", startX, maxY - startY + 10);
event.gc.drawText("20 sec", startX + GRAPH_ITEM_GAP, maxY - startY + 10);
event.gc.drawText("15 sec", startX + GRAPH_ITEM_GAP * 2, maxY - startY + 10);
event.gc.drawText("10 sec", startX + GRAPH_ITEM_GAP * 3, maxY - startY + 10);
event.gc.drawText(" 5 sec", startX + GRAPH_ITEM_GAP * 4, maxY - startY + 10);
event.gc.drawText(" 0 sec", startX + GRAPH_ITEM_GAP * 5, maxY - startY + 10);
// plot the graph now for values
event.gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
canvasData = canvas.getData(GRAPH_VALUES);
long[] graphValues = (long[]) canvasData;
for (int i = 0; i < graphValues.length; i++)
{
int x = startX + i * GRAPH_ITEM_GAP;
int yTotalLength = (maxY - 2 * startY);