Statistics
| Revision:

svn-gvsig-desktop / branches / gvSIG_GisPlanet / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / Layout.java @ 2176

History | View | Annotate | Download (36 KB)

1
/*
2
 * Created on 20-feb-2004
3
 *
4
 */
5
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
6
 *
7
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
22
 *
23
 * For more information, contact:
24
 *
25
 *  Generalitat Valenciana
26
 *   Conselleria d'Infraestructures i Transport
27
 *   Av. Blasco Ib??ez, 50
28
 *   46010 VALENCIA
29
 *   SPAIN
30
 *
31
 *      +34 963862235
32
 *   gvsig@gva.es
33
 *      www.gvsig.gva.es
34
 *
35
 *    or
36
 *
37
 *   IVER T.I. S.A
38
 *   Salamanca 50
39
 *   46005 Valencia
40
 *   Spain
41
 *
42
 *   +34 963163400
43
 *   dac@iver.es
44
 */
45
package com.iver.cit.gvsig.gui.layout;
46

    
47
import com.iver.andami.PluginServices;
48
import com.iver.andami.messages.NotificationManager;
49
import com.iver.andami.ui.mdiManager.SingletonView;
50
import com.iver.andami.ui.mdiManager.ViewInfo;
51
import com.iver.andami.ui.mdiManager.ViewListener;
52

    
53
import com.iver.cit.gvsig.Abrir;
54
import com.iver.cit.gvsig.fmap.ColorEvent;
55
import com.iver.cit.gvsig.fmap.DriverException;
56
import com.iver.cit.gvsig.fmap.ExtentEvent;
57
import com.iver.cit.gvsig.fmap.ViewPortListener;
58
import com.iver.cit.gvsig.fmap.layers.XMLException;
59
import com.iver.cit.gvsig.gui.layout.dialogs.FConfigLayoutDialog;
60
import com.iver.cit.gvsig.gui.layout.fframes.FFrame;
61
import com.iver.cit.gvsig.gui.layout.fframes.FFrameGraphics;
62
import com.iver.cit.gvsig.gui.layout.fframes.FFrameLegend;
63
import com.iver.cit.gvsig.gui.layout.fframes.FFramePicture;
64
import com.iver.cit.gvsig.gui.layout.fframes.FFrameScaleBar;
65
import com.iver.cit.gvsig.gui.layout.fframes.FFrameText;
66
import com.iver.cit.gvsig.gui.layout.fframes.FFrameView;
67
import com.iver.cit.gvsig.gui.layout.fframes.IFFrame;
68
import com.iver.cit.gvsig.gui.layout.fframes.dialogs.FFrameGraphicsDialog;
69
import com.iver.cit.gvsig.gui.layout.fframes.dialogs.FFrameLegendDialog;
70
import com.iver.cit.gvsig.gui.layout.fframes.dialogs.FFramePictureDialog;
71
import com.iver.cit.gvsig.gui.layout.fframes.dialogs.FFrameScaleBarDialog;
72
import com.iver.cit.gvsig.gui.layout.fframes.dialogs.FFrameTextDialog;
73
import com.iver.cit.gvsig.gui.layout.fframes.dialogs.FFrameViewDialog;
74
import com.iver.cit.gvsig.gui.layout.fframes.dialogs.IFFrameDialog;
75
import com.iver.cit.gvsig.gui.project.MapProperties;
76
import com.iver.cit.gvsig.project.Project;
77
import com.iver.cit.gvsig.project.ProjectMap;
78

    
79
import com.iver.utiles.XMLEntity;
80

    
81
import org.apache.log4j.Logger;
82

    
83
import java.awt.Color;
84
import java.awt.Cursor;
85
import java.awt.Graphics;
86
import java.awt.Graphics2D;
87
import java.awt.Image;
88
import java.awt.Point;
89
import java.awt.Rectangle;
90
import java.awt.Toolkit;
91
import java.awt.event.ActionEvent;
92
import java.awt.event.KeyEvent;
93
import java.awt.geom.AffineTransform;
94
import java.awt.geom.Rectangle2D;
95
import java.awt.image.BufferedImage;
96
import java.awt.print.PageFormat;
97
import java.awt.print.Printable;
98
import java.awt.print.PrinterException;
99
import java.awt.print.PrinterJob;
100

    
101
import java.beans.PropertyChangeEvent;
102
import java.beans.PropertyChangeListener;
103

    
104
import java.util.ArrayList;
105
import java.util.Hashtable;
106

    
107
import javax.print.Doc;
108
import javax.print.DocFlavor;
109
import javax.print.DocPrintJob;
110
import javax.print.PrintException;
111
import javax.print.PrintService;
112
import javax.print.PrintServiceLookup;
113
import javax.print.ServiceUI;
114
import javax.print.SimpleDoc;
115
import javax.print.attribute.PrintRequestAttributeSet;
116
import javax.print.event.PrintJobAdapter;
117
import javax.print.event.PrintJobEvent;
118
import javax.print.event.PrintJobListener;
119

    
120
import javax.swing.AbstractAction;
121
import javax.swing.Action;
122
import javax.swing.ImageIcon;
123
import javax.swing.JPanel;
124
import javax.swing.KeyStroke;
125

    
126

    
127
/**
128
 * Mapa.
129
 *
130
 * @author Vicente Caballero Navarro
131
 */
