Statistics
| Revision:

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

History | View | Annotate | Download (10.8 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.app.extension.wmsclient.gui.panel;
24

    
25
import java.util.Vector;
26

    
27
import javax.swing.JEditorPane;
28
import javax.swing.JPanel;
29
import javax.swing.JScrollPane;
30

    
31
import org.gvsig.andami.PluginServices;
32
import org.gvsig.fmap.dal.coverage.dataset.io.wms.WMSLayerNode;
33
import org.gvsig.fmap.dal.coverage.store.remote.RemoteRasterServiceStore;
34

    
35

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

    
40
class InfoPanel extends JPanel {
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 srs_title           = "SRS";
58
    private final String properties                         = PluginServices.getText(this, "properties");
59
    private final String layer_name                         = PluginServices.getText(this, "name");
60
        private JEditorPane editor = null;
61

    
62

    
63
    /**
64
     * Creates a new instance of InfoPanel with double buffer and null layout
65
     *
66
     */
67
        public InfoPanel() {
68
                super();
69
        setLayout(null);
70
        JScrollPane src = new JScrollPane();
71
        src.setBounds(5, 5, 485, 375);
72
        add(src, null);
73
        src.setViewportView(getEditor());
74
        }
75

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

    
89

    
90
    /**
91
     * Fills the text pane with a data table describing the service and the
92
     * selected settings.
93
     *
94
     * @param dataSource
95
     */
96

    
97
    public void refresh(RemoteRasterServiceStore dataSource, Vector layers, Vector styles, String format, String srs, Vector dimensions) {
98

    
99
        String server_text = dataSource.getHost();
100
        String server_type_text = dataSource.getServerType();
101
        String server_title_text = dataSource.getTitle();
102
        String server_abstract_text = dataSource.getAbstract();
103
        String font = "Arial";
104

    
105
        if (server_text == null)
106
            server_text = "-";
107
        if (server_type_text == null)
108
            server_type_text = "-";
109
        if (server_title_text == null)
110
            server_title_text = "-";
111
        if (server_abstract_text == null)
112
            server_abstract_text = "-";
113

    
114
        if (format == null)
115
            format = PluginServices.getText(this, "none_selected");
116
        if (srs == null)
117
            srs = PluginServices.getText(this, "none_selected");
118

    
119
        String layers_html = "";
120
        for (int i = 0; i < layers.size(); i++) {
121
            WMSLayerNode layer = (WMSLayerNode) layers.get(i);
122
            String layer_name_text = layer.getName();
123
            String style_title = (styles==null) ? PluginServices.getText(this, "not_available") : (String) styles.get(i);//((FMapWMSStyle) selectedStyles.get(i)).title;
124
            String layer_abstract_text = layer.getAbstract();
125
            String layer_title_text = layer.getTitle();
126

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

    
181
        String format_html =
182
                "  <tr valign=\"top\" bgcolor=\"#FFFFFF\">" +
183
            "    <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+properties+"</font></b></td>" +
184
            "  </tr>" +
185
            "  <tr valign=\"top\" bgcolor="+bgColor0+">" +
186
            "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+format_title+"</b></font></td>" +
187
            "    <td><font face=\""+font+"\" size=\"3\"><font face=\""+font+"\" size=\"3\">"+format+"</font></td>" +
188
            "  </tr>" +
189
            "  <tr valign=\"top\" bgcolor="+bgColor1+">" +
190
            "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+srs_title+"</font></b></td>" +
191
            "    <td><font face=\""+font+"\" size=\"3\">"+srs+"</font></td>" +
192
            "  </tr>";
193

    
194
        String html =
195

    
196
            "<html>" +
197
            "<body>" +
198
            "<table align=\"center\" width=\"437\" height=\"156\" border=\"0\" cellpadding=\"4\" cellspacing=\"4\">" +
199
            "  <tr valign=\"top\" bgcolor=\"#FFFFFF\">" +
200
            "    <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+service_title+"</font></b></td>" +
201
            "  </tr>" +
202
            "  <tr valign=\"top\" bgcolor="+bgColor0+">" +
203
            "    <td width=\"92\" height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server+"</font></b></td>" +
204
            "    <td width=\"268\"><font face=\""+font+"\" size=\"3\">"+server_text+"</font></td>" +
205
            "  </tr>" +
206
            "  <tr valign=\"top\" bgcolor="+bgColor1+">" +
207
            "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server_type+"</b></font></td>" +
208
            "    <td><font face=\""+font+"\" size=\"3\">"+server_type_text+"</font></td>" +
209
            "  </tr>" +
210
            "  <tr valign=\"top\" bgcolor="+bgColor0+">" +
211
            "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server_title+"</b></font></td>" +
212
            "    <td><font face=\""+font+"\" size=\"3\"><font face=\""+font+"\" size=\"3\">"+server_title_text+"</font></td>" +
213
            "  </tr>" +
214
            "  <tr valign=\"top\" bgcolor="+bgColor1+">" +
215
            "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server_abstract+"</font></b></td>" +
216
            "    <td><font face=\""+font+"\" size=\"3\">"+server_abstract_text+"</font></td>" +
217
            "  </tr>" +
218

    
219
            "  <tr>" +
220
            "  </tr>" +
221
            layers_html +
222
            dimension_html +
223
            format_html +
224
            "</table>" +
225
            "</body>" +
226
            "</html>";
227

    
228
        getEditor().setContentType("text/html");
229
        getEditor().setText(html);
230
    }
231
}