changeset 9693:2197a7ccb4a8

LegendWindow zu 3.1. + 3.2 DEBUG
author dnt_bjoernsen <d.tironi@bjoernsen.de>
date Tue, 19 Jan 2021 16:39:50 +0100
parents da21bbabd3ad
children 94b976204a0a
files gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/LegendWindow.java
diffstat 1 files changed, 25 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/LegendWindow.java	Tue Jan 19 15:00:50 2021 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/LegendWindow.java	Tue Jan 19 16:39:50 2021 +0100
@@ -74,13 +74,33 @@
         final HLayout row = new HLayout();
         row.addMember(label);
         row.addMember(img);
-
-        row.setHeight(150);
-        row.setWidth(400);
-
+        
+        String url = "url";
+        
+        if (img instanceof Image) {
+        	setDimensions( row, ((Image) img).getHeight(),  ((Image) img).getWidth());
+        	url = " url " + ((Image) img).getUrl();
+        }
+        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;
+   //   
+//        final HLayout row2= new HLayout();
+        row.addMember(new Label(labelText));
         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(final AttributedTheme at) {
 
         final String legend = at.getAttr("legend");
@@ -100,11 +120,8 @@
 
             // final double heightPercent = imageHeight / 150.;
             if (widthPercent > 1)// || heightPercent > 1) {
-                // if (widthPercent > heightPercent)
                 image.setSize((int) (imageWidth / widthPercent) + "px", (int) (imageHeight / widthPercent) + "px");
-            // else
-            // image.setSize((int) (imageWidth / heightPercent) + "px", (int) (imageHeight / heightPercent) + "px");
-            // }
+            
             return image;
         }
         final String imgUrl = MapUtils.getLegendGraphicUrl(at.getAttr("url"), at.getAttr("layers"));

http://dive4elements.wald.intevation.org