svn-gvsig-desktop / branches / v05 / extensions / extWMS / src / com / iver / cit / gvsig / gui / panels / InfoPanel.java @ 3855
History | View | Annotate | Download (10.4 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
|
42 |
/* CVS MESSAGES:
|
43 |
*
|
44 |
* $Id: InfoPanel.java 3855 2006-01-31 16:25:24Z jaume $
|
45 |
* $Log$
|
46 |
* Revision 1.2.2.3 2006-01-31 16:25:24 jaume
|
47 |
* correcciones de bugs
|
48 |
*
|
49 |
* Revision 1.3 2006/01/26 16:07:14 jaume
|
50 |
* *** empty log message ***
|
51 |
*
|
52 |
* Revision 1.2.2.1 2006/01/26 12:59:32 jaume
|
53 |
* 0.5
|
54 |
*
|
55 |
* Revision 1.2 2006/01/26 12:50:20 jaume
|
56 |
* *** empty log message ***
|
57 |
*
|
58 |
* Revision 1.1 2006/01/25 09:08:53 jaume
|
59 |
* test save and reload project
|
60 |
*
|
61 |
*
|
62 |
*/
|
63 |
package com.iver.cit.gvsig.gui.panels; |
64 |
|
65 |
import java.util.Vector; |
66 |
|
67 |
import javax.swing.JEditorPane; |
68 |
import javax.swing.JPanel; |
69 |
import javax.swing.JScrollPane; |
70 |
|
71 |
import com.iver.andami.PluginServices; |
72 |
import com.iver.cit.gvsig.fmap.layers.WMSLayerNode; |
73 |
import com.iver.cit.gvsig.gui.wizards.WMSWizardData; |
74 |
|
75 |
/**
|
76 |
* Service Information Panel
|
77 |
*/
|
78 |
|
79 |
class InfoPanel extends JPanel { |
80 |
private final String bgColor0 = "\"#FEEDD6\""; // light salmon |
81 |
private final String bgColor1 = "\"#EAEAEA\""; // light grey |
82 |
private final String bgColor2 = "\"#F2FEFF\""; // light blue |
83 |
private final String bgColor3 = "\"#FBFFE1\""; // light yellow |
84 |
|
85 |
private final String service_title = PluginServices.getText(this, "service_info"); |
86 |
private final String server = PluginServices.getText(this, "server"); |
87 |
private final String server_type = PluginServices.getText(this, "server_type"); |
88 |
private final String server_abstract = PluginServices.getText(this, "server_abstract"); |
89 |
private final String server_title = PluginServices.getText(this, "server_title"); |
90 |
private final String layers_title = PluginServices.getText(this, "selected_layers"); |
91 |
private final String layer_title = PluginServices.getText(this, "layer_title"); |
92 |
private final String layer_abstract = PluginServices.getText(this, "layer_abstract"); |
93 |
private final String selected_dimensions = PluginServices.getText(this, "selected_dimensions"); |
94 |
private final String style = PluginServices.getText(this, "style"); |
95 |
private final String format_title = PluginServices.getText(this, "format"); |
96 |
private final String srs_title = "SRS"; |
97 |
private JEditorPane editor = null; |
98 |
|
99 |
|
100 |
/**
|
101 |
* Creates a new instance of InfoPanel with double buffer and null layout
|
102 |
*
|
103 |
*/
|
104 |
public InfoPanel() {
|
105 |
super();
|
106 |
setLayout(null);
|
107 |
JScrollPane src = new JScrollPane(); |
108 |
src.setBounds(5, 5, 455, 375); |
109 |
add(src, null);
|
110 |
src.setViewportView(getEditor()); |
111 |
} |
112 |
|
113 |
/**
|
114 |
* This method initializes tblInfo
|
115 |
*
|
116 |
* @return javax.swing.JTable
|
117 |
*/
|
118 |
private JEditorPane getEditor() { |
119 |
if (editor == null) { |
120 |
editor = new JEditorPane(); |
121 |
editor.setEditable(false);
|
122 |
} |
123 |
return editor;
|
124 |
} |
125 |
|
126 |
|
127 |
/**
|
128 |
* Fills the text pane with a data table describing the service and the
|
129 |
* selected settings.
|
130 |
*
|
131 |
* @param dataSource
|
132 |
*/
|
133 |
|
134 |
public void refresh(WMSWizardData dataSource, Vector layers, Vector styles, String format, String srs, Vector dimensions) { |
135 |
|
136 |
String server_text = dataSource.getHost();
|
137 |
String server_type_text = dataSource.getServerType();
|
138 |
String server_title_text = dataSource.getTitle();
|
139 |
String server_abstract_text = dataSource.getAbstract();
|
140 |
String font = "Arial"; |
141 |
|
142 |
if (server_text == null) |
143 |
server_text = "-";
|
144 |
if (server_type_text == null) |
145 |
server_type_text = "-";
|
146 |
if (server_title_text == null) |
147 |
server_title_text = "-";
|
148 |
if (server_abstract_text == null) |
149 |
server_abstract_text = "-";
|
150 |
|
151 |
if (format == null) |
152 |
format = PluginServices.getText(this, "none_selected"); |
153 |
if (srs == null) |
154 |
srs = PluginServices.getText(this, "none_selected"); |
155 |
|
156 |
String layers_html = ""; |
157 |
for (int i = 0; i < layers.size(); i++) { |
158 |
WMSLayerNode layer = (WMSLayerNode) layers.get(i); |
159 |
String style_title = (styles==null) ? PluginServices.getText(this, "not_available") : (String) styles.get(i);//((FMapWMSStyle) selectedStyles.get(i)).title; |
160 |
String layer_abstract_text = layer.getAbstract();
|
161 |
String layer_title_text = layer.getTitle();
|
162 |
String layer_html =
|
163 |
" <tr valign=\"top\">" +
|
164 |
" <td width=\"119\" height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\"><b>"+layer_title+"</b></font></td>" + |
165 |
" <td width=\"322\" height=\"18\" bgcolor="+bgColor1+"><font face=\"Arial\" size=\"3\">"+layer_title_text+"</font></td>" + |
166 |
" </tr>" +
|
167 |
" <tr valign=\"top\">" +
|
168 |
" <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\" align=\"right\"><b>"+layer_abstract+"</b></font></td>" + |
169 |
" <td bgcolor="+bgColor0+"><font face=\"Arial\" size=\"3\">"+layer_abstract_text+"</font></td>" + |
170 |
" </tr>" +
|
171 |
" <tr valign=\"top\">" +
|
172 |
" <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\" align=\"right\"><b>"+style+"</b></font></td>" + |
173 |
" <td bgcolor="+bgColor2+"><font face=\"Arial\" size=\"3\">"+style_title+"</font></td>" + |
174 |
" </tr>" +
|
175 |
" <tr>" +
|
176 |
" </tr>";
|
177 |
layers_html += layer_html; |
178 |
} |
179 |
if (!layers_html.equals("")) |
180 |
layers_html = |
181 |
" <tr valign=\"top\" bgcolor=\"#FFFFFF\">" +
|
182 |
" <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+layers_title+"</font></b></td>" + |
183 |
" </tr>" + layers_html;
|
184 |
String dimension_html = ""; |
185 |
if (dimensions!=null) { |
186 |
boolean swap = false; |
187 |
for (int i = 0; i < dimensions.size(); i++) { |
188 |
String color = swap ? bgColor0 : bgColor1;
|
189 |
String[] dimension = ((String) dimensions.get(i)).split("="); |
190 |
dimension_html += |
191 |
" <tr valign=\"top\" bgcolor="+color+">" + |
192 |
" <td width=\"120\" height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><b>"+dimension[0]+"</b></td>" + |
193 |
" <td width=\"322\" height=\"18\">"+dimension[1]+"</td>" + |
194 |
" </tr>";
|
195 |
swap = !swap; |
196 |
} |
197 |
} |
198 |
if (!dimension_html.equals("")) |
199 |
dimension_html = |
200 |
" <tr valign=\"top\">" +
|
201 |
" <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+selected_dimensions+"</font></b></td>" + |
202 |
" </tr>" + dimension_html;
|
203 |
|
204 |
String html =
|
205 |
|
206 |
"<html>" +
|
207 |
"<body>" +
|
208 |
"<table align=\"center\" width=\"437\" height=\"156\" border=\"0\" cellpadding=\"4\" cellspacing=\"4\">" +
|
209 |
" <tr valign=\"top\" bgcolor=\"#FFFFFF\">" +
|
210 |
" <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+service_title+"</font></b></td>" + |
211 |
" </tr>" +
|
212 |
" <tr valign=\"top\" bgcolor="+bgColor0+">" + |
213 |
" <td width=\"92\" height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server+"</font></b></td>" + |
214 |
" <td width=\"268\"><font face=\""+font+"\" size=\"3\">"+server_text+"</font></td>" + |
215 |
" </tr>" +
|
216 |
" <tr valign=\"top\" bgcolor="+bgColor1+">" + |
217 |
" <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server_type+"</b></font></td>" + |
218 |
" <td><font face=\""+font+"\" size=\"3\">"+server_type_text+"</font></td>" + |
219 |
" </tr>" +
|
220 |
" <tr valign=\"top\" bgcolor="+bgColor0+">" + |
221 |
" <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server_title+"</b></font></td>" + |
222 |
" <td><font face=\""+font+"\" size=\"3\"><font face=\""+font+"\" size=\"3\">"+server_title_text+"</font></td>" + |
223 |
" </tr>" +
|
224 |
" <tr valign=\"top\" bgcolor="+bgColor1+">" + |
225 |
" <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server_abstract+"</font></b></td>" + |
226 |
" <td><font face=\""+font+"\" size=\"3\">"+server_abstract_text+"</font></td>" + |
227 |
" </tr>" +
|
228 |
" <tr valign=\"top\" bgcolor="+bgColor0+">" + |
229 |
" <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+format_title+"</b></font></td>" + |
230 |
" <td><font face=\""+font+"\" size=\"3\"><font face=\""+font+"\" size=\"3\">"+format+"</font></td>" + |
231 |
" </tr>" +
|
232 |
" <tr valign=\"top\" bgcolor="+bgColor1+">" + |
233 |
" <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+srs_title+"</font></b></td>" + |
234 |
" <td><font face=\""+font+"\" size=\"3\">"+srs+"</font></td>" + |
235 |
" </tr>" +
|
236 |
|
237 |
" <tr>" +
|
238 |
" </tr>" +
|
239 |
layers_html + |
240 |
dimension_html + |
241 |
"</table>" +
|
242 |
"</body>" +
|
243 |
"</html>";
|
244 |
|
245 |
getEditor().setContentType("text/html");
|
246 |
getEditor().setText(html); |
247 |
} |
248 |
} |