Commit | Line | Data |
---|---|---|
34313553 | 1 | /******************************************************************************* |
ed902a2b | 2 | * Copyright (c) 2009, 2014 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 | ||
2bdf0193 | 15 | package org.eclipse.tracecompass.tmf.ui.widgets.timegraph; |
34313553 | 16 | |
496f76d3 GB |
17 | import java.util.ArrayList; |
18 | import java.util.List; | |
34313553 PT |
19 | import java.util.Map; |
20 | ||
34313553 PT |
21 | import org.eclipse.swt.graphics.GC; |
22 | import org.eclipse.swt.graphics.Image; | |
23 | import org.eclipse.swt.graphics.Rectangle; | |
2bdf0193 AM |
24 | import org.eclipse.tracecompass.internal.tmf.ui.Messages; |
25 | import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent; | |
26 | import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry; | |
27 | import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.ITmfTimeGraphDrawingHelper; | |
34313553 PT |
28 | |
29 | /** | |
30 | * Provider class for the time graph provider | |
31 | * | |
34313553 PT |
32 | * @author Patrick Tasse |
33 | * | |
34 | */ | |
4999a196 GB |
35 | public class TimeGraphPresentationProvider implements ITimeGraphPresentationProvider2 { |
36 | ||
37 | private ITmfTimeGraphDrawingHelper fDrawingHelper; | |
38 | private final String fStateTypeName; | |
34313553 | 39 | |
496f76d3 | 40 | // The list of listeners for graph color changes |
507b1336 | 41 | private final List<ITimeGraphColorListener> fListeners = new ArrayList<>(); |
496f76d3 | 42 | |
34313553 PT |
43 | // ------------------------------------------------------------------------ |
44 | // Constants | |
45 | // ------------------------------------------------------------------------ | |
46 | private static final int DEFAULT_ITEM_HEIGHT = 19; | |
47 | ||
48 | // ------------------------------------------------------------------------ | |
49 | // Operations | |
50 | // ------------------------------------------------------------------------ | |
51 | ||
4999a196 GB |
52 | /** |
53 | * Constructor | |
ae09c4ad | 54 | * |
4999a196 | 55 | * @param stateTypeName The state type name |
4999a196 GB |
56 | */ |
57 | public TimeGraphPresentationProvider(String stateTypeName) { | |
58 | fStateTypeName = stateTypeName; | |
59 | } | |
60 | ||
61 | /** | |
62 | * Constructor | |
4999a196 GB |
63 | */ |
64 | public TimeGraphPresentationProvider() { | |
65 | this(Messages.TmfTimeLegend_TRACE_STATES); | |
66 | } | |
67 | ||
34313553 PT |
68 | @Override |
69 | public String getStateTypeName() { | |
4999a196 | 70 | return fStateTypeName; |
34313553 PT |
71 | } |
72 | ||
34313553 PT |
73 | @Override |
74 | public String getStateTypeName(ITimeGraphEntry entry) { | |
75 | return null; | |
76 | } | |
11252342 | 77 | |
34313553 PT |
78 | @Override |
79 | public StateItem[] getStateTable() { | |
80 | return null; | |
81 | } | |
82 | ||
34313553 PT |
83 | @Override |
84 | public int getStateTableIndex(ITimeEvent event) { | |
85 | return 0; | |
86 | } | |
87 | ||
4999a196 GB |
88 | @Override |
89 | public ITmfTimeGraphDrawingHelper getDrawingHelper() { | |
90 | return fDrawingHelper; | |
91 | } | |
92 | ||
4999a196 GB |
93 | @Override |
94 | public void setDrawingHelper(ITmfTimeGraphDrawingHelper helper) { | |
95 | fDrawingHelper = helper; | |
96 | } | |
97 | ||
34313553 PT |
98 | @Override |
99 | public void postDrawControl(Rectangle bounds, GC gc) { | |
100 | // Override to add own drawing code | |
101 | } | |
102 | ||
34313553 PT |
103 | @Override |
104 | public void postDrawEntry(ITimeGraphEntry entry, Rectangle bounds, GC gc) { | |
105 | // Override to add own drawing code | |
106 | } | |
107 | ||
34313553 PT |
108 | @Override |
109 | public void postDrawEvent(ITimeEvent event, Rectangle bounds, GC gc) { | |
110 | // Override to add own drawing code | |
111 | } | |
112 | ||
34313553 PT |
113 | @Override |
114 | public int getItemHeight(ITimeGraphEntry entry) { | |
115 | return DEFAULT_ITEM_HEIGHT; | |
116 | } | |
117 | ||
34313553 PT |
118 | @Override |
119 | public Image getItemImage(ITimeGraphEntry entry) { | |
120 | return null; | |
121 | } | |
122 | ||
34313553 PT |
123 | @Override |
124 | public String getEventName(ITimeEvent event) { | |
125 | return null; | |
126 | } | |
127 | ||
34313553 PT |
128 | @Override |
129 | public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event) { | |
130 | return null; | |
131 | } | |
132 | ||
34313553 PT |
133 | @Override |
134 | public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event, long hoverTime) { | |
135 | return getEventHoverToolTipInfo(event); | |
136 | } | |
137 | ||
1e9f8bef XR |
138 | @Override |
139 | public boolean displayTimesInTooltip() { | |
140 | return true; | |
141 | } | |
142 | ||
496f76d3 GB |
143 | @Override |
144 | public void addColorListener(ITimeGraphColorListener listener) { | |
145 | if (!fListeners.contains(listener)) { | |
146 | fListeners.add(listener); | |
147 | } | |
148 | } | |
149 | ||
150 | @Override | |
151 | public void removeColorListener(ITimeGraphColorListener listener) { | |
152 | fListeners.remove(listener); | |
153 | } | |
154 | ||
155 | /** | |
156 | * Notifies listeners of the state table change | |
157 | */ | |
158 | protected void fireColorSettingsChanged() { | |
159 | for (ITimeGraphColorListener listener : fListeners) { | |
160 | listener.colorSettingsChanged(getStateTable()); | |
161 | } | |
162 | } | |
163 | ||
1e9f8bef | 164 | } |