Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / LayoutControl.java @ 28304

History | View | Annotate | Download (22.6 KB)

1 9392 caballero
package com.iver.cit.gvsig.project.documents.layout;
2
3 12826 jaume
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 24759 jmvivo
import org.gvsig.fmap.dal.exception.ReadException;
20 20994 jmvivo
21 9392 caballero
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame;
22
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameEditableVertex;
23
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameUseFMap;
24 21299 vcaballero
import com.iver.cit.gvsig.project.documents.layout.geometryadapters.GeometryAdapter;
25
import com.iver.cit.gvsig.project.documents.layout.geometryadapters.PolyLineAdapter;
26 10007 caballero
import com.iver.cit.gvsig.project.documents.layout.gui.FPopupMenu;
27 9392 caballero
import com.iver.cit.gvsig.project.documents.layout.gui.Layout;
28
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddBoxListenerImpl;
29
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddCircleListenerImpl;
30
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddLegendListenerImpl;
31
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddLineListenerImpl;
32
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddNorthListenerImpl;
33
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddOverViewListenerImpl;
34
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddPictureListenerImpl;
35
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddPointListenerImpl;
36
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddPolygonListenerImpl;
37
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddPolylineListenerImpl;
38
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddRectangleListenerImpl;
39
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddScaleListenerImpl;
40
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddTextListenerImpl;
41
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddViewListenerImpl;
42
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutEditGraphicsListenerImpl;
43
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutPanListenerImpl;
44
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutSelectListenerImpl;
45
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutViewPanListenerImpl;
46
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutViewZoomInListenerImpl;
47
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutViewZoomOutListenerImpl;
48
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutZoomInListenerImpl;
49
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutZoomOutListenerImpl;
50
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutBehavior;
51
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutEditBehavior;
52
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutMoveBehavior;
53
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutPointBehavior;
54
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutRectangleBehavior;
55
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutSelectBehavior;
56
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutViewMoveBehavior;
57 9557 caballero
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutViewZoomBehavior;
58 9392 caballero
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutZoomBehavior;
59
import com.iver.cit.gvsig.project.documents.layout.tools.listener.ILayoutGraphicListener;
60
61 10007 caballero
62 9392 caballero
/**
63 10007 caballero
 * Control of Layout.
64 9392 caballero
 *
65
 * @author Vicente Caballero Navarro
66
 */
67 9806 caballero
public class LayoutControl extends JComponent implements LayoutDrawListener {
68 10007 caballero
    public static final int DESACTUALIZADO = 4;
69 9392 caballero
    public static final int ACTUALIZADO = 5;
70
    private int status = DESACTUALIZADO;
71
    private Rectangle2D rectVisible;
72
    private BufferedImage img = null;
73
    private BufferedImage imgRuler = null;
74
    private boolean initial = true;
75 10007 caballero
    private LayoutContext layoutContext;
76
    private Point origin = new Point(50, 50);
77
    private Point rectOrigin = new Point(origin);
78
    private Rectangle2D.Double rect = new Rectangle2D.Double(rectOrigin.x,
79
            rectOrigin.y, 400, 300);
80
    private FLayoutDraw layoutDraw = null;
81
    private FLayoutFunctions layoutFunctions = null;
82
    private LayoutBehavior currentLayoutTool = null;
83
    private Image imageCursor = null;
84
    private HashMap namesLayoutTools = new HashMap();
85
    private Point m_FirstPoint = new Point(0, 0);
86
    private Point m_PointAnt = new Point(0, 0);
87
    private Point m_LastPoint = new Point(0, 0);
88
    private LayoutEvents layoutEvents;
89
    private Point position;
90
    private GeometryAdapter geometryAdapter = new PolyLineAdapter();
91 9392 caballero
92 10007 caballero
    //private String prevTool;
93
    private String currentTool;
94
    private boolean m_bCancelDrawing = false;
95
    private Rectangle reSel = null;
96
    private boolean isReSel = true;
97
    private FLayoutZooms layoutZooms;
98 24563 vcaballero
99
    private static Cursor transparentCursor = Toolkit.getDefaultToolkit()
100
            .createCustomCursor(Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(
101
            16, 16, new int[16 * 16], 0, 16)),
102
            new Point(0, 0), "invisiblecursor");
