Mercurial > dive4elements > river
changeset 551:13c7f90917fc
Added a PanControl to pan charts.
flys-client/trunk@2064 c6561f87-3c4e-4783-a992-168aeb5c3f6f
line wrap: on
line diff
--- a/flys-client/ChangeLog Tue Jun 07 12:51:57 2011 +0000 +++ b/flys-client/ChangeLog Tue Jun 07 13:07:27 2011 +0000 @@ -1,3 +1,34 @@ +2011-06-07 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/client/client/event/HasPanHandlers.java, + src/main/java/de/intevation/flys/client/client/event/PanEvent.java, + src/main/java/de/intevation/flys/client/client/event/PanHandler.java: + New. Classes and interfaces necessary for a pan listeners mechanism. + + * src/main/java/de/intevation/flys/client/client/ui/chart/PanControl.java: + New. A control that enables the user to pan a chart. + + * src/main/webapp/images/pan.png, + src/main/webapp/images/pan_Selected.png: Icons for the PanControl. + + * src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants.java: Added + links to the pan icons. + +2011-06-07 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/client/client/services/CSVExportServiceAsync.java, + src/main/java/de/intevation/flys/client/client/services/CSVExportService.java, + src/main/java/de/intevation/flys/client/server/CSVExportServiceImpl.java: + Changed the return value of this service from List to List<String[]>. + This helps GWT creating JavaScript objects. + + * src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java: + Adjusted the return value of the CSVExportService and added a warning + dialog if an error occured while fetching those data. + 2011-06-07 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/client/server/ChartServiceHelper.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Tue Jun 07 12:51:57 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Tue Jun 07 13:07:27 2011 +0000 @@ -76,6 +76,8 @@ String zoom_out(); + String pan(); + String fix(); String next();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Tue Jun 07 12:51:57 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Tue Jun 07 13:07:27 2011 +0000 @@ -74,6 +74,7 @@ zoom_all = images/zoom-1.png zoom_in = images/zoom-in.png zoom_out = images/zoom-out.png +pan = images/pan.png discharge_curve = Discharge Curves at Gauges computed_discharge_curve = Discharge Curve
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Tue Jun 07 12:51:57 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Tue Jun 07 13:07:27 2011 +0000 @@ -74,6 +74,7 @@ zoom_all = images/zoom-1.png zoom_in = images/zoom-in.png zoom_out = images/zoom-out.png +pan = images/pan.png discharge_curve = Abflusskurven an Pegeln computed_discharge_curve = Abflusskurve
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Tue Jun 07 12:51:57 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Tue Jun 07 13:07:27 2011 +0000 @@ -74,6 +74,7 @@ zoom_all = images/zoom-1.png zoom_in = images/zoom-in.png zoom_out = images/zoom-out.png +pan = images/pan.png discharge_curve = Discharge Curves at Gauges computed_discharge_curve = Discharge Curve
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/event/HasPanHandlers.java Tue Jun 07 13:07:27 2011 +0000 @@ -0,0 +1,11 @@ +package de.intevation.flys.client.client.event; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public interface HasPanHandlers { + + void addPanHandler(PanHandler handler); +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/event/PanEvent.java Tue Jun 07 13:07:27 2011 +0000 @@ -0,0 +1,28 @@ +package de.intevation.flys.client.client.event; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class PanEvent { + + protected int[] startPos; + protected int[] endPos; + + + public PanEvent(int[] startPos, int[] endPos) { + this.startPos = startPos; + this.endPos = endPos; + } + + + public int[] getStartPos() { + return startPos; + } + + + public int[] getEndPos() { + return endPos; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/event/PanHandler.java Tue Jun 07 13:07:27 2011 +0000 @@ -0,0 +1,11 @@ +package de.intevation.flys.client.client.event; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public interface PanHandler { + + void onPan(PanEvent event); +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/PanControl.java Tue Jun 07 13:07:27 2011 +0000 @@ -0,0 +1,166 @@ +package de.intevation.flys.client.client.ui.chart; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gwt.core.client.GWT; + +import com.smartgwt.client.types.Overflow; +import com.smartgwt.client.types.SelectionType; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.ImgButton; +import com.smartgwt.client.widgets.events.MouseDownEvent; +import com.smartgwt.client.widgets.events.MouseDownHandler; +import com.smartgwt.client.widgets.events.MouseMoveEvent; +import com.smartgwt.client.widgets.events.MouseMoveHandler; +import com.smartgwt.client.widgets.events.MouseOutEvent; +import com.smartgwt.client.widgets.events.MouseOutHandler; +import com.smartgwt.client.widgets.events.MouseUpEvent; +import com.smartgwt.client.widgets.events.MouseUpHandler; + +import de.intevation.flys.client.client.event.HasPanHandlers; +import de.intevation.flys.client.client.event.PanEvent; +import de.intevation.flys.client.client.event.PanHandler; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class PanControl +extends ImgButton +implements MouseDownHandler, MouseMoveHandler, MouseUpHandler, + MouseOutHandler, HasPanHandlers +{ + protected ChartOutputTab chartTab; + + protected List<PanHandler> handlers; + + protected int[] start; + protected int[] end; + + + public PanControl(ChartOutputTab chartTab, String imageUrl) { + super(); + + this.chartTab = chartTab; + this.handlers = new ArrayList<PanHandler>(); + this.start = new int[] { -1, -1 }; + this.end = new int[] { -1, -1 }; + + String baseUrl = GWT.getHostPageBaseURL(); + setSrc(baseUrl + imageUrl); + setActionType(SelectionType.CHECKBOX); + setSize(20); + setShowRollOver(false); + setSelected(false); + + chartTab.getChartPanel().addMouseDownHandler(this); + chartTab.getChartPanel().addMouseMoveHandler(this); + chartTab.getChartPanel().addMouseUpHandler(this); + chartTab.getChartPanel().addMouseOutHandler(this); + } + + + /** + * Method used to register a new PanHandler. + * + * @param handler A new PanHandler. + */ + public void addPanHandler(PanHandler handler) { + if (handler != null) { + handlers.add(handler); + } + } + + + /** + * This event starts the dragging operation if the control is activated. + * + * @param event The mouse down event which contains the start coordinates. + */ + public void onMouseDown(MouseDownEvent event) { + if (!isSelected()) { + return; + } + + Canvas parent = chartTab.getChartPanel().getParentElement(); + parent.setOverflow(Overflow.HIDDEN); + + start[0] = event.getX(); + start[1] = event.getY(); + + end[0] = start[0]; + end[1] = start[1]; + } + + + /** + * This event is used to reposition the chart image based on the current + * drag operation. + * + * @param event The move event which contains the new coordinates to update + * the chart image position. + */ + public void onMouseMove(MouseMoveEvent event) { + if (!isSelected() || start[0] == -1 || start[1] == -1) { + return; + } + + int x = event.getX() - end[0]; + int y = event.getY() - end[1]; + + end[0] = end[0] + x; + end[1] = end[1] + y; + + Canvas c = chartTab.getChartPanel(); + c.moveBy(x, y); + } + + + /** + * This event stops the dragging operation and fires a DragEnd event to the + * registered listeners. + * + * @param event The mouse up event which contains the end coordinates. + */ + public void onMouseUp(MouseUpEvent event) { + if (!isSelected()) { + return; + } + + end[0] = event.getX(); + end[1] = event.getY(); + + Canvas parent = chartTab.getChartPanel().getParentElement(); + parent.setOverflow(Overflow.AUTO); + + fireOnPan(); + + start[0] = -1; + start[1] = -1; + } + + + /** + * This event is used to cancel the current dragging operation. + * + * @param event The mouse out event. + */ + public void onMouseOut(MouseOutEvent event) { + // TODO Cancel dragging if mouse pointer leaves chart area + } + + + /** + * A pan event is fired to inform the registered listeners about a pan + * operation has finished. + */ + protected void fireOnPan() { + PanEvent event = new PanEvent(start, end); + + for (PanHandler handler: handlers) { + handler.onPan(event); + } + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :