Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / layout / tools / behavior / LayoutViewMoveBehavior.java @ 29598

History | View | Annotate | Download (5.4 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 org.gvsig.app.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 org.gvsig.app.project.documents.layout.fframes.IFFrame;
50
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap;
51
import org.gvsig.app.project.documents.layout.tools.listener.LayoutMoveListener;
52
import org.gvsig.app.project.documents.layout.tools.listener.LayoutToolListener;
53
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
54
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent;
55

    
56

    
57

    
58
/**
59
 * Behaviour que espera un listener de tipo MoveListener.
60
 *
61
 * @author Vicente Caballero Navarro
62
 */
63
public class LayoutViewMoveBehavior extends LayoutBehavior {
64
        private LayoutMoveListener listener;
65

    
66
        /**
67
         * Crea un nuevo MoveBehavior.
68
         *
69
         * @param pli listener.
70
         */
71
        public LayoutViewMoveBehavior(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
                IFFrame[] fframes=getLayoutControl().getLayoutContext().getFFrames();
80
                 for (int i = 0; i < fframes.length; i++) {
81
             if (fframes[i] instanceof IFFrameUseFMap) {
82
                 IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
83

    
84
                 if (((IFFrame) fframe).getSelected() != IFFrame.NOSELECT) {
85
                     Rectangle2D.Double rec = ((IFFrame) fframe)
86
                             .getBoundingBox(getLayoutControl().getAT());
87

    
88
                     if (getLayoutControl().getImage() != null) {
89
                         rec = (Rectangle2D.Double) rec
90
                                 .createIntersection(getLayoutControl().getVisibleRect());
91
                     }
92

    
93
                     if (fframe.getBufferedImage() != null) {
94
                         getLayoutControl().getLayoutDraw().drawHandlers((Graphics2D) g, Color.black);
95
                         g.clipRect((int) rec.x, (int) rec.y,
96
                                 (int) rec.width, (int) rec.height);
97

    
98
                         Rectangle2D.Double r1 = ((IFFrame) fframe)
99
                                 .getBoundingBox(getLayoutControl().getAT());
100
                         g.drawImage(fframe.getBufferedImage(), (int) r1
101
                                 .getX()
102
                                 + getLayoutControl().getLastPoint().x - getLayoutControl().getPointAnt().x, (int) r1
103
                                 .getY()
104
                                 + getLayoutControl().getLastPoint().y - getLayoutControl().getPointAnt().y, getLayoutControl());
105

    
106
                         fframe.refresh();
107
                     }
108
                 }
109
             }
110
         }
111

    
112
         //g.setClip(rClip);
113
                 getLayoutControl().getLayoutDraw().drawHandlers((Graphics2D)g,Color.black);
114
         g.drawImage(getLayoutControl().getImgRuler(), 0, 0, getLayoutControl());
115

    
116
        }
117

    
118
        /**
119
         * @throws BehaviorException
120
         * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
121
         */
122
        public void mousePressed(MouseEvent e) throws BehaviorException {
123
                super.mousePressed(e);
124
                PointEvent event = new PointEvent(e.getPoint(), e);
125
                listener.press(event);
126
        }
127

    
128
        /**
129
         * Reimplementaci?n del m?todo mouseReleased de Behavior.
130
         *
131
         * @param e MouseEvent
132
         *
133
         * @throws BehaviorException Excepci?n lanzada cuando el Behavior.
134
         */
135
        public void mouseReleased(MouseEvent e) throws BehaviorException {
136
                super.mouseReleased(e);
137
                PointEvent event = new PointEvent(e.getPoint(), e);
138
                listener.release(event);
139

    
140
        }
141

    
142
        /**
143
         * Reimplementaci?n del m?todo mouseDragged de Behavior.
144
         *
145
         * @param e MouseEvent
146
         * @throws BehaviorException
147
         */
148
        public void mouseDragged(MouseEvent e) throws BehaviorException {
149
                super.mouseDragged(e);
150
                PointEvent event = new PointEvent(e.getPoint(), e);
151
                listener.drag(event);
152
        }
153

    
154
        /**
155
         * @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#setListener(com.iver.cit.gvsig.fmap.tools.ToolListener)
156
         */
157
        public void setListener(LayoutToolListener listener) {
158
                this.listener = (LayoutMoveListener) listener;
159
        }
160

    
161
        /**
162
         * @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#getListener()
163
         */
164
        public LayoutToolListener getListener() {
165
                return listener;
166
        }
167
}