103
104
105 10007 caballero
    /**
106
     * Create a new object of LayoutControl.
107
     * @param layout
108
     */
109
    public LayoutControl(Layout layout) {
110
        setLayoutContext(layout.getLayoutContext());
111
        layoutDraw = new FLayoutDraw(layout);
112
        layoutEvents = new LayoutEvents(layout);
113
        layoutZooms = new FLayoutZooms(layout);
114
        layoutFunctions = new FLayoutFunctions(layout);
115
        addComponentListener(layoutEvents);
116
        addMouseMotionListener(layoutEvents);
117
        addMouseListener(layoutEvents);
118 9392 caballero
119 10007 caballero
        layoutContext.updateFFrames();
120 9392 caballero
121 10007 caballero
        LayoutPanListenerImpl lpl = new LayoutPanListenerImpl(layout);
122 9392 caballero
        addLayoutTool("layoutpan", new LayoutMoveBehavior(lpl));
123
124
        LayoutZoomInListenerImpl lzil = new LayoutZoomInListenerImpl(layout);
125
        addLayoutTool("layoutzoomin", new LayoutZoomBehavior(lzil));
126
127
        LayoutZoomOutListenerImpl lzol = new LayoutZoomOutListenerImpl(layout);
128
        addLayoutTool("layoutzoomout", new LayoutZoomBehavior(lzol));
129
130
        LayoutAddViewListenerImpl lavl = new LayoutAddViewListenerImpl(layout);
131
        addLayoutTool("layoutaddview", new LayoutRectangleBehavior(lavl));
132
133
        LayoutAddOverViewListenerImpl laovl = new LayoutAddOverViewListenerImpl(layout);
134
        addLayoutTool("layoutaddoverview", new LayoutRectangleBehavior(laovl));
135
136
        LayoutAddPictureListenerImpl lapl = new LayoutAddPictureListenerImpl(layout);
137
        addLayoutTool("layoutaddpicture", new LayoutRectangleBehavior(lapl));
138
139
        LayoutAddNorthListenerImpl lanorthl = new LayoutAddNorthListenerImpl(layout);
140
        addLayoutTool("layoutaddnorth", new LayoutRectangleBehavior(lanorthl));
141
142
        LayoutAddScaleListenerImpl lasl = new LayoutAddScaleListenerImpl(layout);
143
        addLayoutTool("layoutaddscale", new LayoutRectangleBehavior(lasl));
144
145
        LayoutAddLegendListenerImpl lall = new LayoutAddLegendListenerImpl(layout);
146
        addLayoutTool("layoutaddlegend", new LayoutRectangleBehavior(lall));
147
148
        LayoutAddTextListenerImpl latl = new LayoutAddTextListenerImpl(layout);
149
        addLayoutTool("layoutaddtext", new LayoutRectangleBehavior(latl));
150
151
        LayoutAddBoxListenerImpl labl = new LayoutAddBoxListenerImpl(layout);
152
        addLayoutTool("layoutaddbox", new LayoutRectangleBehavior(labl));
153
154
        LayoutAddPointListenerImpl lapointl = new LayoutAddPointListenerImpl(layout);
155
        addLayoutTool("layoutaddpoint", new LayoutPointBehavior(lapointl));
156
157
        LayoutAddLineListenerImpl lalinel = new LayoutAddLineListenerImpl(layout);
158
        addLayoutTool("layoutaddline", new LayoutPointBehavior(lalinel));
159
160
        LayoutAddPolygonListenerImpl lapolygonl = new LayoutAddPolygonListenerImpl(layout);
161
        addLayoutTool("layoutaddpolygon", new LayoutPointBehavior(lapolygonl));
162
163
        LayoutAddPolylineListenerImpl lapolylinel = new LayoutAddPolylineListenerImpl(layout);
164
        addLayoutTool("layoutaddpolyline", new LayoutPointBehavior(lapolylinel));
165
166
        LayoutAddCircleListenerImpl lacirclel = new LayoutAddCircleListenerImpl(layout);
167
        addLayoutTool("layoutaddcircle", new LayoutPointBehavior(lacirclel));
168
169
        LayoutAddRectangleListenerImpl larectanglel = new LayoutAddRectangleListenerImpl(layout);
170 10007 caballero
        addLayoutTool("layoutaddrectangle",
171
            new LayoutPointBehavior(larectanglel));
172 9392 caballero
173
        LayoutViewPanListenerImpl lvpl = new LayoutViewPanListenerImpl(layout);
174
        addLayoutTool("layoutviewpan", new LayoutViewMoveBehavior(lvpl));
175
176
        LayoutViewZoomInListenerImpl lvzil = new LayoutViewZoomInListenerImpl(layout);
177 9557 caballero
        addLayoutTool("layoutviewzoomin", new LayoutViewZoomBehavior(lvzil));
178 9392 caballero
179
        LayoutViewZoomOutListenerImpl lvzol = new LayoutViewZoomOutListenerImpl(layout);
180 9557 caballero
        addLayoutTool("layoutviewzoomout", new LayoutViewZoomBehavior(lvzol));
181 9392 caballero
182
        LayoutSelectListenerImpl lselectl = new LayoutSelectListenerImpl(layout);
183
        addLayoutTool("layoutselect", new LayoutSelectBehavior(lselectl));
184
185
        LayoutEditGraphicsListenerImpl leditl = new LayoutEditGraphicsListenerImpl(layout);
186
        addLayoutTool("layoutedit", new LayoutEditBehavior(leditl));
187
188
        setTool("layoutzoomin");
189 9806 caballero
        FPopupMenu.registerExtensionPoint();
190 10007 caballero
    }