132
public class Layout extends JPanel implements SingletonView, ViewPortListener,
133
        ViewListener {
134
        private static Logger logger = Logger.getLogger(Layout.class.getName());
135
        public static final int ZOOM_MAS = 1;
136
        public static final int ZOOM_MENOS = 2;
137
        public static final int PAN = 3;
138
        public static final int DESACTUALIZADO = 4;
139
        public static final int RECTANGLEVIEW = 5;
140
        public static final int RECTANGLEPICTURE = 6;
141
        public static final int RECTANGLESCALEBAR = 7;
142
        public static final int RECTANGLELEGEND = 8;
143
        public static final int RECTANGLETEXT = 9;
144
        public static final int RECTANGLE = 10;
145
        public static final int ACTUALIZADO = 11;
146
        public static final int SELECT = 12;
147
        public static final int POINT = 13;
148
        public static final int LINE = 14;
149
        public static final int POLYLINE = 15;
150
        public static final int RECTANGLESIMPLE = 16;
151
        public static final int CIRCLE = 17;
152
        public static final int POLYGON = 18;
153
        public static final int GRAPHICS = 19;
154
        public static final int RECTANGLESYMBOL = 20;
155
        public static final int RECTANGLEGROUP = 21;
156
        public static final int VIEW_ZOOMIN = 22;
157
        public static final int VIEW_ZOOMOUT = 23;
158
        public static final int VIEW_FULL = 24;
159
        public static final int VIEW_PAN = 25;
160
        public static final int SET_TAG = 26;
161
        public static final Image iLayoutpan = new ImageIcon(Abrir.class.getClassLoader()
162
                                                                                                                                        .getResource("images/LayoutHand.gif")).getImage();
163
        public static final Image ipan = new ImageIcon(Abrir.class.getClassLoader()
164
                                                                                                                          .getResource("images/Hand.gif")).getImage();
165
        public static final Image iLayoutzoomin = new ImageIcon(Abrir.class.getClassLoader()
166
                                                                                                                                           .getResource("images/LayoutZoomInCursor.gif")).getImage();
167
        public static final Image izoomin = new ImageIcon(Abrir.class.getClassLoader()
168
                                                                                                                                 .getResource("images/ZoomInCursor.gif")).getImage();
169
        public static final Image iLayoutzoomout = new ImageIcon(Abrir.class.getClassLoader()
170
                                                                                                                                                .getResource("images/LayoutZoomOutCursor.gif")).getImage();
171
        public static final Image izoomout = new ImageIcon(Abrir.class.getClassLoader()
172
                                                                                                                                  .getResource("images/ZoomOutCursor.gif")).getImage();
173
        public static final Image iinfo = new ImageIcon(Abrir.class.getClassLoader()
174
                                                                                                                           .getResource("images/InfoCursor.gif")).getImage();
175
        public static final Image icrux = new ImageIcon(Abrir.class.getClassLoader()
176
                                                                                                                           .getResource("images/CruxCursor.png")).getImage();
177
        public static final Image itag = new ImageIcon(Abrir.class.getClassLoader()
178
                                                                                                                          .getResource("images/tagCursor.gif")).getImage();
179
        public static final Image iPoint = new ImageIcon(Abrir.class.getClassLoader()
180
                                                                                                                                .getResource("images/PointCursor.png")).getImage();
181
        public static final Image iRect = new ImageIcon(Abrir.class.getClassLoader()
182
                                                                                                                           .getResource("images/RectCursor.png")).getImage();
183
        public static final Image iLine = new ImageIcon(Abrir.class.getClassLoader()
184
                                                                                                                           .getResource("images/LineCursor.png")).getImage();
185
        public static final Image iRectangle = new ImageIcon(Abrir.class.getClassLoader()
186
                                                                                                                                        .getResource("images/RectangleCursor.png")).getImage();
187
        public static final Image iCircle = new ImageIcon(Abrir.class.getClassLoader()
188
                                                                                                                                 .getResource("images/CircleCursor.png")).getImage();
189
        public static final Image iPoligon = new ImageIcon(Abrir.class.getClassLoader()
190
                                                                                                                                  .getResource("images/PoligonCursor.png")).getImage();
191
        public static Hashtable nums = new Hashtable();
192
        private Point origin = new Point(50, 50);
193
        private Point rectOrigin = new Point(origin);
194
        private Rectangle2D.Double rect = new Rectangle2D.Double(rectOrigin.x,
195
                        rectOrigin.y, 400, 300);
196
        private Point m_FirstPoint = new Point(0, 0);
197
        private Point m_PointAnt = new Point(0, 0);
198
        private Point m_LastPoint = new Point(0, 0);
199
        private EventsHandler events;
200
        private int tool = ZOOM_MAS;
201
        private int status = DESACTUALIZADO;
202
        private BufferedImage img = null;
203
        private AffineTransform m_MatrizTransf;
204
        private Rectangle2D rectVisible;
205
        private IFFrameDialog fframedialog = null;
206
        private ArrayList m_fframes = new ArrayList();
207
        private FConfigLayoutDialog m_configLayout = null;
208
        private MapProperties m_propertiesLayout = null;
209
        private Attributes m_attributes = null;
210
        private PrintService[] m_cachePrintServices = null;
211
        private PrintRequestAttributeSet m_cachePrintRequestAtributeSet = null;
212
        private PrintService m_cachePrintService = null;
213
        private boolean m_bCancelDrawing = false;
214
        private boolean isCuadricula = false;
215
        private boolean initial = true;
216
        private ProjectMap map = null;
217
        private Rectangle reSel = null;
218
        private boolean isReSel = true;
219

    
220
        // private String m_name = null;
221
        private boolean m_showRuler = true;
222
        private FLayoutDraw layoutPaint = null;
223
        private boolean isDrawCuadricula = true;
224
        private Doc doc = null;
225
        private PrintRequestAttributeSet att = null;
226

    
227
        /**
228
         * Creates a new Layout object.
229
         */
230
        public Layout() {
231
                this.setLayout(null);
232
                events = new EventsHandler(this);
233
                layoutPaint = new FLayoutDraw(this);
234
                addComponentListener(events);
235
                addMouseMotionListener(events);
236
                addMouseListener(events);
237
                m_MatrizTransf = new AffineTransform();
238
                m_MatrizTransf.setToIdentity();
239
                this.initComponents();
240
        }
241

    
242
        /**
243
         * Rellena el ProjectMap del Layout.
244
         *
245
         * @param m ProjectMap.
246
         */
247
        public void setProjectMap(ProjectMap m) {
248
                map = m;
249
                map.addPropertyChangeListener(new PropertyChangeListener() {
250
                                public void propertyChange(PropertyChangeEvent evt) {
251
                                        if (evt.getPropertyName().equals("name")) {
252
                                                PluginServices.getMDIManager().getViewInfo(Layout.this)
253
                                                                          .setTitle(PluginServices.getText(this,
254
                                                                "Mapa") + " : " + (String) evt.getNewValue());
255
                                        }
256
                                }
257
                        });
258
        }
259

    
260
        /**
261
         * Devuelve el rect?ngulo de selecci?n por rect?ngulo.
262
         *
263
         * @return Rect?ngulo de selecci?n.
264
         */
265
        public Rectangle getReSel() {
266
                return reSel;
267
        }
268

    
269
        /**
270
         * Devuelve true si se debe dibujar el rect?ngulo de selecci?n y realizar
271
         * la sellecci?n.
272
         *
273
         * @return true si se realiza la selecci?n por rect?ngulo.
274
         */
275
        public boolean isReSel() {
276
                return isReSel;
277
        }
278

    
279
        /**
280
         * Rellena con true si se debe de dibujar y seleccionar por rect?ngulo de
281
         * selecci?n.
282
         *
283
         * @param b boolean.
284
         */
285
        public void setIsReSel(boolean b) {
286
                isReSel = b;
287
        }
288

    
289
        /**
290
         * Devuelve true si el dibujado ha sido cancelado.
291
         *
292
         * @return true si el dibujado ha sido cancelado.
293
         */
294
        public synchronized boolean isDrawingCancelled() {
295
                return m_bCancelDrawing;
296
        }
297

    
298
        /**
299
         * Pone el dibuja a cancelado o no seg?n se quiera.
300
         *
301
         * @param b true si se quiere cancelar el dibujado.
302
         */
303
        public synchronized void setCancelDrawing(boolean b) {
304
                m_bCancelDrawing = b;
305

    
306
                for (int i = 0; i < getFFrames().size(); i++) {
307
                        IFFrame fframe = (IFFrame) getFFrames().get(i);
308

    
309
                        if (fframe instanceof FFrameView &&
310
                                        (((FFrameView) fframe).getFMap() != null)) {
311
                                ////TODO((FFrameView) getFFrames().get(i)).getFMap().setCancelDrawing(b);
312
                        }
313
                }
314
        }
315

    
316
        /**
317
         * Obtiene el ArrayList con todos los FFrames que se han a?adido al Layout.
318
         *
319
         * @return Array con todos los fframes que contiene el Layout.
320
         */
321
        public ArrayList getFFrames() {
322
                return m_fframes;
323
        }
324

    
325
        /**
326
         * Obtiene el rect que se ajusta al tama?o de la ventana, para ver el folio
327
         * entero.
328
         */
329
        public void fullRect() {
330
                rect.setRect(origin.x, origin.y, getWidth() - (origin.x * 2),
331
                        getHeight() - (origin.x * 2));
332

    
333
                if (m_attributes.isLandSpace()) {
334
                        rect = m_attributes.getRectangleLandscape(rect, getWidth(),
335
                                        getHeight());
336
                } else {
337
                        rect = m_attributes.getRectanglePortrait(rect, getWidth(),
338
                                        getHeight());
339
                }
340

    
341
                status = DESACTUALIZADO;
342
                repaint();
343
        }
344

    
345
        /**
346
         * M?todo para imprimir el Layout sin modificar la matriz de
347
         * transformaci?n.
348
         *
349
         * @param g2
350
         */
351
        public void drawLayoutPrint(Graphics2D g2) {
352
                setCancelDrawing(false);
353

    
354
                setCursor(Cursor.getDefaultCursor());
355

    
356
                double scale = 0;
357

    
358
                ///if (rect.width > rect.height) {
359
                ///    scale = rect.width / m_attributes.m_sizePaper.getAlto() * 1;
360
                ///} else {
361
                scale = rect.height / m_attributes.m_sizePaper.getAlto() * 1;
362

    
363
                ///}
364
                AffineTransform escalado = new AffineTransform();
365
                AffineTransform translacion = new AffineTransform();
366
                translacion.setToTranslation(rect.getMinX(), rect.getMinY());
367
                escalado.setToScale(scale, scale);
368
                m_MatrizTransf.setToIdentity();
369
                m_MatrizTransf.concatenate(translacion);
370
                m_MatrizTransf.concatenate(escalado);
371
                m_attributes.setDistanceUnitX(rect);
372
                m_attributes.setDistanceUnitY(rect);
373

    
374
                for (int i = 0; i < getFFrames().size(); i++) {
375
                        try {
376
                                ((IFFrame) getFFrames().get(i)).print(g2, getAT());
377
                        } catch (DriverException e) {
378
                                NotificationManager.addError(e.getMessage(), e);
379
                        }
380
                }
381

    
382
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
383
        }
384

    
385
        /**
386
         * Clip sobre el rect?ngulo visible.
387
         *
388
         * @param g2d Graphics sobre el que hacer el clip.
389
         */
390
        private void clipVisibleRect(Graphics2D g2d) {
391
                rectVisible = this.getVisibleRect();
392
                g2d.clipRect((int) rectVisible.getMinX(), (int) rectVisible.getMinY(),
393
                        (int) rectVisible.getWidth(), (int) rectVisible.getHeight());
394
        }
395

    
396
        /**
397
         * Inicializa los componentes.
398
         */
399
        private void initComponents() {
400
                m_attributes = new Attributes();
401
                m_attributes.setDistanceUnitX(rect);
402
                m_attributes.setDistanceUnitY(rect);
403
                actionDelFFrame();
404
        }
405

    
406
        /**
407
         * Crea un ActionEvent para controlar las teclas que se pulsen cuando este
408
         * el Layout Focusable a true.
409
         */
410
        private void actionDelFFrame() {
411
                Action doNothing = new AbstractAction() {
412
                                public void actionPerformed(ActionEvent e) {
413
                                        for (int i = getFFrames().size() - 1; i >= 0; i--) {
414
                                                IFFrame fframe = (IFFrame) getFFrames().get(i);
415

    
416
                                                if (fframe.getSelected() != FFrame.NOSELECT) {
417
                                                        getFFrames().remove(i);
418
                                                }
419
                                        }
420

    
421
                                        refresh();
422
                                }
423
                        };
424

    
425
                this.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),
426
                        "doNothing");
427
                this.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0),
428
                        "doNothing");
429
                this.getActionMap().put("doNothing", doNothing);
430
        }
431

    
432
        /**
433
         * paintComponent del Layout.
434
         *
435
         * @param g Graphics del Layout.
436
         */
437
        protected void paintComponent(Graphics g) {
438
                super.paintComponent(g);
439

    
440
                clipVisibleRect((Graphics2D) g);
441

    
442
                Rectangle rClip = g.getClipBounds();
443

    
444
                if (rClip == null) {
445
                        System.err.println("clip = null");
446
                }
447

    
448
                switch (status) {
449
                        case ZOOM_MAS:
450
                                logger.debug("zoom mas");
451
                                layoutPaint.drawRectangle((Graphics2D) g);
452

    
453
                                g.drawImage(img, 0, 0, this);
454

    
455
                                g.setClip(rClip);
456
                                layoutPaint.drawGrid((Graphics2D) g);
457
                                layoutPaint.drawRuler((Graphics2D) g, Color.black);
458
                                g.setColor(Color.black);
459
                                g.setXORMode(Color.white);
460

    
461
                                Rectangle r = new Rectangle();
462

    
463
                                r.setFrameFromDiagonal(m_FirstPoint, m_LastPoint);
464
                                g.drawRect(r.x, r.y, r.width, r.height);
465

    
466
                                break;
467

    
468
                        case RECTANGLE:
469
                                logger.debug("rectangle");
470
                                layoutPaint.drawRectangle((Graphics2D) g);
471

    
472
                                g.drawImage(img, 0, 0, this);
473

    
474
                                g.setClip(rClip);
475
                                layoutPaint.drawGrid((Graphics2D) g);
476
                                layoutPaint.drawRuler((Graphics2D) g, Color.black);
477
                                g.setColor(Color.black);
478
                                g.setXORMode(Color.white);
479

    
480
                                Rectangle re = new Rectangle();
481
                                re.setFrameFromDiagonal(m_FirstPoint, m_LastPoint);
482

    
483
                                if (isCuadricula()) {
484
                                        FLayoutUtilities.setRectGrid(re,
485
                                                m_attributes.getUnitInPixelsX(),
486
                                                m_attributes.getUnitInPixelsY(), m_MatrizTransf);
487
                                }
488

    
489
                                g.drawRect(re.x, re.y, re.width, re.height);
490

    
491
                                break;
492

    
493
                        case PAN:
494
                                logger.debug("pan");
495

    
496
                                //g.setXORMode(Color.black);
497
                                rect.x = rectOrigin.x + (m_LastPoint.x - m_PointAnt.x);
498
                                rect.y = rectOrigin.y + (m_LastPoint.y - m_PointAnt.y);
499

    
500
                                //g.clearRect(0, 0, getWidth(), getHeight());
501
                                layoutPaint.drawRectangle((Graphics2D) g);
502

    
503
                                if (img != null) {
504
                                        g.drawImage(img, (getLastPoint().x - getPointAnt().x),
505
                                                (m_LastPoint.y - m_PointAnt.y), this);
506
                                }
507

    
508
                                g.setClip(rClip);
509
                                layoutPaint.drawGrid((Graphics2D) g);
510
                                layoutPaint.drawRuler((Graphics2D) g, Color.black);
511

    
512
                                break;
513

    
514
                        case VIEW_PAN:
515

    
516
                                // logger.debug("View pan");
517
                                layoutPaint.drawRectangle((Graphics2D) g);
518

    
519
                                for (int i = 0; i < getFFrames().size(); i++) {
520
                                        if (getFFrames().get(i) instanceof FFrameView) {
521
                                                FFrameView fframe = (FFrameView) getFFrames().get(i);
522

    
523
                                                if (fframe.getSelected() != FFrame.NOSELECT) {
524
                                                        Rectangle2D.Double rec = fframe.getBoundingBox(getAT());
525

    
526
                                                        if (img != null) {
527
                                                                //g.drawImage(img, 0, 0, this);
528
                                                                rec = (Rectangle2D.Double) rec.createIntersection(getVisibleRect());
529

    
530
                                                                //((Graphics2D)g).clearRect((int)rec.x,(int)rec.y,(int)rec.width,(int)rec.height);
531
                                                        }
532

    
533
                                                        if (fframe.getBufferedImage() != null) {
534
                                                                layoutPaint.drawHandlers((Graphics2D) g,
535
                                                                        Color.black);
536
                                                                g.clipRect((int) rec.x, (int) rec.y,
537
                                                                        (int) rec.width, (int) rec.height);
538

    
539
                                                                //g.setColor(Color.gray);
540
                                                                //g.fillRect(0,0,getWidth(),getHeight());
541
                                                                layoutPaint.drawRectangle((Graphics2D) g);
542
                                                                layoutPaint.drawRuler((Graphics2D) g,
543
                                                                        Color.black);
544

    
545
                                                                g.drawImage(fframe.getBufferedImage(),
546
                                                                        m_LastPoint.x - m_PointAnt.x,
547
                                                                        m_LastPoint.y - m_PointAnt.y, this);
548

    
549
                                                                /*System.out.println(
550
                                                                   "m_LastPoint.x - m_PointAnt.x" +
551
                                                                   (m_LastPoint.x - m_PointAnt.x));
552
                                                                   System.out.println(
553
                                                                           "m_LastPoint.y - m_PointAnt.y" +
554
                                                                           (m_LastPoint.y - m_PointAnt.y));
555
                                                                 */
556
                                                        }
557
                                                }
558
                                        }
559
                                }
560

    
561
                                g.setClip(rClip);
562
                                layoutPaint.drawGrid((Graphics2D) g);
563
                                layoutPaint.drawRuler((Graphics2D) g, Color.black);
564

    
565
                                //g.setXORMode(Color.black);
566
                                break;
567

    
568
                        case SELECT:
569
                                logger.debug("select");
570
                                layoutPaint.drawRectangle((Graphics2D) g);
571

    
572
                                g.drawImage(img, 0, 0, this);
573

    
574
                                if (isReSel) {
575
                                        reSel = new Rectangle();
576
                                        reSel.setFrameFromDiagonal(m_FirstPoint, m_LastPoint);
577
                                        g.drawRect(reSel.x, reSel.y, reSel.width, reSel.height);
578
                                }
579

    
580
                                for (int i = 0; i < getFFrames().size(); i++) {
581
                                        IFFrame fframe = (IFFrame) getFFrames().get(i);
582

    
583
                                        if (fframe.getSelected() != FFrame.NOSELECT) {
584
                                                g.setColor(Color.black);
585
                                                fframe.drawHandlers((Graphics2D) g);
586

    
587
                                                int difx = (m_LastPoint.x - m_FirstPoint.x);
588
                                                int dify = (m_LastPoint.y - m_FirstPoint.y);
589

    
590
                                                if ((Math.abs(difx) > 3) || (Math.abs(dify) > 3)) {
591
                                                        Rectangle2D rectangle = fframe.getMovieRect(difx,
592
                                                                        dify);
593

    
594
                                                        if (rectangle != null) {
595
                                                                if (isCuadricula) {
596
                                                                        FLayoutUtilities.setRectGrid(rectangle,
597
                                                                                m_attributes.getUnitInPixelsX(),
598
                                                                                m_attributes.getUnitInPixelsY(),
599
                                                                                m_MatrizTransf);
600
                                                                }
601

    
602
                                                                g.drawRect((int) rectangle.getMinX(),
603
                                                                        (int) rectangle.getMinY(),
604
                                                                        (int) rectangle.getWidth(),
605
                                                                        (int) rectangle.getHeight());
606
                                                        }
607
                                                }
608
                                        }
609
                                }
610

    
611
                                g.setClip(rClip);
612
                                layoutPaint.drawGrid((Graphics2D) g);
613
                                layoutPaint.drawRuler((Graphics2D) g, Color.black);
614
                                PluginServices.getMainFrame().enableControls();
615

    
616
                                break;
617

    
618
                        case GRAPHICS:
619
                                layoutPaint.drawRectangle((Graphics2D) g);
620
                                g.drawImage(img, 0, 0, this);
621
                                g.setClip(rClip);
622
                                layoutPaint.drawGrid((Graphics2D) g);
623
                                layoutPaint.drawRuler((Graphics2D) g, Color.black);
624

    
625
                                break;
626

    
627
                        case DESACTUALIZADO:
628
                                logger.debug("desactualizado");
629
                                img = new BufferedImage(getWidth(), getHeight(),
630
                                                BufferedImage.TYPE_INT_ARGB);
631

    
632
                                Graphics gimag = img.getGraphics();
633
                                clipVisibleRect((Graphics2D) gimag);
634

    
635
                                if (initial) {
636
                                        fullRect();
637
                                        initial = false;
638
                                }
639

    
640
                                try {
641
                                        layoutPaint.drawLayout((Graphics2D) gimag, img);
642
                                } catch (DriverException e) {
643
                                        e.printStackTrace();
644
                                }
645

    
646
                                g.setClip(rClip);
647
                                layoutPaint.drawRectangle((Graphics2D) g);
648

    
649
                                g.drawImage(img, 0, 0, this);
650
                                g.setClip(rClip);
651
                                layoutPaint.drawGrid((Graphics2D) g);
652
                                layoutPaint.drawHandlers((Graphics2D) g, Color.black);
653
                                layoutPaint.drawRuler((Graphics2D) g, Color.black);
654

    
655
                                break;
656

    
657
                        case ACTUALIZADO:
658
                                layoutPaint.drawRectangle((Graphics2D) g);
659

    
660
                                g.drawImage(img, 0, 0, this);
661

    
662
                                g.setClip(rClip);
663
                                layoutPaint.drawGrid((Graphics2D) g);
664

    
665
                                layoutPaint.drawHandlers((Graphics2D) g, Color.black);
666
                                layoutPaint.drawRuler((Graphics2D) g, Color.black);
667
                }
668
        }
669

    
670
        /**
671
         * A?ade un fframe al Arraylist m_fframes.
672
         *
673
         * @param frame fframe a a?adir.
674
         * @param clearSelection para que se quede seleccionado ?nicamente  el que
675
         *                   a?adimos y false si lo que se pretende es que no se
676
         *                   deseleccionen lo que ya est?n seleccionados.
677
         */
678
        public void addFFrame(IFFrame frame, boolean clearSelection) {
679
                if (clearSelection) {
680
                        for (int i = getFFrames().size() - 1; i >= 0; i--) {
681
                                IFFrame fframe1 = (IFFrame) getFFrames().get(i);
682
                                fframe1.setSelected(false);
683
                        }
684
                }
685

    
686
                if (frame instanceof FFrameView &&
687
                                (((FFrameView) frame).getFMap() != null)) {
688
                        ((FFrameView) frame).getFMap().getViewPort().addViewPortListener(this);
689
                }
690

    
691
                if (nums.containsKey(frame.getClass())) {
692
                        nums.put(frame.getClass(),
693
                                new Integer(Integer.parseInt(nums.get(frame.getClass())
694
                                                                                                 .toString()) + 1));
695
                } else {
696
                        nums.put(frame.getClass(), new Integer(0));
697
                }
698

    
699
                frame.setNum(Integer.parseInt(nums.get(frame.getClass()).toString()));
700
                getFFrames().add(frame);
701
                frame.setSelected(true);
702
        }
703

    
704
        /**
705
         * Abre el di?logo de propiedades del folio, pasando como par?metro el
706
         * PrinterJob.
707
         *
708
         * @param job
709
         */
710
        public void showPagePropertiesWindow(PrinterJob job) {
711
                PageFormat pf1; //=new PageFormat();
712

    
713
                pf1 = m_attributes.getPageFormat();
714
                pf1 = job.pageDialog(pf1);
715
                m_attributes.setPageFormat(pf1);
716
                refresh();
717
        }
718

    
719
        /**
720
         * Refresca el Layout.
721
         */
722
        public void refresh() {
723
                //rect = m_attributes.obtainRect(false, rect, getWidth(), getHeight());
724
                status = DESACTUALIZADO;
725
                repaint();
726
        }
727

    
728
        /**
729
         * Obtiene el rect?ngulo que representa el folio con las caracter?sticas
730
         * que contiene attributes y diferenciando si es para visualizar en
731
         * pantalla o para imprimir.
732
         *
733
         * @param isPrint si es para imprimir.
734
         */
735
        public void obtainRect(boolean isPrint) {
736
                m_attributes.obtainRect(isPrint, rect, getWidth(), getHeight());
737
        }
738

    
739
        /**
740
         * Muestra el di?logo de configuraci?n del Layout.
741
         */
742
        public void showFConfig() {
743
                FConfigLayoutDialog m_configLayout = new FConfigLayoutDialog(this);
744
                PluginServices.getMDIManager().addView(m_configLayout);
745
        }
746

    
747
        /**
748
         * Mestra el di?logo de propiedades del Layout.
749
         */
750
        public void showFProperties() {
751
                if (map == null) {
752
                        map = new ProjectMap();
753
                        map.setModel(this);
754
                        map.setName(getName());
755
                }
756

    
757
                m_propertiesLayout = new MapProperties(map);
758
                PluginServices.getMDIManager().addView(m_propertiesLayout);
759
        }
760

    
761
        /**
762
         * Muestra el di?logo de imprimir pasandole el printerJob como par?metro.
763
         *
764
         * @param job
765
         */
