Statistics
| Revision:

svn-document-layout / trunk / org.gvsig.app.document.layout2.app / org.gvsig.app.document.layout2.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / tools / behavior / LayoutBehavior.java @ 1714

History | View | Annotate | Download (3.54 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.Color;
25
import java.awt.Graphics;
26
import java.awt.Graphics2D;
27
import java.awt.Image;
28
import java.awt.event.MouseEvent;
29
import java.awt.event.MouseWheelEvent;
30
import org.gvsig.app.project.documents.layout.LayoutControl;
31
import org.gvsig.app.project.documents.layout.tools.listener.LayoutToolListener;
32
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
33

    
34
/**
35
 * Ejecuta acciones respondiendo a eventos, por
36
 * delegaci?n desde el Layout.
37
 * 
38
 * @author Vicente Caballero Navarro
39
 */
40
public abstract class LayoutBehavior implements ILayoutBehavior {
41

    
42
    private LayoutControl layout;
43

    
44
    @Override
45
    public abstract LayoutToolListener getListener();
46

    
47
    @Override
48
    public void paintComponent(Graphics g) {
49
        g.drawImage(getLayoutControl().getImage(), 0, 0, layout.getComponent());
50

    
51
        getLayoutControl().getLayoutDraw().drawGrid((Graphics2D) g);
52
        getLayoutControl().getLayoutDraw().drawRuler((Graphics2D) g,
53
            Color.black);
54
        getLayoutControl().getGeometryAdapter().paint((Graphics2D) g,
55
            layout.getAT(), true);
56
        getLayoutControl().getLayoutDraw().drawHandlers((Graphics2D) g,
57
            Color.black);
58
    }
59

    
60
    @Override
61
    public void setLayoutControl(LayoutControl lc) {
62
        layout = lc;
63
    }
64

    
65
    @Override
66
    public Image getImageCursor() {
67
        return getListener().getImageCursor();
68
    }
69

    
70
    @Override
71
    public LayoutControl getLayoutControl() {
72
        return layout;
73
    }
74

    
75
    @Override
76
    public void mouseClicked(MouseEvent e) throws BehaviorException {
77
    }
78

    
79
    @Override
80
    public void mouseEntered(MouseEvent e) throws BehaviorException {
81
    }
82

    
83
    @Override
84
    public void mouseExited(MouseEvent e) throws BehaviorException {
85
    }
86

    
87
    @Override
88
    public void mousePressed(MouseEvent e) throws BehaviorException {
89
        if (e.getButton() == MouseEvent.BUTTON1) {
90
            layout.setPointAnt();
91
            layout.setFirstPoint();
92
        }
93
    }
94

    
95
    @Override
96
    public void mouseReleased(MouseEvent e) throws BehaviorException {
97
        if (e.getButton() != MouseEvent.BUTTON3) {
98
            layout.setLastPoint();
99
            layout.setPointAnt();
100
        }
101
    }
102

    
103
    @Override
104
    public void mouseDragged(MouseEvent e) throws BehaviorException {
105
        if (e.getButton() != MouseEvent.BUTTON3) {
106
            layout.setLastPoint();
107
        }
108
    }
109

    
110
    @Override
111
    public void mouseMoved(MouseEvent e) throws BehaviorException {
112
    }
113

    
114
    @Override
115
    public void mouseWheelMoved(MouseWheelEvent e) throws BehaviorException {
116
    }
117

    
118
    @Override
119
    public boolean isAdjustable() {
120
        return false;
121
    }
122
    }