svn-document-layout / trunk / org.gvsig.app.document.layout.app / org.gvsig.app.document.layout.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / tools / behavior / LayoutPointBehavior.java @ 5
History | View | Annotate | Download (3.59 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.behavior; |
23 |
|
24 |
import java.awt.Graphics; |
25 |
import java.awt.event.MouseEvent; |
26 |
|
27 |
import org.gvsig.app.project.documents.layout.tools.listener.LayoutPointListener; |
28 |
import org.gvsig.app.project.documents.layout.tools.listener.LayoutToolListener; |
29 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
30 |
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent; |
31 |
import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener; |
32 |
|
33 |
/**
|
34 |
* LayoutBehaviour que espera un listener de tipo LayoutPointListener.
|
35 |
*
|
36 |
* @author Vicente Caballero Navarro
|
37 |
*/
|
38 |
public class LayoutPointBehavior extends LayoutBehavior { |
39 |
|
40 |
private LayoutPointListener listener;
|
41 |
private boolean doubleClick = false; |
42 |
|
43 |
/**
|
44 |
* Crea un nuevo LayoutPointBehavior.
|
45 |
*
|
46 |
* @param l
|
47 |
* listener.
|
48 |
*/
|
49 |
public LayoutPointBehavior(LayoutPointListener l) {
|
50 |
listener = l; |
51 |
} |
52 |
|
53 |
/**
|
54 |
* Reimplementaci?n del m?todo mousePressed de Behavior.
|
55 |
*
|
56 |
* @param e
|
57 |
* MouseEvent
|
58 |
* @throws BehaviorException
|
59 |
*/
|
60 |
public void mousePressed(MouseEvent e) throws BehaviorException { |
61 |
super.mousePressed(e);
|
62 |
if (listener.cancelDrawing()) {
|
63 |
// getMapControl().cancelDrawing();
|
64 |
} |
65 |
if (e.getClickCount() == 2) { |
66 |
doubleClick = true;
|
67 |
} |
68 |
} |
69 |
|
70 |
/**
|
71 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#paintComponent(java.awt.Graphics)
|
72 |
*/
|
73 |
public void paintComponent(Graphics g) { |
74 |
super.paintComponent(g);
|
75 |
} |
76 |
|
77 |
/**
|
78 |
* Reimplementaci?n del m?todo mouseReleased de Behavior.
|
79 |
*
|
80 |
* @param e
|
81 |
* MouseEvent
|
82 |
*
|
83 |
* @throws BehaviorException
|
84 |
* Excepci?n lanzada cuando el Maptool.
|
85 |
*/
|
86 |
public void mouseReleased(MouseEvent e) throws BehaviorException { |
87 |
super.mouseReleased(e);
|
88 |
PointEvent event = new PointEvent(e.getPoint(), e);
|
89 |
listener.point(event); |
90 |
if (doubleClick) {
|
91 |
listener.pointDoubleClick(event); |
92 |
doubleClick = false;
|
93 |
} |
94 |
} |
95 |
|
96 |
/**
|
97 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#setListener(com.iver.cit.gvsig.fmap.tools.ToolListener)
|
98 |
*/
|
99 |
public void setListener(ToolListener listener) { |
100 |
this.listener = (LayoutPointListener) listener;
|
101 |
} |
102 |
|
103 |
/**
|
104 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#getListener()
|
105 |
*/
|
106 |
public LayoutToolListener getListener() {
|
107 |
return listener;
|
108 |
} |
109 |
|
110 |
public void mouseMoved(MouseEvent e) throws BehaviorException { |
111 |
super.mouseMoved(e);
|
112 |
getLayoutControl().setGeometryAdapterPoinPosition(); |
113 |
} |
114 |
|
115 |
public boolean isAdjustable() { |
116 |
return true; |
117 |
} |
118 |
} |