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