191 9392 caballero
192 10007 caballero
    /**
193
     * Returns the name of the current selected tool on this Layout
194
     *
195
     * @return A tool name.
196
     */
197
    public String getCurrentTool() {
198
        return currentTool;
199
    }
200
201
    /**
202
     * Add a new Layout tool.
203
     *
204
     * @param name Name of tool.
205
     * @param tool LayoutBehavior
206
     */
207 9392 caballero
    public void addLayoutTool(String name, LayoutBehavior tool) {
208 10007 caballero
        namesLayoutTools.put(name, tool);
209
        tool.setLayoutControl(this);
210
    }
211 9392 caballero
212 10007 caballero
    /**
213
     * Inserts the LayoutContext.
214
     *
215
     * @param lc LayoutContext.
216
     */
217 9392 caballero
    public void setLayoutContext(LayoutContext lc) {
218 10007 caballero
        layoutContext = lc;
219
        layoutContext.addLayoutDrawListener(this);
220 9392 caballero
    }
221 10007 caballero
222 9392 caballero
    /**
223 10007 caballero
     * paintComponent of Layout.
224 9392 caballero
     *
225 10007 caballero
     * @param g Graphics of Layout.
226 9392 caballero
     */
227
    protected void paintComponent(Graphics g) {
228
        clipVisibleRect((Graphics2D) g);
229
230
        Rectangle rClip = g.getClipBounds();
231
232
        if (rClip == null) {
233
            System.err.println("clip = null");
234
        }
235
236
        switch (status) {
237 10007 caballero
        case DESACTUALIZADO:
238
            if (getWidth() == 0) {
239
                return;
240
            }
241
242 9392 caballero
            img = new BufferedImage(getWidth(), getHeight(),
243
                    BufferedImage.TYPE_INT_ARGB);
244
            imgRuler = new BufferedImage(getWidth(), getHeight(),
245
                    BufferedImage.TYPE_INT_ARGB);
246 10007 caballero
247 9392 caballero
            Graphics gimag = img.getGraphics();
248
            Graphics gimgRuler = imgRuler.getGraphics();
249
            clipVisibleRect((Graphics2D) gimag);
250
251
            if (initial) {
252
                fullRect();
253
                initial = false;
254
            }
255
256
            try {
257
                layoutDraw.drawLayout((Graphics2D) gimag, img);
258 21299 vcaballero
            } catch (ReadException e) {
259 9392 caballero
                e.printStackTrace();
260
            }
261 10007 caballero
262 9392 caballero
            g.setClip(rClip);
263
            layoutDraw.drawRectangle((Graphics2D) g);
264
265
            g.drawImage(img, 0, 0, this);
266
            g.setClip(rClip);
267
268
            layoutDraw.drawGrid((Graphics2D) gimgRuler);
269
            layoutDraw.drawRuler((Graphics2D) gimgRuler, Color.black);
270
            setStatus(ACTUALIZADO);
271
            repaint();
272 10007 caballero
273 9392 caballero
            break;
274
275
        case ACTUALIZADO:
276
            layoutDraw.drawRectangle((Graphics2D) g);
277
278 10007 caballero
            if (currentLayoutTool != null) {
279 9392 caballero
                currentLayoutTool.paintComponent(g);
280 10007 caballero
            } else {
281
                g.drawImage(img, 0, 0, this);
282 9392 caballero
283 10007 caballero
                layoutDraw.drawHandlers((Graphics2D) g, Color.black);
284 9392 caballero
            }
285 10007 caballero
286 9392 caballero
            g.setClip(rClip);
287
            drawCursor(g);
288
        }
289 10007 caballero
    }
