Statistics
| Revision:

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

History | View | Annotate | Download (4.53 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

    
48
import com.iver.cit.gvsig.fmap.tools.BehaviorException;
49
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent;
50
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame;
51
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameEditableVertex;
52
import com.iver.cit.gvsig.project.documents.layout.tools.listener.LayoutMoveListener;
53
import com.iver.cit.gvsig.project.documents.layout.tools.listener.LayoutToolListener;
54

    
55

    
56
/**
57
 * Behaviour que espera un listener de tipo MoveListener.
58
 *
59
 * @author Vicente Caballero Navarro
60
 */
61
public class LayoutEditBehavior extends LayoutBehavior{
62
        private LayoutMoveListener listener;
63
        private boolean dragged=false;
64

    
65
        /**
66
         * Crea un nuevo MoveBehavior.
67
         *
68
         * @param pli listener.
69
         */
70
        public LayoutEditBehavior(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
                getLayoutControl().getLayoutDraw().drawRectangle((Graphics2D) g);
79
        g.drawImage(getLayoutControl().getImage(), 0, 0, getLayoutControl());
80
        getLayoutControl().getLayoutDraw().drawHandlers((Graphics2D) g, Color.black);
81

    
82
            IFFrame[] fframeSelect = getLayoutControl().getLayoutContext().getFFrameSelected();
83
            for (int i = 0; i < fframeSelect.length; i++) {
84
                if (fframeSelect[i] instanceof IFFrameEditableVertex && dragged) {
85
                    ((IFFrameEditableVertex) fframeSelect[i]).paint(
86
                            (Graphics2D) g, getLayoutControl().getAT());
87
                }
88
            }
89
//        }
90
//        else {
91
//            geometryAdapter.paint((Graphics2D) g, getAT(), true);
92
//        }
93
        g.drawImage(getLayoutControl().getImgRuler(), 0, 0, getLayoutControl());
94
//        getLayout().drawCursor(g);
95
        }
96

    
97
        /**
98
         * @throws BehaviorException
99
         * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
100
         */
101
        public void mousePressed(MouseEvent e) throws BehaviorException {
102
                super.mousePressed(e);
103
                PointEvent event = new PointEvent(e.getPoint(), e);
104
                listener.press(event);
105
        }
106

    
107
        /**
108
         * Reimplementaci?n del m?todo mouseReleased de Behavior.
109
         *
110
         * @param e MouseEvent
111
         *
112
         * @throws BehaviorException Excepci?n lanzada cuando el Behavior.
113
         */
114
        public void mouseReleased(MouseEvent e) throws BehaviorException {
115
                super.mouseReleased(e);
116
                PointEvent event = new PointEvent(e.getPoint(), e);
117
                listener.release(event);
118
                dragged=false;
119
        }
120

    
121
        /**
122
         * Reimplementaci?n del m?todo mouseDragged de Behavior.
123
         *
124
         * @param e MouseEvent
125
         * @throws BehaviorException
126
         */
127
        public void mouseDragged(MouseEvent e) throws BehaviorException {
128
                super.mouseDragged(e);
129
                PointEvent event = new PointEvent(e.getPoint(), e);
130
                listener.drag(event);
131
                dragged=true;
132
        }
133

    
134
        /**
135
         * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#setListener(com.iver.cit.gvsig.fmap.tools.ToolListener)
136
         */
137
        public void setListener(LayoutToolListener listener) {
138
                this.listener = (LayoutMoveListener) listener;
139
        }
140

    
141
        /**
142
         * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#getListener()
143
         */
144
        public LayoutToolListener getListener() {
145
                return listener;
146
        }
147

    
148
        public boolean isAdjustable() {
149
                return true;
150
        }
151
}