Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ZoomboxControl.java @ 5462:f2371f3aaf03
Show top level folder icons only if node has no factory
If you have an empty folder the folder icon is still shown.
This makes it possible to add functional "Top Level" entries
in the Datacage
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Tue, 26 Mar 2013 18:29:13 +0100 |
parents | f1a559d13eef |
children |
rev | line source |
---|---|
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.client.ui.chart; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import java.util.ArrayList; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import java.util.List; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 |
543
9c2cf4811a7d
Added a control to reset the zoom of a chart. In addition, the zoom buttons are displayed as ImgButtons now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
541
diff
changeset
|
6 import com.google.gwt.core.client.GWT; |
9c2cf4811a7d
Added a control to reset the zoom of a chart. In addition, the zoom buttons are displayed as ImgButtons now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
541
diff
changeset
|
7 |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import com.smartgwt.client.types.Positioning; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import com.smartgwt.client.types.SelectionType; |
543
9c2cf4811a7d
Added a control to reset the zoom of a chart. In addition, the zoom buttons are displayed as ImgButtons now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
541
diff
changeset
|
10 import com.smartgwt.client.widgets.ImgButton; |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import com.smartgwt.client.widgets.Canvas; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import com.smartgwt.client.widgets.events.MouseDownEvent; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 import com.smartgwt.client.widgets.events.MouseDownHandler; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import com.smartgwt.client.widgets.events.MouseMoveEvent; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import com.smartgwt.client.widgets.events.MouseMoveHandler; |
546
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
16 import com.smartgwt.client.widgets.events.MouseOutEvent; |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
17 import com.smartgwt.client.widgets.events.MouseOutHandler; |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import com.smartgwt.client.widgets.events.MouseUpEvent; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 import com.smartgwt.client.widgets.events.MouseUpHandler; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 import de.intevation.flys.client.client.event.HasZoomHandlers; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 import de.intevation.flys.client.client.event.ZoomEvent; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 import de.intevation.flys.client.client.event.ZoomHandler; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 /** |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 * This control observes that panel retrieved by ChartOutputTab.getChartPanel(). |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 * If activated, a zoombox is drawn. One of the two edges is the position of the |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 * mouse down event on the observed panel. The other edge is specified by the |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 * current mouse position. If the mouse up event occurs, start and end point |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 * relative to the left and upper border of the observed panel is determined and |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 * a ZoomEvent is fired. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 * |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 public class ZoomboxControl |
543
9c2cf4811a7d
Added a control to reset the zoom of a chart. In addition, the zoom buttons are displayed as ImgButtons now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
541
diff
changeset
|
37 extends ImgButton |
546
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
38 implements MouseDownHandler, MouseUpHandler, MouseMoveHandler, HasZoomHandlers, |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
39 MouseOutHandler |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 { |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 protected List<ZoomHandler> handlers; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 protected ChartOutputTab chartTab; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 protected Canvas zoombox; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 protected int[] start; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 protected int[] end; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 |
543
9c2cf4811a7d
Added a control to reset the zoom of a chart. In addition, the zoom buttons are displayed as ImgButtons now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
541
diff
changeset
|
51 public ZoomboxControl(ChartOutputTab chartTab, String imageUrl) { |
9c2cf4811a7d
Added a control to reset the zoom of a chart. In addition, the zoom buttons are displayed as ImgButtons now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
541
diff
changeset
|
52 super(); |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 this.handlers = new ArrayList<ZoomHandler>(); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 this.chartTab = chartTab; |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
56 this.start = new int[] { -1, -1 }; |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 this.end = new int[2]; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 this.zoombox = new Canvas(); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 initZoombox(); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 |
543
9c2cf4811a7d
Added a control to reset the zoom of a chart. In addition, the zoom buttons are displayed as ImgButtons now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
541
diff
changeset
|
62 String baseUrl = GWT.getHostPageBaseURL(); |
9c2cf4811a7d
Added a control to reset the zoom of a chart. In addition, the zoom buttons are displayed as ImgButtons now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
541
diff
changeset
|
63 setSrc(baseUrl + imageUrl); |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 setActionType(SelectionType.CHECKBOX); |
543
9c2cf4811a7d
Added a control to reset the zoom of a chart. In addition, the zoom buttons are displayed as ImgButtons now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
541
diff
changeset
|
65 setSize(20); |
9c2cf4811a7d
Added a control to reset the zoom of a chart. In addition, the zoom buttons are displayed as ImgButtons now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
541
diff
changeset
|
66 setShowRollOver(false); |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 setSelected(false); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
69 Canvas chart = chartTab.getChartPanel(); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
70 chart.addMouseDownHandler(this); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
71 chart.addMouseOutHandler(this); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
72 chart.addMouseMoveHandler(this); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
73 chart.addMouseUpHandler(this); |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 /** |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 * Initializes the zoombox that is displayed over the observed area. The |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 * zoombox has an opaque background. Its height/width and x/y values are |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 * determined by the start point (mouse down) and the current mouse |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 * position. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 protected void initZoombox() { |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
84 Canvas chart = chartTab.getChartPanel(); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
85 chart.addChild(zoombox); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
86 |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 zoombox.setPosition(Positioning.ABSOLUTE); |
541
ed29599e06e5
Added the ChartOutputTab as ZoomHandler for the ZoomboxControl - no zooming is done yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
540
diff
changeset
|
88 zoombox.setBorder("2px solid black"); |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 zoombox.setOpacity(50); |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
90 zoombox.setWidth(1); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
91 zoombox.setHeight(1); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
92 zoombox.setLeft(-10000); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
93 zoombox.setTop(-10000); |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 /** |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 * Registers a new ZoomHandler that wants to listen to ZoomEvents. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 * |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 * @param handler A new ZoomHandler. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
102 public void addZoomHandler(ZoomHandler handler) { |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 if (handler != null) { |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 handlers.add(handler); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
105 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
106 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 /** |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 * A mouse down event on the specified area will set the start point for the |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
111 * zoombox. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
112 * |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
113 * @param event The mouse down event which contains the xy coordinates of |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
114 * the observed area. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
115 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
116 public void onMouseDown(MouseDownEvent event) { |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
117 if (!isSelected()) { |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 return; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
120 |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
121 start[0] = getRelativeX(event.getX()) - 1; |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
122 start[1] = getRelativeY(event.getY()) + 1; |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
123 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
124 end[0] = start[0]; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
125 end[1] = start[1]; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
126 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
127 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
128 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
129 /** |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
130 * A mouse move event on the specified area will set the end point for the |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
131 * zoombox. If the end point differs from the start point, an opaque box is |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
132 * displayed. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
133 * |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
134 * @param event The mouse move event which contains the xy coordinates of |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
135 * the observed area. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
136 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
137 public void onMouseMove(MouseMoveEvent event) { |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
138 if (!isSelected() || !isZooming()) { |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
139 return; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
140 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
141 |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
142 int x = getRelativeX(event.getX()); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
143 int y = getRelativeY(event.getY()); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
144 |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
145 end[0] = x > start[0] ? x-1 : x+1; |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
146 end[1] = y > start[1] ? y-1 : y+1; |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
147 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
148 positionZoombox(); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
149 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
150 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
151 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
152 /** |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
153 * The mouse up event finalizes the zoom operation. It sets the end point |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
154 * for this operation, clears the zoombox and fires a ZoomEvent. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
155 * |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
156 * @param event The mouse up event which contains the xy coordinates of the |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
157 * observed area. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
158 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
159 public void onMouseUp(MouseUpEvent event) { |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
160 if (!isSelected()) { |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
161 return; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
162 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
163 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
164 end[0] = getRelativeX(event.getX()); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
165 end[1] = getRelativeY(event.getY()); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
166 |
541
ed29599e06e5
Added the ChartOutputTab as ZoomHandler for the ZoomboxControl - no zooming is done yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
540
diff
changeset
|
167 fireZoomEvent(); |
ed29599e06e5
Added the ChartOutputTab as ZoomHandler for the ZoomboxControl - no zooming is done yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
540
diff
changeset
|
168 |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
169 reset(); |
546
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
170 } |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
171 |
546
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
172 |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
173 /** |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
174 * The mouse out event is used to cancel an active zoom operation. |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
175 * |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
176 * @param event The mouse out event. |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
177 */ |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
178 public void onMouseOut(MouseOutEvent event) { |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
179 if (!isSelected() || !isMouseOut(event.getX(), event.getY())) { |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
180 return; |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
181 } |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
182 |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
183 reset(); |
546
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
184 } |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
185 |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
186 |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
187 /** |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
188 * Returns the chart panel. |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
189 * |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
190 * @return the chart panel. |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
191 */ |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
192 protected Canvas getChartPanel() { |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
193 return chartTab.getChartPanel(); |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
194 } |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
195 |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
196 |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
197 /** |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
198 * This method is required to check manually if the mouse pointer really |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
199 * moves out the chart area. The MouseOutEvent is also fired if the mouse |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
200 * goes down which doesn't seem to be correct. So, we gonna check this |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
201 * manually. |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
202 * |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
203 * @param x The x coordinate. |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
204 * @param y The y coordinate. |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
205 * |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
206 * @return true, if the mouse is really out of the chart area, otherwise |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
207 * false. |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
208 */ |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
209 protected boolean isMouseOut(int x, int y) { |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
210 Canvas chart = getChartPanel(); |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
211 |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
212 int left = chart.getPageLeft(); |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
213 int right = chart.getPageRight(); |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
214 int top = chart.getPageTop(); |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
215 int bottom = chart.getPageBottom(); |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
216 |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
217 if (x <= left || x >= right || y <= top || y >= bottom) { |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
218 return true; |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
219 } |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
220 |
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
221 return false; |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
222 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
223 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
224 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
225 /** |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
226 * Returns true, if a zoom action is in process. |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
227 * |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
228 * @return true, if a zoom action is in process. |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
229 */ |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
230 public boolean isZooming() { |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
231 return start[0] > 0 && start[1] > 0; |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
232 } |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
233 |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
234 |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
235 /** |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
236 * Returns the X coordinate relative to the left border. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
237 * |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
238 * @param x The X coordinate relative to the window. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
239 * |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
240 * @return the X coordinate relative to the left border. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
241 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
242 protected int getRelativeX(int x) { |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
243 return x - chartTab.getChartPanel().getPageLeft(); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
244 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
245 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
246 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
247 /** |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
248 * Returns the Y coordinate relative to the top border. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
249 * |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
250 * @param y The Y coordinate relative to the window. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
251 * |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
252 * @return the Y coordinate relative to the top border. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
253 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
254 protected int getRelativeY(int y) { |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
255 return y - chartTab.getChartPanel().getPageTop(); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
256 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
257 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
258 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
259 /** |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
260 * Returns min and max x/y values based on the stored values in <i>start</i> |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
261 * and <i>end</i>. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
262 * |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
263 * @return an int[] as follows: [xmin, ymin, xmax, ymax]. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
264 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
265 protected int[] orderPositions() { |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
266 int xmin = start[0] < end[0] ? start[0] : end[0]; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
267 int ymin = start[1] < end[1] ? start[1] : end[1]; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
268 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
269 int xmax = start[0] >= end[0] ? start[0] : end[0]; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
270 int ymax = start[1] >= end[1] ? start[1] : end[1]; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
271 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
272 return new int[] { xmin, ymin, xmax, ymax }; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
273 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
274 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
275 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
276 /** |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
277 * Sets the width, height, x and y values of the zoombox. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
278 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
279 protected void positionZoombox() { |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
280 int[] values = orderPositions(); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
281 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
282 zoombox.setLeft(values[0]); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
283 zoombox.setTop(values[1]); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
284 zoombox.setWidth(values[2] - values[0]); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
285 zoombox.setHeight(values[3] - values[1]); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
286 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
287 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
288 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
289 /** |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
290 * Clears the zoombox (set position and size to null). |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
291 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
292 protected void clearZoombox() { |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
293 zoombox.setLeft(-10000); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
294 zoombox.setTop(-10000); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
295 zoombox.setWidth(1); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
296 zoombox.setHeight(1); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
297 } |
546
feaf6a8881ee
Improved the zoombox control: cancel the zoom operation if the mouse pointer leaves the chart area.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
543
diff
changeset
|
298 |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
299 |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
300 /** |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
301 * Resets the zoom control (start point and zoombox). |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
302 */ |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
303 protected void reset() { |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
304 start[0] = -1; |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
305 start[1] = -1; |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
306 |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
307 clearZoombox(); |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
308 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
309 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
310 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
311 /** |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
312 * Fires a ZoomEvent to all registered listeners. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
313 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
314 protected void fireZoomEvent() { |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
315 int[] pos = orderPositions(); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
316 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
317 ZoomEvent event = new ZoomEvent(pos[0], pos[1], pos[2], pos[3]); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
318 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
319 for (ZoomHandler handler: handlers) { |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
320 handler.onZoom(event); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
321 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
322 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
323 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
324 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |