Commit | Line | Data |
---|---|---|
34313553 | 1 | /******************************************************************************* |
4999a196 | 2 | * Copyright (c) 2009, 2013 Ericsson, École Polytechnique de Montréal |
34313553 PT |
3 | * |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Alvaro Sanchez-Leon - Initial API and implementation | |
11 | * Patrick Tasse - Refactoring | |
4999a196 | 12 | * Geneviève Bastien - Add drawing helper methods |
34313553 PT |
13 | *******************************************************************************/ |
14 | ||
15 | package org.eclipse.linuxtools.tmf.ui.widgets.timegraph; | |
16 | ||
496f76d3 GB |
17 | import java.util.ArrayList; |
18 | import java.util.List; | |
34313553 PT |
19 | import java.util.Map; |
20 | ||
21 | import org.eclipse.linuxtools.internal.tmf.ui.Messages; | |
22 | import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent; | |
23 | import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry; | |
4999a196 | 24 | import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.ITmfTimeGraphDrawingHelper; |
34313553 PT |
25 | import org.eclipse.swt.graphics.GC; |
26 | import org.eclipse.swt.graphics.Image; | |
27 | import org.eclipse.swt.graphics.Rectangle; | |
28 | ||
29 | /** | |
30 | * Provider class for the time graph provider | |
31 | * | |
32 | * @version 1.0 | |
33 | * @author Patrick Tasse | |
34 | * | |
35 | */ | |
4999a196 GB |
36 | public class TimeGraphPresentationProvider implements ITimeGraphPresentationProvider2 { |
37 | ||
38 | private ITmfTimeGraphDrawingHelper fDrawingHelper; | |
39 | private final String fStateTypeName; | |
34313553 | 40 | |
496f76d3 | 41 | // The list of listeners for graph color changes |
507b1336 | 42 | private final List<ITimeGraphColorListener> fListeners = new ArrayList<>(); |
496f76d3 | 43 | |
34313553 PT |
44 | // ------------------------------------------------------------------------ |
45 | // Constants | |
46 | // ------------------------------------------------------------------------ | |
47 | private static final int DEFAULT_ITEM_HEIGHT = 19; | |
48 | ||
49 | // ------------------------------------------------------------------------ | |
50 | // Operations | |
51 | // ------------------------------------------------------------------------ | |
52 | ||
4999a196 GB |
53 | /** |
54 | * Constructor | |
55 | * @param stateTypeName The state type name | |
4b121c48 | 56 | * @since 2.1 |
4999a196 GB |
57 | */ |
58 | public TimeGraphPresentationProvider(String stateTypeName) { | |
59 | fStateTypeName = stateTypeName; | |
60 | } | |
61 | ||
62 | /** | |
63 | * Constructor | |
64 | * @since 2.1 | |
65 | */ | |
66 | public TimeGraphPresentationProvider() { | |
67 | this(Messages.TmfTimeLegend_TRACE_STATES); | |
68 | } | |
69 | ||
34313553 PT |
70 | @Override |
71 | public String getStateTypeName() { | |
4999a196 | 72 | return fStateTypeName; |
34313553 PT |
73 | } |
74 | ||
75 | /** | |
76 | * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider#getStateTypeName(org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) | |
77 | * @since 2.0 | |
78 | */ | |
79 | @Override | |
80 | public String getStateTypeName(ITimeGraphEntry entry) { | |
81 | return null; | |
82 | } | |
11252342 | 83 | |
34313553 PT |
84 | @Override |
85 | public StateItem[] getStateTable() { | |
86 | return null; | |
87 | } | |
88 | ||
34313553 PT |
89 | @Override |
90 | public int getStateTableIndex(ITimeEvent event) { | |
91 | return 0; | |
92 | } | |
93 | ||
4999a196 | 94 | /** |
4b121c48 | 95 | * @since 2.1 |
4999a196 GB |
96 | */ |
97 | @Override | |
98 | public ITmfTimeGraphDrawingHelper getDrawingHelper() { | |
99 | return fDrawingHelper; | |
100 | } | |
101 | ||
102 | /** | |
4b121c48 | 103 | * @since 2.1 |
4999a196 GB |
104 | */ |
105 | @Override | |
106 | public void setDrawingHelper(ITmfTimeGraphDrawingHelper helper) { | |
107 | fDrawingHelper = helper; | |
108 | } | |
109 | ||
34313553 PT |
110 | @Override |
111 | public void postDrawControl(Rectangle bounds, GC gc) { | |
112 | // Override to add own drawing code | |
113 | } | |
114 | ||
34313553 PT |
115 | @Override |
116 | public void postDrawEntry(ITimeGraphEntry entry, Rectangle bounds, GC gc) { | |
117 | // Override to add own drawing code | |
118 | } | |
119 | ||
34313553 PT |
120 | @Override |
121 | public void postDrawEvent(ITimeEvent event, Rectangle bounds, GC gc) { | |
122 | // Override to add own drawing code | |
123 | } | |
124 | ||
34313553 PT |
125 | @Override |
126 | public int getItemHeight(ITimeGraphEntry entry) { | |
127 | return DEFAULT_ITEM_HEIGHT; | |
128 | } | |
129 | ||
34313553 PT |
130 | @Override |
131 | public Image getItemImage(ITimeGraphEntry entry) { | |
132 | return null; | |
133 | } | |
134 | ||
34313553 PT |
135 | @Override |
136 | public String getEventName(ITimeEvent event) { | |
137 | return null; | |
138 | } | |
139 | ||
34313553 PT |
140 | @Override |
141 | public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event) { | |
142 | return null; | |
143 | } | |
144 | ||
34313553 PT |
145 | /** |
146 | * @since 2.0 | |
147 | */ | |
148 | @Override | |
149 | public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event, long hoverTime) { | |
150 | return getEventHoverToolTipInfo(event); | |
151 | } | |
152 | ||
1e9f8bef XR |
153 | /** |
154 | * @since 3.0 | |
155 | */ | |
156 | @Override | |
157 | public boolean displayTimesInTooltip() { | |
158 | return true; | |
159 | } | |
160 | ||
c4767854 AM |
161 | /** |
162 | * @since 3.0 | |
163 | */ | |
496f76d3 GB |
164 | @Override |
165 | public void addColorListener(ITimeGraphColorListener listener) { | |
166 | if (!fListeners.contains(listener)) { | |
167 | fListeners.add(listener); | |
168 | } | |
169 | } | |
170 | ||
c4767854 AM |
171 | /** |
172 | * @since 3.0 | |
173 | */ | |
496f76d3 GB |
174 | @Override |
175 | public void removeColorListener(ITimeGraphColorListener listener) { | |
176 | fListeners.remove(listener); | |
177 | } | |
178 | ||
179 | /** | |
180 | * Notifies listeners of the state table change | |
c4767854 | 181 | * @since 3.0 |
496f76d3 GB |
182 | */ |
183 | protected void fireColorSettingsChanged() { | |
184 | for (ITimeGraphColorListener listener : fListeners) { | |
185 | listener.colorSettingsChanged(getStateTable()); | |
186 | } | |
187 | } | |
188 | ||
1e9f8bef | 189 | } |