comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java @ 4329:c9dcce9448f2

Added a new control 'show legend' to the map's toolbar. This control opens a window that displays the legends of all activated layers. Currently, the row in that window has a fixed size of 400x150. The size is fixed, because there are problems with SmartGWT to build panels with auto height/width :-/
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 30 Oct 2012 12:16:26 +0100
parents 0be65bc65cee
children 6e01499bfbdf
comparison
equal deleted inserted replaced
4328:25157125f4a0 4329:c9dcce9448f2
1 package de.intevation.flys.client.client.ui.map; 1 package de.intevation.flys.client.client.ui.map;
2 2
3 import org.gwtopenmaps.openlayers.client.Bounds;
4 import org.gwtopenmaps.openlayers.client.Map;
5 import org.gwtopenmaps.openlayers.client.control.DragPan;
6 import org.gwtopenmaps.openlayers.client.control.SelectFeature;
7 import org.gwtopenmaps.openlayers.client.control.SelectFeatureOptions;
8 import org.gwtopenmaps.openlayers.client.control.ZoomBox;
9 import org.gwtopenmaps.openlayers.client.event.MapZoomListener;
10 import org.gwtopenmaps.openlayers.client.feature.VectorFeature;
11 import org.gwtopenmaps.openlayers.client.layer.Vector;
12 import org.gwtopenmaps.openlayers.client.util.Attributes;
13
3 import com.google.gwt.core.client.GWT; 14 import com.google.gwt.core.client.GWT;
4
5 import com.smartgwt.client.types.Alignment; 15 import com.smartgwt.client.types.Alignment;
6 import com.smartgwt.client.types.SelectionType; 16 import com.smartgwt.client.types.SelectionType;
7 import com.smartgwt.client.util.SC; 17 import com.smartgwt.client.util.SC;
8 import com.smartgwt.client.widgets.Button; 18 import com.smartgwt.client.widgets.Button;
9 import com.smartgwt.client.widgets.Canvas; 19 import com.smartgwt.client.widgets.Canvas;
16 import de.intevation.flys.client.client.FLYSConstants; 26 import de.intevation.flys.client.client.FLYSConstants;
17 import de.intevation.flys.client.client.ui.ImgLink; 27 import de.intevation.flys.client.client.ui.ImgLink;
18 import de.intevation.flys.client.client.ui.Toolbar; 28 import de.intevation.flys.client.client.ui.Toolbar;
19 import de.intevation.flys.client.client.utils.EnableDisableCmd; 29 import de.intevation.flys.client.client.utils.EnableDisableCmd;
20 import de.intevation.flys.client.shared.model.Collection; 30 import de.intevation.flys.client.shared.model.Collection;
21 31 import de.intevation.flys.client.shared.model.ThemeList;
22 import org.gwtopenmaps.openlayers.client.Bounds;
23 import org.gwtopenmaps.openlayers.client.Map;
24 import org.gwtopenmaps.openlayers.client.control.DragPan;
25 import org.gwtopenmaps.openlayers.client.control.SelectFeature;
26 import org.gwtopenmaps.openlayers.client.control.SelectFeatureOptions;
27 import org.gwtopenmaps.openlayers.client.control.ZoomBox;
28 import org.gwtopenmaps.openlayers.client.event.MapZoomListener;
29 import org.gwtopenmaps.openlayers.client.feature.VectorFeature;
30 import org.gwtopenmaps.openlayers.client.layer.Vector;
31 import org.gwtopenmaps.openlayers.client.util.Attributes;
32 32
33 33
34 /** 34 /**
35 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> 35 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
36 */ 36 */
46 protected SelectFeature selectFeature; 46 protected SelectFeature selectFeature;
47 protected GetFeatureInfo getFeatureInfo; 47 protected GetFeatureInfo getFeatureInfo;
48 48
49 protected Button manageThemesButton; 49 protected Button manageThemesButton;
50 protected Button datacageButton; 50 protected Button datacageButton;
51 protected Button legendButton;
51 52
52 protected ImgButton addWMSButton; 53 protected ImgButton addWMSButton;
53 protected ImgButton zoomToMaxButton; 54 protected ImgButton zoomToMaxButton;
54 protected ImgButton zoomBoxButton; 55 protected ImgButton zoomBoxButton;
55 protected ImgButton zoomOutButton; 56 protected ImgButton zoomOutButton;
62 63
63 protected Label epsgLabel; 64 protected Label epsgLabel;
64 65
65 protected DrawControl drawControl; 66 protected DrawControl drawControl;
66 protected MeasureControl measureControl; 67 protected MeasureControl measureControl;
68
69 protected LegendWindow legendWindow;
67 70
68 protected Canvas position; 71 protected Canvas position;
69 72
70 73
71 public MapToolbar(MapOutputTab mapTab, FloodMap floodMap) { 74 public MapToolbar(MapOutputTab mapTab, FloodMap floodMap) {
110 addMember(manageThemesButton); 113 addMember(manageThemesButton);
111 114
112 datacageButton = createDatacageControl(); 115 datacageButton = createDatacageControl();
113 addMember(datacageButton); 116 addMember(datacageButton);
114 117
118 legendButton = createLegendControl();
119 addMember(legendButton);
120
115 addWMSButton = createWMSControl(); 121 addWMSButton = createWMSControl();
116 addMember(addWMSButton); 122 addMember(addWMSButton);
117 123
118 printMapLink = createPrintMapLink(); 124 printMapLink = createPrintMapLink();
119 addMember(printMapLink); 125 addMember(printMapLink);
560 566
561 return btn; 567 return btn;
562 } 568 }
563 569
564 570
571 protected Button createLegendControl() {
572 Button btn = new Button(MSG.legend());
573 btn.addClickHandler(new ClickHandler() {
574 @Override
575 public void onClick(ClickEvent event) {
576 openLegendWindow();
577 }
578 });
579
580 return btn;
581 }
582
583
584 protected void openLegendWindow() {
585 if (legendWindow == null) {
586 MapOutputTab tab = (MapOutputTab) getOutputTab();
587 legendWindow = new LegendWindow(tab.getThemePanel().getThemeList());
588 }
589
590 legendWindow.show();
591 }
592
593
565 protected ImgButton createGetFeatureInfo() { 594 protected ImgButton createGetFeatureInfo() {
566 MapOutputTab ot = (MapOutputTab) getOutputTab(); 595 MapOutputTab ot = (MapOutputTab) getOutputTab();
567 if (ot == null) { 596 if (ot == null) {
568 return null; 597 return null;
569 } 598 }
676 705
677 url += "uuid=" + uuid + "&maptype=" + mapType; 706 url += "uuid=" + uuid + "&maptype=" + mapType;
678 707
679 return url; 708 return url;
680 } 709 }
710
711
712 public void updateThemes(ThemeList themeList) {
713 if (legendWindow != null) {
714 legendWindow.update(themeList);
715 }
716 }
681 } 717 }
682 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 718 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org