766
        public void showPrintDialog(PrinterJob job) {
767
                if (job != null) {
768
                        job.printDialog();
769

    
770
                        try {
771
                                job.setPrintable((Printable) PluginServices.getExtension(
772
                                                com.iver.cit.gvsig.Print.class));
773
                                job.print();
774
                        } catch (PrinterException e) {
775
                                e.printStackTrace();
776
                        }
777
                } else {
778
                        boolean print = false;
779

    
780
                        //Actualizar attributes
781
                        att = m_attributes.toPrintAttributes();
782

    
783
                        //------------------ The Printing things --------------------- //
784
                        DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
785

    
786
                        // returns the set of printers that support printing a specific document type (such as GIF)
787
                        // with a specific set of attributes (such as two sided).
788
                        // PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
789
                        // interestingly, the printer dialog's default behavior has changed with the new API: by default the dialog is not shown.
790
                        // So we must use the ServiceUI class to create a print dialog
791
                        // returns the default print service.
792
                        if (m_cachePrintServices == null) {
793
                                m_cachePrintServices = PrintServiceLookup.lookupPrintServices(flavor,
794
                                                null);
795
                        }
796

    
797
                        PrintService defaultService = null;
798

    
799
                        if (m_cachePrintService == null) {
800
                                defaultService = PrintServiceLookup.lookupDefaultPrintService();
801
                        }
802

    
803
                        if (m_cachePrintService == null) {
804
                                m_cachePrintService = ServiceUI.printDialog(null, 200, 200,
805
                                                m_cachePrintServices, defaultService, flavor, att);
806

    
807
                                // m_cachePrintRequestAtributeSet = new HashPrintRequestAttributeSet();
808
                                // m_cachePrintRequestAtributeSet.addAll(pras);
809
                        } else {
810
                                m_cachePrintService = ServiceUI.printDialog(null, 200, 200,
811
                                                m_cachePrintServices, m_cachePrintService, flavor, att);
812
                        }
813

    
814
                        if (m_cachePrintService != null) {
815
                                DocPrintJob jobNuevo = m_cachePrintService.createPrintJob();
816
                                PrintJobListener pjlistener = new PrintJobAdapter() {
817
                                                public void printDataTransferCompleted(PrintJobEvent e) {
818
                                                        System.out.println("Fin de impresi?n");
819
                                                }
820
                                        };
821

    
822
                                jobNuevo.addPrintJobListener(pjlistener);
823

    
824
                                // DocAttributeSet das = new HashDocAttributeSet();
825
                                doc = new SimpleDoc((Printable) PluginServices.getExtension(
826
                                                        com.iver.cit.gvsig.Print.class), flavor, null);
827

    
828
                                try {
829
                                        jobNuevo.print(doc, att);
830

    
831
                                        // m_attributes.
832
                                } catch (PrintException pe) {
833
                                        pe.printStackTrace();
834
                                }
835
                        }
836
                }
837

    
838
                /* try {
839
                   print = job.printDialog(att);
840
                   } catch (Exception e) {
841
                       logger.error("Abriendo el Di?logo de imprimir"); //System.out.println("Excepci?n "+e);
842
                   }
843
                   if (print) {
844
                       job.setPrintable((Printable) App.instance.getPc().getExtension(com.iver.cit.gvsig.Print.class));
845
                       try {
846
                           job.print(att);
847
                       } catch (Exception ex) {
848
                           ex.printStackTrace();
849
                       }
850
                   } */
851
                fullRect();
852
        }
853

    
854
        /**
855
         * Sustituye el puntero del rat?n por la imagen que se le pasa como
856
         * par?metro.
857
         *
858
         * @param image
859
         */
860
        public void setMapCursor(Image image) {
861
                Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(image,
862
                                new Point(16, 16), "");
863
                setCursor(cur);
864
        }
865

    
866
        /**
867
         * Cambia el puntero del raton al cusor que se le introduce como par?metro.
868
         *
869
         * @param cursor cursor a mostrar en el puntero del rat?n.
870
         */
871
        public void setMapCursor(Cursor cursor) {
872
                setCursor(cursor);
873
        }
874

    
875
        /**
876
         * Pone como seleccionada a la herramienta a partir de su n?mero.
877
         *
878
         * @param i
879
         */
880
        public void setTool(int i) {
881
                tool = i;
882

    
883
                if (getTool() == PAN) {
884
                        setMapCursor(ipan);
885
                } else if (getTool() == ZOOM_MAS) {
886
                        setMapCursor(izoomin);
887
                } else if (getTool() == ZOOM_MENOS) {
888
                        setMapCursor(izoomout);
889
                } else if (getTool() == RECTANGLEVIEW) {
890
                        setMapCursor(icrux);
891
                } else if (getTool() == RECTANGLEPICTURE) {
892
                        setMapCursor(icrux);
893
                } else if (getTool() == RECTANGLESCALEBAR) {
894
                        setMapCursor(icrux);
895
                } else if (getTool() == RECTANGLELEGEND) {
896
                        setMapCursor(icrux);
897
                } else if (getTool() == RECTANGLETEXT) {
898
                        setMapCursor(icrux);
899
                } else if (getTool() == SELECT) {
900
                        setCursor(Cursor.getDefaultCursor());
901
                } else if (getTool() == SET_TAG) {
902
                        setMapCursor(itag);
903
                } else if (getTool() == POINT) {
904
                        setMapCursor(iPoint);
905
                } else if (getTool() == LINE) {
906
                        setMapCursor(iRect);
907
                } else if (getTool() == RECTANGLESIMPLE) {
908
                        setMapCursor(iRectangle);
909
                } else if (getTool() == POLYLINE) {
910
                        setMapCursor(iLine);
911
                } else if (getTool() == POLYGON) {
912
                        setMapCursor(iPoligon);
913
                } else if (getTool() == CIRCLE) {
914
                        setMapCursor(iCircle);
915
                }
916
        }
917

    
918
        /**
919
         * Se crean aqu? los dialogos cada vez que se necesitan.
920
         *
921
         * @param fframe Rectangle que representa el lugar que ocupara el elemento
922
         *                   a?adido.
923
         *
924
         * @return true si se debe de a?adir el fframe.
925
         */
926
        public boolean openFFrameDialog(IFFrame fframe) {
927
                switch (tool) {
928
                        case RECTANGLEVIEW:
929
                                fframedialog = new FFrameViewDialog(this, (FFrameView) fframe);
930

    
931
                                break;
932

    
933
                        case RECTANGLEPICTURE:
934
                                fframedialog = new FFramePictureDialog(this,
935
                                                (FFramePicture) fframe);
936

    
937
                                break;
938

    
939
                        case RECTANGLESCALEBAR:
940
                                fframedialog = new FFrameScaleBarDialog(this,
941
                                                (FFrameScaleBar) fframe);
942

    
943
                                break;
944

    
945
                        case RECTANGLELEGEND:
946
                                fframedialog = new FFrameLegendDialog(this,
947
                                                (FFrameLegend) fframe);
948

    
949
                                break;
950

    
951
                        case RECTANGLETEXT:
952
                                fframedialog = new FFrameTextDialog(this, (FFrameText) fframe);
953

    
954
                                break;
955

    
956
                        case GRAPHICS:
957
                                fframedialog = new FFrameGraphicsDialog(this,
958
                                                (FFrameGraphics) fframe);
959

    
960
                                break;
961

    
962
                        default:
963
                                return true;
964
                }
965

    
966
                if (fframedialog != null) {
967
                        fframedialog.setRectangle(fframe.getBoundingBox(m_MatrizTransf));
968
                        PluginServices.getMDIManager().addView(fframedialog);
969
                }
970

    
971
                return fframedialog.getIsAcepted();
972
        }
