svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / tools / behavior / LayoutViewZoomBehavior.java @ 21743
History | View | Annotate | Download (4.47 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.Rectangle; |
47 |
import java.awt.event.MouseEvent; |
48 |
import java.awt.image.BufferedImage; |
49 |
|
50 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
51 |
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent; |
52 |
|
53 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame; |
54 |
import com.iver.cit.gvsig.project.documents.layout.tools.listener.LayoutMoveListener; |
55 |
import com.iver.cit.gvsig.project.documents.layout.tools.listener.LayoutToolListener; |
56 |
|
57 |
|
58 |
/**
|
59 |
* Behaviour que espera un listener de tipo MoveListener.
|
60 |
*
|
61 |
* @author Vicente Caballero Navarro
|
62 |
*/
|
63 |
public class LayoutViewZoomBehavior extends LayoutBehavior { |
64 |
private LayoutMoveListener listener;
|
65 |
private boolean dragged=false; |
66 |
/**
|
67 |
* Crea un nuevo MoveBehavior.
|
68 |
*
|
69 |
* @param pli listener.
|
70 |
*/
|
71 |
public LayoutViewZoomBehavior(LayoutMoveListener lpl) {
|
72 |
listener = lpl; |
73 |
} |
74 |
|
75 |
/**
|
76 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#paintComponent(java.awt.Graphics)
|
77 |
*/
|
78 |
public void paintComponent(Graphics g) { |
79 |
BufferedImage img = getLayoutControl().getImage();
|
80 |
BufferedImage imgRuler=getLayoutControl().getImgRuler();
|
81 |
g.drawImage(img, 0, 0, getLayoutControl()); |
82 |
g.drawImage(imgRuler, 0, 0, getLayoutControl()); |
83 |
g.setColor(Color.black);
|
84 |
g.setXORMode(Color.white);
|
85 |
|
86 |
// Borramos el anterior
|
87 |
Rectangle r = new Rectangle(); |
88 |
|
89 |
// Dibujamos el actual
|
90 |
if (dragged && (getLayoutControl().getFirstPoint() != null) && (getLayoutControl().getLastPoint() != null)) { |
91 |
r.setFrameFromDiagonal(getLayoutControl().getFirstPoint(), getLayoutControl().getLastPoint()); |
92 |
g.drawRect(r.x, r.y, r.width, r.height); |
93 |
} |
94 |
IFFrame[] frames = getLayoutControl().getLayoutContext().getFFrameSelected();
|
95 |
for (int i = 0; i < frames.length; i++) { |
96 |
g.setColor(Color.black);
|
97 |
frames[i].drawHandlers((Graphics2D) g);
|
98 |
} |
99 |
g.setPaintMode(); |
100 |
} |
101 |
|
102 |
/**
|
103 |
* @throws BehaviorException
|
104 |
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
|
105 |
*/
|
106 |
public void mousePressed(MouseEvent e) throws BehaviorException { |
107 |
super.mousePressed(e);
|
108 |
PointEvent event = new PointEvent(e.getPoint(), e);
|
109 |
listener.press(event); |
110 |
} |
111 |
|
112 |
/**
|
113 |
* Reimplementaci?n del m?todo mouseReleased de Behavior.
|
114 |
*
|
115 |
* @param e MouseEvent
|
116 |
*
|
117 |
* @throws BehaviorException Excepci?n lanzada cuando el Behavior.
|
118 |
*/
|
119 |
public void mouseReleased(MouseEvent e) throws BehaviorException { |
120 |
super.mouseReleased(e);
|
121 |
PointEvent event = new PointEvent(e.getPoint(), e);
|
122 |
listener.release(event); |
123 |
dragged=false;
|
124 |
} |
125 |
|
126 |
/**
|
127 |
* Reimplementaci?n del m?todo mouseDragged de Behavior.
|
128 |
*
|
129 |
* @param e MouseEvent
|
130 |
* @throws BehaviorException
|
131 |
*/
|
132 |
public void mouseDragged(MouseEvent e) throws BehaviorException { |
133 |
super.mouseDragged(e);
|
134 |
PointEvent event = new PointEvent(e.getPoint(), e);
|
135 |
listener.drag(event); |
136 |
dragged=true;
|
137 |
} |
138 |
|
139 |
/**
|
140 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#setListener(com.iver.cit.gvsig.fmap.tools.ToolListener)
|
141 |
*/
|
142 |
public void setListener(LayoutToolListener listener) { |
143 |
this.listener = (LayoutMoveListener) listener;
|
144 |
} |
145 |
|
146 |
/**
|
147 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#getListener()
|
148 |
*/
|
149 |
public LayoutToolListener getListener() {
|
150 |
return listener;
|
151 |
} |
152 |
} |