Statistics
| Revision:

gvsig-raster / org.gvsig.raster.wms / trunk / org.gvsig.raster.wms / org.gvsig.raster.wms.app.wmsclient / src / main / java / org / gvsig / raster / wms / app / wmsclient / gui / panel / InfoPanel.java @ 22713

History | View | Annotate | Download (11.3 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22
 
23
package org.gvsig.raster.wms.app.wmsclient.gui.panel;
24

    
25
import java.awt.BorderLayout;
26
import java.util.Vector;
27
import javax.swing.JEditorPane;
28
import javax.swing.JPanel;
29
import javax.swing.JScrollPane;
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.raster.wms.io.WMSLayerNode;
32
import org.gvsig.raster.wms.io.WMSServerExplorer;
33

    
34

    
35
/**
36
 * Service Information Panel
37
 */
38

    
39
class InfoPanel extends JPanel {
40
        private static final long serialVersionUID = 1L;
41
        private final String bgColor0 = "\"#FEEDD6\""; // light salmon
42
    private final String bgColor1 = "\"#EAEAEA\""; // light grey
43
    //private final String bgColor2 = "\"#F2FEFF\""; // light blue
44
    private final String bgColor3 = "\"#FBFFE1\""; // light yellow
45

    
46
    private final String service_title       = PluginServices.getText(this, "service_info");
47
    private final String server              = PluginServices.getText(this, "server");
48
    private final String server_type         = PluginServices.getText(this, "server_type");
49
    private final String server_abstract     = PluginServices.getText(this, "server_abstract");
50
    private final String server_title        = PluginServices.getText(this, "server_title");
51
    private final String layers_title        = PluginServices.getText(this, "selected_layers");
52
    private final String layer_title         = PluginServices.getText(this, "layer_title");
53
    private final String layer_abstract      = PluginServices.getText(this, "layer_abstract");
54
    private final String selected_dimensions = PluginServices.getText(this, "selected_dimensions");
55
    private final String style               = PluginServices.getText(this, "style");
56
    private final String format_title        = PluginServices.getText(this, "format");
57
    private final String infoformat_title    = PluginServices.getText(this, "infoformat");
58
    private final String srs_title           = "SRS";
59
    private final String properties                         = PluginServices.getText(this, "properties");
60
    private final String layer_name                         = PluginServices.getText(this, "name");
61
        private JEditorPane editor = null;
62

    
63

    
64
    /**
65
     * Creates a new instance of InfoPanel with double buffer and null layout
66
     *
67
     */
68
        public InfoPanel() {
69
                super();
70
        this.setLayout(new BorderLayout(5, 5));
71
        this.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
72
        JScrollPane src = new JScrollPane(getEditor());
73
        src.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
74
        src.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
75
        this.add(src, BorderLayout.CENTER);
76
        }
77

    
78
    /**
79
     * This method initializes tblInfo
80
     *
81
     * @return javax.swing.JTable
82
     */
83
    private JEditorPane getEditor() {
84
        if (editor == null) {
85
            editor = new JEditorPane();
86
            editor.setEditable(false);
87
        }
88
        return editor;
89
    }
90

    
91

    
92
    /**
93
     * Fills the text pane with a data table describing the service and the
94
     * selected settings.
95
     *
96
     * @param dataSource
97
     */
98
    @SuppressWarnings("unchecked")
99
        public void refresh(WMSServerExplorer dataSource, 
100
                        Vector layers, 
101
                        Vector styles, 
102
                        String format, 
103
                        String infoFormat, 
104
                        String srs, 
105
                        Vector dimensions) {
106

    
107
        String server_text = dataSource.getHost();
108
        String server_type_text = dataSource.getServerType();
109
        String server_title_text = dataSource.getTitle();
110
        String server_abstract_text = dataSource.getAbstract();
111
        String font = "Arial";
112

    
113
        if (server_text == null)
114
            server_text = "-";
115
        if (server_type_text == null)
116
            server_type_text = "-";
117
        if (server_title_text == null)
118
            server_title_text = "-";
119
        if (server_abstract_text == null)
120
            server_abstract_text = "-";
121

    
122
        if (format == null)
123
            format = PluginServices.getText(this, "none_selected");
124
        if (srs == null)
125
            srs = PluginServices.getText(this, "none_selected");
126

    
127
        String layers_html = "";
128
        for (int i = 0; i < layers.size(); i++) {
129
                WMSLayerNode layer = (WMSLayerNode) layers.get(i);
130
            String layer_name_text = layer.getName();
131
            String style_title = (styles==null) ? PluginServices.getText(this, "not_available") : (String) styles.get(i);//((FMapWMSStyle) selectedStyles.get(i)).title;
132
            String layer_abstract_text = layer.getAbstract();
133
            String layer_title_text = layer.getTitle();
134

    
135
            if (layer_name_text ==null)
136
                    layer_name_text = "-";
137
            if (style_title==null)
138
                    style_title = "-";
139
            if (layer_abstract_text==null)
140
                    layer_abstract_text = "-";
141
            if (layer_title_text == null)
142
                    layer_title_text = "-";
143
            String layer_html =
144
                    "  <tr valign=\"top\">" +
145
                "     <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\" align=\"right\"><b>"+layer_name+"</b></font></td>" +
146
                "     <td bgcolor="+bgColor0+"><font face=\"Arial\" size=\"3\">"+layer_name_text+"</font></td>" +
147
                "  </tr>" +
148
                "  <tr valign=\"top\">" +
149
                "     <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\"><b>"+layer_title+"</b></font></td>" +
150
                "     <td bgcolor="+bgColor1+"><font face=\"Arial\" size=\"3\">"+layer_title_text+"</font></td>" +
151
                "  </tr>" +
152
                "  <tr valign=\"top\">" +
153
                "     <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\" align=\"right\"><b>"+layer_abstract+"</b></font></td>" +
154
                "     <td bgcolor="+bgColor0+"><font face=\"Arial\" size=\"3\">"+layer_abstract_text+"</font></td>" +
155
                "  </tr>" +
156
                "  <tr valign=\"top\">" +
157
                "     <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\" align=\"right\"><b>"+style+"</b></font></td>" +
158
                "     <td bgcolor="+bgColor1+"><font face=\"Arial\" size=\"3\">"+style_title+"</font></td>" +
159
                "  </tr>" +
160
                "  <tr>" +
161
                "  </tr>";
162
            layers_html += layer_html;
163
        }
164
        if (!layers_html.equals(""))
165
            layers_html =
166
                "  <tr valign=\"top\" bgcolor=\"#FFFFFF\">" +
167
                "    <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+layers_title+"</font></b></td>" +
168
                "  </tr>" + layers_html;
169
        String dimension_html = "";
170
        if (dimensions != null) {
171
                boolean swap = false;
172
                for (int i = 0; i < dimensions.size(); i++) {
173
                        String color = swap ? bgColor0 : bgColor1;
174
                        String[] dimension = ((String) dimensions.get(i)).split("=");
175
                        dimension_html +=
176
                                "  <tr valign=\"top\" bgcolor=" + color + ">" +
177
                                "    <td bgcolor=\"#D6D6D6\" align=\"right\"><b>" + dimension[0] + "</b></td>" +
178
                                "    <td >" + dimension[1] + "</td>" +
179
                                "  </tr>";
180
                        swap = !swap;
181
                }
182
        }
183
        if (!dimension_html.equals(""))
184
                dimension_html =
185
                        "  <tr valign=\"top\">" +
186
                        "    <td bgcolor=" + bgColor3 + " colspan=\"2\"><font face=\"" + font + "\" size=\"4\"><b>" + selected_dimensions + "</font></b></td>" +
187
                        "  </tr>" + dimension_html;
188

    
189
        String format_html =
190
                "  <tr valign=\"top\" bgcolor=\"#FFFFFF\">" +
191
            "    <td bgcolor=" + bgColor3 + " colspan=\"2\"><font face=\"" + font + "\" size=\"4\"><b>" + properties + "</font></b></td>" +
192
            "  </tr>" +
193
            "  <tr valign=\"top\" bgcolor=" + bgColor0 + ">" +
194
            "    <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"" + font + "\" size=\"3\"><b>" + format_title + "</b></font></td>" +
195
            "    <td><font face=\"" + font + "\" size=\"3\"><font face=\"" + font + "\" size=\"3\">" + format + "</font></td>" +
196
            "  </tr>" +
197
            "  <tr valign=\"top\" bgcolor=" + bgColor1 + ">" +
198
            "    <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"" + font + "\" size=\"3\"><b>" + srs_title + "</font></b></td>" +
199
            "    <td><font face=\"" + font + "\" size=\"3\">" + srs + "</font></td>" +
200
            "  </tr>" +
201
            "  <tr valign=\"top\" bgcolor=" + bgColor0 + ">" +
202
            "    <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"" + font + "\" size=\"3\"><b>" + infoformat_title + "</font></b></td>" +
203
            "    <td><font face=\"" + font + "\" size=\"3\">" + infoFormat + "</font></td>" +
204
            "  </tr>";
205

    
206
        String html =
207

    
208
            "<html>" +
209
            "<body>" +
210
            "<table align=\"center\" width=\"100%\" height=\"100%\" border=\"0\" cellpadding=\"4\" cellspacing=\"4\">" +
211
            "  <tr valign=\"top\" bgcolor=\"#FFFFFF\">" +
212
            "    <td bgcolor=" + bgColor3 + " colspan=\"2\"><font face=\"" + font + "\" size=\"4\"><b>"+service_title+"</font></b></td>" +
213
            "  </tr>" +
214
            "  <tr valign=\"top\" bgcolor=" + bgColor0 + ">" +
215
            "    <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"" + font + "\" size=\"3\"><b>"+server+"</font></b></td>" +
216
            "    <td ><font face=\"" + font + "\" size=\"3\">" + server_text + "</font></td>" +
217
            "  </tr>" +
218
            "  <tr valign=\"top\" bgcolor=" + bgColor1 + ">" +
219
            "    <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"" + font + "\" size=\"3\"><b>" + server_type + "</b></font></td>" +
220
            "    <td><font face=\"" + font + "\" size=\"3\">" + server_type_text + "</font></td>" +
221
            "  </tr>" +
222
            "  <tr valign=\"top\" bgcolor=" + bgColor0 + ">" +
223
            "    <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"" + font + "\" size=\"3\"><b>" + server_title + "</b></font></td>" +
224
            "    <td><font face=\"" + font+  "\" size=\"3\"><font face=\"" + font + "\" size=\"3\">" + server_title_text + "</font></td>" +
225
            "  </tr>" +
226
            "  <tr valign=\"top\" bgcolor=" + bgColor1 + ">" +
227
            "    <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"" + font + "\" size=\"3\"><b>" +  server_abstract + "</font></b></td>" +
228
            "    <td><font face=\"" + font + "\" size=\"3\">" + server_abstract_text + "</font></td>" +
229
            "  </tr>" +
230

    
231
            "  <tr>" +
232
            "  </tr>" +
233
            layers_html +
234
            dimension_html +
235
            format_html +
236
            "</table>" +
237
            "</body>" +
238
            "</html>";
239

    
240
        getEditor().setContentType("text/html");
241
        getEditor().setText(html);
242
    }
243
}