Statistics
| Revision:

svn-document-layout / tags / 2059 / org.gvsig.app.document.layout.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / tools / LayoutAddPolygonListenerImpl.java @ 46

History | View | Annotate | Download (3.95 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;
23

    
24
import java.awt.Image;
25
import java.awt.event.MouseEvent;
26

    
27
import org.gvsig.andami.PluginServices;
28
import org.gvsig.app.project.documents.layout.fframes.FFrameGraphics;
29
import org.gvsig.app.project.documents.layout.geometryadapters.GeometryAdapter;
30
import org.gvsig.app.project.documents.layout.geometryadapters.PolygonAdapter;
31
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
32
import org.gvsig.app.project.documents.layout.tools.listener.ILayoutGraphicListener;
33
import org.gvsig.app.project.documents.layout.tools.listener.LayoutPointListener;
34
import org.gvsig.fmap.geom.Geometry;
35
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent;
36

    
37
/**
38
 * Implementaci�n de la interfaz LayoutPointListener como herramienta para
39
 * realizar
40
 * un zoom menos.
41
 * 
42
 * @author Vicente Caballero Navarro
43
 */
44
public class LayoutAddPolygonListenerImpl extends AbstractLayoutToolListener
45
    implements LayoutPointListener, ILayoutGraphicListener {
46

    
47
    public static final Image iPolygon = PluginServices.getIconTheme()
48
        .get("cursor-layout-insert-polygon").getImage();
49

    
50
    /**
51
     * Crea un nuevo LayoutZoomOutListenerImpl.
52
     * 
53
     * @param mapControl
54
     *            MapControl.
55
     */
56
    public LayoutAddPolygonListenerImpl(LayoutPanel layoutPanel) {
57
        super(layoutPanel);
58
    }
59

    
60
    /**
61
     * @see org.gvsig.fmap.mapcontrol.tools.Listeners.PointListener#point(com.iver.cit.gvsig.fmap.tools.PointEvent)
62
     */
63
    public void point(PointEvent event) {
64
        if (event.getEvent().getButton() == MouseEvent.BUTTON1) {
65
            layoutPanel.getLayoutControl().addGeometryAdapterPoint();
66
        }
67
    }
68

    
69
    /**
70
     * @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#getCursor()
71
     */
72
    public Image getImageCursor() {
73
        return iPolygon;
74
    }
75

    
76
    /**
77
     * @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#cancelDrawing()
78
     */
79
    public boolean cancelDrawing() {
80
        System.out.println("cancelDrawing del ZoomOutListenerImpl");
81
        return true;
82
    }
83

    
84
    public void pointDoubleClick(PointEvent event) {
85
        layoutPanel.getLayoutControl().delLastPoint();
86
        endGraphic();
87
    }
88

    
89
    public void endGraphic() {
90
        layoutPanel.getLayoutControl().getGeometryAdapter().end();
91
        FFrameGraphics fframe =
92
            (FFrameGraphics) layoutManager
93
                .createFrame(FFrameGraphics.PERSISTENCE_DEFINITION_NAME);
94
        fframe.setGeometryAdapter(layoutPanel.getLayoutControl()
95
            .getGeometryAdapter());
96
        fframe.update(Geometry.TYPES.SURFACE, layoutPanel.getLayoutControl()
97
            .getAT());
98
        fframe.setBoundBox(layoutPanel.getLayoutControl().getGeometryAdapter()
99
            .getBounds2D());
100
        layoutPanel.getLayoutContext().addFFrame(fframe, true, true);
101
        layoutPanel.getLayoutControl().setGeometryAdapter(new PolygonAdapter());
102
        PluginServices.getMainFrame().enableControls();
103
        layoutPanel.getLayoutControl().refresh();
104
    }
105

    
106
    public GeometryAdapter createGeometryAdapter() {
107
        return new PolygonAdapter();
108
    }
109
}