# HG changeset patch # User Ingo Weinzierl # Date 1308851168 0 # Node ID ea2191b1299d9fa2de637f35de7ce51d121879fa # Parent 418be98527f09ede611f596d392fe5a971ed967c #170 Changed the DOM manipulation while zoom and drag operation. flys-client/trunk@2223 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 418be98527f0 -r ea2191b1299d flys-client/ChangeLog --- a/flys-client/ChangeLog Thu Jun 23 17:16:08 2011 +0000 +++ b/flys-client/ChangeLog Thu Jun 23 17:46:08 2011 +0000 @@ -1,3 +1,19 @@ +2011-06-23 Ingo Weinzierl + + flys/issue170 (Diagramm: Initiales Zoomen zeigt verschobenen Bereich) + + * src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java: + The chart image is no longer removed from DOM but it's source is set to + a new value after the panel's size changes. This makes the zoom actions + much smoother and there the initial zoom values are no longer broken. + + * src/main/java/de/intevation/flys/client/client/ui/chart/PanControl.java: + Panning will now move the image itself but not its parent element. + + * src/main/java/de/intevation/flys/client/shared/model/ChartInfo.java, + src/main/java/de/intevation/flys/client/shared/Transform2D.java: Added + methods to dump the objects to GWT log. + 2011-06-23 Sascha L. Teichmann * src/main/java/de/intevation/flys/client/client/FLYSConstants.properties, diff -r 418be98527f0 -r ea2191b1299d flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java Thu Jun 23 17:16:08 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java Thu Jun 23 17:46:08 2011 +0000 @@ -7,6 +7,8 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.types.Overflow; + import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Img; @@ -72,6 +74,8 @@ /** The canvas that wraps the chart.*/ protected Canvas right; + protected Img chart; + /** Chart zoom options.*/ protected int[] xrange; @@ -122,7 +126,10 @@ ChartThemePanel ctp = new ChartThemePanel(collection, mode); ctp.addOutputParameterChangeHandler(this); - right.addChild(createChartPanel()); + chart = createChartImg(); + right.addChild(chart); + right.setOverflow(Overflow.HIDDEN); + //right.addChild(createChartPanel()); left.addChild(ctp); vLayout.addMember(tbarPanel); @@ -357,7 +364,7 @@ getChartAttributes(), new AsyncCallback() { public void onFailure(Throwable caught) { - GWT.log("ERROR: " + caught.getMessage()); + GWT.log("ChartInfo ERROR: " + caught.getMessage()); } public void onSuccess(ChartInfo chartInfo) { @@ -368,12 +375,10 @@ public void updateChartPanel() { - Canvas[] children = right.getChildren(); - for (Canvas child: children) { - right.removeChild(child); - } + int w = right.getWidth(); + int h = right.getHeight(); - right.addChild(createChartPanel(right.getWidth(), right.getHeight())); + chart.setSrc(getImgUrl(w, h)); } @@ -383,14 +388,12 @@ * @return the existing chart panel. */ public Canvas getChartPanel() { - Canvas[] children = right.getChildren(); + return right; + } - if (children == null || children.length == 0) { - GWT.log("=> No chart image in the panel."); - return right; - } - return children[0]; + public Canvas getChartImg() { + return chart; } @@ -435,8 +438,8 @@ * * @return the created chart panel. */ - protected Canvas createChartPanel() { - return createChartPanel(DEFAULT_CHART_WIDTH, DEFAULT_CHART_HEIGHT); + protected Img createChartImg() { + return createChartImg(DEFAULT_CHART_WIDTH, DEFAULT_CHART_HEIGHT); } @@ -448,7 +451,7 @@ * * @return the created chart panel. */ - protected Canvas createChartPanel(int width, int height) { + protected Img createChartImg(int width, int height) { Img chart = getChartImg(width, height); chart.setWidth100(); chart.setHeight100(); @@ -496,8 +499,6 @@ double[] zoom = getZoomValues(); if (zoom != null) { - GWT.log("Zoom to specified range."); - imgUrl += "&minx=" + Double.toString(zoom[0]); imgUrl += "&maxx=" + Double.toString(zoom[1]); imgUrl += "&miny=" + Double.toString(zoom[2]); diff -r 418be98527f0 -r ea2191b1299d flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/PanControl.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/PanControl.java Thu Jun 23 17:16:08 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/PanControl.java Thu Jun 23 17:46:08 2011 +0000 @@ -84,9 +84,6 @@ return; } - Canvas parent = chartTab.getChartPanel().getParentElement(); - parent.setOverflow(Overflow.HIDDEN); - start[0] = event.getX(); start[1] = event.getY(); @@ -113,7 +110,7 @@ end[0] = end[0] + x; end[1] = end[1] + y; - Canvas c = chartTab.getChartPanel(); + Canvas c = chartTab.getChartImg(); c.moveBy(x, y); } @@ -132,8 +129,9 @@ end[0] = event.getX(); end[1] = event.getY(); - Canvas parent = chartTab.getChartPanel().getParentElement(); - parent.setOverflow(Overflow.AUTO); + Canvas c = chartTab.getChartImg(); + c.setLeft(0); + c.setTop(0); fireOnPan(); @@ -155,8 +153,9 @@ return; } - Canvas parent = chartTab.getChartPanel().getParentElement(); - parent.setOverflow(Overflow.AUTO); + Canvas c = chartTab.getChartImg(); + c.setLeft(0); + c.setTop(0); fireOnPan(); @@ -178,7 +177,7 @@ * false. */ protected boolean isMouseOut(int x, int y) { - Canvas chart = chartTab.getChartPanel(); + Canvas chart = chartTab.getChartImg(); if (chart instanceof Img) { chart = chart.getParentElement(); diff -r 418be98527f0 -r ea2191b1299d flys-client/src/main/java/de/intevation/flys/client/shared/Transform2D.java --- a/flys-client/src/main/java/de/intevation/flys/client/shared/Transform2D.java Thu Jun 23 17:16:08 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/Transform2D.java Thu Jun 23 17:46:08 2011 +0000 @@ -2,6 +2,8 @@ import java.io.Serializable; +import com.google.gwt.core.client.GWT; + /** * This object supports a linear transformation to transform xy coordinates into @@ -48,5 +50,13 @@ return new double[] { resX, resY }; } + + + public void dumpGWT() { + GWT.log("SX = " + sx); + GWT.log("SY = " + sy); + GWT.log("TX = " + tx); + GWT.log("TY = " + ty); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 418be98527f0 -r ea2191b1299d flys-client/src/main/java/de/intevation/flys/client/shared/model/ChartInfo.java --- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/ChartInfo.java Thu Jun 23 17:16:08 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/ChartInfo.java Thu Jun 23 17:46:08 2011 +0000 @@ -2,6 +2,8 @@ import java.io.Serializable; +import com.google.gwt.core.client.GWT; + import de.intevation.flys.client.shared.Transform2D; @@ -62,5 +64,28 @@ return null; } + + + public void dumpGWT() { + StringBuilder sb = new StringBuilder(); + + Axis x = getXAxis(0); + + GWT.log("X axis:"); + GWT.log("... from " + x.getFrom() + " to " + x.getTo()); + GWT.log("... min " + x.getMin() + " max " + x.getMax()); + + for (int i = 0, count = getYAxisCount(); i < count; i++) { + Axis y = getYAxis(i); + + GWT.log("Y axis " + i + ":"); + GWT.log("... from " + y.getFrom() + " to " + y.getTo()); + GWT.log("... min " + y.getMin() + " max " + y.getMax()); + } + + for (Transform2D t: transformer) { + t.dumpGWT(); + } + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :