comparison 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
comparison
equal deleted inserted replaced
9704:ca9ed55d6f51 9705:bfdf98529a66
63 continue; 63 continue;
64 } 64 }
65 try { 65 try {
66 if (theme instanceof AttributedTheme) { 66 if (theme instanceof AttributedTheme) {
67 Canvas createLegendGraphicsRow = createLegendGraphicsRow((AttributedTheme) theme); 67 Canvas createLegendGraphicsRow = createLegendGraphicsRow((AttributedTheme) theme);
68 this.legendContainer.addMember(createLegendGraphicsRow); 68 this.legendContainer.addMember(createLegendGraphicsRow);
69 } 69 }
70 } catch (Exception e) { 70 } catch (Exception e) {
71 continue; 71 continue;
72 } 72 }
73 } 73 }
74 } 74 }
75 75
76 private Canvas createLegendGraphicsRow(final AttributedTheme at) { 76 private Canvas createLegendGraphicsRow(final AttributedTheme at) {
77 final Label label = new Label(at.getDescription()); 77 final Label label = new Label(at.getDescription());
78 final HLayout row = new HLayout(); 78 final HLayout row = new HLayout();
79 final Widget img = createLegendGraphics(row ,at); 79 final Widget img = createLegendGraphics(row, at);
80 80
81 row.addMember(label); 81 row.addMember(label);
82 row.addMember(img); 82 row.addMember(img);
83 83
84 // String url = "url"; 84 // setDimensions(row, 150, 400);
85 if (img instanceof Image) {
86 // url = " url " + ((Image) img).getUrl();
87 // new MyLoadHandler(row, ((Image) img));
88
89 // } else if (img instanceof Img) {
90 // setDimensions(row, ((Img) img).getHeight(), ((Img) img).getWidth());
91 // url = " dataPath " + ((Img) img).getDataPath();
92 } else {
93 setDimensions(row, 150, 400); // not sure when this is executed
94 }
95 // String labelText = at.getDescription() + ", height: " + row.getHeight() + "width: " + row.getWidth() + " "
96 // + url;
97
98 // com.smartgwt.client.util.SC.say(labelText);
99 return row; 85 return row;
100 }
101
102 private void setDimensions(HLayout row, int height, int width) {
103 final int minHeight = 30;
104 row.setHeight(height < minHeight ? minHeight : height);
105 row.setWidth(width);
106 } 86 }
107 87
108 private Widget createLegendGraphics(HLayout row, final AttributedTheme at) { 88 private Widget createLegendGraphics(HLayout row, final AttributedTheme at) {
109 89
110 final String legend = at.getAttr("legend"); 90 final String legend = at.getAttr("legend");
111 // TEST: final Image img = new Image("/images/FLYS_Donau.png"); (funktioniert!), 91 // TEST: final Image img = new Image("/images/FLYS_Donau.png"); (funktioniert!),
112 // ebenso FLYSResources.getTest(); 92 // ebenso FLYSResources.getTest();
113 String attr = at.getAttr("url"); 93 String urlAttr = at.getAttr("url");
114 String attr2 = at.getAttr("layers"); 94 String layersAttr = at.getAttr("layers");
115
116 if (legend != null && !"".equals(legend)) {
117 95
118 final String imgUrl = URL.encode(GWT.getHostPageBaseURL() + "images/wms_legend/" + legend); 96 final String imgUrl = getUrl(legend, urlAttr, layersAttr);
119 97
120 final Image image = new Image(imgUrl);
121 new MyWMSLoadHandler(row, image);
122
123 return image;
124 }
125
126 final String imgUrl = MapUtils.getLegendGraphicUrl(attr, attr2);
127 final Image image = new Image(imgUrl); 98 final Image image = new Image(imgUrl);
128 99 new MyWMSLoadHandler(row, image);
129 // com.smartgwt.client.util.SC.say(imgUrl);
130 new MyLoadHandler(row, ((Image) image));
131 // Image image = new Image(imgUrl);
132 // Widget widget = image.asWidget();
133 // final Img img = new Img(imgUrl);
134 // img.setImageType(ImageStyle.CENTER);
135 // img.setAutoFit(true);
136 100
137 return image; 101 return image;
102 }
103
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 }
138 } 110 }
139 111
140 private void init() { 112 private void init() {
141 this.legendContainer.setAutoHeight(); 113 this.legendContainer.setAutoHeight();
142 this.legendContainer.setLayoutAlign(VerticalAlignment.TOP); 114 this.legendContainer.setLayoutAlign(VerticalAlignment.TOP);

http://dive4elements.wald.intevation.org