gvsig-raster / org.gvsig.raster.wms / trunk / org.gvsig.raster.wms / org.gvsig.raster.wms.app / org.gvsig.raster.wms.app.wmsclient / src / main / java / org / gvsig / raster / wms / app / wmsclient / infobypoint / MainInfoByPointDialog.java @ 1364
History | View | Annotate | Download (6.39 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 |
package org.gvsig.raster.wms.app.wmsclient.infobypoint; |
23 |
|
24 |
import java.awt.BorderLayout; |
25 |
import java.awt.Component; |
26 |
import java.awt.Dimension; |
27 |
import java.io.Reader; |
28 |
import java.util.HashMap; |
29 |
|
30 |
import javax.swing.ImageIcon; |
31 |
import javax.swing.JEditorPane; |
32 |
import javax.swing.JPanel; |
33 |
import javax.swing.JScrollPane; |
34 |
import javax.swing.event.HyperlinkEvent; |
35 |
import javax.swing.event.HyperlinkListener; |
36 |
import javax.swing.text.Document; |
37 |
import javax.swing.text.html.HTMLEditorKit; |
38 |
import javax.swing.text.html.StyleSheet; |
39 |
|
40 |
import org.gvsig.andami.IconThemeHelper; |
41 |
import org.gvsig.andami.PluginServices; |
42 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
43 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
44 |
import org.gvsig.fmap.mapcontrol.tools.CompoundBehavior; |
45 |
import org.gvsig.raster.swing.RasterSwingLocator; |
46 |
import org.gvsig.raster.swing.infobypoint.InfoByPointDataModel; |
47 |
import org.gvsig.raster.swing.infobypoint.MainInfoByPointPanel; |
48 |
import org.gvsig.raster.swing.pixelinspector.PixelInspector; |
49 |
import org.gvsig.utils.BrowserControl; |
50 |
|
51 |
/**
|
52 |
* Dialog for the information by point of a raster layer
|
53 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
54 |
*/
|
55 |
public class MainInfoByPointDialog extends JPanel implements IWindow, HyperlinkListener { |
56 |
private static final long serialVersionUID = 1L; |
57 |
private MainInfoByPointPanel mainPanel = null; |
58 |
private JScrollPane scroll = null; |
59 |
private JPanel wmsInfo = null; |
60 |
private JEditorPane jeditor = null; |
61 |
|
62 |
public MainInfoByPointDialog() {
|
63 |
setLayout(new BorderLayout()); |
64 |
add((Component)getMainPanel(), BorderLayout.WEST); |
65 |
add((Component)getWMSInfoPanel(), BorderLayout.CENTER); |
66 |
} |
67 |
|
68 |
public MainInfoByPointPanel getMainPanel() {
|
69 |
if(mainPanel == null) { |
70 |
HashMap<String, String> translations = new HashMap<String, String>(); |
71 |
translations.put("info", PluginServices.getText(this, "info")); |
72 |
translations.put("view", PluginServices.getText(this, "view")); |
73 |
translations.put("layer_list", PluginServices.getText(this, "layer_list")); |
74 |
translations.put("band_values", PluginServices.getText(this, "band_values")); |
75 |
translations.put("pixel_point", PluginServices.getText(this, "pixel_point")); |
76 |
translations.put("view_point", PluginServices.getText(this, "view_point")); |
77 |
translations.put("world_point", PluginServices.getText(this, "world_point")); |
78 |
translations.put("bands", PluginServices.getText(this, "bands")); |
79 |
translations.put("colors", PluginServices.getText(this, "colors")); |
80 |
translations.put("coords", PluginServices.getText(this, "coords")); |
81 |
translations.put("lat", PluginServices.getText(this, "lat")); |
82 |
translations.put("long", PluginServices.getText(this, "long")); |
83 |
translations.put("red", PluginServices.getText(this, "red")); |
84 |
translations.put("green", PluginServices.getText(this, "green")); |
85 |
translations.put("blue", PluginServices.getText(this, "blue")); |
86 |
HashMap<String, ImageIcon> icons = new HashMap<String, ImageIcon>(); |
87 |
icons.put("forward-icon", IconThemeHelper.getImageIcon("forward-icon")); |
88 |
icons.put("backward-icon", IconThemeHelper.getImageIcon("backward-icon")); |
89 |
mainPanel = RasterSwingLocator.getSwingManager().createInfoByPointPanel( |
90 |
translations, icons, null);
|
91 |
((JPanel)mainPanel).setPreferredSize(new Dimension(230, 0)); |
92 |
} |
93 |
return mainPanel;
|
94 |
} |
95 |
|
96 |
private JPanel getWMSInfoPanel() { |
97 |
if(wmsInfo == null) { |
98 |
wmsInfo = new JPanel(); |
99 |
wmsInfo.setLayout(new BorderLayout()); |
100 |
jeditor = new JEditorPane(); |
101 |
scroll = new JScrollPane(jeditor); |
102 |
jeditor.addHyperlinkListener(this);
|
103 |
jeditor.setEditable(false);
|
104 |
wmsInfo.add(scroll, BorderLayout.CENTER);
|
105 |
} |
106 |
return wmsInfo;
|
107 |
} |
108 |
|
109 |
public void setWMSInfoText(String text, String type) { |
110 |
if(type.equals("text/html")) { |
111 |
HTMLEditorKit kit = new HTMLEditorKit(); |
112 |
jeditor.setEditorKit(kit); |
113 |
|
114 |
if(text.contains("<style") && text.contains("</style>")) { |
115 |
int initIndex = text.indexOf("<style"); |
116 |
int endIndex = text.indexOf("</style>"); |
117 |
text = text.substring(0, initIndex) + text.substring(endIndex + 8, text.length()); |
118 |
} |
119 |
|
120 |
StyleSheet s = kit.getStyleSheet();
|
121 |
s.addRule("body {font-family:verdana; margin: 15px; }");
|
122 |
s.addRule("caption {background-color:#FBFFE1;font-style:normal;color:black}");
|
123 |
s.addRule("th {background-color:#D6D6D6;color:white;}");
|
124 |
s.addRule("td {background-color:#FEEDD6;color:black;}");
|
125 |
Document doc = kit.createDefaultDocument();
|
126 |
jeditor.setDocument(doc); |
127 |
} |
128 |
jeditor.setContentType(type); |
129 |
jeditor.setText(text); |
130 |
} |
131 |
|
132 |
/*
|
133 |
* (non-Javadoc)
|
134 |
* @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
|
135 |
*/
|
136 |
public WindowInfo getWindowInfo() {
|
137 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE);
|
138 |
m_viewinfo.setTitle(PluginServices.getText(this, "WMS InfoByPoint")); |
139 |
m_viewinfo.setHeight(380);
|
140 |
m_viewinfo.setWidth(500);
|
141 |
return m_viewinfo;
|
142 |
} |
143 |
|
144 |
/*
|
145 |
* (non-Javadoc)
|
146 |
* @see com.iver.andami.ui.mdiManager.IWindowListener#windowClosed()
|
147 |
*/
|
148 |
public void windowClosed() { |
149 |
CompoundBehavior.setAllControlsBehavior(InfoByWMSPointExtension.oldBehavior); |
150 |
} |
151 |
|
152 |
public Object getWindowProfile() { |
153 |
return WindowInfo.PROPERTIES_PROFILE;
|
154 |
} |
155 |
|
156 |
public InfoByPointDataModel getInfoByPointDataModel() {
|
157 |
return getMainPanel().getInfoByPointDataModel();
|
158 |
} |
159 |
|
160 |
public PixelInspector getPixelInspector() {
|
161 |
return getMainPanel().getPixelInspectorPanel();
|
162 |
} |
163 |
|
164 |
public void hyperlinkUpdate(HyperlinkEvent e) { |
165 |
if(e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { |
166 |
BrowserControl.displayURL(e.getURL().toString()); |
167 |
} |
168 |
} |
169 |
} |