973

    
974
        /**
975
         * Devuelve el Rectangle2D que representa en pixels al folio.
976
         *
977
         * @return Rectangle2D.Double
978
         */
979
        public Rectangle2D.Double getRect() {
980
                return rect;
981
        }
982

    
983
        /**
984
         * Obtiene un entero que representa la herramienta seleccionada.
985
         *
986
         * @return entero.
987
         */
988
        public int getTool() {
989
                return tool;
990
        }
991

    
992
        /**
993
         * Devuelve la Matriz transformada que se esta plicando al Layout.
994
         *
995
         * @return AffineTransform
996
         */
997
        public AffineTransform getAT() {
998
                return m_MatrizTransf;
999
        }
1000

    
1001
        /**
1002
         * Devuelve los atributos del Mapa.
1003
         *
1004
         * @return Attributes.
1005
         */
1006
        public Attributes getAtributes() {
1007
                return m_attributes;
1008
        }
1009

    
1010
        /**
1011
         * Pone el estado que se quiera.
1012
         *
1013
         * @param s estado.
1014
         */
1015
        public void setStatus(int s) {
1016
                status = s;
1017
        }
1018

    
1019
        /**
1020
         * Devuelve el punto que representa la esquina noroeste del mapa.
1021
         *
1022
         * @return un punto.
1023
         */
1024
        public Point getRectOrigin() {
1025
                return rectOrigin;
1026
        }
1027

    
1028
        /**
1029
         * Devuelve el punto del primer click de rat?n.
1030
         *
1031
         * @return un punto.
1032
         */
1033
        public Point getFirstPoint() {
1034
                return m_FirstPoint;
1035
        }
1036

    
1037
        /**
1038
         * Devuelve el punto de click de rat?n anterior.
1039
         *
1040
         * @return un punto.
1041
         */
1042
        public Point getPointAnt() {
1043
                return m_PointAnt;
1044
        }
1045

    
1046
        /**
1047
         * Devuelve el punto donde se solt? el bot?n del rat?n.
1048
         *
1049
         * @return un punto.
1050
         */
1051
        public Point getLastPoint() {
1052
                return m_LastPoint;
1053
        }
1054

    
1055
        /**
1056
         * Rellena el primer punto de click de rat?n.
1057
         *
1058
         * @param p punto.
1059
         */
1060
        public void setFirstPoint(Point p) {
1061
                m_FirstPoint = p;
1062
        }
1063

    
1064
        /**
1065
         * Rellena el punto de click de rat?n anterior.
1066
         *
1067
         * @param p punto.
1068
         */
1069
        public void setPointAnt(Point p) {
1070
                m_PointAnt = p;
1071
        }
1072

    
1073
        /**
1074
         * Rellena el punto donde se solto el bot?n del rat?n.
1075
         *
1076
         * @param p punto.
1077
         */
1078
        public void setLastPoint(Point p) {
1079
                m_LastPoint = p;
1080
        }
1081

    
1082
        /**
1083
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
1084
         */
1085
        public ViewInfo getViewInfo() {
1086
                ViewInfo m_viewinfo = new ViewInfo(ViewInfo.ICONIFIABLE |
1087
                                ViewInfo.MAXIMIZABLE | ViewInfo.RESIZABLE);
1088

    
1089
                m_viewinfo.setWidth(500);
1090
                m_viewinfo.setHeight(400);
1091

    
1092
                m_viewinfo.setTitle(PluginServices.getText(this, "Mapa") + " : " +
1093
                        getName());
1094

    
1095
                return m_viewinfo;
1096
        }
1097

    
1098
        /**
1099
         * Inserta si se muestra o no la regla del Layout.
1100
         *
1101
         * @param b True si se muestra la regla.
1102
         */
1103
        public void setRuler(boolean b) {
1104
                m_showRuler = b;
1105
        }
1106

    
1107
        /**
1108
         * Devuelve si se muestra la regla del Layout.
1109
         *
1110
         * @return True si se muestra la regla.
1111
         */
1112
        public boolean getRuler() {
1113
                return m_showRuler;
1114
        }
1115

    
1116
        /**
1117
         * Devuelve si se esta aplicando en los fframes que se a?den al Layout la
1118
         * cuadr?cula, o no.
1119
         *
1120
         * @return true si se esta aplicando la cuadr?cula.
1121
         */
1122
        public boolean isCuadricula() {
1123
                return isCuadricula;
1124
        }
1125

    
1126
        /**
1127
         * Se actualiza el estado de la cuadr?cula, si se aplica o no.
1128
         *
1129
         * @param b true si se aplica la cuadr?cula.
1130
         */
1131
        public void setIsCuadricula(boolean b) {
1132
                isCuadricula = b;
1133
        }
1134

    
1135
        /**
1136
         * Realiza una exteni?n completa de las capas que contiene la vista del
1137
         * FFrameView.
1138
         *
1139
         * @throws DriverException
1140
         */
1141
        public void viewFull() throws DriverException {
1142
                for (int i = 0; i < getFFrames().size(); i++) {
1143
                        if (getFFrames().get(i) instanceof FFrameView) {
1144
                                FFrameView fframe = (FFrameView) getFFrames().get(i);
1145

    
1146
                                if (fframe.getSelected() != FFrame.NOSELECT) {
1147
                                        fframe.getFMap().getViewPort().setExtent(fframe.getFMap()
1148
                                                                                                                                   .getFullExtent());
1149
                                }
1150
                        }
1151
                }
1152

    
1153
                setStatus(DESACTUALIZADO);
1154
                repaint();
1155
        }
1156

    
1157
        /**
1158
         * Devuelve un Objeto XMLEntity con la informaci?n los atributos necesarios
1159
         * para poder despu?s volver a crear el objeto original.
1160
         *
1161
         * @return XMLEntity.
1162
         * @throws XMLException
1163
         */
