Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / LayoutControl.java @ 28368

History | View | Annotate | Download (22.6 KB)

1
package com.iver.cit.gvsig.project.documents.layout;
2

    
3
import java.awt.Color;
4
import java.awt.Cursor;
5
import java.awt.Graphics;
6
import java.awt.Graphics2D;
7
import java.awt.Image;
8
import java.awt.Point;
9
import java.awt.Rectangle;
10
import java.awt.Toolkit;
11
import java.awt.geom.AffineTransform;
12
import java.awt.geom.Rectangle2D;
13
import java.awt.image.BufferedImage;
14
import java.awt.image.MemoryImageSource;
15
import java.util.HashMap;
16

    
17
import javax.swing.JComponent;
18

    
19
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
20
import com.iver.cit.gvsig.fmap.core.adapter.GeometryAdapter;
21
import com.iver.cit.gvsig.fmap.core.adapter.PolyLineAdapter;
22
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame;
23
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameEditableVertex;
24
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameUseFMap;
25
import com.iver.cit.gvsig.project.documents.layout.gui.FPopupMenu;
26
import com.iver.cit.gvsig.project.documents.layout.gui.Layout;
27
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddBoxListenerImpl;
28
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddCircleListenerImpl;
29
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddLegendListenerImpl;
30
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddLineListenerImpl;
31
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddNorthListenerImpl;
32
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddOverViewListenerImpl;
33
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddPictureListenerImpl;
34
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddPointListenerImpl;
35
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddPolygonListenerImpl;
36
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddPolylineListenerImpl;
37
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddRectangleListenerImpl;
38
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddScaleListenerImpl;
39
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddTextListenerImpl;
40
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddViewListenerImpl;
41
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutEditGraphicsListenerImpl;
42
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutPanListenerImpl;
43
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutSelectListenerImpl;
44
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutViewPanListenerImpl;
45
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutViewZoomInListenerImpl;
46
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutViewZoomOutListenerImpl;
47
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutZoomInListenerImpl;
48
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutZoomOutListenerImpl;
49
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutBehavior;
50
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutEditBehavior;
51
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutMoveBehavior;
52
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutPointBehavior;
53
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutRectangleBehavior;
54
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutSelectBehavior;
55
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutViewMoveBehavior;
56
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutViewZoomBehavior;
57
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutZoomBehavior;
58
import com.iver.cit.gvsig.project.documents.layout.tools.listener.ILayoutGraphicListener;
59

    
60

    
61
/**
62
 * Control of Layout.
63
 *
64
 * @author Vicente Caballero Navarro
65
 */
66
public class LayoutControl extends JComponent implements LayoutDrawListener {
67
    public static final int DESACTUALIZADO = 4;
68
    public static final int ACTUALIZADO = 5;
69
    private int status = DESACTUALIZADO;
70
    private Rectangle2D rectVisible;
71
    private BufferedImage img = null;
72
    private BufferedImage imgRuler = null;
73
    private boolean initial = true;
74
    private LayoutContext layoutContext;
75
    private Point origin = new Point(50, 50);
76
    private Point rectOrigin = new Point(origin);
77
    private Rectangle2D.Double rect = new Rectangle2D.Double(rectOrigin.x,
78
            rectOrigin.y, 400, 300);
79
    private FLayoutDraw layoutDraw = null;
80
    private FLayoutFunctions layoutFunctions = null;
81
    private LayoutBehavior currentLayoutTool = null;
82
    private Image imageCursor = null;
83
    private HashMap namesLayoutTools = new HashMap();
84
    private Point m_FirstPoint = new Point(0, 0);
85
    private Point m_PointAnt = new Point(0, 0);
86
    private Point m_LastPoint = new Point(0, 0);
87
    private LayoutEvents layoutEvents;
88
    private Point position;
89
    private GeometryAdapter geometryAdapter = new PolyLineAdapter();
90

    
91
    //private String prevTool;
92
    private String currentTool;
93
    private boolean m_bCancelDrawing = false;
94
    private Rectangle reSel = null;
95
    private boolean isReSel = true;
96
    private FLayoutZooms layoutZooms;
97

    
98
//    private static Cursor transparentCursor = Toolkit.getDefaultToolkit()
99
//                                          .createCustomCursor(Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(
100
//                                                  16, 16, new int[16 * 16], 0, 16)),
101
//                new Point(0, 0), "invisiblecursor");
102

    
103

    
104
    /**
105
     * Create a new object of LayoutControl.
106
     * @param layout
107
     */
108
    public LayoutControl(Layout layout) {
109
            setLayoutContext(layout.getLayoutContext());
110
        layoutDraw = new FLayoutDraw(layout);
111
        layoutEvents = new LayoutEvents(layout);
112
        layoutZooms = new FLayoutZooms(layout);
113
        layoutFunctions = new FLayoutFunctions(layout);
114
        addComponentListener(layoutEvents);
115
        addMouseMotionListener(layoutEvents);
116
        addMouseListener(layoutEvents);
117

    
118
        layoutContext.updateFFrames();
119

    
120
        LayoutPanListenerImpl lpl = new LayoutPanListenerImpl(layout);
121
        addLayoutTool("layoutpan", new LayoutMoveBehavior(lpl));
122

    
123
        LayoutZoomInListenerImpl lzil = new LayoutZoomInListenerImpl(layout);
124
        addLayoutTool("layoutzoomin", new LayoutZoomBehavior(lzil));
125

    
126
        LayoutZoomOutListenerImpl lzol = new LayoutZoomOutListenerImpl(layout);
127
        addLayoutTool("layoutzoomout", new LayoutZoomBehavior(lzol));
128

    
129
        LayoutAddViewListenerImpl lavl = new LayoutAddViewListenerImpl(layout);
130
        addLayoutTool("layoutaddview", new LayoutRectangleBehavior(lavl));
131

    
132
        LayoutAddOverViewListenerImpl laovl = new LayoutAddOverViewListenerImpl(layout);
133
        addLayoutTool("layoutaddoverview", new LayoutRectangleBehavior(laovl));
134

    
135
        LayoutAddPictureListenerImpl lapl = new LayoutAddPictureListenerImpl(layout);
136
        addLayoutTool("layoutaddpicture", new LayoutRectangleBehavior(lapl));
137

    
138
        LayoutAddNorthListenerImpl lanorthl = new LayoutAddNorthListenerImpl(layout);
139
        addLayoutTool("layoutaddnorth", new LayoutRectangleBehavior(lanorthl));
140

    
141
        LayoutAddScaleListenerImpl lasl = new LayoutAddScaleListenerImpl(layout);
142
        addLayoutTool("layoutaddscale", new LayoutRectangleBehavior(lasl));
143

    
144
        LayoutAddLegendListenerImpl lall = new LayoutAddLegendListenerImpl(layout);
145
        addLayoutTool("layoutaddlegend", new LayoutRectangleBehavior(lall));
146

    
147
        LayoutAddTextListenerImpl latl = new LayoutAddTextListenerImpl(layout);
148
        addLayoutTool("layoutaddtext", new LayoutRectangleBehavior(latl));
149

    
150
        LayoutAddBoxListenerImpl labl = new LayoutAddBoxListenerImpl(layout);
151
        addLayoutTool("layoutaddbox", new LayoutRectangleBehavior(labl));
152

    
153
        LayoutAddPointListenerImpl lapointl = new LayoutAddPointListenerImpl(layout);
154
        addLayoutTool("layoutaddpoint", new LayoutPointBehavior(lapointl));
155

    
156
        LayoutAddLineListenerImpl lalinel = new LayoutAddLineListenerImpl(layout);
157
        addLayoutTool("layoutaddline", new LayoutPointBehavior(lalinel));
158

    
159
        LayoutAddPolygonListenerImpl lapolygonl = new LayoutAddPolygonListenerImpl(layout);
160
        addLayoutTool("layoutaddpolygon", new LayoutPointBehavior(lapolygonl));
161

    
162
        LayoutAddPolylineListenerImpl lapolylinel = new LayoutAddPolylineListenerImpl(layout);
163
        addLayoutTool("layoutaddpolyline", new LayoutPointBehavior(lapolylinel));
164

    
165
        LayoutAddCircleListenerImpl lacirclel = new LayoutAddCircleListenerImpl(layout);
166
        addLayoutTool("layoutaddcircle", new LayoutPointBehavior(lacirclel));
167

    
168
        LayoutAddRectangleListenerImpl larectanglel = new LayoutAddRectangleListenerImpl(layout);
169
        addLayoutTool("layoutaddrectangle",
170
            new LayoutPointBehavior(larectanglel));
171

    
172
        LayoutViewPanListenerImpl lvpl = new LayoutViewPanListenerImpl(layout);
173
        addLayoutTool("layoutviewpan", new LayoutViewMoveBehavior(lvpl));
174

    
175
        LayoutViewZoomInListenerImpl lvzil = new LayoutViewZoomInListenerImpl(layout);
176
        addLayoutTool("layoutviewzoomin", new LayoutViewZoomBehavior(lvzil));
177

    
178
        LayoutViewZoomOutListenerImpl lvzol = new LayoutViewZoomOutListenerImpl(layout);
179
        addLayoutTool("layoutviewzoomout", new LayoutViewZoomBehavior(lvzol));
180

    
181
        LayoutSelectListenerImpl lselectl = new LayoutSelectListenerImpl(layout);
182
        addLayoutTool("layoutselect", new LayoutSelectBehavior(lselectl));
183

    
184
        LayoutEditGraphicsListenerImpl leditl = new LayoutEditGraphicsListenerImpl(layout);
185
        addLayoutTool("layoutedit", new LayoutEditBehavior(leditl));
186

    
187
        setTool("layoutzoomin");
188
        FPopupMenu.registerExtensionPoint();
189
    }
190

    
191
    /**
192
     * Returns the name of the current selected tool on this Layout
193
     *
194
     * @return A tool name.
195
     */
196
    public String getCurrentTool() {
197
        return currentTool;
198
    }
199

    
200
    /**
201
     * Add a new Layout tool.
202
     *
203
     * @param name Name of tool.
204
     * @param tool LayoutBehavior
205
     */
206
    public void addLayoutTool(String name, LayoutBehavior tool) {
207
        namesLayoutTools.put(name, tool);
208
        tool.setLayoutControl(this);
209
    }
210

    
211
    /**
212
     * Inserts the LayoutContext.
213
     *
214
     * @param lc LayoutContext.
215
     */
216
    public void setLayoutContext(LayoutContext lc) {
217
        layoutContext = lc;
218
        layoutContext.addLayoutDrawListener(this);
219
    }
220

    
221
    /**
222
     * paintComponent of Layout.
223
     *
224
     * @param g Graphics of Layout.
225
     */
226
    protected void paintComponent(Graphics g) {
227
        clipVisibleRect((Graphics2D) g);
228

    
229
        Rectangle rClip = g.getClipBounds();
230

    
231
        if (rClip == null) {
232
            System.err.println("clip = null");
233
        }
234

    
235
        switch (status) {
236
        case DESACTUALIZADO:
237
            if (getWidth() == 0) {
238
                return;
239
            }
240

    
241
            img = new BufferedImage(getWidth(), getHeight(),
242
                    BufferedImage.TYPE_INT_ARGB);
243
            imgRuler = new BufferedImage(getWidth(), getHeight(),
244
                    BufferedImage.TYPE_INT_ARGB);
245

    
246
            Graphics gimag = img.getGraphics();
247
            Graphics gimgRuler = imgRuler.getGraphics();
248
            clipVisibleRect((Graphics2D) gimag);
249

    
250
            if (initial) {
251
                fullRect();
252
                initial = false;
253
            }
254

    
255
            try {
256
                layoutDraw.drawLayout((Graphics2D) gimag, img);
257
            } catch (ReadDriverException e) {
258
                e.printStackTrace();
259
            }
260

    
261
            g.setClip(rClip);
262
//            layoutDraw.drawRectangle((Graphics2D) gimag);
263

    
264
//            g.drawImage(img, 0, 0, this);
265
            g.setClip(rClip);
266

    
267
            layoutDraw.drawGrid((Graphics2D) gimgRuler);
268
            layoutDraw.drawRuler((Graphics2D) gimgRuler, Color.black);
269
            setStatus(ACTUALIZADO);
270
            repaint();
271
            break;
272

    
273
        case ACTUALIZADO:
274
//            layoutDraw.drawRectangle((Graphics2D) g);
275

    
276
            if (currentLayoutTool != null) {
277
                currentLayoutTool.paintComponent(g);
278
            } else {
279
                g.drawImage(img, 0, 0, this);
280

    
281
                layoutDraw.drawHandlers((Graphics2D) g, Color.black);
282
            }
283

    
284
            g.setClip(rClip);
285
//            drawCursor(g);
286
        }
287
    }
288

    
289
    /**
290
     * Inserts the status of Layout.
291
     *
292
     * @param s Status of Layout.
293
     */
294
    public void setStatus(int s) {
295
        status = s;
296
    }
297

    
298
    /**
299
     * Clip on visible rectangle.
300
     *
301
     * @param g2d Graphics.
302
     */
303
    private void clipVisibleRect(Graphics2D g2d) {
304
        rectVisible = this.getVisibleRect();
305
        g2d.clipRect((int) rectVisible.getMinX(), (int) rectVisible.getMinY(),
306
            (int) rectVisible.getWidth(), (int) rectVisible.getHeight());
307
    }
308

    
309
    /**
310
     * Returns the image with the ruler.
311
     *
312
     * @return Ruler image.
313
     */
314
    public BufferedImage getImgRuler() {
315
        return imgRuler;
316
    }
317

    
318
    /**
319
         * It obtains the rect that is adjusted to the size of the window,
320
         * to see the full extent of layout.
321
         */
322
    public void fullRect() {
323
        rect.setRect(origin.x, origin.y, getWidth() - (origin.x * 2),
324
            getHeight() - (origin.x * 2));
325

    
326
        if (layoutContext.getAtributes().isLandSpace()) {
327
            rect = layoutContext.getAtributes().getRectangleLandscape(rect,
328
                    getWidth(), getHeight());
329
        } else {
330
            rect = layoutContext.getAtributes().getRectanglePortrait(rect,
331
                    getWidth(), getHeight());
332
        }
333

    
334
        refresh();
335
    }
336

    
337
    /**
338
         * Returns the rectangle that represents the sheet.
339
         * In pixels.
340
         *
341
         * @return Rectangle2D.Double Rectangle that represents the sheet.
342
         */
343
    public Rectangle2D.Double getRect() {
344
        return rect;
345
    }
346

    
347
    /**
348
         * Inserts the rectangle that represents the sheet.
349
         * In pixels.
350
         *
351
         */
352
    public void setRect(Rectangle2D r) {
353
        rect.setRect(r);
354
    }
355

    
356
    /**
357
     * Returns the current image of Layout.
358
     *
359
     * @return Current image of Layout.
360
     */
361
    public BufferedImage getImage() {
362
        return img;
363
    }
364

    
365
    /**
366
     * Draw the cursor on the Graphics.
367
     *
368
     * @param g Graphics.
369
     */
370
    public void drawCursor(Graphics g) {
371
        if ((imageCursor != null) && (position != null)) {
372
            Point pAdjusted = position;
373
            g.drawImage(imageCursor, (int) pAdjusted.getX() - 16,
374
                (int) pAdjusted.getY() - 16, this);
375
        }
376
    }
377

    
378
    /**
379
         * Changes the pointer of the mouse by the image of parameter.
380
         *
381
         * @param image Image
382
         */
383
   public void setMapCursor(Cursor cursor) {
384
        this.setCursor(cursor);
385
    }
386

    
387
    /**
388
         * It establishes as selected to the tool from its name of identification.
389
         *
390
         * @param toolName Name of identification tool.
391
         */
392
    public void setTool(String toolName) {
393
        //prevTool=getCurrentTool();
394
        LayoutBehavior layoutTool = (LayoutBehavior) namesLayoutTools.get(toolName);
395
        currentLayoutTool = layoutTool;
396
        currentLayoutTool.setLayoutControl(this);
397
        currentTool = toolName;
398
        this.setMapCursor(layoutTool.getCursor());
399

    
400
        if (getCurrentLayoutTool().getListener() instanceof ILayoutGraphicListener) {
401
            geometryAdapter = ((ILayoutGraphicListener) getCurrentLayoutTool()
402
                                                            .getListener()).createGeometryAdapter();
403
        }
404

    
405
        if (getCurrentTool().equals("layoutedit")) {
406
            startEdit();
407
        } else {
408
            stopEdit();
409
        }
410
    }
411

    
412
    /**
413
         * Start the vertex edition of graphics.
414
         *
415
         */
416
    public void startEdit() {
417
        IFFrame[] fframes = layoutContext.getFFrames();
418

    
419
        for (int i = 0; i < fframes.length; i++) {
420
            IFFrame frame = fframes[i];
421

    
422
            if (frame instanceof IFFrameEditableVertex) {
423
                if (frame.getSelected() != IFFrame.NOSELECT) {
424
                    ((IFFrameEditableVertex) frame).startEditing();
425
                } else {
426
                    ((IFFrameEditableVertex) frame).stopEditing();
427
                }
428
            }
429
        }
430

    
431
        refresh();
432
    }
433

    
434
    /**
435
         * Stop the vertex edition of graphics.
436
         *
437
         */
438
    public void stopEdit() {
439
        boolean refresh = false;
440
        IFFrame[] fframes = layoutContext.getFFrames();
441

    
442
        for (int i = 0; i < fframes.length; i++) {
443
            IFFrame frame = fframes[i];
444

    
445
            if (frame instanceof IFFrameEditableVertex) {
446
                if (((IFFrameEditableVertex) frame).isEditing()) {
447
                    ((IFFrameEditableVertex) fframes[i]).stopEditing();
448
                    refresh = true;
449
                }
450
            }
451
        }
452

    
453
        if (refresh) {
454
            refresh();
455
        }
456
    }
457

    
458
    /**
459
         * It returns the point that represents the northwest corner of the Layout.
460
         *
461
         * @return Point.
462
         */
463
    public Point getRectOrigin() {
464
        return rectOrigin;
465
    }
466

    
467
    /**
468
     * Returns the object to draw the Layout.
469
     *
470
     * @return FLayoutDraw.
471
     */
472
    public FLayoutDraw getLayoutDraw() {
473
        return layoutDraw;
474
    }
475

    
476
    /**
477
     * Returns the current Layout tool.
478
     *
479
     * @return LayoutBehavior Current Layout Tool.
480
     */
481
    public LayoutBehavior getCurrentLayoutTool() {
482
        return currentLayoutTool;
483
    }
484

    
485
    /**
486
         * It returns the first click point of mouse.
487
         *
488
         * @return Point.
489
         */
490
    public Point getFirstPoint() {
491
        return m_FirstPoint;
492
    }
493

    
494
    /**
495
         * Returns the previous click of mouse.
496
         *
497
         * @return Point.
498
         */
499
    public Point getPointAnt() {
500
        return m_PointAnt;
501
    }
502

    
503
    /**
504
         * Returns the last click point of mouse.
505
         *
506
         * @return Point.
507
         */
508
    public Point getLastPoint() {
509
        return m_LastPoint;
510
    }
511

    
512
    /**
513
         * Inserts the first click point of mouse.
514
         *
515
         * @param p
516
         *            Point.
517
         */
518
    public void setFirstPoint() {
519
        m_FirstPoint = position;
520
    }
521

    
522
    /**
523
         * Inserts the previous click point of mouse.
524
         *
525
         * @param p
526
         *            Point.
527
         */
528
    public void setPointAnt() {
529
        m_PointAnt = position;
530
    }
531

    
532
    /**
533
         * Inserts the last click point of mouse.
534
         *
535
         * @param p
536
         *            Point.
537
         */
538
    public void setLastPoint() {
539
        m_LastPoint = position;
540
    }
541

    
542
    /**
543
     * Insert the position point and calculate the new position if the grid is actived.
544
     *
545
     * @param point2 Position.
546
     */
547
    public void setPosition(Point point2) {
548
        if (layoutContext.isAdjustingToGrid() &&
549
                getCurrentLayoutTool().isAdjustable()) {
550
            position = FLayoutUtilities.getPointGrid(point2,
551
                    layoutContext.getAtributes().getNumUnitsX(),
552
                    layoutContext.getAtributes().getNumUnitsY(),
553
                    layoutContext.getAT());
554
        } else {
555
            position = point2;
556
        }
557
    }
558

    
559
    /**
560
     * Returns the position adjusted point.
561
     *
562
     * @return
563
     */
564
    public Point getPosition() {
565
        return position;
566
    }
567

    
568
    /**
569
         * Returns the AffineTransform that is applying in the Layout.
570
         *
571
         * @return AffineTransform
572
         */
573
    public AffineTransform getAT() {
574
        return layoutContext.getAT();
575
    }
576

    
577
    /**
578
         * It returns the current GeometryAdapter.
579
         * @return Current GeometryAdapter.
580
         */
581
    public GeometryAdapter getGeometryAdapter() {
582
        return geometryAdapter;
583
    }
584

    
585
    /**
586
          * Remove last point of geometryAdapter.
587
          *
588
          */
589
    public void delLastPoint() {
590
        getGeometryAdapter().delLastPoint();
591
    }
592

    
593
    /**
594
     * Add a new point to geometryAdapter.
595
     *
596
     * @return Number of points in the geometryAdapter.
597
     */
598
    public int addGeometryAdapterPoint() {
599
        return getGeometryAdapter().addPoint(FLayoutUtilities.toSheetPoint(
600
                getPosition(), getAT()));
601
    }
602

    
603
    /**
604
     * Change the position of mousemoved point of geometryAdapter.
605
     */
606
    public void setGeometryAdapterPoinPosition() {
607
        getGeometryAdapter().pointPosition(FLayoutUtilities.toSheetPoint(
608
                getPosition(), getAT()));
609
    }
610

    
611
    /**
612
     * Clear the image of pointer of mouse.
613
     */
614
//    public void clearMouseImage() {
615
//        setCursor(transparentCursor);
616
//    }
617

    
618
    /**
619
     * Refres the Layout.
620
     */
621
    public void refresh() {
622
        setStatus(LayoutControl.DESACTUALIZADO);
623
        repaint();
624
    }
625

    
626
    /**
627
         * It returns true if the drawing has been canceled.
628
         *
629
         * @return true if the drawn has been canceled.
630
         */
631
    public synchronized boolean isDrawingCancelled() {
632
        return m_bCancelDrawing;
633
    }
634

    
635
    /**
636
         * It cancels the drawing if the parameter is true.
637
         *
638
         * @param b true if the drawing wants to be canceled
639
         */
640
    public synchronized void setCancelDrawing(boolean b) {
641
        m_bCancelDrawing = b;
642

    
643
        for (int i = 0; i < layoutContext.getFFrames().length; i++) {
644
            IFFrame fframe = layoutContext.getFFrame(i);
645

    
646
            if (fframe instanceof IFFrameUseFMap &&
647
                    (((IFFrameUseFMap) fframe).getMapContext() != null)) {
648
                // //TODO((FFrameView)
649
                // getFFrames().get(i)).getFMap().setCancelDrawing(b);
650
            }
651
        }
652
    }
653

    
654
    /**
655
         * Returns the rectangle of selection.
656
         *
657
         * @return Rectangle of selection.
658
         */
659
    public Rectangle getReSel() {
660
        return reSel;
661
    }
662

    
663
    /**
664
         * It returns true if should draw the rectangle of selection and does the selection.
665
         *
666
         * @return true if should draw the rectangle of selection.
667
         */
668
    public boolean isReSel() {
669
        return isReSel;
670
    }
671

    
672
    /**
673
         * Insert true if should draw the rectangle of selection and does the selection.
674
         *
675
         * @param b boolean.
676
         */
677
    public void setIsReSel(boolean b) {
678
        isReSel = b;
679
    }
680

    
681
    /**
682
         * It does a full extent of the layers that contains the view of the
683
         * FFrameView selected.
684
         *
685
         * @throws ReadDriverException
686
         */
687
    public void viewFull() throws ReadDriverException {
688
        IFFrame[] fframes = layoutContext.getFFrameSelected();
689

    
690
        for (int i = 0; i < fframes.length; i++) {
691
            if (fframes[i] instanceof IFFrameUseFMap) {
692
                IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
693

    
694
                if (fframe.getMapContext() != null) {
695
                    fframe.fullExtent();
696
                }
697

    
698
                fframe.refresh();
699
            }
700
        }
701

    
702
        refresh();
703
    }
704

    
705
    /**
706
     * Returns the object to make zooms.
707
     *
708
     * @return FLayoutZooms.
709
     */
710
    public FLayoutZooms getLayoutZooms() {
711
        return layoutZooms;
712
    }
713

    
714
    /**
715
     * Returns the object of FLayoutFunctions.
716
     *
717
     * @return FLayoutFunctions
718
     */
719
    public FLayoutFunctions getLayoutFunctions() {
720
        return layoutFunctions;
721
    }
722

    
723
    /**
724
     * Returns the LayoutContext.
725
     *
726
     * @return LayoutContext.
727
     */
728
    public LayoutContext getLayoutContext() {
729
        return layoutContext;
730
    }
731

    
732
    /**
733
     * Inserts the geometryAdapter.
734
     *
735
     * @param adapter GeometryAdapter.
736
     */
737
    public void setGeometryAdapter(GeometryAdapter adapter) {
738
        geometryAdapter = adapter;
739
    }
740
}