Mercurial > dive4elements > river
annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/LegendWindow.java @ 9705:bfdf98529a66
cleanup
author | dnt_bjoernsen <d.tironi@bjoernsen.de> |
---|---|
date | Thu, 21 Jan 2021 15:05:24 +0100 |
parents | ca9ed55d6f51 |
children |
rev | line source |
---|---|
5861
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5993
ea9eef426962
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5861
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5861
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5993
ea9eef426962
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5861
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5861
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
9 package org.dive4elements.river.client.client.ui.map; |
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import java.util.List; |
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
9619 | 13 import org.dive4elements.river.client.client.FLYSConstants; |
14 import org.dive4elements.river.client.shared.MapUtils; | |
15 import org.dive4elements.river.client.shared.model.AttributedTheme; | |
16 import org.dive4elements.river.client.shared.model.Theme; | |
17 import org.dive4elements.river.client.shared.model.ThemeList; | |
18 | |
7958
632c724fed2d
i18n for WMS legend window title.
Tom Gottfried <tom@intevation.de>
parents:
5993
diff
changeset
|
19 import com.google.gwt.core.client.GWT; |
9698 | 20 import com.google.gwt.event.shared.HandlerRegistration; |
9644 | 21 import com.google.gwt.http.client.URL; |
9619 | 22 import com.google.gwt.user.client.ui.Image; |
23 import com.google.gwt.user.client.ui.Widget; | |
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 import com.smartgwt.client.types.ImageStyle; |
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 import com.smartgwt.client.types.VerticalAlignment; |
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 import com.smartgwt.client.widgets.Canvas; |
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 import com.smartgwt.client.widgets.Img; |
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 import com.smartgwt.client.widgets.Label; |
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 import com.smartgwt.client.widgets.Window; |
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 import com.smartgwt.client.widgets.layout.HLayout; |
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 import com.smartgwt.client.widgets.layout.VLayout; |
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 |
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 public class LegendWindow extends Window { |
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
9696 | 35 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); |
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 |
9696 | 37 private ThemeList themeList; |
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 |
9696 | 39 private final VLayout legendContainer; |
9694 | 40 |
9696 | 41 public LegendWindow(final ThemeList themeList) { |
42 this.themeList = themeList; | |
43 this.legendContainer = new VLayout(); | |
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
9696 | 45 init(); |
46 } | |
47 | |
48 public void update(final ThemeList themeList) { | |
49 this.themeList = themeList; | |
50 | |
51 final Canvas[] legends = this.legendContainer.getMembers(); | |
52 this.legendContainer.removeMembers(legends); | |
53 | |
54 addLegends(); | |
55 } | |
56 | |
57 private void addLegends() { | |
58 final List<Theme> themes = this.themeList.getActiveThemes(); | |
59 | |
60 for (int i = 0; i < themes.size(); i++) { | |
61 final Theme theme = themes.get(i); | |
62 if (theme.getActive() == 0) { | |
63 continue; | |
64 } | |
65 try { | |
66 if (theme instanceof AttributedTheme) { | |
67 Canvas createLegendGraphicsRow = createLegendGraphicsRow((AttributedTheme) theme); | |
9705 | 68 this.legendContainer.addMember(createLegendGraphicsRow); |
9696 | 69 } |
70 } catch (Exception e) { | |
71 continue; | |
72 } | |
73 } | |
74 } | |
75 | |
76 private Canvas createLegendGraphicsRow(final AttributedTheme at) { | |
77 final Label label = new Label(at.getDescription()); | |
9700
b2768f367dff
handler for wms theme legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents:
9699
diff
changeset
|
78 final HLayout row = new HLayout(); |
9705 | 79 final Widget img = createLegendGraphics(row, at); |
9696 | 80 |
81 row.addMember(label); | |
82 row.addMember(img); | |
83 | |
9705 | 84 // setDimensions(row, 150, 400); |
9696 | 85 return row; |
86 } | |
87 | |
9700
b2768f367dff
handler for wms theme legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents:
9699
diff
changeset
|
88 private Widget createLegendGraphics(HLayout row, final AttributedTheme at) { |
9619 | 89 |
9696 | 90 final String legend = at.getAttr("legend"); |
91 // TEST: final Image img = new Image("/images/FLYS_Donau.png"); (funktioniert!), | |
92 // ebenso FLYSResources.getTest(); | |
9705 | 93 String urlAttr = at.getAttr("url"); |
94 String layersAttr = at.getAttr("layers"); | |
9696 | 95 |
9705 | 96 final String imgUrl = getUrl(legend, urlAttr, layersAttr); |
97 | |
9702
20456a3c92e2
Img -> Image; correct URL for WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents:
9701
diff
changeset
|
98 final Image image = new Image(imgUrl); |
9705 | 99 new MyWMSLoadHandler(row, image); |
9696 | 100 |
9702
20456a3c92e2
Img -> Image; correct URL for WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents:
9701
diff
changeset
|
101 return image; |
9696 | 102 } |
103 | |
9705 | 104 private String getUrl(final String legend, String urlAttr, String layersAttr) { |
105 if (legend != null && !"".equals(legend)) { | |
106 return URL.encode(GWT.getHostPageBaseURL() + "images/wms_legend/" + legend); | |
107 } else { | |
108 return MapUtils.getLegendGraphicUrl(urlAttr, layersAttr); | |
109 } | |
110 } | |
111 | |
9696 | 112 private void init() { |
113 this.legendContainer.setAutoHeight(); | |
114 this.legendContainer.setLayoutAlign(VerticalAlignment.TOP); | |
115 this.legendContainer.setAlign(VerticalAlignment.CENTER); | |
116 | |
117 setTitle(this.MSG.wms_legend()); | |
118 setAutoSize(true); | |
119 setCanDragResize(true); | |
120 setIsModal(false); | |
121 setShowModalMask(false); | |
122 setLayoutAlign(VerticalAlignment.TOP); | |
123 setAlign(VerticalAlignment.TOP); | |
124 | |
125 addItem(this.legendContainer); | |
126 addLegends(); | |
127 | |
128 centerInPage(); | |
129 } | |
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
130 } |