290 9392 caballero
291 10007 caballero
    /**
292
     * Inserts the status of Layout.
293
     *
294
     * @param s Status of Layout.
295
     */
296
    public void setStatus(int s) {
297
        status = s;
298 9392 caballero
    }
299
300 10007 caballero
    /**
301
     * Clip on visible rectangle.
302 9392 caballero
     *
303 10007 caballero
     * @param g2d Graphics.
304 9392 caballero
     */
305
    private void clipVisibleRect(Graphics2D g2d) {
306
        rectVisible = this.getVisibleRect();
307
        g2d.clipRect((int) rectVisible.getMinX(), (int) rectVisible.getMinY(),
308 10007 caballero
            (int) rectVisible.getWidth(), (int) rectVisible.getHeight());
309 9392 caballero
    }
310 10007 caballero
311
    /**
312
     * Returns the image with the ruler.
313
     *
314
     * @return Ruler image.
315
     */
316 9392 caballero
    public BufferedImage getImgRuler() {
317 10007 caballero
        return imgRuler;
318
    }
319
320 9392 caballero
    /**
321 10007 caballero
         * It obtains the rect that is adjusted to the size of the window,
322
         * to see the full extent of layout.
323
         */
324 9392 caballero
    public void fullRect() {
325
        rect.setRect(origin.x, origin.y, getWidth() - (origin.x * 2),
326 10007 caballero
            getHeight() - (origin.x * 2));
327 9392 caballero
328 23069 vcaballero
        if (layoutContext.getAttributes().isLandSpace()) {
329
            rect = layoutContext.getAttributes().getRectangleLandscape(rect,
330 10007 caballero
                    getWidth(), getHeight());
331 9392 caballero
        } else {
332 23069 vcaballero
            rect = layoutContext.getAttributes().getRectanglePortrait(rect,
333 10007 caballero
                    getWidth(), getHeight());
334 9392 caballero
        }
335 10007 caballero
336 9392 caballero
        refresh();
337
    }
338
339
    /**
340 10007 caballero
         * Returns the rectangle that represents the sheet.
341
         * In pixels.
342
         *
343
         * @return Rectangle2D.Double Rectangle that represents the sheet.
344
         */
345 9392 caballero
    public Rectangle2D.Double getRect() {
346
        return rect;
347
    }
348
349 10007 caballero
    /**
350
         * Inserts the rectangle that represents the sheet.
351
         * In pixels.
352
         *
353
         */
354 9392 caballero
    public void setRect(Rectangle2D r) {
355
        rect.setRect(r);
356
    }
357 10007 caballero
358
    /**
359
     * Returns the current image of Layout.
360
     *
361
     * @return Current image of Layout.
362
     */
363 9392 caballero
    public BufferedImage getImage() {
364 10007 caballero
        return img;
365
    }
366
367
    /**
368
     * Draw the cursor on the Graphics.
369
     *
370
     * @param g Graphics.
371
     */
