view flys-client/src/main/java/de/intevation/flys/client/client/ui/map/GetFeatureInfo.java @ 4205:0dd8963cec9c

Set also the width of the GaugeTree when resizing the GaugePanel GWT is no longer able to calculate and set the correct width of the GaugeTree since the GaugeTree is added via a Canvas wrapper. Therefore set the width manually when resizing the GaugeTree.
author Björn Ricks <bjoern.ricks@intevation.de>
date Mon, 22 Oct 2012 15:33:16 +0200
parents 46fc11ad697f
children af2aa716152f
line wrap: on
line source
package de.intevation.flys.client.client.ui.map;

import java.util.List;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;

import com.smartgwt.client.util.SC;

import org.gwtopenmaps.openlayers.client.Map;
import org.gwtopenmaps.openlayers.client.LonLat;
import org.gwtopenmaps.openlayers.client.Pixel;
import org.gwtopenmaps.openlayers.client.event.MapClickListener;

import de.intevation.flys.client.shared.model.FeatureInfo;

import de.intevation.flys.client.client.FLYSConstants;
import de.intevation.flys.client.client.services.GFIService;
import de.intevation.flys.client.client.services.GFIServiceAsync;
import de.intevation.flys.client.client.ui.ThemePanel;


public class GetFeatureInfo implements MapClickListener {

    protected GFIServiceAsync gfiService = GWT.create(GFIService.class);

    protected FLYSConstants MSG = GWT.create(FLYSConstants.class);

    protected GetFeatureInfoWindow gfiWindow;

    protected Map        map;
    protected ThemePanel themePanel;
    protected String     infoFormat;


    /**
     * @param map
     * @param themes
     * @param url
     * @param infoFormat
     */
    public GetFeatureInfo(Map map, ThemePanel themePanel, String infoFormat) {
        this.map        = map;
        this.themePanel = themePanel;
        this.infoFormat = infoFormat;
    }


    public void activate(boolean activate) {
        if (activate) {
            map.addMapClickListener(this);
        }
        else {
            map.removeListener(this);
        }
    }


    protected void newGetFeatureInfoWindow(List<FeatureInfo> features) {
        if (gfiWindow != null) {
            gfiWindow.destroy();
        }

        gfiWindow = new GetFeatureInfoWindow(features);
        gfiWindow.show();
    }


    @Override
    public void onClick(MapClickListener.MapClickEvent e) {
        LonLat lonlat = e.getLonLat();
        Pixel  pixel  = map.getPixelFromLonLat(lonlat);

        gfiService.query(
            themePanel.getThemeList().getActiveThemes(),
            infoFormat,
            map.getExtent().toString(),
            map.getProjection(),
            (int) map.getSize().getHeight(),
            (int) map.getSize().getWidth(),
            pixel.x(), pixel.y(),
            new AsyncCallback<List<FeatureInfo>>() {
            public void onFailure(Throwable e) {
                SC.warn(MSG.getString(e.getMessage()));
            }

            public void onSuccess(List<FeatureInfo> features) {
                newGetFeatureInfoWindow(features);
            }
        });
    }
}

http://dive4elements.wald.intevation.org