Revision 3513 branches/gvSIG_CAD/applications/appgvSIG/src/com/iver/cit/gvsig/gui/View.java
View.java | ||
---|---|---|
73 | 73 |
import com.iver.cit.gvsig.fmap.tools.Behavior.PolygonBehavior; |
74 | 74 |
import com.iver.cit.gvsig.fmap.tools.Behavior.PolylineBehavior; |
75 | 75 |
import com.iver.cit.gvsig.fmap.tools.Behavior.RectangleBehavior; |
76 |
import com.iver.cit.gvsig.gui.cad.CadMapControl; |
|
76 | 77 |
import com.iver.cit.gvsig.gui.thememanager.FThemeManagerWindow; |
77 | 78 |
import com.iver.cit.gvsig.gui.toc.TOC; |
78 | 79 |
import com.iver.cit.gvsig.gui.toolListeners.AreaListener; |
... | ... | |
101 | 102 |
SingletonView,ViewListener, IView{ |
102 | 103 |
|
103 | 104 |
/** DOCUMENT ME! */ |
104 |
private MapControl m_MapControl;
|
|
105 |
private CadMapControl m_CadMapControl;
|
|
105 | 106 |
private MapOverview m_MapLoc; |
106 | 107 |
|
107 | 108 |
/** DOCUMENT ME! */ |
... | ... | |
141 | 142 |
//Se registra como listener de cambios en FMap |
142 | 143 |
FMap fmap = modelo.getMapContext(); |
143 | 144 |
|
144 |
//Se configura el mapControl
|
|
145 |
m_MapControl.setMapContext(fmap); |
|
145 |
//Se configura el CadMapControl
|
|
146 |
m_CadMapControl.setMapContext(fmap);
|
|
146 | 147 |
m_TOC.setMapContext(fmap); |
147 |
m_MapControl.setBackground(new Color(255, 255, 255)); |
|
148 |
m_CadMapControl.setBackground(new Color(255, 255, 255));
|
|
148 | 149 |
if (modelo.getMapOverViewContext()!=null){ |
149 | 150 |
m_MapLoc.setModel(modelo.getMapOverViewContext()); |
150 | 151 |
} |
... | ... | |
155 | 156 |
} |
156 | 157 |
} |
157 | 158 |
}); |
158 |
if (m_MapControl.getViewPort() != null){ |
|
159 |
m_MapControl.getViewPort().addViewPortListener(new ViewPortListener() {
|
|
160 |
public void extentChanged(ExtentEvent e) {
|
|
161 |
if (PluginServices.getMainFrame() != null){
|
|
162 |
PluginServices.getMainFrame().getStatusBar().setMessage("6", "1:"+m_MapControl.getMapContext().getScaleView());
|
|
163 |
PluginServices.getMainFrame().getStatusBar().setMessage("7", getMapControl().getViewPort().getProjection().getAbrev());
|
|
164 |
}
|
|
159 |
|
|
160 |
if (m_CadMapControl.getMapContext().getViewPort() != null){
|
|
161 |
m_CadMapControl.getMapContext().getViewPort().addViewPortListener(new ViewPortListener() {
|
|
162 |
public void extentChanged(ExtentEvent e) {
|
|
163 |
if (PluginServices.getMainFrame() != null){
|
|
164 |
PluginServices.getMainFrame().getStatusBar().setMessage("6", "1:"+m_CadMapControl.getMapContext().getScaleView());
|
|
165 |
PluginServices.getMainFrame().getStatusBar().setMessage("7", m_CadMapControl.getMapContext().getViewPort().getProjection().getAbrev());
|
|
165 | 166 |
} |
167 |
} |
|
166 | 168 |
|
167 | 169 |
public void backColorChanged(ColorEvent e) { |
168 | 170 |
} |
... | ... | |
174 | 176 |
* DOCUMENT ME! |
175 | 177 |
*/ |
176 | 178 |
private void initComponents() { //GEN-BEGIN:initComponents |
177 |
m_MapControl = new MapControl(); //Default is paintEnabled = false. Remember to activate it
|
|
178 |
m_MapControl.addExceptionListener(mapControlExceptionListener);
|
|
179 |
// modelo.setMapContext(m_MapControl.getMapContext()); |
|
179 |
m_CadMapControl = new CadMapControl();
|
|
180 |
m_CadMapControl.getMapControl().addExceptionListener(mapControlExceptionListener);
|
|
181 |
// modelo.setMapContext(m_CadMapControl.getMapContext());
|
|
180 | 182 |
|
181 | 183 |
// m_MapControl.setAcceptEvents(true); Lo comento porque ya se hace en el setModel |
182 | 184 |
m_TOC = new TOC(); |
... | ... | |
185 | 187 |
tempMainSplit.setPreferredSize(new Dimension(500, 300)); |
186 | 188 |
|
187 | 189 |
// Ponemos el localizador |
188 |
m_MapLoc = new MapOverview(m_MapControl);
|
|
190 |
m_MapLoc = new MapOverview(m_CadMapControl.getMapControl());
|
|
189 | 191 |
m_MapLoc.setPreferredSize(new Dimension(150, 200)); |
190 | 192 |
JSplitPane tempSplitToc = new JSplitPane(JSplitPane.VERTICAL_SPLIT); |
191 | 193 |
|
... | ... | |
199 | 201 |
m_TOC.setVisible(true); |
200 | 202 |
|
201 | 203 |
// m_TOC.setPreferredSize(new Dimension(150,50)); |
202 |
tempMainSplit.setRightComponent(m_MapControl); |
|
204 |
tempMainSplit.setRightComponent(m_CadMapControl);
|
|
203 | 205 |
this.setLayout(new BorderLayout()); |
204 | 206 |
this.add(tempMainSplit, BorderLayout.CENTER); |
205 | 207 |
|
206 | 208 |
//Listener de eventos de movimiento que pone las coordenadas del rat?n en la barra de estado |
207 |
StatusBarListener sbl = new StatusBarListener(m_MapControl); |
|
209 |
StatusBarListener sbl = new StatusBarListener(m_CadMapControl.getMapControl()); |
|
210 |
m_CadMapControl.addMapTool("coords", new MouseMovementBehavior(sbl)); |
|
211 |
m_CadMapControl.getMapControl().pushTool("coords"); |
|
208 | 212 |
|
209 | 213 |
// Zoom out (pinchas y el mapa se centra y te muestra m?s). |
210 | 214 |
// No es dibujando un rect?ngulo, es solo pinchando. |
211 |
|
|
212 |
ZoomOutListener zol = new ZoomOutListener(m_MapControl); |
|
213 |
m_MapControl.addMapTool("zoomOut", new Behavior[]{new PointBehavior(zol), new MouseMovementBehavior(sbl)}); |
|
215 |
ZoomOutListener zol = new ZoomOutListener(m_CadMapControl.getMapControl()); |
|
216 |
m_CadMapControl.addMapTool("zoomOut", new PointBehavior(zol)); |
|
214 | 217 |
|
215 | 218 |
// pan |
216 | 219 |
|
217 |
PanListener pl = new PanListener(m_MapControl);
|
|
218 |
m_MapControl.addMapTool("pan", new Behavior[]{new MoveBehavior(pl), new MouseMovementBehavior(sbl)});
|
|
220 |
PanListener pl = new PanListener(m_CadMapControl.getMapControl());
|
|
221 |
m_CadMapControl.addMapTool("pan", new MoveBehavior(pl));
|
|
219 | 222 |
|
220 | 223 |
// Medir |
221 | 224 |
|
222 |
MeasureListener mli = new MeasureListener(m_MapControl);
|
|
223 |
m_MapControl.addMapTool("medicion", new Behavior[]{new PolylineBehavior(mli), new MouseMovementBehavior(sbl)});
|
|
225 |
MeasureListener mli = new MeasureListener(m_CadMapControl.getMapControl());
|
|
226 |
m_CadMapControl.addMapTool("medicion", new PolylineBehavior(mli));
|
|
224 | 227 |
|
225 | 228 |
// Area |
226 | 229 |
|
227 |
AreaListener ali = new AreaListener(m_MapControl);
|
|
228 |
m_MapControl.addMapTool("area", new Behavior[]{new PolygonBehavior(ali), new MouseMovementBehavior(sbl)});
|
|
230 |
AreaListener ali = new AreaListener(m_CadMapControl.getMapControl());
|
|
231 |
m_CadMapControl.addMapTool("area", new PolygonBehavior(ali));
|
|
229 | 232 |
|
230 | 233 |
//Seleccion por punto |
231 |
PointSelectListener psl = new PointSelectListener(m_MapControl);
|
|
232 |
m_MapControl.addMapTool("pointSelection", new Behavior[]{new PointBehavior(psl), new MouseMovementBehavior(sbl)});
|
|
234 |
PointSelectListener psl = new PointSelectListener(m_CadMapControl.getMapControl());
|
|
235 |
m_CadMapControl.addMapTool("pointSelection", new PointBehavior(psl));
|
|
233 | 236 |
|
234 | 237 |
//Info por punto |
235 |
InfoListener il = new InfoListener(m_MapControl);
|
|
236 |
m_MapControl.addMapTool("info", new Behavior[]{new PointBehavior(il), new MouseMovementBehavior(sbl)});
|
|
238 |
InfoListener il = new InfoListener(m_CadMapControl.getMapControl());
|
|
239 |
m_CadMapControl.addMapTool("info", new PointBehavior(il));
|
|
237 | 240 |
|
238 | 241 |
// Link por punto |
239 |
LinkListener ll = new LinkListener(m_MapControl);
|
|
240 |
m_MapControl.addMapTool("link", new Behavior[]{new PointBehavior(ll), new MouseMovementBehavior(sbl)});
|
|
242 |
LinkListener ll = new LinkListener(m_CadMapControl.getMapControl());
|
|
243 |
m_CadMapControl.addMapTool("link", new PointBehavior(ll));
|
|
241 | 244 |
|
242 | 245 |
//Selecci?n por rect?ngulo |
243 |
RectangleSelectListener rsl = new RectangleSelectListener(m_MapControl); |
|
244 |
m_MapControl.addMapTool("rectSelection", new Behavior[]{new RectangleBehavior(rsl), new MouseMovementBehavior(sbl)}); |
|
245 |
|
|
246 |
RectangleSelectListener rsl = new RectangleSelectListener(m_CadMapControl.getMapControl()); |
|
247 |
m_CadMapControl.addMapTool("rectSelection", new RectangleBehavior(rsl)); |
|
248 |
|
|
249 |
//TODO zoom m?s, esto impide que pulsando el bot?n derecho se haga zoom menos. Pero est? porque funcionaba mal. |
|
250 |
ZoomInListener zil = new ZoomInListener(m_CadMapControl.getMapControl()); |
|
251 |
m_CadMapControl.addMapTool("zoomIn", new RectangleBehavior(zil)); |
|
252 |
|
|
246 | 253 |
// Zoom por rect?ngulo |
247 |
ZoomOutRightButtonListener zoil = new ZoomOutRightButtonListener(m_MapControl);
|
|
248 |
ZoomInListener zil = new ZoomInListener(m_MapControl);
|
|
249 |
m_MapControl.addMapTool("zoomIn", new Behavior[]{new RectangleBehavior(zil),
|
|
254 |
ZoomOutRightButtonListener zoil = new ZoomOutRightButtonListener(m_CadMapControl.getMapControl());
|
|
255 |
ZoomInListener zili = new ZoomInListener(m_CadMapControl.getMapControl());
|
|
256 |
m_CadMapControl.addMapTool("zoomIn", new Behavior[]{new RectangleBehavior(zili),
|
|
250 | 257 |
new PointBehavior(zoil), new MouseMovementBehavior(sbl)}); |
251 | 258 |
|
252 | 259 |
//Salvar a Raster |
253 |
SaveRasterListener srl = new SaveRasterListener(m_MapControl);
|
|
254 |
m_MapControl.addMapTool("saveRaster", new Behavior[]{ |
|
260 |
SaveRasterListener srl = new SaveRasterListener(m_CadMapControl.getMapControl());
|
|
261 |
m_CadMapControl.addMapTool("saveRaster", new Behavior[]{
|
|
255 | 262 |
new RectangleBehavior(srl), new MouseMovementBehavior(sbl)}); |
256 | 263 |
|
257 |
SelectImageListener sil = new SelectImageListener(m_MapControl);
|
|
258 |
m_MapControl.addMapTool("selectImage", new Behavior[]{ |
|
264 |
SelectImageListener sil = new SelectImageListener(m_CadMapControl.getMapControl());
|
|
265 |
m_CadMapControl.addMapTool("selectImage", new Behavior[]{
|
|
259 | 266 |
new PointBehavior(sil), new MouseMovementBehavior(sbl)}); |
260 | 267 |
|
261 |
ZoomPixelCursorListener zp = new ZoomPixelCursorListener(m_MapControl);
|
|
262 |
m_MapControl.addMapTool("zoom_pixel_cursor", new Behavior[]{new PointBehavior(zp), new MouseMovementBehavior(sbl)}); |
|
268 |
ZoomPixelCursorListener zp = new ZoomPixelCursorListener(m_CadMapControl.getMapControl());
|
|
269 |
m_CadMapControl.addMapTool("zoom_pixel_cursor", new Behavior[]{new PointBehavior(zp), new MouseMovementBehavior(sbl)});
|
|
263 | 270 |
|
264 |
m_MapControl.setTool("zoomIn"); // Por defecto
|
|
271 |
m_CadMapControl.getMapControl().setTool("zoomIn"); // Por defecto
|
|
265 | 272 |
// m_MapControl.setPaintEnabled(true); |
266 | 273 |
} |
267 | 274 |
|
... | ... | |
291 | 298 |
* |
292 | 299 |
* @return DOCUMENT ME! |
293 | 300 |
*/ |
294 |
public MapControl getMapControl() { |
|
295 |
return m_MapControl; |
|
301 |
public CadMapControl getMapControl() {
|
|
302 |
return m_CadMapControl;
|
|
296 | 303 |
} |
297 | 304 |
|
298 | 305 |
/** |
... | ... | |
308 | 315 |
* DOCUMENT ME! |
309 | 316 |
*/ |
310 | 317 |
public void repaintMap() { |
311 |
m_MapControl.drawMap(true);
|
|
318 |
m_CadMapControl.getMapControl().drawMap(false);
|
|
312 | 319 |
} |
313 | 320 |
|
314 | 321 |
/* (non-Javadoc) |
... | ... | |
340 | 347 |
public void viewActivated() { |
341 | 348 |
PluginServices.getMainFrame().getStatusBar().setMessage("1", |
342 | 349 |
FConstant.NAMES[getMapControl().getMapContext().getViewPort().getDistanceUnits()]); |
343 |
PluginServices.getMainFrame().getStatusBar().setMessage("6", "1:"+m_MapControl.getMapContext().getScaleView()); |
|
344 |
PluginServices.getMainFrame().getStatusBar().setMessage("7", getMapControl().getViewPort().getProjection().getAbrev()); |
|
350 |
PluginServices.getMainFrame().getStatusBar().setMessage("6", "1:"+m_CadMapControl.getMapContext().getScaleView());
|
|
351 |
PluginServices.getMainFrame().getStatusBar().setMessage("7", getMapControl().getMapControl().getViewPort().getProjection().getAbrev());
|
|
345 | 352 |
} |
346 | 353 |
|
347 | 354 |
/** |
348 | 355 |
* @return |
349 | 356 |
*/ |
350 | 357 |
public BufferedImage getImage() { |
351 |
return m_MapControl.getImage();
|
|
358 |
return m_CadMapControl.getMapControl().getImage();
|
|
352 | 359 |
} |
353 | 360 |
|
354 | 361 |
public void setProjection(IProjection proj) |
355 | 362 |
{ |
356 |
getMapControl().setProjection(proj); |
|
363 |
getMapControl().getMapControl().setProjection(proj);
|
|
357 | 364 |
} |
358 | 365 |
public IProjection getProjection() |
359 | 366 |
{ |
360 |
return getMapControl().getProjection(); |
|
367 |
return getMapControl().getMapControl().getProjection();
|
|
361 | 368 |
} |
362 | 369 |
|
363 | 370 |
public class ViewExceptionListener implements ExceptionListener { |
Also available in: Unified diff