svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / gui / BaseView.java @ 9199
History | View | Annotate | Download (8.25 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig.project.documents.view.gui; |
42 |
|
43 |
import java.awt.image.BufferedImage; |
44 |
|
45 |
import javax.swing.JPanel; |
46 |
import javax.swing.JSplitPane; |
47 |
|
48 |
import org.cresques.cts.IProjection; |
49 |
|
50 |
import com.iver.andami.PluginServices; |
51 |
import com.iver.andami.messages.NotificationManager; |
52 |
import com.iver.andami.ui.mdiManager.IWindowListener; |
53 |
import com.iver.andami.ui.mdiManager.IWindowTransform; |
54 |
import com.iver.andami.ui.mdiManager.SingletonWindow; |
55 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
56 |
import com.iver.cit.gvsig.fmap.MapControl; |
57 |
import com.iver.cit.gvsig.project.documents.gui.IDocumentWindow; |
58 |
import com.iver.cit.gvsig.project.documents.gui.WindowData; |
59 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
60 |
import com.iver.cit.gvsig.project.documents.view.MapOverview; |
61 |
import com.iver.cit.gvsig.project.documents.view.toc.gui.TOC; |
62 |
import com.iver.utiles.exceptionHandling.ExceptionListener; |
63 |
|
64 |
//import javax.swing.JSplitPane;
|
65 |
//import com.iver.cit.gvsig.gui.panels.MapOverViewPalette;
|
66 |
//import java.util.HashMap;
|
67 |
|
68 |
public abstract class BaseView extends JPanel implements IView, |
69 |
IWindowListener, IWindowTransform, SingletonWindow, IDocumentWindow { |
70 |
|
71 |
protected MapControl m_MapControl;
|
72 |
protected MapOverview m_MapLoc;
|
73 |
|
74 |
// store the properties of the window
|
75 |
protected WindowInfo m_viewInfo = null; |
76 |
|
77 |
/** DOCUMENT ME! */
|
78 |
protected TOC m_TOC;
|
79 |
protected IProjectView modelo;
|
80 |
protected ViewExceptionListener mapControlExceptionListener = new ViewExceptionListener(); |
81 |
|
82 |
protected boolean isPalette=false; |
83 |
protected MapOverViewPalette movp;
|
84 |
protected JSplitPane tempMainSplit, tempSplitToc=null; |
85 |
|
86 |
|
87 |
protected WindowData windowData = null; |
88 |
|
89 |
// OVERRIDE THESE
|
90 |
public void windowActivated() {} |
91 |
public void toPalette() {} |
92 |
public void restore() {} |
93 |
|
94 |
|
95 |
/**
|
96 |
* Creates a new View object. Before using it, it must be initialized
|
97 |
* using the <code>initialize()</code> method.
|
98 |
*
|
99 |
* @see initialize()
|
100 |
*/
|
101 |
public BaseView() {
|
102 |
|
103 |
} |
104 |
|
105 |
/**
|
106 |
* Create the internal componentes and populate the window with them.
|
107 |
* If the layout properties were set using the
|
108 |
* <code>setWindowData(WindowData)</code>
|
109 |
* method, the window will be populated according to this
|
110 |
* properties.
|
111 |
*/
|
112 |
public void initialize() {} |
113 |
|
114 |
/**
|
115 |
* This method is used to get <strong>an initial</strong> ViewInfo object
|
116 |
* for this View. It is not intended to retrieve the ViewInfo object in a
|
117 |
* later time. <strong>Use PluginServices.getMDIManager().getViewInfo(view)
|
118 |
* to retrieve the ViewInfo object at any time after the creation of the
|
119 |
* object.
|
120 |
*
|
121 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
|
122 |
*/
|
123 |
public WindowInfo getWindowInfo() {
|
124 |
if (m_viewInfo == null) |
125 |
{ |
126 |
m_viewInfo = new WindowInfo(WindowInfo.ICONIFIABLE | WindowInfo.RESIZABLE |
|
127 |
WindowInfo.MAXIMIZABLE); |
128 |
|
129 |
m_viewInfo.setWidth(500);
|
130 |
m_viewInfo.setHeight(300);
|
131 |
m_viewInfo.setTitle(PluginServices.getText(this, "Vista") + " : " + |
132 |
modelo.getName()); |
133 |
} |
134 |
return m_viewInfo;
|
135 |
} |
136 |
|
137 |
/**
|
138 |
* @see com.iver.andami.ui.mdiManager.IWindowListener#windowClosed()
|
139 |
*/
|
140 |
public void windowClosed() { |
141 |
if (movp!=null) |
142 |
PluginServices.getMDIManager().closeWindow(movp); |
143 |
///PluginServices.getMainFrame().getStatusBar().setMessage("1","");
|
144 |
|
145 |
if (modelo != null) |
146 |
modelo.storeWindowData(getWindowData()); |
147 |
} |
148 |
|
149 |
/**
|
150 |
* DOCUMENT ME!
|
151 |
*
|
152 |
* @return DOCUMENT ME!
|
153 |
*/
|
154 |
public IProjectView getModel() {
|
155 |
return modelo;
|
156 |
} |
157 |
|
158 |
/**
|
159 |
* DOCUMENT ME!
|
160 |
*
|
161 |
* @return DOCUMENT ME!
|
162 |
*/
|
163 |
public MapOverview getMapOverview() {
|
164 |
return m_MapLoc;
|
165 |
} |
166 |
|
167 |
/**
|
168 |
* DOCUMENT ME!
|
169 |
*
|
170 |
* @return DOCUMENT ME!
|
171 |
*/
|
172 |
public MapControl getMapControl() {
|
173 |
return m_MapControl;
|
174 |
} |
175 |
|
176 |
/**
|
177 |
* DOCUMENT ME!
|
178 |
*
|
179 |
* @return DOCUMENT ME!
|
180 |
*/
|
181 |
public TOC getTOC() {
|
182 |
return m_TOC;
|
183 |
} |
184 |
|
185 |
/* (non-Javadoc)
|
186 |
* @see com.iver.mdiApp.ui.MDIManager.SingletonView#getModel()
|
187 |
*/
|
188 |
|
189 |
public Object getWindowModel() { |
190 |
return modelo;
|
191 |
} |
192 |
|
193 |
/**
|
194 |
* This method is used to get <strong>an initial</strong> ViewInfo object
|
195 |
* for this View. It is not intended to retrieve the ViewInfo object in a
|
196 |
* later time. <strong>Use PluginServices.getMDIManager().getViewInfo(view)
|
197 |
* to retrieve the ViewInfo object at any time after the creation of the
|
198 |
* object.
|
199 |
*
|
200 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
|
201 |
*/
|
202 |
|
203 |
public boolean isPalette() { |
204 |
return isPalette;
|
205 |
} |
206 |
|
207 |
/**
|
208 |
* DOCUMENT ME!
|
209 |
*/
|
210 |
public void repaintMap() { |
211 |
m_MapControl.drawMap(false);
|
212 |
} |
213 |
|
214 |
public class ViewExceptionListener implements ExceptionListener { |
215 |
|
216 |
/**
|
217 |
* @see com.iver.cit.gvsig.fmap.ExceptionListener#exceptionThrown(java.lang.Throwable)
|
218 |
*/
|
219 |
public void exceptionThrown(Throwable t) { |
220 |
NotificationManager.addError(t.getMessage(), t); |
221 |
} |
222 |
|
223 |
} |
224 |
|
225 |
/**
|
226 |
* @return
|
227 |
*/
|
228 |
public BufferedImage getImage() { |
229 |
return m_MapControl.getImage();
|
230 |
} |
231 |
|
232 |
public void setProjection(IProjection proj) |
233 |
{ |
234 |
getMapControl().setProjection(proj); |
235 |
} |
236 |
public IProjection getProjection()
|
237 |
{ |
238 |
return getMapControl().getProjection();
|
239 |
} |
240 |
|
241 |
public WindowData getWindowData() {
|
242 |
updateWindowData(); |
243 |
return windowData;
|
244 |
} |
245 |
|
246 |
private void updateWindowData() { |
247 |
if (windowData == null) |
248 |
windowData = new WindowData();
|
249 |
windowData.set("MainWindow.X", Integer.toString(this.getX())); |
250 |
windowData.set("MainWindow.Y", Integer.toString(this.getY())); |
251 |
windowData.set("MainWindow.Width", Integer.toString(this.getWidth())); |
252 |
windowData.set("MainWindow.Height", Integer.toString(this.getHeight())); |
253 |
|
254 |
windowData.set("MainDivider.Location", Integer.toString(tempMainSplit.getDividerLocation())); |
255 |
windowData.set("MainDivider.X", Integer.toString(tempMainSplit.getX())); |
256 |
windowData.set("MainDivider.Y", Integer.toString(tempMainSplit.getY())); |
257 |
windowData.set("MainDivider.Width", Integer.toString(tempMainSplit.getWidth())); |
258 |
windowData.set("MainDivider.Height", Integer.toString(tempMainSplit.getHeight())); |
259 |
|
260 |
if (isPalette())
|
261 |
windowData.set("GraphicLocator.isPalette", "true"); |
262 |
else {
|
263 |
windowData.set("GraphicLocator.isPalette", "false"); |
264 |
if (tempSplitToc!=null) { |
265 |
windowData.set("TOCDivider.Location", Integer.toString(tempSplitToc.getDividerLocation())); |
266 |
windowData.set("TOCDivider.X", Integer.toString(tempSplitToc.getX())); |
267 |
windowData.set("TOCDivider.Y", Integer.toString(tempSplitToc.getY())); |
268 |
windowData.set("TOCDivider.Width", Integer.toString(tempSplitToc.getWidth())); |
269 |
windowData.set("TOCDivider.Height", Integer.toString(tempSplitToc.getHeight())); |
270 |
} |
271 |
} |
272 |
if (m_TOC!=null) { |
273 |
windowData.set("TOC.Width", Integer.toString(m_TOC.getWidth())); |
274 |
windowData.set("TOC.Height", Integer.toString(m_TOC.getHeight())); |
275 |
} |
276 |
if (m_MapControl!=null) { |
277 |
windowData.set("MapControl.Width", Integer.toString(m_MapControl.getWidth())); |
278 |
windowData.set("MapControl.Height", Integer.toString(m_MapControl.getHeight())); |
279 |
} |
280 |
if (m_MapLoc!=null) { |
281 |
windowData.set("GraphicLocator.Width", Integer.toString(m_MapLoc.getWidth())); |
282 |
windowData.set("GraphicLocator.Height", Integer.toString(m_MapLoc.getHeight())); |
283 |
} |
284 |
|
285 |
} |
286 |
|
287 |
public void setWindowData(WindowData data) { |
288 |
windowData = data; |
289 |
} |
290 |
} |