Internalize lttng.core APIs
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / latency / listeners / TooltipListener.java
CommitLineData
fbd124dd
BH
1/*******************************************************************************\r
2 * Copyright (c) 2010, 2011 Ericsson\r
3 * \r
4 * All rights reserved. This program and the accompanying materials are\r
5 * made available under the terms of the Eclipse Public License v1.0 which\r
6 * accompanies this distribution, and is available at\r
7 * http://www.eclipse.org/legal/epl-v10.html\r
8 * \r
9 * Contributors:\r
10 * Philippe Sawicki (INF4990.A2010@gmail.com) - Initial API and implementation\r
11 * Bernd Hufmann - Changed display interface implementation\r
12 *******************************************************************************/\r
13package org.eclipse.linuxtools.lttng.ui.views.latency.listeners;\r
14\r
15import org.eclipse.linuxtools.lttng.ui.views.latency.AbstractViewer;\r
16import org.eclipse.linuxtools.lttng.ui.views.latency.Messages;\r
17\r
18/**\r
19 * <b><u>TooltipListener</u></b>\r
20 * <p>\r
21 * Tooltip listener, displays the event count for each latency selected by the mouse click area on histogram.\r
22 * \r
23 * @author Ali Jawhar\r
24 */\r
25public class TooltipListener extends AbstractMouseTrackListener {\r
26\r
27 // ------------------------------------------------------------------------\r
28 // Attributes\r
29 // ------------------------------------------------------------------------\r
30\r
31 /**\r
32 * A reference to the observed view.\r
33 */\r
34 protected AbstractViewer fView;\r
35\r
36 /**\r
37 * A reference to the HistogramPaintListener.\r
38 */\r
39 protected HistogramPaintListener fHistogram;\r
40\r
41 /**\r
42 * Is the mouse over the warning icon, indicating that a bar is higher than the draw area due to zooming ?\r
43 */\r
44 protected boolean fDisplayWarning = false;\r
45\r
46 // ------------------------------------------------------------------------\r
47 // Constructors\r
48 // ------------------------------------------------------------------------\r
49 \r
50 /**\r
51 * Constructor.\r
52 * @param view\r
53 * A reference to the observed view.\r
54 * @param histogramPaintListener\r
55 * A reference to the histogram's paintListener.\r
56 */\r
57 public TooltipListener(AbstractViewer view, HistogramPaintListener histogramPaintListener) {\r
58 fView = view;\r
59 fHistogram = histogramPaintListener;\r
60 }\r
61\r
62 // ------------------------------------------------------------------------\r
63 // Operations\r
64 // ------------------------------------------------------------------------\r
65\r
66 /*\r
67 * (non-Javadoc)\r
68 * @see org.eclipse.linuxtools.lttng.ui.views.latency.listeners.AbstractMouseTrackListener#display()\r
69 */\r
70 @Override\r
71 protected void display() {\r
72 displayWarningTooltip();\r
73 displayTooltip();\r
74 }\r
75\r
76 // ------------------------------------------------------------------------\r
77 // Helper Functions\r
78 // ------------------------------------------------------------------------\r
79 \r
80 /**\r
81 * Displays a tooltip if the mouse is over the warning icon indication that a bar cannot be draw entirely due to the\r
82 * zoom factor.\r
83 */\r
84 protected void displayWarningTooltip() {\r
85 if (fHistogram.barIsClipped() && fMouseX > 5 && fMouseX < 21 && fMouseY > 3 && fMouseY < 18) {\r
86 fView.setToolTipText(Messages.LatencyView_ClippingWarning);\r
87 fDisplayWarning = true;\r
88 } else {\r
89 fDisplayWarning = false;\r
90 }\r
91 }\r
92\r
93 /**\r
94 * Displays the tooltip showing the details of the histogram bar pointed by the mouse.\r
95 */\r
96 protected void displayTooltip() {\r
97 if (!fDisplayWarning)\r
98 fView.setToolTipText(fHistogram.formatToolTipLabel(fMouseX, fMouseY));\r
99 }\r
100}
This page took 0.027321 seconds and 5 git commands to generate.