1164
        public XMLEntity getXMLEntity() throws XMLException {
1165
                XMLEntity xml = new XMLEntity();
1166
                xml.putProperty("className", this.getClass().getName());
1167
                xml.setName("layout");
1168
                xml.putProperty("isCuadricula", isCuadricula());
1169
                xml.putProperty("m_name", this.getName());
1170
                xml.addChild(getAtributes().getXMLEntity());
1171

    
1172
                for (int i = 0; i < getFFrames().size(); i++) {
1173
                        xml.addChild(((IFFrame) getFFrames().get(i)).getXMLEntity());
1174
                }
1175

    
1176
                return xml;
1177
        }
1178

    
1179
        /**
1180
         * Crea un Objeto de esta clase a partir de la informaci?n del XMLEntity.
1181
         *
1182
         * @param xml XMLEntity
1183
         * @param p Proyecto.
1184
         *
1185
         * @return Objeto de esta clase.
1186
         */
1187
        public static Layout createLayout(XMLEntity xml, Project p) {
1188
                Layout layout = new Layout();
1189
                layout.isCuadricula = xml.getBooleanProperty("isCuadricula");
1190
                layout.setName(xml.getStringProperty("m_name"));
1191
                layout.m_attributes = Attributes.createAtributes(xml.getChild(0));
1192

    
1193
                for (int i = 1; i < xml.getNumChild(); i++) {
1194
                        if (xml.getChild(i).getStringProperty("className").equals("com.iver.cit.gvsig.gui.layout.fframe.FFrameView")) {
1195
                                layout.addFFrame(FFrame.createFFrame(xml.getChild(i), layout, p),
1196
                                        true);
1197
                        }
1198
                }
1199

    
1200
                for (int i = 1; i < xml.getNumChild(); i++) {
1201
                        if (!xml.getChild(i).getStringProperty("className").equals("com.iver.cit.gvsig.gui.layout.fframe.FFrameView")) {
1202
                                layout.addFFrame(FFrame.createFFrame(xml.getChild(i), layout, p),
1203
                                        true);
1204
                        }
1205
                }
1206

    
1207
                return layout;
1208
        }
1209

    
1210
        /**
1211
         * Crea un Objeto de esta clase a partir de la informaci?n del XMLEntity.
1212
         *
1213
         * @param xml XMLEntity
1214
         * @param p Proyecto.
1215
         *
1216
         * @return Objeto de esta clase.
1217
         */
1218
        public static Layout createLayout03(XMLEntity xml, Project p) {
1219
                Layout layout = new Layout();
1220
                layout.isCuadricula = xml.getBooleanProperty("isCuadricula");
1221
                layout.setName(xml.getStringProperty("m_name"));
1222
                layout.m_attributes = Attributes.createAtributes03(xml.getChild(0));
1223

    
1224
                for (int i = 1; i < xml.getNumChild(); i++) {
1225
                        if (xml.getChild(i).getStringProperty("className").equals("com.iver.cit.gvsig.gui.layout.fframe.FFrameView")) {
1226
                                layout.addFFrame(FFrame.createFFrame03(xml.getChild(i), layout, p),
1227
                                        true);
1228
                        }
1229
                }
1230

    
1231
                for (int i = 1; i < xml.getNumChild(); i++) {
1232
                        if (!xml.getChild(i).getStringProperty("className").equals("com.iver.cit.gvsig.gui.layout.fframe.FFrameView")) {
1233
                                layout.addFFrame(FFrame.createFFrame03(xml.getChild(i), layout, p),
1234
                                        true);
1235
                        }
1236
                }
1237

    
1238
                return layout;
1239
        }
1240

    
1241
        /**
1242
         * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
1243
         */
1244
        public void viewActivated() {
1245
                PluginServices.getMainFrame().getStatusBar().setMessage("1",
1246
                        getAtributes().getNameUnit());
1247

    
1248
                ///System.out.println("---------- 1 "+ getAtributes().getNameUnit());
1249
        }
1250

    
1251
        /**
1252
         * @see com.iver.cit.gvsig.fmap.IMapExtentListener#extentChanged(java.awt.geom.Rectangle2D)
1253
         */
1254
        public void extentChanged(Rectangle2D newExtent) {
1255
        }
1256

    
1257
        /**
1258
         * @see com.iver.mdiApp.ui.MDIManager.SingletonView#getViewModel()
1259
         */
1260
        public Object getViewModel() {
1261
                return map;
1262
        }
1263

    
1264
        /**
1265
         * Devuelve si se dibuja el Grid en el Layout o no.
1266
         *
1267
         * @return True si se dibuja el Grid en el Layout.
1268
         */
1269
        public boolean getIsDrawGrid() {
1270
                return isDrawCuadricula;
1271
        }
1272

    
1273
        /**
1274
         * Inserta si se muestra el Grid del Layout.
1275
         *
1276
         * @param b True si se muestra el Grid del Layout.
1277
         */
1278
        public void setIsDrawGrid(boolean b) {
1279
                isDrawCuadricula = b;
1280
        }
1281

    
1282
        /**
1283
         * @see com.iver.cit.gvsig.fmap.ExtentListener#extentChanged(com.iver.cit.gvsig.fmap.ExtentEvent)
1284
         */
1285
        public void extentChanged(ExtentEvent e) {
1286
        }
1287

    
1288
        /**
1289
         * @see com.iver.andami.ui.mdiManager.ViewListener#viewClosed()
1290
         */
1291
        public void viewClosed() {
1292
                ///PluginServices.getMainFrame().getStatusBar().setMessage("1","");
1293
        }
1294

    
1295
        /**
1296
         * @see com.iver.cit.gvsig.fmap.ViewPortListener#backColorChanged(com.iver.cit.gvsig.fmap.ColorEvent)
1297
         */
1298
        public void backColorChanged(ColorEvent e) {
1299
        }
1300

    
1301
        /**
1302
         * DOCUMENT ME!
1303
         *
1304
         * @return DOCUMENT ME!
1305
         */
1306
        public IFFrame[] getFFrameSelected() {
1307
                ArrayList selecList = new ArrayList();
1308

    
1309
                for (int i = getFFrames().size() - 1; i >= 0; i--) {
1310
                        IFFrame fframe = (IFFrame) getFFrames().get(i);
1311

    
1312
                        if (fframe.getSelected() != FFrame.NOSELECT) {
1313
                                selecList.add(fframe);
1314
                        }
1315
                }
1316

    
1317
                return (IFFrame[]) selecList.toArray(new IFFrame[0]);
1318
        }
1319
}