* '''Right Arrow''': Moves the current event to the next non-empty bar
* '''Home''': Sets the current time to the first non-empty bar
* '''End''': Sets the current time to the last non-empty histogram bar
+* '''Plus (+)''': Zoom in
+* '''Minus (-)''': Zoom out
== Statistics View ==
fCanvas.removeMouseWheelListener(listener);
}
+ /**
+ * Add a key listener to the histogram
+ * @param listener the key listener
+ * @since 3.1
+ */
+ public void addKeyListener(KeyListener listener) {
+ fCanvas.addKeyListener(listener);
+ }
+
+ /**
+ * Remove a key listener from the histogram
+ * @param listener the key listener
+ * @since 3.1
+ */
+ public void removeKeyListener(KeyListener listener) {
+ fCanvas.removeKeyListener(listener);
+ }
+
// ------------------------------------------------------------------------
// Helper functions
// ------------------------------------------------------------------------
package org.eclipse.linuxtools.tmf.ui.views.histogram;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseWheelListener;
* @author Francois Chouinard
* <p>
*/
-public class HistogramZoom implements MouseWheelListener {
+public class HistogramZoom implements MouseWheelListener, KeyListener {
// ------------------------------------------------------------------------
// Constants
fRangeStartTime = fAbsoluteStartTime;
fRangeDuration = fAbsoluteStartTime + fMinWindowSize;
+
+ histogram.addMouseWheelListener(this);
+ histogram.addKeyListener(this);
}
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
@Override
- public synchronized void mouseScrolled(MouseEvent event) {
+ public void mouseScrolled(MouseEvent event) {
zoom(event.count);
}
+ /**
+ * @since 3.1
+ */
+ @Override
+ public void keyPressed(KeyEvent e) {
+ if (e.character == '+') {
+ zoom(1);
+ } else if (e.character == '-') {
+ zoom(-1);
+ }
+ }
+
+ /**
+ * @since 3.1
+ */
+ @Override
+ public void keyReleased(KeyEvent e) {
+ }
+
private synchronized void zoom(int nbClicks) {
// Compute the new time range
long requestedRange = (nbClicks > 0) ? Math.round(ZOOM_FACTOR * fRangeDuration) : (long) Math.ceil(fRangeDuration * (1.0 / ZOOM_FACTOR));