Commit | Line | Data |
---|---|---|
f05aabed FC |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009, 2010 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 | * Modifications: | |
10 | * 2010-07-16 Yuriy Vashchuk - Base class simplification | |
11 | *******************************************************************************/ | |
12 | ||
6e512b93 ASL |
13 | package org.eclipse.linuxtools.lttng.ui.views.histogram; |
14 | ||
15 | import org.eclipse.swt.events.ControlEvent; | |
16 | import org.eclipse.swt.events.ControlListener; | |
17 | ||
18 | /** | |
19 | * <b><u>HistogramCanvasControlListener</u></b> | |
20 | * <p> | |
21 | * Implementation of a ControlListener for the need of the HistogramCanvas | |
22 | * <p> | |
23 | */ | |
24 | public class HistogramCanvasControlListener implements ControlListener { | |
25 | ||
f05aabed FC |
26 | private HistogramCanvas ourCanvas = null; |
27 | ||
28 | /** | |
29 | * HistogramCanvasControlListener default constructor | |
30 | */ | |
31 | public HistogramCanvasControlListener() { | |
32 | } | |
6e512b93 ASL |
33 | |
34 | /** | |
35 | * HistogramCanvasControlListener constructor | |
36 | * | |
37 | * @param newCanvas Related canvas | |
38 | */ | |
39 | public HistogramCanvasControlListener(HistogramCanvas newCanvas) { | |
f05aabed | 40 | ourCanvas = newCanvas; |
6e512b93 ASL |
41 | } |
42 | ||
43 | ||
44 | /** | |
45 | * Method called when the canvas is moved.<p> | |
46 | * | |
47 | * Just redraw the canvas... | |
48 | * | |
49 | * @param event The controle event generated by the move. | |
50 | */ | |
d4011df2 | 51 | @Override |
6e512b93 | 52 | public void controlMoved(ControlEvent event) { |
1a971e96 FC |
53 | if (ourCanvas != null) |
54 | ourCanvas.redraw(); | |
6e512b93 ASL |
55 | } |
56 | ||
57 | /** | |
58 | * Method called when the canvas is resized.<p> | |
59 | * | |
3e9fdb8b | 60 | * We need to tell the content that the canvas size changed |
6e512b93 | 61 | * |
7ef9ae3f | 62 | * @param event The control event generated by the resize. |
6e512b93 | 63 | */ |
d4011df2 | 64 | @Override |
6e512b93 ASL |
65 | public void controlResized(ControlEvent event) { |
66 | ||
f05aabed | 67 | if ( (ourCanvas != null) && (ourCanvas.getHistogramContent() != null) ) { |
6e512b93 | 68 | // Set the new canvas size |
f05aabed | 69 | ourCanvas.getHistogramContent().setCanvasWindowSize(ourCanvas.getSize().x); |
6e512b93 ASL |
70 | } |
71 | } | |
72 | } |