comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSHeader.java @ 27:e4155a6833a9

Integrated a header that contains a FLYS and a BfG logo. flys-client/trunk@1427 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 08 Mar 2011 15:15:59 +0000
parents
children a361ce81abcf
comparison
equal deleted inserted replaced
26:c19985f75118 27:e4155a6833a9
1 package de.intevation.flys.client.client.ui;
2
3 import com.google.gwt.core.client.GWT;
4 import com.google.gwt.resources.client.ImageResource;
5
6 import com.smartgwt.client.types.Alignment;
7 import com.smartgwt.client.widgets.Img;
8 import com.smartgwt.client.widgets.Label;
9 import com.smartgwt.client.widgets.layout.HLayout;
10 import com.smartgwt.client.widgets.layout.VLayout;
11
12 import de.intevation.flys.client.client.FLYSImages;
13 import de.intevation.flys.client.client.FLYSMessages;
14
15
16 /**
17 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
18 */
19 public class FLYSHeader extends HLayout {
20
21 /** The interface that provides the image resources. */
22 private FLYSImages IMAGES = GWT.create(FLYSImages.class);
23
24 /** The interface that provides the message resources. */
25 private FLYSMessages MESSAGES = GWT.create(FLYSMessages.class);
26
27 /** The height used for this header.*/
28 public static final int HEIGHT = 75;
29
30 /** The height used for the images.*/
31 public static final int IMG_HEIGHT = 50;
32
33
34 public FLYSHeader() {
35 init();
36 }
37
38 public void init() {
39 setWidth100();
40 setHeight(HEIGHT);
41 setLayoutLeftMargin(5);
42 setLayoutRightMargin(5);
43
44 ImageResource flysRes = IMAGES.logoFlys();
45 ImageResource bfgRes = IMAGES.logoBfg();
46
47 Img flys = new Img(
48 flysRes.getURL(),
49 calcWidth(flysRes,IMG_HEIGHT),
50 IMG_HEIGHT);
51
52 Img bfg = new Img(
53 bfgRes.getURL(),
54 calcWidth(bfgRes, IMG_HEIGHT),
55 IMG_HEIGHT);
56
57 Label fullname = new Label(MESSAGES.fullname());
58 fullname.setHeight(HEIGHT - IMG_HEIGHT);
59
60 VLayout left = new VLayout();
61 left.addMember(flys);
62 left.addMember(fullname);
63
64 HLayout right = new HLayout();
65 right.setAlign(Alignment.RIGHT);
66 right.addMember(bfg);
67
68 addMember(left);
69 addMember(right);
70 }
71
72
73 /**
74 * This method calculates the wight of an image relative to the given
75 * height.
76 *
77 * @param res The ImageResource that points to the image.
78 * @param height The pre-defined height.
79 *
80 * @return the calculated width that should be used for the image.
81 */
82 protected int calcWidth(ImageResource res, int height) {
83 int widthOrig = res.getWidth();
84 int heightOrig = res.getHeight();
85
86 double factor = heightOrig / height;
87 double width = widthOrig / factor;
88
89 return (int) width * 10 / 10;
90 }
91 }
92 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org