Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/LegendWindow.java @ 9700:b2768f367dff
handler for wms theme legend
author | dnt_bjoernsen <d.tironi@bjoernsen.de> |
---|---|
date | Wed, 20 Jan 2021 19:06:57 +0100 |
parents | 94362af5928e |
children | 0caaca0df028 |
comparison
equal
deleted
inserted
replaced
9699:94362af5928e | 9700:b2768f367dff |
---|---|
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 private Canvas createLegendGraphicsRow(final AttributedTheme at) { | 76 private Canvas createLegendGraphicsRow(final AttributedTheme at) { |
77 final Label label = new Label(at.getDescription()); | 77 final Label label = new Label(at.getDescription()); |
78 final Widget img = createLegendGraphics(at); | 78 final HLayout row = new HLayout(); |
79 final Widget img = createLegendGraphics(row ,at); | |
79 | 80 |
80 final HLayout row = new HLayout(); | |
81 row.addMember(label); | 81 row.addMember(label); |
82 row.addMember(img); | 82 row.addMember(img); |
83 | 83 |
84 // String url = "url"; | 84 // String url = "url"; |
85 if (img instanceof Image) { | 85 if (img instanceof Image) { |
103 final int minHeight = 30; | 103 final int minHeight = 30; |
104 row.setHeight(height < minHeight ? minHeight : height); | 104 row.setHeight(height < minHeight ? minHeight : height); |
105 row.setWidth(width); | 105 row.setWidth(width); |
106 } | 106 } |
107 | 107 |
108 private Widget createLegendGraphics(final AttributedTheme at) { | 108 private Widget createLegendGraphics(HLayout row, final AttributedTheme at) { |
109 | 109 |
110 final String legend = at.getAttr("legend"); | 110 final String legend = at.getAttr("legend"); |
111 // TEST: final Image img = new Image("/images/FLYS_Donau.png"); (funktioniert!), | 111 // TEST: final Image img = new Image("/images/FLYS_Donau.png"); (funktioniert!), |
112 // ebenso FLYSResources.getTest(); | 112 // ebenso FLYSResources.getTest(); |
113 if (legend != null && !"".equals(legend)) { | 113 if (legend != null && !"".equals(legend)) { |
114 | 114 |
115 final String imgUrl = URL.encode(GWT.getHostPageBaseURL() + "images/wms_legend/" + legend); | 115 final String imgUrl = URL.encode(GWT.getHostPageBaseURL() + "images/wms_legend/" + legend); |
116 | 116 |
117 final Image image = new Image(imgUrl); | 117 final Image image = new Image(imgUrl); |
118 final int imageWidth = image.getWidth(); | 118 new MyWMSLoadHandler(row, image); |
119 final int imageHeight = image.getHeight(); | |
120 final double widthPercent = imageWidth / 400.; | |
121 | |
122 // removing the limit of 150px height (legend can have an infinite height now, | |
123 // as long as the width is less/eq 400px; if the width is >400, | |
124 // the legend will be scaled to 400px width; the ratio will be kept) | |
125 | |
126 // final double heightPercent = imageHeight / 150.; | |
127 if (widthPercent > 1)// || heightPercent > 1) { | |
128 image.setSize((int) (imageWidth / widthPercent) + "px", (int) (imageHeight / widthPercent) + "px"); | |
129 | 119 |
130 return image; | 120 return image; |
131 } | 121 } |
132 final String imgUrl = MapUtils.getLegendGraphicUrl(at.getAttr("url"), at.getAttr("layers")); | 122 final String imgUrl = MapUtils.getLegendGraphicUrl(at.getAttr("url"), at.getAttr("layers")); |
133 | 123 |