Mercurial > dive4elements > river
annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/chart/ZoomboxControl.java @ 7172:e1c875583a94
Move MINFO-fixation-stuff to MINFO-datacage and give specified names.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 26 Sep 2013 16:17:36 +0200 |
parents | ea9eef426962 |
children | 5e38e2924c07 |
rev | line source |
---|---|
5861
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5993
ea9eef426962
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5861
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5861
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5993
ea9eef426962
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5861
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5861
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
9 package org.dive4elements.river.client.client.ui.chart; |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 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
|
12 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
|
13 |
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
|
14 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
|
15 |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 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
|
17 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
|
18 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
|
19 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
|
20 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
|
21 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
|
22 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
|
23 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
|
24 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
|
25 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
|
26 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
|
27 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
|
28 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
29 import org.dive4elements.river.client.client.event.HasZoomHandlers; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
30 import org.dive4elements.river.client.client.event.ZoomEvent; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
31 import org.dive4elements.river.client.client.event.ZoomHandler; |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 |
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 /** |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 * 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
|
36 * 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
|
37 * 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
|
38 * 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
|
39 * 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
|
40 * 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
|
41 * |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 * @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
|
43 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 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
|
45 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
|
46 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
|
47 MouseOutHandler |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 { |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 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
|
50 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 protected ChartOutputTab chartTab; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 protected Canvas zoombox; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 protected int[] start; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 protected int[] end; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 |
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
|
59 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
|
60 super(); |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 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
|
63 this.chartTab = chartTab; |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
64 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
|
65 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
|
66 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
|
67 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 initZoombox(); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 |
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
|
70 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
|
71 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
|
72 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
|
73 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
|
74 setShowRollOver(false); |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 setSelected(false); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
77 Canvas chart = chartTab.getChartPanel(); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
78 chart.addMouseDownHandler(this); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
79 chart.addMouseOutHandler(this); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
80 chart.addMouseMoveHandler(this); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
81 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
|
82 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 /** |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 * 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
|
87 * 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
|
88 * 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
|
89 * position. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 protected void initZoombox() { |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
92 Canvas chart = chartTab.getChartPanel(); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
93 chart.addChild(zoombox); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
94 |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 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
|
96 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
|
97 zoombox.setOpacity(50); |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
98 zoombox.setWidth(1); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
99 zoombox.setHeight(1); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
100 zoombox.setLeft(-10000); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
101 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
|
102 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 |
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 * 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
|
107 * |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 * @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
|
109 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 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
|
111 if (handler != null) { |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
112 handlers.add(handler); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
113 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
114 } |
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 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
117 /** |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 * 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
|
119 * zoombox. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
120 * |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 * @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
|
122 * the observed area. |
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 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
|
125 if (!isSelected()) { |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
126 return; |
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 |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
129 start[0] = getRelativeX(event.getX()) - 1; |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
130 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
|
131 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
132 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
|
133 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
|
134 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
135 |
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 /** |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
138 * 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
|
139 * 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
|
140 * displayed. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
141 * |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
142 * @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
|
143 * the observed area. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
144 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
145 public void onMouseMove(MouseMoveEvent event) { |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
146 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
|
147 return; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
148 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
149 |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
150 int x = getRelativeX(event.getX()); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
151 int y = getRelativeY(event.getY()); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
152 |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
153 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
|
154 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
|
155 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
156 positionZoombox(); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
157 } |
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 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
160 /** |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
161 * 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
|
162 * 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
|
163 * |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
164 * @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
|
165 * observed area. |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
166 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
167 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
|
168 if (!isSelected()) { |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
169 return; |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
170 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
171 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
172 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
|
173 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
|
174 |
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
|
175 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
|
176 |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
177 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
|
178 } |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
179 |
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
|
180 |
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 * 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
|
183 * |
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 * @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
|
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 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
|
187 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
|
188 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
|
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 |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
191 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
|
192 } |
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 |
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 * 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
|
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 * @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
|
199 */ |
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 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
|
201 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
|
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 |
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 |
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 * 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
|
207 * 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
|
208 * 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
|
209 * 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
|
210 * |
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 * @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
|
212 * @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
|
213 * |
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 * @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
|
215 * 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
|
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 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
|
218 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
|
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 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
|
221 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
|
222 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
|
223 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
|
224 |
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
|
225 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
|
226 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
|
227 } |
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
|
228 |
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
|
229 return false; |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
230 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
231 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
232 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
233 /** |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
234 * 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
|
235 * |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
236 * @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
|
237 */ |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
238 public boolean isZooming() { |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
239 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
|
240 } |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
241 |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
242 |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
243 /** |
540
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
244 * 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
|
245 * |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
246 * @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
|
247 * |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
248 * @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
|
249 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
250 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
|
251 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
|
252 } |
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 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
255 /** |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
256 * 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
|
257 * |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
258 * @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
|
259 * |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
260 * @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
|
261 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
262 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
|
263 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
|
264 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
265 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
266 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
267 /** |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
268 * 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
|
269 * 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
|
270 * |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
271 * @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
|
272 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
273 protected int[] orderPositions() { |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
274 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
|
275 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
|
276 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
277 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
|
278 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
|
279 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
280 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
|
281 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
282 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
283 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
284 /** |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
285 * 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
|
286 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
287 protected void positionZoombox() { |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
288 int[] values = orderPositions(); |
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 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
|
291 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
|
292 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
|
293 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
|
294 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
295 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
296 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
297 /** |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
298 * 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
|
299 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
300 protected void clearZoombox() { |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
301 zoombox.setLeft(-10000); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
302 zoombox.setTop(-10000); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
303 zoombox.setWidth(1); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
304 zoombox.setHeight(1); |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
305 } |
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
|
306 |
779
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
307 |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
308 /** |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
309 * 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
|
310 */ |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
311 protected void reset() { |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
312 start[0] = -1; |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
313 start[1] = -1; |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
314 |
f1a559d13eef
#185 Repaired zooming for IE8 and Chrome.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
546
diff
changeset
|
315 clearZoombox(); |
540
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 |
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 /** |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
320 * 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
|
321 */ |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
322 protected void fireZoomEvent() { |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
323 int[] pos = orderPositions(); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
324 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
325 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
|
326 |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
327 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
|
328 handler.onZoom(event); |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
329 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
330 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
331 } |
a866cdf1ca40
Implemented a zoombox control and added it to the chart toolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
332 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |