Revision 3714 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/View.java
View.java | ||
---|---|---|
46 | 46 |
import java.awt.image.BufferedImage; |
47 | 47 |
import java.beans.PropertyChangeEvent; |
48 | 48 |
import java.beans.PropertyChangeListener; |
49 |
import java.util.HashMap; |
|
50 |
import java.util.Iterator; |
|
49 | 51 |
|
52 |
import javax.swing.FocusManager; |
|
50 | 53 |
import javax.swing.JPanel; |
51 |
import javax.swing.JScrollPane; |
|
52 | 54 |
import javax.swing.JSplitPane; |
53 | 55 |
|
54 | 56 |
import org.cresques.cts.IProjection; |
... | ... | |
64 | 66 |
import com.iver.cit.gvsig.fmap.MapControl; |
65 | 67 |
import com.iver.cit.gvsig.fmap.ViewPortListener; |
66 | 68 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
67 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
69 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
|
70 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
|
68 | 71 |
import com.iver.cit.gvsig.fmap.tools.ZoomOutRightButtonListener; |
69 | 72 |
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior; |
70 | 73 |
import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior; |
... | ... | |
73 | 76 |
import com.iver.cit.gvsig.fmap.tools.Behavior.PolygonBehavior; |
74 | 77 |
import com.iver.cit.gvsig.fmap.tools.Behavior.PolylineBehavior; |
75 | 78 |
import com.iver.cit.gvsig.fmap.tools.Behavior.RectangleBehavior; |
76 |
import com.iver.cit.gvsig.gui.thememanager.FThemeManagerWindow; |
|
77 | 79 |
import com.iver.cit.gvsig.gui.toc.TOC; |
78 | 80 |
import com.iver.cit.gvsig.gui.toolListeners.AreaListener; |
79 | 81 |
import com.iver.cit.gvsig.gui.toolListeners.InfoListener; |
... | ... | |
89 | 91 |
import com.iver.cit.gvsig.gui.toolListeners.ZoomOutListener; |
90 | 92 |
import com.iver.cit.gvsig.gui.toolListeners.ZoomPixelCursorListener; |
91 | 93 |
import com.iver.cit.gvsig.project.ProjectView; |
94 |
import com.iver.utiles.console.JConsole; |
|
95 |
import com.iver.utiles.console.ResponseListener; |
|
92 | 96 |
import com.iver.utiles.exceptionHandling.ExceptionListener; |
93 | 97 |
|
94 | 98 |
|
... | ... | |
105 | 109 |
private MapOverview m_MapLoc; |
106 | 110 |
|
107 | 111 |
/** DOCUMENT ME! */ |
108 |
private FThemePropertiesDialog m_Themeproperties; |
|
109 |
private FThemeManagerWindow fThemeManagerWindow; |
|
110 |
private JScrollPane jscrollTOC; |
|
111 | 112 |
private TOC m_TOC; |
112 | 113 |
private ProjectView modelo; |
113 |
private Table table = null; |
|
114 |
private ViewExceptionListener mapControlExceptionListener = new ViewExceptionListener(); |
|
115 |
|
|
116 |
/** |
|
114 |
private ViewExceptionListener mapControlExceptionListener = new ViewExceptionListener(); |
|
115 |
private JConsole console; |
|
116 |
private JSplitPane split=new JSplitPane(JSplitPane.VERTICAL_SPLIT); |
|
117 |
private ResponseAdapter consoleResponseAdapter = new ResponseAdapter(); |
|
118 |
/** |
|
117 | 119 |
* Creates a new View object. |
118 | 120 |
*/ |
119 | 121 |
public View() { |
120 | 122 |
//this.setName(Utilities.getMessage(this, "Vista")+ " : "+modelo.getName()); |
121 | 123 |
// this.setPreferredSize(new Dimension(500, 300)); |
122 | 124 |
initComponents(); |
125 |
hideConsole(); |
|
123 | 126 |
} |
124 | 127 |
|
125 | 128 |
/** |
... | ... | |
141 | 144 |
//Se registra como listener de cambios en FMap |
142 | 145 |
FMap fmap = modelo.getMapContext(); |
143 | 146 |
|
144 |
//Se configura el mapControl |
|
147 |
FLayers layers=fmap.getLayers(); |
|
148 |
for (int i=0;i<layers.getLayersCount();i++){ |
|
149 |
if (layers.getLayer(i).isEditing() && layers.getLayer(i) instanceof FLyrVect){ |
|
150 |
this.showConsole(); |
|
151 |
} |
|
152 |
} |
|
153 |
|
|
154 |
//Se configura el mapControl |
|
145 | 155 |
m_MapControl.setMapContext(fmap); |
146 | 156 |
m_TOC.setMapContext(fmap); |
147 | 157 |
m_MapControl.setBackground(new Color(255, 255, 255)); |
... | ... | |
158 | 168 |
if (m_MapControl.getViewPort() != null){ |
159 | 169 |
m_MapControl.getViewPort().addViewPortListener(new ViewPortListener() { |
160 | 170 |
public void extentChanged(ExtentEvent e) { |
161 |
if (PluginServices.getMainFrame() != null){
|
|
171 |
if (PluginServices.getMainFrame() != null){ |
|
162 | 172 |
PluginServices.getMainFrame().getStatusBar().setMessage("6", "1:"+m_MapControl.getMapContext().getScaleView()); |
163 | 173 |
PluginServices.getMainFrame().getStatusBar().setMessage("7", getMapControl().getViewPort().getProjection().getAbrev()); |
164 | 174 |
} |
... | ... | |
166 | 176 |
|
167 | 177 |
public void backColorChanged(ColorEvent e) { |
168 | 178 |
} |
169 |
});
|
|
179 |
}); |
|
170 | 180 |
} |
171 | 181 |
} |
182 |
public JConsole getConsolePanel(){ |
|
183 |
if (console==null){ |
|
184 |
console=new JConsole(); |
|
185 |
} |
|
186 |
return console; |
|
187 |
} |
|
172 | 188 |
|
189 |
|
|
190 |
public void addConsoleListener(String prefix, ResponseListener listener) { |
|
191 |
consoleResponseAdapter.putSpaceListener(prefix, listener); |
|
192 |
|
|
193 |
} |
|
194 |
|
|
195 |
public void removeConsoleListener(ResponseListener listener) { |
|
196 |
consoleResponseAdapter.deleteListener(listener); |
|
197 |
|
|
198 |
} |
|
199 |
|
|
200 |
public void focusConsole(String text) { |
|
201 |
getConsolePanel().addResponseText(text); |
|
202 |
FocusManager fm=FocusManager.getCurrentManager(); |
|
203 |
fm.focusNextComponent(getConsolePanel()); |
|
204 |
|
|
205 |
} |
|
206 |
|
|
207 |
public void hideConsole() { |
|
208 |
split.setDividerLocation(1.0); |
|
209 |
|
|
210 |
} |
|
211 |
|
|
212 |
public void showConsole() { |
|
213 |
split.setDividerLocation(0.8); |
|
214 |
|
|
215 |
} |
|
216 |
private class ResponseAdapter implements ResponseListener{ |
|
217 |
|
|
218 |
private HashMap spaceListener = new HashMap(); |
|
219 |
|
|
220 |
public void putSpaceListener(String namespace, ResponseListener listener){ |
|
221 |
spaceListener.put(namespace, listener); |
|
222 |
} |
|
223 |
|
|
224 |
/** |
|
225 |
* @see com.iver.utiles.console.ResponseListener#acceptResponse(java.lang.String) |
|
226 |
*/ |
|
227 |
public void acceptResponse(String response) { |
|
228 |
boolean nameSpace = false; |
|
229 |
int n = -1; |
|
230 |
if (response != null){ |
|
231 |
if ((n = response.indexOf(':')) != -1){ |
|
232 |
nameSpace = true; |
|
233 |
} |
|
234 |
} |
|
235 |
|
|
236 |
if (nameSpace){ |
|
237 |
ResponseListener listener = (ResponseListener) spaceListener.get(response.substring(0, n)); |
|
238 |
if (listener != null) |
|
239 |
listener.acceptResponse(response.substring(n+1)); |
|
240 |
}else{ |
|
241 |
Iterator i = spaceListener.values().iterator(); |
|
242 |
while (i.hasNext()) { |
|
243 |
ResponseListener listener = (ResponseListener) i.next(); |
|
244 |
listener.acceptResponse(response); |
|
245 |
} |
|
246 |
} |
|
247 |
} |
|
248 |
|
|
249 |
/** |
|
250 |
* @param listener |
|
251 |
*/ |
|
252 |
public void deleteListener(ResponseListener listener) { |
|
253 |
Iterator i = spaceListener.keySet().iterator(); |
|
254 |
while (i.hasNext()) { |
|
255 |
String namespace = (String) i.next(); |
|
256 |
ResponseListener l = (ResponseListener) spaceListener.get(namespace); |
|
257 |
if (l == listener){ |
|
258 |
spaceListener.remove(namespace); |
|
259 |
} |
|
260 |
} |
|
261 |
} |
|
262 |
|
|
263 |
} |
|
264 |
|
|
265 |
|
|
266 |
|
|
267 |
|
|
173 | 268 |
/** |
174 |
* DOCUMENT ME! |
|
175 |
*/ |
|
176 |
private void initComponents() { //GEN-BEGIN:initComponents |
|
177 |
m_MapControl = new MapControl(); //Default is paintEnabled = false. Remember to activate it |
|
269 |
* DOCUMENT ME! |
|
270 |
*/ |
|
271 |
private void initComponents() { // GEN-BEGIN:initComponents |
|
272 |
m_MapControl = new MapControl(); // Default is paintEnabled = false. |
|
273 |
// Remember to activate it |
|
178 | 274 |
m_MapControl.addExceptionListener(mapControlExceptionListener); |
179 | 275 |
// modelo.setMapContext(m_MapControl.getMapContext()); |
180 | 276 |
|
181 | 277 |
// m_MapControl.setAcceptEvents(true); Lo comento porque ya se hace en el setModel |
182 | 278 |
m_TOC = new TOC(); |
183 |
|
|
184 | 279 |
JSplitPane tempMainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); |
185 | 280 |
tempMainSplit.setPreferredSize(new Dimension(500, 300)); |
186 | 281 |
|
... | ... | |
192 | 287 |
tempSplitToc.setTopComponent((TOC) m_TOC); |
193 | 288 |
tempSplitToc.setBottomComponent(m_MapLoc); |
194 | 289 |
tempSplitToc.setResizeWeight(0.7); |
195 |
|
|
196 |
// tempSplitToc.resetToPreferredSizes(); |
|
197 | 290 |
tempMainSplit.setLeftComponent(tempSplitToc); |
198 | 291 |
|
199 | 292 |
m_TOC.setVisible(true); |
293 |
tempMainSplit.setRightComponent(m_MapControl); |
|
200 | 294 |
|
201 |
// m_TOC.setPreferredSize(new Dimension(150,50)); |
|
202 |
tempMainSplit.setRightComponent(m_MapControl); |
|
295 |
|
|
296 |
|
|
297 |
split.setBottomComponent(getConsolePanel()); |
|
298 |
split.setTopComponent(tempMainSplit); |
|
299 |
//split.setResizeWeight(0.9); |
|
203 | 300 |
this.setLayout(new BorderLayout()); |
204 |
this.add(tempMainSplit, BorderLayout.CENTER);
|
|
301 |
this.add(split, BorderLayout.CENTER);
|
|
205 | 302 |
|
303 |
|
|
304 |
|
|
305 |
|
|
206 | 306 |
//Listener de eventos de movimiento que pone las coordenadas del rat?n en la barra de estado |
207 | 307 |
StatusBarListener sbl = new StatusBarListener(m_MapControl); |
208 |
|
|
308 |
|
|
209 | 309 |
// Zoom out (pinchas y el mapa se centra y te muestra m?s). |
210 | 310 |
// No es dibujando un rect?ngulo, es solo pinchando. |
211 | 311 |
|
212 | 312 |
ZoomOutListener zol = new ZoomOutListener(m_MapControl); |
213 | 313 |
m_MapControl.addMapTool("zoomOut", new Behavior[]{new PointBehavior(zol), new MouseMovementBehavior(sbl)}); |
214 |
|
|
314 |
|
|
215 | 315 |
// pan |
216 | 316 |
|
217 | 317 |
PanListener pl = new PanListener(m_MapControl); |
218 | 318 |
m_MapControl.addMapTool("pan", new Behavior[]{new MoveBehavior(pl), new MouseMovementBehavior(sbl)}); |
219 |
|
|
319 |
|
|
220 | 320 |
// Medir |
221 | 321 |
|
222 | 322 |
MeasureListener mli = new MeasureListener(m_MapControl); |
... | ... | |
226 | 326 |
|
227 | 327 |
AreaListener ali = new AreaListener(m_MapControl); |
228 | 328 |
m_MapControl.addMapTool("area", new Behavior[]{new PolygonBehavior(ali), new MouseMovementBehavior(sbl)}); |
229 |
|
|
329 |
|
|
230 | 330 |
//Seleccion por punto |
231 | 331 |
PointSelectListener psl = new PointSelectListener(m_MapControl); |
232 | 332 |
m_MapControl.addMapTool("pointSelection", new Behavior[]{new PointBehavior(psl), new MouseMovementBehavior(sbl)}); |
233 |
|
|
333 |
|
|
234 | 334 |
//Info por punto |
235 | 335 |
InfoListener il = new InfoListener(m_MapControl); |
236 | 336 |
m_MapControl.addMapTool("info", new Behavior[]{new PointBehavior(il), new MouseMovementBehavior(sbl)}); |
237 |
|
|
337 |
|
|
238 | 338 |
// Link por punto |
239 | 339 |
LinkListener ll = new LinkListener(m_MapControl); |
240 | 340 |
m_MapControl.addMapTool("link", new Behavior[]{new PointBehavior(ll), new MouseMovementBehavior(sbl)}); |
241 |
|
|
341 |
|
|
242 | 342 |
//Selecci?n por rect?ngulo |
243 | 343 |
RectangleSelectListener rsl = new RectangleSelectListener(m_MapControl); |
244 | 344 |
m_MapControl.addMapTool("rectSelection", new Behavior[]{new RectangleBehavior(rsl), new MouseMovementBehavior(sbl)}); |
... | ... | |
248 | 348 |
ZoomInListener zil = new ZoomInListener(m_MapControl); |
249 | 349 |
m_MapControl.addMapTool("zoomIn", new Behavior[]{new RectangleBehavior(zil), |
250 | 350 |
new PointBehavior(zoil), new MouseMovementBehavior(sbl)}); |
251 |
|
|
351 |
|
|
252 | 352 |
//Salvar a Raster |
253 | 353 |
SaveRasterListener srl = new SaveRasterListener(m_MapControl); |
254 | 354 |
m_MapControl.addMapTool("saveRaster", new Behavior[]{ |
255 | 355 |
new RectangleBehavior(srl), new MouseMovementBehavior(sbl)}); |
256 |
|
|
356 |
|
|
257 | 357 |
SelectImageListener sil = new SelectImageListener(m_MapControl); |
258 | 358 |
m_MapControl.addMapTool("selectImage", new Behavior[]{ |
259 | 359 |
new PointBehavior(sil), new MouseMovementBehavior(sbl)}); |
260 |
|
|
360 |
|
|
261 | 361 |
ZoomPixelCursorListener zp = new ZoomPixelCursorListener(m_MapControl); |
262 | 362 |
m_MapControl.addMapTool("zoom_pixel_cursor", new Behavior[]{new PointBehavior(zp), new MouseMovementBehavior(sbl)}); |
263 |
|
|
363 |
|
|
264 | 364 |
m_MapControl.setTool("zoomIn"); // Por defecto |
265 | 365 |
// m_MapControl.setPaintEnabled(true); |
266 | 366 |
} |
... | ... | |
329 | 429 |
m_viewInfo.setHeight(300); |
330 | 430 |
m_viewInfo.setTitle(PluginServices.getText(this, "Vista") + " : " + |
331 | 431 |
modelo.getName()); |
332 |
|
|
432 |
|
|
333 | 433 |
return m_viewInfo; |
334 |
|
|
434 |
|
|
335 | 435 |
} |
336 | 436 |
|
337 | 437 |
/** |
... | ... | |
350 | 450 |
public BufferedImage getImage() { |
351 | 451 |
return m_MapControl.getImage(); |
352 | 452 |
} |
353 |
|
|
453 |
|
|
354 | 454 |
public void setProjection(IProjection proj) |
355 | 455 |
{ |
356 | 456 |
getMapControl().setProjection(proj); |
... | ... | |
359 | 459 |
{ |
360 | 460 |
return getMapControl().getProjection(); |
361 | 461 |
} |
362 |
|
|
462 |
|
|
363 | 463 |
public class ViewExceptionListener implements ExceptionListener { |
364 | 464 |
|
365 | 465 |
/** |
... | ... | |
368 | 468 |
public void exceptionThrown(Throwable t) { |
369 | 469 |
NotificationManager.addError(t.getMessage(), t); |
370 | 470 |
} |
371 |
|
|
471 |
|
|
372 | 472 |
} |
373 | 473 |
|
374 | 474 |
/** |
... | ... | |
377 | 477 |
public void viewClosed() { |
378 | 478 |
///PluginServices.getMainFrame().getStatusBar().setMessage("1",""); |
379 | 479 |
} |
380 |
|
|
480 |
|
|
381 | 481 |
} |
Also available in: Unified diff