view flys-client/src/main/java/de/intevation/flys/client/client/widgets/DischargeTablesChart.java @ 5462:f2371f3aaf03

Show top level folder icons only if node has no factory If you have an empty folder the folder icon is still shown. This makes it possible to add functional "Top Level" entries in the Datacage
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 26 Mar 2013 18:29:13 +0100
parents 6ae99d996f79
children
line wrap: on
line source
package de.intevation.flys.client.client.widgets;

import com.google.gwt.core.client.GWT;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.events.ResizedEvent;
import com.smartgwt.client.widgets.events.ResizedHandler;

import de.intevation.flys.client.shared.model.Artifact;
import de.intevation.flys.client.shared.model.ArtifactDescription;


public class DischargeTablesChart extends Canvas implements ResizedHandler {

    protected Artifact artifact;

    protected Img img;

    public DischargeTablesChart() {
        super();
    }

    public DischargeTablesChart(Artifact artifact) {
        super();
        this.artifact = artifact;
        init();
    }

    private void init() {
        addChild(createImage());
        addResizedHandler(this);
        setSize("100%", "100%");
    }

    protected Img createImage() {
        img = new Img(getUrl());
        img.setSize("100%", "100%");

        return img;
    }

    protected String getUrl() {
        String url = GWT.getModuleBaseURL();
        url += "dischargetablesoverview";
        url += "?gauge=" + getGauge();
        url += "&format=png";

        String[] timerange = getTimerange();
        url += "&lower=" + timerange[0];
        url += "&upper=" + timerange[1];

        int width = 600;
        int height = 400;
        if (img != null) {
            width = img.getWidth();
            height = img.getHeight();
        }

        url += "&width=" + String.valueOf(width);
        url += "&height=" + String.valueOf(height);

        // add time millis to 'deactivate' caching
        url += "&timemillis" + System.currentTimeMillis();

        GWT.log("DischargeTablesService URL = '" + url + "'");
        return url;
    }

    protected String getGauge() {
        ArtifactDescription desc = artifact.getArtifactDescription();
        return desc.getReferenceGauge();
    }

    protected String[] getTimerange() {
        ArtifactDescription desc = artifact.getArtifactDescription();
        String yearStr = desc.getDataValueAsString("year_range");

        if (yearStr != null && yearStr.length() > 0) {
            return yearStr.split(";");
        }

        return new String[2];
    }

    @Override
    public void onResized(ResizedEvent event) {
        GWT.log("resized discharge tables overview chart");
        img.setSrc(getUrl());
    }
}

http://dive4elements.wald.intevation.org