372 9392 caballero
    private void drawCursor(Graphics g) {
373 10007 caballero
        if ((imageCursor != null) && (position != null)) {
374
            Point pAdjusted = position;
375
            g.drawImage(imageCursor, (int) pAdjusted.getX() - 16,
376
                (int) pAdjusted.getY() - 16, this);
377 9392 caballero
        }
378
    }
379 10007 caballero
380 9392 caballero
    /**
381 10007 caballero
         * Changes the pointer of the mouse by the image of parameter.
382
         *
383
         * @param image Image
384
         */
385 9392 caballero
    public void setMapCursor(Image image) {
386 10007 caballero
        imageCursor = image;
387 9392 caballero
    }
388 10007 caballero
389 9392 caballero
    /**
390 10007 caballero
         * It establishes as selected to the tool from its name of identification.
391 9392 caballero
         *
392 10007 caballero
         * @param toolName Name of identification tool.
393 9392 caballero
         */
394 10007 caballero
    public void setTool(String toolName) {
395
        //prevTool=getCurrentTool();
396
        LayoutBehavior layoutTool = (LayoutBehavior) namesLayoutTools.get(toolName);
397
        currentLayoutTool = layoutTool;
398
        currentLayoutTool.setLayoutControl(this);
399
        currentTool = toolName;
400
        this.setMapCursor(layoutTool.getImageCursor());
401
402
        if (getCurrentLayoutTool().getListener() instanceof ILayoutGraphicListener) {
403
            geometryAdapter = ((ILayoutGraphicListener) getCurrentLayoutTool()
404
                                                            .getListener()).createGeometryAdapter();
405
        }
406
407
        if (getCurrentTool().equals("layoutedit")) {
408
            startEdit();
409
        } else {
410
            stopEdit();
411
        }
412 9392 caballero
    }
413
414 10007 caballero
    /**
415
         * Start the vertex edition of graphics.
416
         *
417
         */
418
    public void startEdit() {
419
        IFFrame[] fframes = layoutContext.getFFrames();
420 9392 caballero
421 10007 caballero
        for (int i = 0; i < fframes.length; i++) {
422
            IFFrame frame = fframes[i];
423
424
            if (frame instanceof IFFrameEditableVertex) {
425
                if (frame.getSelected() != IFFrame.NOSELECT) {
426
                    ((IFFrameEditableVertex) frame).startEditing();
427
                } else {
428
                    ((IFFrameEditableVertex) frame).stopEditing();
429
                }
430
            }
431
        }
432
433
        refresh();
434
    }
435
436
    /**
437
         * Stop the vertex edition of graphics.
438
         *
439
         */
440
    public void stopEdit() {
441
        boolean refresh = false;
442
        IFFrame[] fframes = layoutContext.getFFrames();
443
444
        for (int i = 0; i < fframes.length; i++) {
445
            IFFrame frame = fframes[i];
446
447
            if (frame instanceof IFFrameEditableVertex) {
448
                if (((IFFrameEditableVertex) frame).isEditing()) {
449
                    ((IFFrameEditableVertex) fframes[i]).stopEditing();
450
                    refresh = true;
451
                }
452
            }
453
        }
454
455
        if (refresh) {
456
            refresh();
457
        }
458
    }
459
460
    /**
461
         * It returns the point that represents the northwest corner of the Layout.
462
         *
463
         * @return Point.
464
         */
465 9392 caballero
    public Point getRectOrigin() {
466
        return rectOrigin;
467
    }
468 10007 caballero
469
    /**
470
     * Returns the object to draw the Layout.
471
     *
472
     * @return FLayoutDraw.
473
     */
474 9392 caballero
    public FLayoutDraw getLayoutDraw() {
475 10007 caballero
        return layoutDraw;
476
    }
477
478
    /**
479
     * Returns the current Layout tool.
480 9392 caballero
     *
481 10007 caballero
     * @return LayoutBehavior Current Layout Tool.
482 9392 caballero
     */
483 10007 caballero
    public LayoutBehavior getCurrentLayoutTool() {
484
        return currentLayoutTool;
485
    }
486
487
    /**
488
         * It returns the first click point of mouse.
489
         *
490
         * @return Point.
491
         */
492 9392 caballero
    public Point getFirstPoint() {
493
        return m_FirstPoint;
494
    }
495
496
    /**
497 10007 caballero
         * Returns the previous click of mouse.
498
         *
499
         * @return Point.
500
         */
501 9392 caballero
    public Point getPointAnt() {
502
        return m_PointAnt;
503
    }
504
505
    /**
506 10007 caballero
         * Returns the last click point of mouse.
507
         *
508
         * @return Point.
509
         */
510 9392 caballero
    public Point getLastPoint() {
511
        return m_LastPoint;
512
    }
513
514
    /**
515 10007 caballero
         * Inserts the first click point of mouse.
516
         *
517
         * @param p
518
         *            Point.
519
         */
520 9392 caballero
    public void setFirstPoint() {
521 10007 caballero
        m_FirstPoint = position;
522 9392 caballero
    }
523
524
    /**
525 10007 caballero
         * Inserts the previous click point of mouse.
526
         *
527
         * @param p
528
         *            Point.
529
         */
530 9392 caballero
    public void setPointAnt() {
531 10007 caballero
        m_PointAnt = position;
532 9392 caballero
    }
533
534
    /**
535 10007 caballero
         * Inserts the last click point of mouse.
536
         *
537
         * @param p
538
         *            Point.
539
         */
540
    public void setLastPoint() {
541
        m_LastPoint = position;
542
    }
543
544
    /**
545
     * Insert the position point and calculate the new position if the grid is actived.
546 9392 caballero
     *
547 10007 caballero
     * @param point2 Position.
548 9392 caballero
     */
549
    public void setPosition(Point point2) {
550 10007 caballero
        if (layoutContext.isAdjustingToGrid() &&
551
                getCurrentLayoutTool().isAdjustable()) {
552
            position = FLayoutUtilities.getPointGrid(point2,
553 23069 vcaballero
                    layoutContext.getAttributes().getNumUnitsX(),
554
                    layoutContext.getAttributes().getNumUnitsY(),
555 10007 caballero
                    layoutContext.getAT());
556
        } else {
557
            position = point2;
558 9392 caballero
        }
559
    }
560 10007 caballero
561
    /**
562
     * Returns the position adjusted point.
563 9392 caballero
     *
564 10007 caballero
     * @return
565 9392 caballero
     */
566 10007 caballero
    public Point getPosition() {
567
        return position;
568
    }
569
570
    /**
571
         * Returns the AffineTransform that is applying in the Layout.
572
         *
573
         * @return AffineTransform
574
         */
575 9392 caballero
    public AffineTransform getAT() {
576 9806 caballero
        return layoutContext.getAT();
577 9392 caballero
    }
578 10007 caballero
579
    /**
580
         * It returns the current GeometryAdapter.
581
         * @return Current GeometryAdapter.
582
         */
583 9392 caballero
    public GeometryAdapter getGeometryAdapter() {
584
        return geometryAdapter;
585
    }
586 10007 caballero
587
    /**
588
          * Remove last point of geometryAdapter.
589
          *
590
          */
591 9392 caballero
    public void delLastPoint() {
592
        getGeometryAdapter().delLastPoint();
593
    }
594 10007 caballero
595
    /**
596
     * Add a new point to geometryAdapter.
597
     *
598
     * @return Number of points in the geometryAdapter.
599
     */
600 9392 caballero
    public int addGeometryAdapterPoint() {
601 10007 caballero
        return getGeometryAdapter().addPoint(FLayoutUtilities.toSheetPoint(
602
                getPosition(), getAT()));
603 9392 caballero
    }
604
605 10007 caballero
    /**
606
     * Change the position of mousemoved point of geometryAdapter.
607
     */
608 9392 caballero
    public void setGeometryAdapterPoinPosition() {
609 10007 caballero
        getGeometryAdapter().pointPosition(FLayoutUtilities.toSheetPoint(
610
                getPosition(), getAT()));
611 9392 caballero
    }
612
613 10007 caballero
    /**
614
     * Clear the image of pointer of mouse.
615
     */
