|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 package com.nokia.carbide.cpp.internal.pi.visual; |
|
19 |
|
20 import org.eclipse.draw2d.FigureCanvas; |
|
21 import org.eclipse.swt.SWT; |
|
22 import org.eclipse.swt.layout.FormAttachment; |
|
23 import org.eclipse.swt.layout.FormData; |
|
24 import org.eclipse.swt.layout.FormLayout; |
|
25 import org.eclipse.swt.widgets.Composite; |
|
26 import org.eclipse.swt.widgets.Label; |
|
27 |
|
28 import com.nokia.carbide.cpp.pi.editors.PIPageEditor; |
|
29 |
|
30 /** |
|
31 * |
|
32 * A GraphComposite is added to the SashForm for a tab. |
|
33 * |
|
34 * A GraphComposite has an option centered title, a left area to contain the y-axis |
|
35 * legend, and a scrollable area containing the graph and the x-axis legend. |
|
36 */ |
|
37 public class GraphComposite extends Composite |
|
38 { |
|
39 public FigureCanvas leftLegend; |
|
40 public FigureCanvas figureCanvas; |
|
41 |
|
42 public GraphComposite(Composite parent, int style, String titleString) |
|
43 { |
|
44 super(parent, style); |
|
45 this.setLayout(new FormLayout()); |
|
46 |
|
47 FormData formData; |
|
48 Label title = null; |
|
49 |
|
50 if (titleString != null) { |
|
51 title = new Label(this, SWT.CENTER); |
|
52 title.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_CYAN)); |
|
53 title.setFont(PIPageEditor.helvetica_8); |
|
54 title.setText(titleString); |
|
55 |
|
56 formData = new FormData(); |
|
57 formData.top = new FormAttachment(0); |
|
58 formData.left = new FormAttachment(0); |
|
59 formData.right = new FormAttachment(100); |
|
60 title.setLayoutData(formData); |
|
61 } |
|
62 |
|
63 leftLegend = new FigureCanvas(this); |
|
64 figureCanvas = new FigureCanvas(this); |
|
65 |
|
66 formData = new FormData(); |
|
67 if (titleString != null) |
|
68 formData.top = new FormAttachment(title, 0, SWT.BOTTOM); |
|
69 else |
|
70 formData.top = new FormAttachment(0); |
|
71 formData.bottom = new FormAttachment(100); |
|
72 formData.left = new FormAttachment(0); |
|
73 formData.width = GenericTraceGraph.yLegendWidth; |
|
74 leftLegend.setLayoutData(formData); |
|
75 |
|
76 formData = new FormData(); |
|
77 if (titleString != null) |
|
78 formData.top = new FormAttachment(title, 0, SWT.BOTTOM); |
|
79 else |
|
80 formData.top = new FormAttachment(0); |
|
81 formData.bottom = new FormAttachment(100); |
|
82 formData.left = new FormAttachment(leftLegend, 0, SWT.RIGHT); |
|
83 formData.right = new FormAttachment(100); |
|
84 figureCanvas.setLayoutData(formData); |
|
85 } |
|
86 } |