Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MyWMSLoadHandler.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 | |
children |
comparison
equal
deleted
inserted
replaced
9699:94362af5928e | 9700:b2768f367dff |
---|---|
1 package org.dive4elements.river.client.client.ui.map; | |
2 | |
3 import com.google.gwt.event.dom.client.LoadEvent; | |
4 import com.google.gwt.event.shared.HandlerRegistration; | |
5 import com.google.gwt.user.client.ui.Image; | |
6 import com.smartgwt.client.widgets.layout.HLayout; | |
7 | |
8 public class MyWMSLoadHandler implements com.google.gwt.event.dom.client.LoadHandler { | |
9 private Image m_image; | |
10 private HLayout m_row; | |
11 private HandlerRegistration m_handelReg; | |
12 | |
13 public MyWMSLoadHandler(HLayout row, Image image) { | |
14 m_image = image; | |
15 m_row = row; | |
16 m_handelReg = image.addLoadHandler(this); | |
17 } | |
18 | |
19 @Override | |
20 public void onLoad(LoadEvent event) { | |
21 setDimensions( ); | |
22 if (m_handelReg != null) | |
23 m_handelReg.removeHandler(); | |
24 } | |
25 | |
26 private void setDimensions() { | |
27 final int imageWidth = m_image.getWidth(); | |
28 final int imageHeight = m_image.getHeight(); | |
29 final double widthPercent = imageWidth / 400.; | |
30 | |
31 // removing the limit of 150px height (legend can have an infinite height now, | |
32 // as long as the width is less/eq 400px; if the width is >400, | |
33 // the legend will be scaled to 400px width; the ratio will be kept) | |
34 | |
35 // final double heightPercent = imageHeight / 150.; | |
36 if (widthPercent > 1)// || heightPercent > 1) { | |
37 m_image.setSize((int) (imageWidth / widthPercent) + "px", (int) (imageHeight / widthPercent) + "px"); | |
38 | |
39 | |
40 final int minHeight = 30; | |
41 m_row.setHeight( m_image.getHeight() < minHeight ? minHeight : m_image.getHeight()); | |
42 m_row.setWidth( m_image.getWidth()); | |
43 } | |
44 } |