changeset 9698:812a6a3eaaf5

another try
author dnt_bjoernsen <d.tironi@bjoernsen.de>
date Wed, 20 Jan 2021 17:19:59 +0100
parents 15404504ea9e
children 94362af5928e
files gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/LegendWindow.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MyLoadHandler.java
diffstat 2 files changed, 50 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/LegendWindow.java	Wed Jan 20 16:17:32 2021 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/LegendWindow.java	Wed Jan 20 17:19:59 2021 +0100
@@ -17,7 +17,11 @@
 import org.dive4elements.river.client.shared.model.ThemeList;
 
 import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.LoadEvent;
 import com.google.gwt.event.dom.client.LoadHandler;
+import com.google.gwt.event.shared.EventBus;
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.event.shared.SimpleEventBus;
 import com.google.gwt.http.client.URL;
 import com.google.gwt.user.client.ui.Image;
 import com.google.gwt.user.client.ui.Widget;
@@ -80,7 +84,6 @@
 	}
 
 	private Canvas createLegendGraphicsRow(final AttributedTheme at) {
-		com.smartgwt.client.util.SC.say("init");
 		final Label label = new Label(at.getDescription());
 		final Widget img = createLegendGraphics(at);
 
@@ -92,8 +95,15 @@
 
 		if (img instanceof Image) {
 			Image.prefetch(((Image) img).getUrl());
-			setDimensions(row, ((Image) img).getHeight(), ((Image) img).getWidth());
+			
 			url = " url " + ((Image) img).getUrl();
+			
+			
+			MyLoadHandler handler = new MyLoadHandler(row, ((Image) img));
+			
+		 final HandlerRegistration handelReg = ((Image) img).addLoadHandler( handler);
+		 handler.setHandelReg(handelReg);
+		 
 		} else if (img instanceof Img) {
 			setDimensions(row, ((Img) img).getHeight(), ((Img) img).getWidth());
 			url = " dataPath " + ((Img) img).getDataPath();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MyLoadHandler.java	Wed Jan 20 17:19:59 2021 +0100
@@ -0,0 +1,38 @@
+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;
+	HLayout m_row;
+
+	public void setHandelReg(HandlerRegistration m_handelReg) {
+		this.m_handelReg = m_handelReg;
+	}
+
+	private HandlerRegistration m_handelReg;
+
+	public MyLoadHandler(HLayout row, Image image) {
+		m_image = image;
+		m_row = row;
+	}
+
+	@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);
+	}
+
+}

http://dive4elements.wald.intevation.org