annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/LegendWindow.java @ 9694:94b976204a0a

legendwindow debug
author dnt_bjoernsen <d.tironi@bjoernsen.de>
date Wed, 20 Jan 2021 11:22:54 +0100
parents 2197a7ccb4a8
children e388db7fd72e
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
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
13 import org.dive4elements.river.client.client.FLYSConstants;
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
14 import org.dive4elements.river.client.shared.MapUtils;
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
15 import org.dive4elements.river.client.shared.model.AttributedTheme;
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
16 import org.dive4elements.river.client.shared.model.Theme;
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
17 import org.dive4elements.river.client.shared.model.ThemeList;
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
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;
9644
152299dadb36 legend URL fix
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9635
diff changeset
20 import com.google.gwt.http.client.URL;
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
21 import com.google.gwt.user.client.ui.Image;
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
22 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
23 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
24 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
25 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
26 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
27 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
28 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
29 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
30 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
31
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 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
33
7958
632c724fed2d i18n for WMS legend window title.
Tom Gottfried <tom@intevation.de>
parents: 5993
diff changeset
34 protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
632c724fed2d i18n for WMS legend window title.
Tom Gottfried <tom@intevation.de>
parents: 5993
diff changeset
35
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 private ThemeList themeList;
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
37
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
38 private final VLayout legendContainer;
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
39
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
40 public LegendWindow(final 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
41 this.themeList = themeList;
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
42 this.legendContainer = new 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
43
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 init();
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
45 }
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
46
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
47 public void update(final 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
48 this.themeList = themeList;
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
49
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
50 final Canvas[] legends = this.legendContainer.getMembers();
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
51 this.legendContainer.removeMembers(legends);
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
52
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
53 addLegends();
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
54 }
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
55
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
56 private void addLegends() {
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
57 final List<Theme> themes = this.themeList.getActiveThemes();
9694
94b976204a0a legendwindow debug
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9693
diff changeset
58 com.smartgwt.client.util.SC.say("themescount " + themes.size());
94b976204a0a legendwindow debug
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9693
diff changeset
59
94b976204a0a legendwindow debug
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9693
diff changeset
60
94b976204a0a legendwindow debug
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9693
diff changeset
61 for (int i = 0; i< themes.size() ; i++) {
94b976204a0a legendwindow debug
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9693
diff changeset
62 final Theme theme = themes.get(i);
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
63 if (theme.getActive() == 0) {
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
64 continue;
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
65 }
9694
94b976204a0a legendwindow debug
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9693
diff changeset
66 try {
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
67 if (theme instanceof AttributedTheme) {
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
68 this.legendContainer.addMember(createLegendGraphicsRow((AttributedTheme) theme));
9694
94b976204a0a legendwindow debug
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9693
diff changeset
69 } } catch (Exception e) {
94b976204a0a legendwindow debug
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9693
diff changeset
70 com.smartgwt.client.util.SC.say("exception at index " + themes.size());
94b976204a0a legendwindow debug
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9693
diff changeset
71 continue;
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
72 }
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
73 }
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
74 }
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
75
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
76 private Canvas createLegendGraphicsRow(final AttributedTheme at) {
9694
94b976204a0a legendwindow debug
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9693
diff changeset
77 com.smartgwt.client.util.SC.say("init");
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
78 final Label label = new Label(at.getDescription());
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
79 final Widget img = createLegendGraphics(at);
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
80
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
81 final HLayout row = new HLayout();
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
82 row.addMember(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
83 row.addMember(img);
9693
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
84
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
85 String url = "url";
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
86
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
87 if (img instanceof Image) {
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
88 setDimensions( row, ((Image) img).getHeight(), ((Image) img).getWidth());
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
89 url = " url " + ((Image) img).getUrl();
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
90 }
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
91 else if (img instanceof Img) {
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
92 setDimensions( row, ((Img) img).getHeight(), ((Img) img).getWidth());
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
93 url = " dataPath " + ((Img) img).getDataPath();
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
94 }
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
95 else {
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
96 setDimensions( row, 150, 400); //not sure when this is executed
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
97 }
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
98 String labelText = at.getDescription() +", height: "+ row.getHeight()+"width: "+ row.getWidth()+" "+url;
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
99 //
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
100 // final HLayout row2= new HLayout();
9694
94b976204a0a legendwindow debug
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9693
diff changeset
101 // row.addMember(new Label(labelText));
94b976204a0a legendwindow debug
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9693
diff changeset
102
94b976204a0a legendwindow debug
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9693
diff changeset
103 com.smartgwt.client.util.SC.say(labelText);
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
104 return row;
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
105 }
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
106
9693
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
107 private void setDimensions(HLayout row, int height, int width ) {
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
108 final int minHeight = 30;
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
109 row.setHeight(height < minHeight ? minHeight : height);
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
110 row.setWidth(width);
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
111 }
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
112
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
113 private Widget createLegendGraphics(final AttributedTheme at) {
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
114
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
115 final String legend = at.getAttr("legend");
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
116 // TEST: final Image img = new Image("/images/FLYS_Donau.png"); (funktioniert!), ebenso FLYSResources.getTest();
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
117 if (legend != null && !"".equals(legend)) {
9644
152299dadb36 legend URL fix
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9635
diff changeset
118
152299dadb36 legend URL fix
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9635
diff changeset
119 final String imgUrl = URL.encode(GWT.getHostPageBaseURL() + "images/wms_legend/" + legend);
152299dadb36 legend URL fix
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9635
diff changeset
120
152299dadb36 legend URL fix
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9635
diff changeset
121 final Image image = new Image(imgUrl);
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
122 final int imageWidth = image.getWidth();
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
123 final int imageHeight = image.getHeight();
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
124 final double widthPercent = imageWidth / 400.;
9635
a03c54129819 pos 21 another review...
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9619
diff changeset
125
a03c54129819 pos 21 another review...
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9619
diff changeset
126 // removing the limit of 150px height (legend can have an infinite height now,
a03c54129819 pos 21 another review...
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9619
diff changeset
127 // as long as the width is less/eq 400px; if the width is >400,
a03c54129819 pos 21 another review...
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9619
diff changeset
128 // the legend will be scaled to 400px width; the ratio will be kept)
a03c54129819 pos 21 another review...
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9619
diff changeset
129
a03c54129819 pos 21 another review...
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9619
diff changeset
130 // final double heightPercent = imageHeight / 150.;
a03c54129819 pos 21 another review...
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9619
diff changeset
131 if (widthPercent > 1)// || heightPercent > 1) {
a03c54129819 pos 21 another review...
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9619
diff changeset
132 image.setSize((int) (imageWidth / widthPercent) + "px", (int) (imageHeight / widthPercent) + "px");
9693
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
133
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
134 return image;
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
135 }
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
136 final String imgUrl = MapUtils.getLegendGraphicUrl(at.getAttr("url"), at.getAttr("layers"));
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
137
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
138 final Img img = new Img(imgUrl);
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
139 img.setImageType(ImageStyle.CENTER);
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
140 img.setAutoFit(true);
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
141
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
142 return 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
143 }
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
144
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
145 private void init() {
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
146 this.legendContainer.setAutoHeight();
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
147 this.legendContainer.setLayoutAlign(VerticalAlignment.TOP);
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
148 this.legendContainer.setAlign(VerticalAlignment.CENTER);
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
149
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
150 setTitle(this.MSG.wms_legend());
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
151 setAutoSize(true);
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
152 setCanDragResize(true);
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
153 setIsModal(false);
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
154 setShowModalMask(false);
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
155 setLayoutAlign(VerticalAlignment.TOP);
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
156 setAlign(VerticalAlignment.TOP);
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
157
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
158 addItem(this.legendContainer);
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
159 addLegends();
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
160
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
161 centerInPage();
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
162 }
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
163 }

http://dive4elements.wald.intevation.org