1 /*******************************************************************************
2 * Copyright (c) 2010, 2011 Ericsson
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
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
;
15 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.latency
.AbstractViewer
;
16 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.latency
.Messages
;
19 * <b><u>TooltipListener</u></b>
21 * Tooltip listener, displays the event count for each latency selected by the mouse click area on histogram.
25 public class TooltipListener
extends AbstractMouseTrackListener
{
27 // ------------------------------------------------------------------------
29 // ------------------------------------------------------------------------
32 * A reference to the observed view.
34 protected AbstractViewer fView
;
37 * A reference to the HistogramPaintListener.
39 protected HistogramPaintListener fHistogram
;
42 * Is the mouse over the warning icon, indicating that a bar is higher than the draw area due to zooming ?
44 protected boolean fDisplayWarning
= false;
46 // ------------------------------------------------------------------------
48 // ------------------------------------------------------------------------
53 * A reference to the observed view.
54 * @param histogramPaintListener
55 * A reference to the histogram's paintListener.
57 public TooltipListener(AbstractViewer view
, HistogramPaintListener histogramPaintListener
) {
59 fHistogram
= histogramPaintListener
;
62 // ------------------------------------------------------------------------
64 // ------------------------------------------------------------------------
68 * @see org.eclipse.linuxtools.lttng.ui.views.latency.listeners.AbstractMouseTrackListener#display()
71 protected void display() {
72 displayWarningTooltip();
76 // ------------------------------------------------------------------------
78 // ------------------------------------------------------------------------
81 * Displays a tooltip if the mouse is over the warning icon indication that a bar cannot be draw entirely due to the
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;
89 fDisplayWarning
= false;
94 * Displays the tooltip showing the details of the histogram bar pointed by the mouse.
96 protected void displayTooltip() {
98 fView
.setToolTipText(fHistogram
.formatToolTipLabel(fMouseX
, fMouseY
));