616
    public void clearMouseImage() {
617
        setCursor(transparentCursor);
618
    }
619 9392 caballero
620 10007 caballero
    /**
621
     * Refres the Layout.
622 9392 caballero
     */
623 10007 caballero
    public void refresh() {
624
        setStatus(LayoutControl.DESACTUALIZADO);
625
        repaint();
626
    }
627
628
    /**
629
         * It returns true if the drawing has been canceled.
630
         *
631
         * @return true if the drawn has been canceled.
632
         */
633 9392 caballero
    public synchronized boolean isDrawingCancelled() {
634
        return m_bCancelDrawing;
635
    }
636
637
    /**
638 10007 caballero
         * It cancels the drawing if the parameter is true.
639
         *
640
         * @param b true if the drawing wants to be canceled
641
         */
642 9392 caballero
    public synchronized void setCancelDrawing(boolean b) {
643
        m_bCancelDrawing = b;
644
645
        for (int i = 0; i < layoutContext.getFFrames().length; i++) {
646
            IFFrame fframe = layoutContext.getFFrame(i);
647
648 10007 caballero
            if (fframe instanceof IFFrameUseFMap &&
649
                    (((IFFrameUseFMap) fframe).getMapContext() != null)) {
650 9392 caballero
                // //TODO((FFrameView)
651
                // getFFrames().get(i)).getFMap().setCancelDrawing(b);
652
            }
653
        }
654
    }
655 9806 caballero
656 9392 caballero
    /**
657 10007 caballero
         * Returns the rectangle of selection.
658
         *
659
         * @return Rectangle of selection.
660
         */
661 9392 caballero
    public Rectangle getReSel() {
662
        return reSel;
663
    }
664
665
    /**
666 10007 caballero
         * It returns true if should draw the rectangle of selection and does the selection.
667
         *
668
         * @return true if should draw the rectangle of selection.
669
         */
670 9392 caballero
    public boolean isReSel() {
671
        return isReSel;
672
    }
673
674
    /**
675 10007 caballero
         * Insert true if should draw the rectangle of selection and does the selection.
676
         *
677
         * @param b boolean.
678
         */
679 9392 caballero
    public void setIsReSel(boolean b) {
680
        isReSel = b;
681
    }
682
683
    /**
684 10007 caballero
         * It does a full extent of the layers that contains the view of the
685
         * FFrameView selected.
686
         *
687 10661 caballero
         * @throws ReadDriverException
688 10007 caballero
         */
689 21299 vcaballero
    public void viewFull() throws ReadException {
690 9392 caballero
        IFFrame[] fframes = layoutContext.getFFrameSelected();
691 10007 caballero
692 9392 caballero
        for (int i = 0; i < fframes.length; i++) {
693
            if (fframes[i] instanceof IFFrameUseFMap) {
694
                IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
695
696
                if (fframe.getMapContext() != null) {
697
                    fframe.fullExtent();
698
                }
699 10007 caballero
700 9392 caballero
                fframe.refresh();
701
            }
702
        }
703 10007 caballero
704 9392 caballero
        refresh();
705
    }
706
707 10007 caballero
    /**
708
     * Returns the object to make zooms.
709
     *
710
     * @return FLayoutZooms.
711
     */
712 9392 caballero
    public FLayoutZooms getLayoutZooms() {
713 10007 caballero
        return layoutZooms;
714
    }
715 9392 caballero
716 10007 caballero
    /**
717
     * Returns the object of FLayoutFunctions.
718
     *
719
     * @return FLayoutFunctions
720
     */
721
    public FLayoutFunctions getLayoutFunctions() {
722
        return layoutFunctions;
723
    }
724 9392 caballero
725 10007 caballero
    /**
726
     * Returns the LayoutContext.
727
     *
728
     * @return LayoutContext.
729
     */
730
    public LayoutContext getLayoutContext() {
731
        return layoutContext;
732
    }
733
734
    /**
735
     * Inserts the geometryAdapter.
736
     *
737
     * @param adapter GeometryAdapter.
738
     */
739
    public void setGeometryAdapter(GeometryAdapter adapter) {
740
        geometryAdapter = adapter;
741
    }
742 9392 caballero
}