Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/LegendWindow.java @ 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 | 152299dadb36 |
children | 94b976204a0a |
comparison
equal
deleted
inserted
replaced
9692:da21bbabd3ad | 9693:2197a7ccb4a8 |
---|---|
72 final Widget img = createLegendGraphics(at); | 72 final Widget img = createLegendGraphics(at); |
73 | 73 |
74 final HLayout row = new HLayout(); | 74 final HLayout row = new HLayout(); |
75 row.addMember(label); | 75 row.addMember(label); |
76 row.addMember(img); | 76 row.addMember(img); |
77 | 77 |
78 row.setHeight(150); | 78 String url = "url"; |
79 row.setWidth(400); | 79 |
80 | 80 if (img instanceof Image) { |
81 setDimensions( row, ((Image) img).getHeight(), ((Image) img).getWidth()); | |
82 url = " url " + ((Image) img).getUrl(); | |
83 } | |
84 else if (img instanceof Img) { | |
85 setDimensions( row, ((Img) img).getHeight(), ((Img) img).getWidth()); | |
86 url = " dataPath " + ((Img) img).getDataPath(); | |
87 } | |
88 else { | |
89 setDimensions( row, 150, 400); //not sure when this is executed | |
90 } | |
91 String labelText = at.getDescription() +", height: "+ row.getHeight()+"width: "+ row.getWidth()+" "+url; | |
92 // | |
93 // final HLayout row2= new HLayout(); | |
94 row.addMember(new Label(labelText)); | |
81 return row; | 95 return row; |
82 } | 96 } |
97 | |
98 private void setDimensions(HLayout row, int height, int width ) { | |
99 final int minHeight = 30; | |
100 row.setHeight(height < minHeight ? minHeight : height); | |
101 row.setWidth(width); | |
102 } | |
83 | 103 |
84 private Widget createLegendGraphics(final AttributedTheme at) { | 104 private Widget createLegendGraphics(final AttributedTheme at) { |
85 | 105 |
86 final String legend = at.getAttr("legend"); | 106 final String legend = at.getAttr("legend"); |
87 // TEST: final Image img = new Image("/images/FLYS_Donau.png"); (funktioniert!), ebenso FLYSResources.getTest(); | 107 // TEST: final Image img = new Image("/images/FLYS_Donau.png"); (funktioniert!), ebenso FLYSResources.getTest(); |
98 // as long as the width is less/eq 400px; if the width is >400, | 118 // as long as the width is less/eq 400px; if the width is >400, |
99 // the legend will be scaled to 400px width; the ratio will be kept) | 119 // the legend will be scaled to 400px width; the ratio will be kept) |
100 | 120 |
101 // final double heightPercent = imageHeight / 150.; | 121 // final double heightPercent = imageHeight / 150.; |
102 if (widthPercent > 1)// || heightPercent > 1) { | 122 if (widthPercent > 1)// || heightPercent > 1) { |
103 // if (widthPercent > heightPercent) | |
104 image.setSize((int) (imageWidth / widthPercent) + "px", (int) (imageHeight / widthPercent) + "px"); | 123 image.setSize((int) (imageWidth / widthPercent) + "px", (int) (imageHeight / widthPercent) + "px"); |
105 // else | 124 |
106 // image.setSize((int) (imageWidth / heightPercent) + "px", (int) (imageHeight / heightPercent) + "px"); | |
107 // } | |
108 return image; | 125 return image; |
109 } | 126 } |
110 final String imgUrl = MapUtils.getLegendGraphicUrl(at.getAttr("url"), at.getAttr("layers")); | 127 final String imgUrl = MapUtils.getLegendGraphicUrl(at.getAttr("url"), at.getAttr("layers")); |
111 | 128 |
112 final Img img = new Img(imgUrl); | 129 final Img img = new Img(imgUrl); |