[PATCH] cleanup

Wald Commits scm-commit at wald.intevation.org
Thu Jan 21 15:05:33 CET 2021


# HG changeset patch
# User dnt_bjoernsen <d.tironi at bjoernsen.de>
# Date 1611237924 -3600
#      Thu Jan 21 15:05:24 2021 +0100
# Node ID bfdf98529a66edec2072aa16a08a7d864adc1516
# Parent  ca9ed55d6f514ddba9cca2874ed5ff23ce19f5dd
cleanup

diff -r ca9ed55d6f51 -r bfdf98529a66 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/LegendWindow.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/LegendWindow.java	Thu Jan 21 14:08:03 2021 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/LegendWindow.java	Thu Jan 21 15:05:24 2021 +0100
@@ -65,7 +65,7 @@
 			try {
 				if (theme instanceof AttributedTheme) {
 					Canvas createLegendGraphicsRow = createLegendGraphicsRow((AttributedTheme) theme);
-					 this.legendContainer.addMember(createLegendGraphicsRow);
+					this.legendContainer.addMember(createLegendGraphicsRow);
 				}
 			} catch (Exception e) {
 				continue;
@@ -76,67 +76,39 @@
 	private Canvas createLegendGraphicsRow(final AttributedTheme at) {
 		final Label label = new Label(at.getDescription());
 		final HLayout row = new HLayout();
-		final Widget img = createLegendGraphics(row ,at);
+		final Widget img = createLegendGraphics(row, at);
 
 		row.addMember(label);
 		row.addMember(img);
 
-//		String url = "url";
-		if (img instanceof Image) {
-//			url = " url " + ((Image) img).getUrl();
-//			new MyLoadHandler(row, ((Image) img));
-
-//		} else if (img instanceof Img) {
-//			setDimensions(row, ((Img) img).getHeight(), ((Img) img).getWidth());
-//			url = " dataPath " + ((Img) img).getDataPath();
-		} else {
-			setDimensions(row, 150, 400); // not sure when this is executed
-		}
-//		String labelText = at.getDescription() + ", height: " + row.getHeight() + "width: " + row.getWidth() + " "
-//				+ url;
-
-//		com.smartgwt.client.util.SC.say(labelText);
+		// setDimensions(row, 150, 400);
 		return row;
 	}
 
-	private void setDimensions(HLayout row, int height, int width) {
-		final int minHeight = 30;
-		row.setHeight(height < minHeight ? minHeight : height);
-		row.setWidth(width);
-	}
-
 	private Widget createLegendGraphics(HLayout row, final AttributedTheme at) {
 
 		final String legend = at.getAttr("legend");
 		// TEST: final Image img = new Image("/images/FLYS_Donau.png"); (funktioniert!),
 		// ebenso FLYSResources.getTest();
-		String attr = at.getAttr("url");
-		String attr2 = at.getAttr("layers");
-		
-		if (legend != null && !"".equals(legend)) {
-
-			final String imgUrl = URL.encode(GWT.getHostPageBaseURL() + "images/wms_legend/" + legend);
-
-			final Image image = new Image(imgUrl);
-			new MyWMSLoadHandler(row, image);
+		String urlAttr = at.getAttr("url");
+		String layersAttr = at.getAttr("layers");
 
-			return image;
-		}
-	
-		final String imgUrl = MapUtils.getLegendGraphicUrl(attr, attr2);
+		final String imgUrl = getUrl(legend, urlAttr, layersAttr);
+
 		final Image image = new Image(imgUrl);
-		
-//		com.smartgwt.client.util.SC.say(imgUrl);
-		new MyLoadHandler(row, ((Image) image));
-//		Image image = new Image(imgUrl);
-//		Widget widget = image.asWidget();
-//		final Img img = new Img(imgUrl);
-//		img.setImageType(ImageStyle.CENTER);
-//		img.setAutoFit(true);
+		new MyWMSLoadHandler(row, image);
 
 		return image;
 	}
 
+	private String getUrl(final String legend, String urlAttr, String layersAttr) {
+		if (legend != null && !"".equals(legend)) {
+			return URL.encode(GWT.getHostPageBaseURL() + "images/wms_legend/" + legend);
+		} else {
+			return MapUtils.getLegendGraphicUrl(urlAttr, layersAttr);
+		}
+	}
+
 	private void init() {
 		this.legendContainer.setAutoHeight();
 		this.legendContainer.setLayoutAlign(VerticalAlignment.TOP);
diff -r ca9ed55d6f51 -r bfdf98529a66 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MyLoadHandler.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MyLoadHandler.java	Thu Jan 21 14:08:03 2021 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-package org.dive4elements.river.client.client.ui.map;
-
-import com.google.gwt.event.dom.client.LoadEvent;
-import com.google.gwt.event.shared.HandlerRegistration;
-import com.google.gwt.user.client.ui.Image;
-import com.smartgwt.client.widgets.layout.HLayout;
-
-public class MyLoadHandler implements com.google.gwt.event.dom.client.LoadHandler {
-	private Image m_image;
-	private HLayout m_row;
-	private HandlerRegistration m_handelReg;
-
-	public MyLoadHandler(HLayout row, Image image) {
-		m_image = image;
-		m_row = row;
-		m_handelReg = image.addLoadHandler(this);
-	}
-
-	@Override
-	public void onLoad(LoadEvent event) {
-		setDimensions(m_row, m_image.getHeight(), m_image.getWidth());
-		if (m_handelReg != null)
-			m_handelReg.removeHandler();
-	}
-
-	private void setDimensions(HLayout row, int height, int width) {
-		final int minHeight = 30;
-		row.setHeight(height < minHeight ? minHeight : height);
-		row.setWidth(width);
-	}
-}
\ No newline at end of file


More information about the Dive4Elements-commits mailing list