Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSHeader.java @ 1339:d935fd42ae0e
Added new values for line type to theme editor.
flys-client/trunk@2988 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Mon, 17 Oct 2011 13:04:31 +0000 |
parents | b92281182c6b |
children | 748e7c828d03 |
line wrap: on
line source
package de.intevation.flys.client.client.ui; import com.google.gwt.core.client.GWT; import com.google.gwt.resources.client.ImageResource; import com.smartgwt.client.types.Alignment; import com.smartgwt.client.widgets.Img; import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; import de.intevation.flys.client.client.FLYSImages; import de.intevation.flys.client.client.FLYSConstants; /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class FLYSHeader extends HLayout { /** The interface that provides the image resources. */ private FLYSImages IMAGES = GWT.create(FLYSImages.class); /** The interface that provides the message resources. */ private FLYSConstants MESSAGES = GWT.create(FLYSConstants.class); /** The height used for this header.*/ public static final int HEIGHT = 75; /** The height used for the images.*/ public static final int IMG_HEIGHT = 50; public FLYSHeader() { init(); } public void init() { setWidth100(); setHeight(HEIGHT); setLayoutLeftMargin(5); setLayoutRightMargin(5); ImageResource flysRes = IMAGES.logoFlys(); ImageResource bfgRes = IMAGES.logoBfg(); Img flys = new Img( flysRes.getURL(), calcWidth(flysRes,IMG_HEIGHT), IMG_HEIGHT); Img bfg = new Img( bfgRes.getURL(), calcWidth(bfgRes, HEIGHT), HEIGHT); Label fullname = new Label(MESSAGES.fullname()); fullname.setHeight(HEIGHT - IMG_HEIGHT); fullname.setStyleName ("fontNormalMid"); VLayout left = new VLayout(); left.addMember(flys); left.addMember(fullname); HLayout right = new HLayout(); right.setAlign(Alignment.RIGHT); right.addMember(bfg); addMember(left); addMember(right); } /** * This method calculates the wight of an image relative to the given * height. * * @param res The ImageResource that points to the image. * @param height The pre-defined height. * * @return the calculated width that should be used for the image. */ protected int calcWidth(ImageResource res, int height) { int widthOrig = res.getWidth(); int heightOrig = res.getHeight(); double factor = (double)heightOrig / height; double width = (double)widthOrig / factor; return (int) width * 10 / 10; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :