comparison flys-client/src/main/java/org/dive4elements/river/client/client/ui/map/LegendWindow.java @ 5834:f507086aa94b

Repaired internal references.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 12:31:32 +0200
parents flys-client/src/main/java/de/intevation/flys/client/client/ui/map/LegendWindow.java@c9dcce9448f2
children 821a02bbfb4e
comparison
equal deleted inserted replaced
5833:a2bdc0f524e8 5834:f507086aa94b
1 package de.intevation.flys.client.client.ui.map;
2
3 import java.util.List;
4
5 import com.smartgwt.client.types.ImageStyle;
6 import com.smartgwt.client.types.VerticalAlignment;
7 import com.smartgwt.client.widgets.Canvas;
8 import com.smartgwt.client.widgets.Img;
9 import com.smartgwt.client.widgets.Label;
10 import com.smartgwt.client.widgets.Window;
11 import com.smartgwt.client.widgets.layout.HLayout;
12 import com.smartgwt.client.widgets.layout.VLayout;
13
14 import de.intevation.flys.client.shared.MapUtils;
15 import de.intevation.flys.client.shared.model.AttributedTheme;
16 import de.intevation.flys.client.shared.model.Theme;
17 import de.intevation.flys.client.shared.model.ThemeList;
18
19
20 public class LegendWindow extends Window {
21
22 private ThemeList themeList;
23
24 private VLayout legendContainer;
25
26 public LegendWindow(ThemeList themeList) {
27 this.themeList = themeList;
28 this.legendContainer = new VLayout();
29
30 init();
31 }
32
33 public void update(ThemeList themeList) {
34 this.themeList = themeList;
35
36 Canvas[] legends = legendContainer.getMembers();
37 legendContainer.removeMembers(legends);
38
39 addLegends();
40 }
41
42 private void addLegends() {
43 List<Theme> themes = themeList.getActiveThemes();
44
45 for (Theme theme : themes) {
46 if (theme.getActive() == 0) {
47 continue;
48 }
49
50 if (theme instanceof AttributedTheme) {
51 legendContainer
52 .addMember(createLegendGraphicsRow((AttributedTheme) theme));
53 }
54 }
55 }
56
57 private Canvas createLegendGraphicsRow(AttributedTheme at) {
58 Label label = new Label(at.getDescription());
59 Img img = createLegendGraphics(at);
60
61 HLayout row = new HLayout();
62 row.addMember(label);
63 row.addMember(img);
64
65 row.setHeight(150);
66 row.setWidth(400);
67
68 return row;
69 }
70
71 private Img createLegendGraphics(AttributedTheme at) {
72 String imgUrl = MapUtils.getLegendGraphicUrl(at.getAttr("url"),
73 at.getAttr("layers"));
74
75 Img img = new Img(imgUrl);
76 img.setImageType(ImageStyle.CENTER);
77 img.setAutoFit(true);
78
79 return img;
80 }
81
82 private void init() {
83 legendContainer.setAutoHeight();
84 legendContainer.setLayoutAlign(VerticalAlignment.TOP);
85 legendContainer.setAlign(VerticalAlignment.CENTER);
86
87 setTitle("WMS Legend");
88 setAutoSize(true);
89 setCanDragResize(true);
90 setIsModal(false);
91 setShowModalMask(false);
92 setLayoutAlign(VerticalAlignment.TOP);
93 setAlign(VerticalAlignment.TOP);
94
95 addItem(legendContainer);
96 addLegends();
97
98 centerInPage();
99 }
100 }

http://dive4elements.wald.intevation.org