Statistics
| Revision:

svn-gvsig-desktop / branches / gvSIG_CAD_Layout_version / applications / appgvSIG / src / com / iver / cit / gvsig / LayoutControls.java @ 1763

History | View | Annotate | Download (5.41 KB)

1
/*
2
 * Created on 05-may-2004
3
 *
4
 * To change the template for this generated file go to
5
 * Window>Preferences>Java>Code Generation>Code and Comments
6
 */
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
package com.iver.cit.gvsig;
48

    
49
import com.iver.andami.PluginServices;
50
import com.iver.andami.plugins.Extension;
51
import com.iver.andami.ui.mdiManager.View;
52

    
53
import com.iver.cit.gvsig.fmap.DriverException;
54
import com.iver.cit.gvsig.fmap.edition.EditionException;
55
import com.iver.cit.gvsig.gui.layout.FLayoutZooms;
56
import com.iver.cit.gvsig.gui.layout.Layout;
57
import com.iver.cit.gvsig.gui.layout.fframes.IFFrame;
58

    
59
import org.apache.log4j.Logger;
60

    
61

    
62
/**
63
 * Extensi?n para controlar las operaciones basicas sobre el Layout.
64
 *
65
 * @author Vicente Caballero Navarro
66
 */
67
public class LayoutControls implements Extension {
68
        private static Logger logger = Logger.getLogger(LayoutControls.class.getName());
69
        private Layout layout = null;
70

    
71
        /**
72
         * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
73
         */
74
        public void execute(String s) {
75
                layout = (Layout) PluginServices.getMDIManager().getActiveView();
76

    
77
                FLayoutZooms zooms = new FLayoutZooms(layout);
78
                logger.debug("Comand : " + s);
79

    
80
                if (s.compareTo("PAN") == 0) {
81
                        layout.setTool(Layout.PAN);
82
                } else if (s.compareTo("ZOOM_IN") == 0) {
83
                        layout.setTool(Layout.ZOOM_MAS);
84
                } else if (s.compareTo("ZOOM_OUT") == 0) {
85
                        layout.setTool(Layout.ZOOM_MENOS);
86
                } else if (s.compareTo("RECTANGLEVIEW") == 0) {
87
                        layout.setTool(Layout.RECTANGLEVIEW);
88
                } else if (s.compareTo("RECTANGLEPICTURE") == 0) {
89
                        layout.setTool(Layout.RECTANGLEPICTURE);
90
                } else if (s.compareTo("RECTANGLESCALEBAR") == 0) {
91
                        layout.setTool(Layout.RECTANGLESCALEBAR);
92
                } else if (s.compareTo("RECTANGLELEGEND") == 0) {
93
                        layout.setTool(Layout.RECTANGLELEGEND);
94
                } else if (s.compareTo("RECTANGLETEXT") == 0) {
95
                        layout.setTool(Layout.RECTANGLETEXT);
96
                } else if (s.compareTo("SELECT") == 0) {
97
                        layout.setTool(Layout.SELECT);
98
                } else if (s.compareTo("CADSELECT") == 0) {
99
                        layout.setCadTool("selection");
100
                        for (int i=0;i<layout.getFFrames().size();i++){
101
                                ((IFFrame)layout.getFFrames().get(i)).setSelected(false);
102
                        }
103
                } else if (s.compareTo("POINT") == 0) {
104
                        layout.setCadTool("point");
105
                } else if (s.compareTo("LINE") == 0) {
106
                        layout.setCadTool("line");
107
                } else if (s.compareTo("POLYLINE") == 0) {
108
                        layout.setCadTool("polyline");
109
                } else if (s.compareTo("CIRCLE") == 0) {
110
                        layout.setCadTool("circle");
111
                } else if (s.compareTo("RECTANGLESIMPLE") == 0) {
112
                        layout.setCadTool("rectangle");
113
                } else if (s.compareTo("POLYGON") == 0) {
114
                        layout.setCadTool("polygon");
115
                } else if (s.compareTo("CONFIG") == 0) {
116
                        layout.showFConfig();
117
                } else if (s.compareTo("PROPERTIES") == 0) {
118
                        layout.showFProperties();
119
                } else if (s.compareTo("FULL") == 0) {
120
                        layout.fullRect();
121
                } else if (s.compareTo("REALZOOM") == 0) {
122
                        zooms.realZoom();
123
                } else if (s.compareTo("ZOOMOUT") == 0) {
124
                        zooms.zoomOut();
125
                } else if (s.compareTo("ZOOMIN") == 0) {
126
                        zooms.zoomIn();
127
                } else if (s.compareTo("ZOOMSELECT") == 0) {
128
                        zooms.zoomSelect();
129
                } else if (s.compareTo("VIEW_ZOOMIN") == 0) {
130
                        layout.setTool(Layout.VIEW_ZOOMIN);
131
                } else if (s.compareTo("VIEW_ZOOMOUT") == 0) {
132
                        layout.setTool(Layout.VIEW_ZOOMOUT);
133
                } else if (s.compareTo("VIEW_FULL") == 0) {
134
                        try {
135
                                layout.viewFull();
136
                        } catch (DriverException e) {
137
                                //TODO Enviar a Andami
138
                                e.printStackTrace();
139
                        }
140
                } else if (s.compareTo("VIEW_PAN") == 0) {
141
                        layout.setTool(Layout.VIEW_PAN);
142
                } else if (s.compareTo("SET_TAG") == 0) {
143
                        layout.setTool(Layout.SET_TAG);
144
                }
145
        }
146

    
147
        /**
148
         * @see com.iver.mdiApp.plugins.Extension#isVisible()
149
         */
150
        public boolean isVisible() {
151
                View f = PluginServices.getMDIManager().getActiveView();
152

    
153
                if (f == null) {
154
                        return false;
155
                }
156

    
157
                if (f.getClass() == Layout.class) {
158
                        Layout layout = (Layout) f;
159

    
160
                        return true; //layout.m_Display.getMapControl().getMapContext().getLayers().layerCount() > 0;
161
                } else {
162
                        return false;
163
                }
164
        }
165

    
166
        /**
167
         * @see com.iver.andami.plugins.Extension#inicializar()
168
         */
169
        public void inicializar() {
170
        }
171

    
172
        /**
173
         * @see com.iver.andami.plugins.Extension#isEnabled()
174
         */
175
        public boolean isEnabled() {
176
                return true;
177
        }
178

    
179
        /**
180
         * Devuelve el Layout sobre el que se opera.
181
         *
182
         * @return Layout.
183
         */
184
        public Layout getLayout() {
185
                return layout;
186
        }
187
}