Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/client/ui/map/GetFeatureInfoWindow.java @ 1557:964e90c5b4c1
Invested 2 seconds after losing 3.
flys-client/trunk@3796 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 27 Jan 2012 13:05:24 +0000 |
parents | 15ef3d3081b7 |
children | 656df7c0bdda |
line wrap: on
line source
package de.intevation.flys.client.client.ui.map; import java.util.List; import java.util.Map; import java.util.Set; import com.google.gwt.core.client.GWT; import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.Window; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; import org.gwtopenmaps.openlayers.client.feature.VectorFeature; import org.gwtopenmaps.openlayers.client.util.Attributes; import org.gwtopenmaps.openlayers.client.util.JSObject; import de.intevation.flys.client.shared.model.FeatureInfo; import de.intevation.flys.client.client.FLYSConstants; public class GetFeatureInfoWindow extends Window { protected FLYSConstants MSG = GWT.create(FLYSConstants.class); protected List<FeatureInfo> features; public static final int ROW_HEIGHT = 25; public GetFeatureInfoWindow(List<FeatureInfo> features) { super(); this.features = features; initLayout(); } protected void initLayout() { VLayout root = new VLayout(); int rows = 0; for (FeatureInfo feature: features) { root.addMember(createFeatureRow(feature)); rows++; } addItem(root); setWidth(400); setHeight(50 + rows * ROW_HEIGHT); setTitle(MSG.getFeatureInfoWindowTitle()); centerInPage(); } protected HLayout createFeatureRow(FeatureInfo feature) { HLayout r = new HLayout(); r.setHeight(ROW_HEIGHT); r.setStyleName("featureinfo-row"); Label l = new Label("Layer: " + feature.getLayername()); l.setHeight(ROW_HEIGHT); r.addMember(l); Map<String, String> attrs = feature.getAttrs(); Set<Map.Entry<String, String>> entries = attrs.entrySet(); for (Map.Entry entry: entries) { Label attr = new Label(entry.getKey() + ": " + entry.getValue()); attr.setHeight(ROW_HEIGHT); r.addMember(attr); } return r; } protected String[][] extractProperties(VectorFeature feature) { Attributes tmp = feature.getAttributes(); JSObject jsobj = tmp.getJSObject(); String tmpNames = jsobj.getPropertyNames(); String[] allNames = tmpNames.split(","); String[][] attr = new String[allNames.length][]; for (int i = 0, n = attr.length; i < n; i++) { attr[i] = new String[] { allNames[i], jsobj.getPropertyAsString(allNames[i]) }; } return attr; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :