svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / View.java @ 312
History | View | Annotate | Download (9.78 KB)
1 |
package com.iver.cit.gvsig.gui; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.Color; |
5 |
import java.awt.Dimension; |
6 |
import java.awt.Point; |
7 |
|
8 |
import javax.swing.JPanel; |
9 |
import javax.swing.JScrollPane; |
10 |
import javax.swing.JSplitPane; |
11 |
|
12 |
import com.iver.cit.gvsig.fmap.FMap; |
13 |
import com.iver.cit.gvsig.fmap.NewMapControl; |
14 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
15 |
import com.iver.cit.gvsig.project.ProjectView; |
16 |
import com.iver.mdiApp.App; |
17 |
import com.iver.mdiApp.Utilities; |
18 |
import com.iver.mdiApp.ui.MDIManager.SingletonView; |
19 |
import com.iver.mdiApp.ui.MDIManager.ViewInfo; |
20 |
|
21 |
|
22 |
/**
|
23 |
* DOCUMENT ME!
|
24 |
*
|
25 |
* @author vcn
|
26 |
*/
|
27 |
public class View extends JPanel implements com.iver.mdiApp.ui.MDIManager.View, |
28 |
SingletonView { |
29 |
|
30 |
/** DOCUMENT ME! */
|
31 |
private NewMapControl m_MapControl;
|
32 |
private NewMapControl m_MapLoc;
|
33 |
|
34 |
/** DOCUMENT ME! */
|
35 |
public FProjection m_Projection;
|
36 |
|
37 |
/** DOCUMENT ME! */
|
38 |
public FThemePropertiesDialog m_Themeproperties;
|
39 |
private JScrollPane jscrollTOC; |
40 |
private TOC m_TOC;
|
41 |
private ProjectView modelo = null; |
42 |
|
43 |
// private FLyrVect layerSelected;
|
44 |
private String m_selectedField = null; |
45 |
private Table table = null; |
46 |
|
47 |
private ViewInfo m_viewInfo = null; |
48 |
|
49 |
/**
|
50 |
* Creates a new View object.
|
51 |
*/
|
52 |
public View() { |
53 |
//this.setName(Utilities.getMessage(this, "Vista")+ " : "+modelo.getName());
|
54 |
this.setPreferredSize(new Dimension(500, 300)); |
55 |
initComponents(); |
56 |
//TODO Poner la herramienta por defecto
|
57 |
// m_MapControl.setTool(MapControl.ZOOM_MAS);
|
58 |
} |
59 |
|
60 |
/**
|
61 |
* DOCUMENT ME!
|
62 |
*
|
63 |
* @return DOCUMENT ME!
|
64 |
*/
|
65 |
public ProjectView getModel() {
|
66 |
return modelo;
|
67 |
} |
68 |
|
69 |
/**
|
70 |
* DOCUMENT ME!
|
71 |
*
|
72 |
* @param model DOCUMENT ME!
|
73 |
*/
|
74 |
public void setModel(ProjectView model) { |
75 |
this.modelo = model;
|
76 |
|
77 |
//Se registra como listener de seleccion de las capas vectoriales
|
78 |
FMap fmap = modelo.getMapContext(); |
79 |
|
80 |
//Se configura el mapControl
|
81 |
m_MapControl.setMapContext(fmap); |
82 |
m_MapControl.setBackground(new Color(255, 255, 255)); |
83 |
|
84 |
m_TOC.setModel(fmap); |
85 |
} |
86 |
|
87 |
/**
|
88 |
* DOCUMENT ME!
|
89 |
*
|
90 |
* @param pScreen DOCUMENT ME!
|
91 |
*/
|
92 |
private void info(Point pScreen) { |
93 |
/*
|
94 |
* TODO Definir el di?logo de informaci?n com?n
|
95 |
* para todas las capas y abrirlo desde aqu?
|
96 |
*/
|
97 |
/*
|
98 |
// OJO:
|
99 |
// El queryByPoint de las capas WMS pide el punto en coordenadas de PANTALLA,
|
100 |
// y el queryByPoint del resto de capas en coordenadas de mundo real.
|
101 |
Point2D pReal = m_MapControl.getMapContext().getViewPort().toMapPoint(pScreen);
|
102 |
|
103 |
ArrayList sel = m_TOC.getSelectedLayers();
|
104 |
|
105 |
// Denro de queryByPoint tenemos que separar los registros que vienen asociados a una
|
106 |
// capa o a otra. Supongo que lo correcto ser?a que montaramos un XML y usar el visor
|
107 |
// de XML que ha empezado Fernando.
|
108 |
// String strResul = m_MapControl.queryByPoint(pScreen,m_MapControl.toMapDistance(3),"");
|
109 |
FInfoDialog dlg = new FInfoDialog();
|
110 |
dlg.clearAll();
|
111 |
dlg.setViewModel(modelo);
|
112 |
|
113 |
FInfoDialogXML dlgXML = new FInfoDialogXML();
|
114 |
MultipleXMLContent xmlModel = new MultipleXMLContent();
|
115 |
|
116 |
// if (strResul == "" ) return;
|
117 |
String strResul;
|
118 |
|
119 |
boolean algunWMS = false;
|
120 |
boolean algunNoWMS = false;
|
121 |
|
122 |
for (int i = 0; i < m_TOC.getSelectedLayers().size(); i++) {
|
123 |
IFLayer laCapa = (IFLayer) m_TOC.getSelectedLayers().get(i);
|
124 |
|
125 |
if (laCapa instanceof FLyrWMS) {
|
126 |
algunWMS = true;
|
127 |
strResul = laCapa.QueryByPoint(pScreen,
|
128 |
m_MapControl.toMapDistance(3), "");
|
129 |
xmlModel.addXML(strResul);
|
130 |
} else {
|
131 |
algunNoWMS = true;
|
132 |
strResul = laCapa.QueryByPoint(pReal,
|
133 |
m_MapControl.toMapDistance(3), "");
|
134 |
|
135 |
String[] arraySplit = null;
|
136 |
arraySplit = strResul.split("\n");
|
137 |
|
138 |
if (arraySplit.length > 1) {
|
139 |
// System.out.println("LWS: strResul="+strResul);
|
140 |
String descrip = "";
|
141 |
|
142 |
if (laCapa.getParentLayer() != null) {
|
143 |
descrip = laCapa.getParentLayer().getName() + "_";
|
144 |
}
|
145 |
|
146 |
dlg.addLayerInfo(descrip + laCapa.getName(), strResul);
|
147 |
}
|
148 |
}
|
149 |
}
|
150 |
|
151 |
if (algunNoWMS) {
|
152 |
dlg = (FInfoDialog) App.instance.getMDIContext().addView(dlg);
|
153 |
}
|
154 |
|
155 |
if (algunWMS) {
|
156 |
try {
|
157 |
dlgXML.setModel(xmlModel);
|
158 |
dlgXML = (FInfoDialogXML) App.instance.getMDIContext().addView(dlgXML);
|
159 |
} catch (SAXException e) {
|
160 |
if (App.instance != null) {
|
161 |
App.instance.getNm().addError("No se reconoce el formato", e);
|
162 |
} else {
|
163 |
}
|
164 |
}
|
165 |
}
|
166 |
|
167 |
dlg.refresh();
|
168 |
*/
|
169 |
} |
170 |
|
171 |
/**
|
172 |
* DOCUMENT ME!
|
173 |
*
|
174 |
* @param pScreen DOCUMENT ME!
|
175 |
*/
|
176 |
private void showLink(Point pScreen) { |
177 |
//TODO implementar bien
|
178 |
/*
|
179 |
Point2D pReal = m_MapControl.getMapContext().getViewPort().toMapPoint(pScreen);
|
180 |
ArrayList sel = m_TOC.getSelectedLayers();
|
181 |
|
182 |
String strResul = m_MapControl.getMapContext().queryByPoint(pScreen,
|
183 |
m_MapControl.getMapContext().getViewPort().toMapDistance(3));
|
184 |
System.err.println("strResul = " + strResul);
|
185 |
|
186 |
URL url = Abrir.class.getClassLoader().getResource("images/" +
|
187 |
strResul.trim());
|
188 |
|
189 |
if (url == null) {
|
190 |
JOptionPane.showMessageDialog((Component) null,
|
191 |
"Fichero " + strResul + " no encontrado.", "Error",
|
192 |
JOptionPane.ERROR_MESSAGE);
|
193 |
} else {
|
194 |
ImageIcon image = new ImageIcon(url);
|
195 |
|
196 |
FImageView imageview = new FImageView(image, strResul);
|
197 |
App.instance.getMDIContext().addView(imageview);
|
198 |
}
|
199 |
*/
|
200 |
} |
201 |
|
202 |
/**
|
203 |
* DOCUMENT ME!
|
204 |
*
|
205 |
* @param s DOCUMENT ME!
|
206 |
*/
|
207 |
public void setSelectedField(String s) { |
208 |
m_selectedField = s; |
209 |
} |
210 |
|
211 |
/**
|
212 |
* DOCUMENT ME!
|
213 |
*
|
214 |
* @return DOCUMENT ME!
|
215 |
*/
|
216 |
public String getSelectedField() { |
217 |
return m_selectedField;
|
218 |
} |
219 |
|
220 |
/**
|
221 |
* DOCUMENT ME!
|
222 |
*/
|
223 |
public void openThemeProperties() { |
224 |
FMap fmap = modelo.getMapContext(); |
225 |
FLayer[] actives = fmap.getLayers().getActives();
|
226 |
|
227 |
for (int i = 0; i < actives.length; i++){ |
228 |
m_Themeproperties = new FThemePropertiesDialog(actives[i], this); |
229 |
App.instance.getMDIContext().addView(m_Themeproperties); |
230 |
} |
231 |
} |
232 |
|
233 |
/**
|
234 |
* DOCUMENT ME!
|
235 |
*/
|
236 |
private void initComponents() { //GEN-BEGIN:initComponents |
237 |
m_MapControl = new NewMapControl();
|
238 |
|
239 |
// m_MapControl.setAcceptEvents(true); Lo comento porque ya se hace en el setModel
|
240 |
m_TOC = new TOC();
|
241 |
|
242 |
JSplitPane tempMainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); |
243 |
tempMainSplit.setPreferredSize(new Dimension(500, 300)); |
244 |
|
245 |
// Ponemos el localizador
|
246 |
m_MapLoc = new NewMapControl();
|
247 |
m_MapLoc.setPreferredSize(new Dimension(150, 200)); |
248 |
|
249 |
JSplitPane tempSplitToc = new JSplitPane(JSplitPane.VERTICAL_SPLIT); |
250 |
|
251 |
tempSplitToc.setTopComponent((TOC) m_TOC); |
252 |
tempSplitToc.setBottomComponent(m_MapLoc); |
253 |
tempSplitToc.setResizeWeight(0.7);
|
254 |
|
255 |
// tempSplitToc.resetToPreferredSizes();
|
256 |
tempMainSplit.setLeftComponent(tempSplitToc); |
257 |
|
258 |
m_TOC.setVisible(true);
|
259 |
|
260 |
// m_TOC.setPreferredSize(new Dimension(150,50));
|
261 |
tempMainSplit.setRightComponent(m_MapControl); |
262 |
this.setLayout(new BorderLayout()); |
263 |
this.add(tempMainSplit, BorderLayout.CENTER); |
264 |
} |
265 |
|
266 |
/**
|
267 |
* DOCUMENT ME!
|
268 |
*/
|
269 |
public void openPropertiesWindow() { |
270 |
} |
271 |
|
272 |
/**
|
273 |
* DOCUMENT ME!
|
274 |
*/
|
275 |
public void openQueryWindow() { |
276 |
} |
277 |
|
278 |
/**
|
279 |
* DOCUMENT ME!
|
280 |
*
|
281 |
* @return DOCUMENT ME!
|
282 |
*/
|
283 |
public NewMapControl getMapOverview() {
|
284 |
return m_MapLoc;
|
285 |
} |
286 |
|
287 |
/**
|
288 |
* DOCUMENT ME!
|
289 |
*
|
290 |
* @return DOCUMENT ME!
|
291 |
*/
|
292 |
public NewMapControl getMapControl() {
|
293 |
return m_MapControl;
|
294 |
} |
295 |
|
296 |
/**
|
297 |
* DOCUMENT ME!
|
298 |
*
|
299 |
* @return DOCUMENT ME!
|
300 |
*/
|
301 |
public TOC getTOC() {
|
302 |
return m_TOC;
|
303 |
} |
304 |
|
305 |
/**
|
306 |
* DOCUMENT ME!
|
307 |
*
|
308 |
* @return DOCUMENT ME!
|
309 |
*/
|
310 |
public String getViewName() { |
311 |
return ""; |
312 |
} |
313 |
|
314 |
/**
|
315 |
* DOCUMENT ME!
|
316 |
*
|
317 |
* @param viewName DOCUMENT ME!
|
318 |
*/
|
319 |
public void setViewName(String viewName) { |
320 |
} |
321 |
|
322 |
/**
|
323 |
* DOCUMENT ME!
|
324 |
*/
|
325 |
public void repaintMap() { |
326 |
m_MapControl.drawMap(); |
327 |
} |
328 |
|
329 |
/* (non-Javadoc)
|
330 |
* @see com.iver.mdiApp.ui.MDIManager.SingletonView#getModel()
|
331 |
*/
|
332 |
public Object getViewModel() { |
333 |
return modelo;
|
334 |
} |
335 |
|
336 |
/**
|
337 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
338 |
*/
|
339 |
public ViewInfo getViewInfo() {
|
340 |
// Si hacemos viewInfo una variable privada y la creamos
|
341 |
// solo la primera vez, despu?s podremos modificar los valores
|
342 |
// en tiempo de ejecuci?n, no se chafar?n cada vez que
|
343 |
// llamemos a getViewInfo
|
344 |
if (m_viewInfo == null) |
345 |
{ |
346 |
m_viewInfo = new ViewInfo();
|
347 |
m_viewInfo.setFeatures(ViewInfo.ICONIFIABLE | ViewInfo.RESIZABLE | |
348 |
ViewInfo.MAXIMIZABLE); |
349 |
|
350 |
m_viewInfo.setWidth(500);
|
351 |
m_viewInfo.setHeight(300);
|
352 |
} |
353 |
m_viewInfo.setTitle(Utilities.getMessage(this, "Vista") + " : " + |
354 |
modelo.getName()); |
355 |
|
356 |
return m_viewInfo;
|
357 |
|
358 |
} |
359 |
|
360 |
/**
|
361 |
* @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
|
362 |
*/
|
363 |
public void viewActivated() { |
364 |
// getMapControl().status = MapControl.DESACTUALIZADO;
|
365 |
// getMapControl().repaint();
|
366 |
} |
367 |
|
368 |
/**
|
369 |
* @return
|
370 |
*/
|
371 |
public Object getImage() { |
372 |
return m_MapControl.getImage();
|
373 |
} |
374 |
} |