root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / tools / behavior / LayoutViewMoveBehavior.java @ 9392
History | View | Annotate | Download (5.41 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.Color; |
44 |
import java.awt.Graphics; |
45 |
import java.awt.Graphics2D; |
46 |
import java.awt.event.MouseEvent; |
47 |
import java.awt.geom.Rectangle2D; |
48 |
|
49 |
import com.iver.cit.gvsig.fmap.tools.BehaviorException; |
50 |
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent; |
51 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame; |
52 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameUseFMap; |
53 |
import com.iver.cit.gvsig.project.documents.layout.tools.listener.LayoutMoveListener; |
54 |
import com.iver.cit.gvsig.project.documents.layout.tools.listener.LayoutToolListener; |
55 |
|
56 |
|
57 |
/**
|
58 |
* Behaviour que espera un listener de tipo MoveListener.
|
59 |
*
|
60 |
* @author Vicente Caballero Navarro
|
61 |
*/
|
62 |
public class LayoutViewMoveBehavior extends LayoutBehavior { |
63 |
private LayoutMoveListener listener;
|
64 |
|
65 |
/**
|
66 |
* Crea un nuevo MoveBehavior.
|
67 |
*
|
68 |
* @param pli listener.
|
69 |
*/
|
70 |
public LayoutViewMoveBehavior(LayoutMoveListener lpl) {
|
71 |
listener = lpl; |
72 |
} |
73 |
|
74 |
/**
|
75 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#paintComponent(java.awt.Graphics)
|
76 |
*/
|
77 |
public void paintComponent(Graphics g) { |
78 |
IFFrame[] fframes=getLayoutControl().getLayoutContext().getFFrames();
|
79 |
for (int i = 0; i < fframes.length; i++) { |
80 |
if (fframes[i] instanceof IFFrameUseFMap) { |
81 |
IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i]; |
82 |
|
83 |
if (((IFFrame) fframe).getSelected() != IFFrame.NOSELECT) {
|
84 |
Rectangle2D.Double rec = ((IFFrame) fframe)
|
85 |
.getBoundingBox(getLayoutControl().getAT()); |
86 |
|
87 |
if (getLayoutControl().getImage() != null) { |
88 |
rec = (Rectangle2D.Double) rec
|
89 |
.createIntersection(getLayoutControl().getVisibleRect()); |
90 |
} |
91 |
|
92 |
if (fframe.getBufferedImage() != null) { |
93 |
getLayoutControl().getLayoutDraw().drawHandlers((Graphics2D) g, Color.black); |
94 |
g.clipRect((int) rec.x, (int) rec.y, |
95 |
(int) rec.width, (int) rec.height); |
96 |
|
97 |
Rectangle2D.Double r1 = ((IFFrame) fframe)
|
98 |
.getBoundingBox(getLayoutControl().getAT()); |
99 |
g.drawImage(fframe.getBufferedImage(), (int) r1
|
100 |
.getX() |
101 |
+ getLayoutControl().getLastPoint().x - getLayoutControl().getPointAnt().x, (int) r1
|
102 |
.getY() |
103 |
+ getLayoutControl().getLastPoint().y - getLayoutControl().getPointAnt().y, getLayoutControl()); |
104 |
|
105 |
fframe.refresh(); |
106 |
} |
107 |
} |
108 |
} |
109 |
} |
110 |
|
111 |
//g.setClip(rClip);
|
112 |
getLayoutControl().getLayoutDraw().drawHandlers((Graphics2D)g,Color.black); |
113 |
g.drawImage(getLayoutControl().getImgRuler(), 0, 0, getLayoutControl()); |
114 |
|
115 |
} |
116 |
|
117 |
/**
|
118 |
* @throws BehaviorException
|
119 |
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
|
120 |
*/
|
121 |
public void mousePressed(MouseEvent e) throws BehaviorException { |
122 |
super.mousePressed(e);
|
123 |
PointEvent event = new PointEvent(e.getPoint(), e);
|
124 |
listener.press(event); |
125 |
} |
126 |
|
127 |
/**
|
128 |
* Reimplementaci?n del m?todo mouseReleased de Behavior.
|
129 |
*
|
130 |
* @param e MouseEvent
|
131 |
*
|
132 |
* @throws BehaviorException Excepci?n lanzada cuando el Behavior.
|
133 |
*/
|
134 |
public void mouseReleased(MouseEvent e) throws BehaviorException { |
135 |
super.mouseReleased(e);
|
136 |
PointEvent event = new PointEvent(e.getPoint(), e);
|
137 |
listener.release(event); |
138 |
|
139 |
} |
140 |
|
141 |
/**
|
142 |
* Reimplementaci?n del m?todo mouseDragged de Behavior.
|
143 |
*
|
144 |
* @param e MouseEvent
|
145 |
* @throws BehaviorException
|
146 |
*/
|
147 |
public void mouseDragged(MouseEvent e) throws BehaviorException { |
148 |
super.mouseDragged(e);
|
149 |
PointEvent event = new PointEvent(e.getPoint(), e);
|
150 |
listener.drag(event); |
151 |
} |
152 |
|
153 |
/**
|
154 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#setListener(com.iver.cit.gvsig.fmap.tools.ToolListener)
|
155 |
*/
|
156 |
public void setListener(LayoutToolListener listener) { |
157 |
this.listener = (LayoutMoveListener) listener;
|
158 |
} |
159 |
|
160 |
/**
|
161 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#getListener()
|
162 |
*/
|
163 |
public LayoutToolListener getListener() {
|
164 |
return listener;
|
165 |
} |
166 |
} |