Statistics
| Revision:

gvsig-raster / org.gvsig.raster.wmts / trunk / org.gvsig.raster.wmts / org.gvsig.raster.wmts.swing / org.gvsig.raster.wmts.swing.impl / src / main / java / org / gvsig / raster / wmts / swing / impl / wizard / InfoPanel.java @ 2613

History | View | Annotate | Download (10.2 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.wmts.swing.impl.wizard;
24

    
25
import java.awt.BorderLayout;
26
import java.util.Vector;
27

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

    
32
import org.gvsig.i18n.Messages;
33
import org.gvsig.raster.wmts.io.WMTSServerExplorer;
34
import org.gvsig.raster.wmts.ogc.struct.WMTSServiceIdentification;
35
import org.gvsig.raster.wmts.ogc.struct.WMTSTheme;
36
import org.gvsig.raster.wmts.swing.impl.wizard.WMTSParamsPanel.LayerUI;
37

    
38

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

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

    
65

    
66
    /**
67
     * Creates a new instance of InfoPanel with double buffer and null layout
68
     *
69
     */
70
        public InfoPanel() {
71
                super();
72
        setLayout(new BorderLayout());
73
        JScrollPane src = new JScrollPane();
74
        add(src, BorderLayout.CENTER);
75
        src.setViewportView(getEditor());
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
        public void refresh(WMTSServerExplorer explorer, Vector layers, Vector styles, String format, String srs) {
99

    
100
            WMTSServiceIdentification id = explorer.getOGCClient().getServiceIdentification();
101
            
102
        String server_text = explorer.getHost();
103
        String server_type_text = id.getServiceType();
104
        String server_title_text = id.getTitle();
105
        String server_abstract_text = id.getAbstract();
106
        String font = "Arial";
107

    
108
        if (server_text == null)
109
            server_text = "-";
110
        if (server_type_text == null)
111
            server_type_text = "-";
112
        if (server_title_text == null)
113
            server_title_text = "-";
114
        if (server_abstract_text == null)
115
            server_abstract_text = "-";
116

    
117
        if (format == null)
118
            format = Messages.getText("none_selected");
119
        if (srs == null)
120
            srs = Messages.getText("none_selected");
121

    
122
        String layers_html = "";
123
        for (int i = 0; i < layers.size(); i++) {
124
                WMTSTheme layer = ((LayerUI) layers.get(i)).theme;
125
            String layer_name_text = layer.getTitle();
126
            String style_title = (((LayerUI) layers.get(i)).styleSelected == null) ? Messages.getText("not_available") : ((LayerUI) layers.get(i)).styleSelected.getTitle();
127
            String layer_abstract_text = layer.getAbstract();
128
            String layer_title_text = layer.getTitle();
129

    
130
            if (layer_name_text == null)
131
                    layer_name_text = "-";
132
            if (style_title == null)
133
                    style_title = "-";
134
            if (layer_abstract_text == null)
135
                    layer_abstract_text = "-";
136
            if (layer_title_text == null)
137
                    layer_title_text = "-";
138
            String layer_html =
139
                    "  <tr valign=\"top\">" +
140
                "     <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\" align=\"right\"><b>"+layer_name+"</b></font></td>" +
141
                "     <td bgcolor="+bgColor0+"><font face=\"Arial\" size=\"3\">"+layer_name_text+"</font></td>" +
142
                "  </tr>" +
143
                "  <tr valign=\"top\">" +
144
                "     <td width=\"119\" height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\"><b>"+layer_title+"</b></font></td>" +
145
                "     <td width=\"322\" height=\"18\" bgcolor="+bgColor1+"><font face=\"Arial\" size=\"3\">"+layer_title_text+"</font></td>" +
146
                "  </tr>" +
147
                "  <tr valign=\"top\">" +
148
                "     <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\" align=\"right\"><b>"+layer_abstract+"</b></font></td>" +
149
                "     <td bgcolor="+bgColor0+"><font face=\"Arial\" size=\"3\">"+layer_abstract_text+"</font></td>" +
150
                "  </tr>" +
151
                "  <tr valign=\"top\">" +
152
                "     <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\" align=\"right\"><b>"+style+"</b></font></td>" +
153
                "     <td bgcolor="+bgColor1+"><font face=\"Arial\" size=\"3\">"+style_title+"</font></td>" +
154
                "  </tr>" +
155
                "  <tr>" +
156
                "  </tr>";
157
            layers_html += layer_html;
158
        }
159
        if (!layers_html.equals(""))
160
            layers_html =
161
                "  <tr valign=\"top\" bgcolor=\"#FFFFFF\">" +
162
                "    <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+layers_title+"</font></b></td>" +
163
                "  </tr>" + layers_html;
164
        String dimension_html = "";
165
        if (!dimension_html.equals(""))
166
                dimension_html =
167
                        "  <tr valign=\"top\">" +
168
                        "    <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+selected_dimensions+"</font></b></td>" +
169
                        "  </tr>" + dimension_html;
170

    
171
        String format_html =
172
                "  <tr valign=\"top\" bgcolor=\"#FFFFFF\">" +
173
            "    <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+properties+"</font></b></td>" +
174
            "  </tr>" +
175
            "  <tr valign=\"top\" bgcolor="+bgColor0+">" +
176
            "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+format_title+"</b></font></td>" +
177
            "    <td><font face=\""+font+"\" size=\"3\"><font face=\""+font+"\" size=\"3\">"+format+"</font></td>" +
178
            "  </tr>" +
179
            "  <tr valign=\"top\" bgcolor="+bgColor1+">" +
180
            "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+srs_title+"</font></b></td>" +
181
            "    <td><font face=\""+font+"\" size=\"3\">"+srs+"</font></td>" +
182
            "  </tr>";
183

    
184
        String html =
185

    
186
            "<html>" +
187
            "<body>" +
188
            "<table align=\"center\" width=\"437\" height=\"156\" border=\"0\" cellpadding=\"4\" cellspacing=\"4\">" +
189
            "  <tr valign=\"top\" bgcolor=\"#FFFFFF\">" +
190
            "    <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+service_title+"</font></b></td>" +
191
            "  </tr>" +
192
            "  <tr valign=\"top\" bgcolor="+bgColor0+">" +
193
            "    <td width=\"92\" height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server+"</font></b></td>" +
194
            "    <td width=\"268\"><font face=\""+font+"\" size=\"3\">"+server_text+"</font></td>" +
195
            "  </tr>" +
196
            "  <tr valign=\"top\" bgcolor="+bgColor1+">" +
197
            "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server_type+"</b></font></td>" +
198
            "    <td><font face=\""+font+"\" size=\"3\">"+server_type_text+"</font></td>" +
199
            "  </tr>" +
200
            "  <tr valign=\"top\" bgcolor="+bgColor0+">" +
201
            "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server_title+"</b></font></td>" +
202
            "    <td><font face=\""+font+"\" size=\"3\"><font face=\""+font+"\" size=\"3\">"+server_title_text+"</font></td>" +
203
            "  </tr>" +
204
            "  <tr valign=\"top\" bgcolor="+bgColor1+">" +
205
            "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server_abstract+"</font></b></td>" +
206
            "    <td><font face=\""+font+"\" size=\"3\">"+server_abstract_text+"</font></td>" +
207
            "  </tr>" +
208

    
209
            "  <tr>" +
210
            "  </tr>" +
211
            layers_html +
212
            dimension_html +
213
            format_html +
214
            "</table>" +
215
            "</body>" +
216
            "</html>";
217

    
218
        getEditor().setContentType("text/html");
219
        getEditor().setText(html);
220
    }
221
}