annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/LegendWindow.java @ 9693:2197a7ccb4a8

LegendWindow zu 3.1. + 3.2 DEBUG
author dnt_bjoernsen <d.tironi@bjoernsen.de>
date Tue, 19 Jan 2021 16:39:50 +0100
parents 152299dadb36
children 94b976204a0a
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();
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
58
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
59 for (final Theme theme : themes) {
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
60 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
61 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
62 }
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
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 if (theme instanceof AttributedTheme) {
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
65 this.legendContainer.addMember(createLegendGraphicsRow((AttributedTheme) theme));
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
66 }
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 }
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
68 }
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
69
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
70 private Canvas createLegendGraphicsRow(final AttributedTheme at) {
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
71 final Label label = new Label(at.getDescription());
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
72 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
73
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
74 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
75 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
76 row.addMember(img);
9693
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
77
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
78 String url = "url";
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
79
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
80 if (img instanceof Image) {
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
81 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
82 url = " url " + ((Image) img).getUrl();
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
83 }
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
84 else if (img instanceof Img) {
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
85 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
86 url = " dataPath " + ((Img) img).getDataPath();
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
87 }
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
88 else {
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
89 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
90 }
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
91 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
92 //
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
93 // final HLayout row2= new HLayout();
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
94 row.addMember(new Label(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
95 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
96 }
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
97
9693
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
98 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
99 final int minHeight = 30;
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
100 row.setHeight(height < minHeight ? minHeight : height);
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
101 row.setWidth(width);
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
102 }
2197a7ccb4a8 LegendWindow zu 3.1. + 3.2 DEBUG
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9644
diff changeset
103
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
104 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
105
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
106 final String legend = at.getAttr("legend");
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
107 // 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
108 if (legend != null && !"".equals(legend)) {
9644
152299dadb36 legend URL fix
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9635
diff changeset
109
152299dadb36 legend URL fix
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9635
diff changeset
110 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
111
152299dadb36 legend URL fix
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9635
diff changeset
112 final Image image = new Image(imgUrl);
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
113 final int imageWidth = image.getWidth();
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
114 final int imageHeight = image.getHeight();
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
115 final double widthPercent = imageWidth / 400.;
9635
a03c54129819 pos 21 another review...
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9619
diff changeset
116
a03c54129819 pos 21 another review...
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9619
diff changeset
117 // 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
118 // 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
119 // 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
120
a03c54129819 pos 21 another review...
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9619
diff changeset
121 // final double heightPercent = imageHeight / 150.;
a03c54129819 pos 21 another review...
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9619
diff changeset
122 if (widthPercent > 1)// || heightPercent > 1) {
a03c54129819 pos 21 another review...
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 9619
diff changeset
123 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
124
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
125 return image;
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
126 }
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
127 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
128
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
129 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
130 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
131 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
132
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
133 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
134 }
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
135
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
136 private void init() {
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
137 this.legendContainer.setAutoHeight();
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
138 this.legendContainer.setLayoutAlign(VerticalAlignment.TOP);
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
139 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
140
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
141 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
142 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
143 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
144 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
145 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
146 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
147 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
148
9619
63bbd5e45839 #21 WMS Legend
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents: 8856
diff changeset
149 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
150 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
151
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 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
153 }
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 }

http://dive4elements.wald.intevation.org