Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / tools / behavior / LayoutPointBehavior.java @ 9392

History | View | Annotate | Download (3.69 KB)

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

    
43
import java.awt.Graphics;
44
import java.awt.event.MouseEvent;
45

    
46
import com.iver.cit.gvsig.fmap.tools.BehaviorException;
47
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent;
48
import com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener;
49
import com.iver.cit.gvsig.project.documents.layout.tools.listener.LayoutPointListener;
50
import com.iver.cit.gvsig.project.documents.layout.tools.listener.LayoutToolListener;
51

    
52

    
53
/**
54
 * LayoutBehaviour que espera un listener de tipo LayoutPointListener.
55
 *
56
 * @author Vicente Caballero Navarro
57
 */
58
public class LayoutPointBehavior extends LayoutBehavior{
59
        private LayoutPointListener listener;
60
        private boolean doubleClick=false;
61
        /**
62
         * Crea un nuevo LayoutPointBehavior.
63
         *
64
         * @param l listener.
65
         */
66
        public LayoutPointBehavior(LayoutPointListener l) {
67
                listener = l;
68
        }
69

    
70
        /**
71
         * Reimplementaci?n del m?todo mousePressed de Behavior.
72
         *
73
         * @param e MouseEvent
74
         * @throws BehaviorException
75
         */
76
        public void mousePressed(MouseEvent e) throws BehaviorException {
77
                super.mousePressed(e);
78
                  if (e.getButton() == MouseEvent.BUTTON1) {
79
                    getLayoutControl().setPointAnt();
80
                    getLayoutControl().setFirstPoint();
81
                  }
82
                if (listener.cancelDrawing()) {
83
                //        getMapControl().cancelDrawing();
84
                }
85
                if (e.getClickCount()==2){
86
                        doubleClick=true;
87
                }
88
        }
89
        /**
90
         * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#paintComponent(java.awt.Graphics)
91
         */
92
        public void paintComponent(Graphics g) {
93
                super.paintComponent(g);
94
        }
95
        /**
96
         * Reimplementaci?n del m?todo mouseReleased de Behavior.
97
         *
98
         * @param e MouseEvent
99
         *
100
         * @throws BehaviorException Excepci?n lanzada cuando el Maptool.
101
         */
102
        public void mouseReleased(MouseEvent e) throws BehaviorException {
103
                super.mouseReleased(e);
104
                PointEvent event = new PointEvent(e.getPoint(), e);
105
                listener.point(event);
106
                if (doubleClick){
107
                        listener.pointDoubleClick(event);
108
                        doubleClick=false;
109
                }
110
        }
111

    
112
        /**
113
         * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#setListener(com.iver.cit.gvsig.fmap.tools.ToolListener)
114
         */
115
        public void setListener(ToolListener listener) {
116
                this.listener = (LayoutPointListener) listener;
117
        }
118

    
119
        /**
120
         * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#getListener()
121
         */
122
        public LayoutToolListener getListener() {
123
                return listener;
124
        }
125

    
126
        public void mouseMoved(MouseEvent e) throws BehaviorException {
127
                super.mouseMoved(e);
128
                 getLayoutControl().setGeometryAdapterPoinPosition();
129
        }
130

    
131
        public boolean isAdjustable() {
132
                return true;
133
        }
134
}