Mercurial > dive4elements > river
view gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MyWMSLoadHandler.java @ 9703:0c8374059484
debug
author | dnt_bjoernsen <d.tironi@bjoernsen.de> |
---|---|
date | Thu, 21 Jan 2021 14:07:24 +0100 |
parents | b2768f367dff |
children |
line wrap: on
line source
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 MyWMSLoadHandler implements com.google.gwt.event.dom.client.LoadHandler { private Image m_image; private HLayout m_row; private HandlerRegistration m_handelReg; public MyWMSLoadHandler(HLayout row, Image image) { m_image = image; m_row = row; m_handelReg = image.addLoadHandler(this); } @Override public void onLoad(LoadEvent event) { setDimensions( ); if (m_handelReg != null) m_handelReg.removeHandler(); } private void setDimensions() { final int imageWidth = m_image.getWidth(); final int imageHeight = m_image.getHeight(); final double widthPercent = imageWidth / 400.; // removing the limit of 150px height (legend can have an infinite height now, // as long as the width is less/eq 400px; if the width is >400, // the legend will be scaled to 400px width; the ratio will be kept) // final double heightPercent = imageHeight / 150.; if (widthPercent > 1)// || heightPercent > 1) { m_image.setSize((int) (imageWidth / widthPercent) + "px", (int) (imageHeight / widthPercent) + "px"); final int minHeight = 30; m_row.setHeight( m_image.getHeight() < minHeight ? minHeight : m_image.getHeight()); m_row.setWidth( m_image.getWidth()); } }