Statistics
| Revision:

svn-document-layout / trunk / org.gvsig.app.document.layout2.app / org.gvsig.app.document.layout2.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / tools / LayoutPanListenerImpl.java @ 357

History | View | Annotate | Download (4.23 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.project.documents.layout.tools;
23

    
24
import java.awt.Image;
25
import java.awt.Point;
26
import java.awt.event.MouseEvent;
27
import java.awt.geom.Rectangle2D;
28

    
29
import org.gvsig.andami.PluginServices;
30
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
31
import org.gvsig.app.project.documents.layout.tools.listener.LayoutMoveListener;
32
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
33
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent;
34

    
35
/**
36
 * Implementaci�n de la interfaz LayoutPanListener como herramienta para
37
 * realizar el
38
 * Pan.
39
 * 
40
 * @author Vicente Caballero Navarro
41
 */
42
public class LayoutPanListenerImpl extends AbstractLayoutToolListener implements
43
    LayoutMoveListener {
44

    
45
    public static final Image iLayoutpan = PluginServices.getIconTheme()
46
        .get("layout-pan-icon").getImage();
47

    
48
    /**
49
     * Crea un nuevo RectangleListenerImpl.
50
     * 
51
     * @param mapControl
52
     *            MapControl.
53
     */
54
    public LayoutPanListenerImpl(LayoutPanel layoutPanel) {
55
        super(layoutPanel);
56
    }
57

    
58
    /**
59
     * @see org.gvsig.fmap.mapcontrol.tools.Listeners.PanListener#move(java.awt.geom.Point2D,
60
     *      java.awt.geom.Point2D)
61
     */
62
    public void drag(PointEvent event) {
63
        Point pLast = layoutPanel.getLayoutControl().getLastPoint();
64
        Point pAnt = layoutPanel.getLayoutControl().getPointAnt();
65
        Point origin = layoutPanel.getLayoutControl().getRectOrigin();
66
        Rectangle2D.Double r = layoutPanel.getLayoutControl().getRect();
67
        r.x = origin.getX() + pLast.getX() - pAnt.getX();
68
        r.y = origin.getY() + pLast.getY() - pAnt.getY();
69
        layoutPanel.getLayoutControl().setRect(r);
70
    }
71

    
72
    /**
73
     * @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#getCursor()
74
     */
75
    public Image getImageCursor() {
76
        return iLayoutpan;
77
    }
78

    
79
    /**
80
     * @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#cancelDrawing()
81
     */
82
    public boolean cancelDrawing() {
83
        return true;
84
    }
85

    
86
    public void press(PointEvent event) throws BehaviorException {
87
        layoutPanel
88
            .getLayoutControl()
89
            .getRectOrigin()
90
            .setLocation(layoutPanel.getLayoutControl().getRect().x,
91
                layoutPanel.getLayoutControl().getRect().y);
92

    
93
    }
94

    
95
    public void release(PointEvent event) throws BehaviorException {
96
        Point p1;
97
        Point p2;
98

    
99
        if (event.getEvent().getButton() == MouseEvent.BUTTON1) {
100
            p1 = layoutPanel.getLayoutControl().getFirstPoint();
101
            p2 = event.getEvent().getPoint();
102
            layoutPanel.getLayoutControl().getLayoutZooms().setPan(p1, p2);
103
            layoutPanel.getLayoutControl().refresh();
104
            PluginServices.getMainFrame().enableControls();
105
        }
106

    
107
        layoutPanel.getLayoutControl().setFirstPoint();
108
        layoutPanel.getLayoutControl().setLastPoint();
109
        layoutPanel.getLayoutControl().setPointAnt();
110
        layoutPanel
111
            .getLayoutControl()
112
            .getRectOrigin()
113
            .setLocation(layoutPanel.getLayoutControl().getRect().x,
114
                layoutPanel.getLayoutControl().getRect().y);
115

    
116
    }
117

    
118
    public void move(PointEvent event) throws BehaviorException {
119
        // TODO Auto-generated method stub
120

    
121
    }
122

    
123
    public void click(PointEvent event) throws BehaviorException {
124
        // TODO Auto-generated method stub
125

    
126
    }
127

    
128
}