view flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSHeader.java @ 4198:1cdbd8a0c994

Added two new tables ClickableQDTable and ClickableWTable and made Ws and Qs clickable in historical discharge calculation. The new tables define listener interfaces (clicked lower or upper icon) to listen to user clicks. In addition to this, there is an enum ClickMode with NONE, SINGLE and RANGE options, which allows to specifiy, which icons are displayed in the tables. NONE means no icon for user clicks, SINGLE has 1 icon, RANGE 2 icons for lower and upper.
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 22 Oct 2012 13:31:25 +0200
parents 047a44270348
children 33bb8bf3899a
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.FLYSConstants;


/**
 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
 */
public class FLYSHeader extends HLayout {

    /** 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);

        String baseUrl = GWT.getHostPageBaseURL();

        Img flys = new Img(
            baseUrl + MESSAGES.flysLogo(),
            50,
            IMG_HEIGHT);

        Img bfg  = new Img(
            baseUrl + MESSAGES.bfgLogo(),
            112,
            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 :

http://dive4elements.wald.intevation.org