Statistics
| Revision:

svn-document-layout / tags / 2059 / org.gvsig.app.document.layout.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / tools / LayoutPanListenerImpl.java @ 46

History | View | Annotate | Download (4.17 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

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

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

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

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

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

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

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

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

    
92
    }
93

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

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

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

    
115
    }
116

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

    
120
    }
121

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

    
125
    }
126

    
127
}