root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / gui / BaseView.java @ 7738
History | View | Annotate | Download (5.53 KB)
1 | 7392 | sbayarri | /* 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.view.IProjectView; |
||
58 | 7738 | jaume | import com.iver.cit.gvsig.project.documents.view.MapOverview; |
59 | 7392 | sbayarri | import com.iver.cit.gvsig.project.documents.view.toc.gui.TOC; |
60 | import com.iver.utiles.exceptionHandling.ExceptionListener; |
||
61 | |||
62 | //import javax.swing.JSplitPane;
|
||
63 | //import com.iver.cit.gvsig.gui.panels.MapOverViewPalette;
|
||
64 | //import java.util.HashMap;
|
||
65 | |||
66 | 7414 | sbayarri | public abstract class BaseView extends JPanel implements IView, |
67 | 7392 | sbayarri | IWindowListener, IWindowTransform, SingletonWindow { |
68 | |||
69 | protected MapControl m_MapControl;
|
||
70 | protected MapOverview m_MapLoc;
|
||
71 | |||
72 | // store the properties of the window
|
||
73 | protected WindowInfo m_viewInfo = null; |
||
74 | |||
75 | /** DOCUMENT ME! */
|
||
76 | protected TOC m_TOC;
|
||
77 | protected IProjectView modelo;
|
||
78 | protected ViewExceptionListener mapControlExceptionListener = new ViewExceptionListener(); |
||
79 | |||
80 | protected boolean isPalette=false; |
||
81 | protected MapOverViewPalette movp;
|
||
82 | protected JSplitPane tempMainSplit; |
||
83 | |||
84 | // OVERRIDE THESE
|
||
85 | public void windowActivated() {} |
||
86 | public void toPalette() {} |
||
87 | public void restore() {} |
||
88 | |||
89 | |||
90 | /**
|
||
91 | * Creates a new View object.
|
||
92 | */
|
||
93 | public BaseView() {
|
||
94 | |||
95 | } |
||
96 | |||
97 | /**
|
||
98 | * This method is used to get <strong>an initial</strong> ViewInfo object
|
||
99 | * for this View. It is not intended to retrieve the ViewInfo object in a
|
||
100 | * later time. <strong>Use PluginServices.getMDIManager().getViewInfo(view)
|
||
101 | * to retrieve the ViewInfo object at any time after the creation of the
|
||
102 | * object.
|
||
103 | *
|
||
104 | * @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
|
||
105 | */
|
||
106 | public WindowInfo getWindowInfo() {
|
||
107 | if (m_viewInfo == null) |
||
108 | { |
||
109 | m_viewInfo = new WindowInfo(WindowInfo.ICONIFIABLE | WindowInfo.RESIZABLE |
|
||
110 | WindowInfo.MAXIMIZABLE); |
||
111 | |||
112 | m_viewInfo.setWidth(500);
|
||
113 | m_viewInfo.setHeight(300);
|
||
114 | m_viewInfo.setTitle(PluginServices.getText(this, "Vista") + " : " + |
||
115 | 7414 | sbayarri | modelo.getName()); |
116 | 7392 | sbayarri | } |
117 | return m_viewInfo;
|
||
118 | } |
||
119 | |||
120 | /**
|
||
121 | * @see com.iver.andami.ui.mdiManager.IWindowListener#windowClosed()
|
||
122 | */
|
||
123 | public void windowClosed() { |
||
124 | if (movp!=null) |
||
125 | PluginServices.getMDIManager().closeWindow(movp); |
||
126 | ///PluginServices.getMainFrame().getStatusBar().setMessage("1","");
|
||
127 | } |
||
128 | |||
129 | /**
|
||
130 | * DOCUMENT ME!
|
||
131 | *
|
||
132 | * @return DOCUMENT ME!
|
||
133 | */
|
||
134 | public IProjectView getModel() {
|
||
135 | return modelo;
|
||
136 | } |
||
137 | |||
138 | /**
|
||
139 | * DOCUMENT ME!
|
||
140 | *
|
||
141 | * @return DOCUMENT ME!
|
||
142 | */
|
||
143 | public MapOverview getMapOverview() {
|
||
144 | return m_MapLoc;
|
||
145 | } |
||
146 | |||
147 | /**
|
||
148 | * DOCUMENT ME!
|
||
149 | *
|
||
150 | * @return DOCUMENT ME!
|
||
151 | */
|
||
152 | public MapControl getMapControl() {
|
||
153 | return m_MapControl;
|
||
154 | } |
||
155 | |||
156 | /**
|
||
157 | * DOCUMENT ME!
|
||
158 | *
|
||
159 | * @return DOCUMENT ME!
|
||
160 | */
|
||
161 | public TOC getTOC() {
|
||
162 | return m_TOC;
|
||
163 | } |
||
164 | |||
165 | /* (non-Javadoc)
|
||
166 | * @see com.iver.mdiApp.ui.MDIManager.SingletonView#getModel()
|
||
167 | */
|
||
168 | |||
169 | public Object getWindowModel() { |
||
170 | return modelo;
|
||
171 | } |
||
172 | |||
173 | /**
|
||
174 | * This method is used to get <strong>an initial</strong> ViewInfo object
|
||
175 | * for this View. It is not intended to retrieve the ViewInfo object in a
|
||
176 | * later time. <strong>Use PluginServices.getMDIManager().getViewInfo(view)
|
||
177 | * to retrieve the ViewInfo object at any time after the creation of the
|
||
178 | * object.
|
||
179 | *
|
||
180 | * @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
|
||
181 | */
|
||
182 | |||
183 | public boolean isPalette() { |
||
184 | return isPalette;
|
||
185 | } |
||
186 | |||
187 | /**
|
||
188 | * DOCUMENT ME!
|
||
189 | */
|
||
190 | public void repaintMap() { |
||
191 | m_MapControl.drawMap(false);
|
||
192 | } |
||
193 | |||
194 | public class ViewExceptionListener implements ExceptionListener { |
||
195 | |||
196 | /**
|
||
197 | * @see com.iver.cit.gvsig.fmap.ExceptionListener#exceptionThrown(java.lang.Throwable)
|
||
198 | */
|
||
199 | public void exceptionThrown(Throwable t) { |
||
200 | NotificationManager.addError(t.getMessage(), t); |
||
201 | } |
||
202 | |||
203 | } |
||
204 | |||
205 | /**
|
||
206 | * @return
|
||
207 | */
|
||
208 | public BufferedImage getImage() { |
||
209 | return m_MapControl.getImage();
|
||
210 | } |
||
211 | |||
212 | public void setProjection(IProjection proj) |
||
213 | { |
||
214 | getMapControl().setProjection(proj); |
||
215 | } |
||
216 | public IProjection getProjection()
|
||
217 | { |
||
218 | return getMapControl().getProjection();
|
||
219 | } |
||
220 | |||
221 | } |