Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / LayoutInsertToolsExtension.java @ 32738

History | View | Annotate | Download (7.12 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;
42

    
43
import org.apache.log4j.Logger;
44

    
45
import com.iver.andami.PluginServices;
46
import com.iver.andami.plugins.Extension;
47
import com.iver.andami.ui.mdiManager.IWindow;
48
import com.iver.cit.gvsig.project.documents.layout.gui.Layout;
49

    
50

    
51
/**
52
 * Extensi?n para editar los v?rtices de las geometr?as a?adidas en un FFrameGraphics.
53
 *
54
 * @author Vicente Caballero Navarro
55
 */
56
public class LayoutInsertToolsExtension extends Extension {
57
    private static Logger logger = Logger.getLogger(LayoutInsertToolsExtension.class.getName());
58
    private Layout layout = null;
59

    
60

    
61
    public void initialize() {
62
                // TODO Auto-generated method stub
63
            registerIcons();
64
        }
65

    
66
    private void registerIcons(){
67

    
68
            PluginServices.getIconTheme().registerDefault(
69
                            "view-select-geometry",
70
                                this.getClass().getClassLoader().getResource("images/Select.png")
71
                        );
72

    
73
            PluginServices.getIconTheme().registerDefault(
74
                            "layout-insert-text",
75
                                this.getClass().getClassLoader().getResource("images/MapaTexto.png")
76
                        );
77

    
78
            PluginServices.getIconTheme().registerDefault(
79
                            "layout-insert-point",
80
                                this.getClass().getClassLoader().getResource("images/Point.png")
81
                        );
82

    
83
            PluginServices.getIconTheme().registerDefault(
84
                            "layout-insert-rectangle",
85
                                this.getClass().getClassLoader().getResource("images/Rectangle.png")
86
                        );
87

    
88
            PluginServices.getIconTheme().registerDefault(
89
                            "layout-insert-circle",
90
                                this.getClass().getClassLoader().getResource("images/Circle.png")
91
                        );
92

    
93

    
94
            PluginServices.getIconTheme().registerDefault(
95
                            "layout-insert-line",
96
                                this.getClass().getClassLoader().getResource("images/Rect.png")
97
                        );
98

    
99
            PluginServices.getIconTheme().registerDefault(
100
                            "layout-insert-polyline",
101
                                this.getClass().getClassLoader().getResource("images/Line.png")
102
                        );
103

    
104
            PluginServices.getIconTheme().registerDefault(
105
                            "layout-insert-poligon",
106
                                this.getClass().getClassLoader().getResource("images/Polygon.png")
107
                        );
108

    
109
            PluginServices.getIconTheme().registerDefault(
110
                            "layout-insert-image",
111
                                this.getClass().getClassLoader().getResource("images/MapaImagen.png")
112
                        );
113

    
114
            PluginServices.getIconTheme().registerDefault(
115
                            "layout-insert-view",
116
                                this.getClass().getClassLoader().getResource("images/MapaVista.png")
117
                        );
118

    
119
            PluginServices.getIconTheme().registerDefault(
120
                            "layout-insert-locator",
121
                                this.getClass().getClassLoader().getResource("images/MapaLocalizador.png")
122
                        );
123

    
124
            PluginServices.getIconTheme().registerDefault(
125
                            "layout-insert-legend",
126
                                this.getClass().getClassLoader().getResource("images/MapaLeyenda.png")
127
                        );
128

    
129
            PluginServices.getIconTheme().registerDefault(
130
                            "layout-insert-scalebar",
131
                                this.getClass().getClassLoader().getResource("images/MapaEscala.png")
132
                        );
133

    
134
            PluginServices.getIconTheme().registerDefault(
135
                            "layout-insert-north",
136
                                this.getClass().getClassLoader().getResource("images/MapaNorth.png")
137
                        );
138

    
139
            PluginServices.getIconTheme().registerDefault(
140
                            "layout-insert-box",
141
                                this.getClass().getClassLoader().getResource("images/box.png")
142
                        );
143
            
144
            PluginServices.getIconTheme().registerDefault(
145
                            "remove-selection",
146
                                this.getClass().getClassLoader().getResource("images/remove.png")
147
                        );
148
    }
149

    
150
    public void execute(String s) {
151
             layout = (Layout) PluginServices.getMDIManager().getActiveWindow();
152

    
153
         logger.debug("Comand : " + s);
154
         boolean insertGroupPosibility=false;
155
        if (s.equals("SELECT")) {
156
             layout.getLayoutControl().setTool("layoutselect");
157
        } else if (s.equals("RECTANGLEVIEW")) {
158
                     layout.getLayoutControl().setTool("layoutaddview");
159
                     insertGroupPosibility=true;
160
             } else if (s.equals("RECTANGLEOVERVIEW")) {
161
                     layout.getLayoutControl().setTool("layoutaddoverview");
162
                     insertGroupPosibility=true;
163
             } else if (s.equals("RECTANGLEPICTURE")) {
164
                     layout.getLayoutControl().setTool("layoutaddpicture");
165
                     insertGroupPosibility=true;
166
             } else if (s.equals("RECTANGLESCALEBAR")) {
167
                     layout.getLayoutControl().setTool("layoutaddscale");
168
                     insertGroupPosibility=true;
169
             } else if (s.equals("RECTANGLELEGEND")) {
170
                     layout.getLayoutControl().setTool("layoutaddlegend");
171
                     insertGroupPosibility=true;
172
             } else if (s.equals("RECTANGLETEXT")) {
173
                     layout.getLayoutControl().setTool("layoutaddtext");
174
                     insertGroupPosibility=true;
175
             } else if (s.equals("RECTANGLENORTH")) {
176
                     layout.getLayoutControl().setTool("layoutaddnorth");
177
                     insertGroupPosibility=true;
178
             } else if (s.equals("RECTANGLEBOX")) {
179
                     layout.getLayoutControl().setTool("layoutaddbox");
180
                     insertGroupPosibility=true;
181
             } else if (s.equals("POINT")) {
182
                     layout.getLayoutControl().setTool("layoutaddpoint");
183
             } else if (s.equals("LINE")) {
184
                     layout.getLayoutControl().setTool("layoutaddline");
185
             } else if (s.equals("POLYLINE")) {
186
                     layout.getLayoutControl().setTool("layoutaddpolyline");
187
             } else if (s.equals("CIRCLE")) {
188
                     layout.getLayoutControl().setTool("layoutaddcircle");
189
             } else if (s.equals("RECTANGLESIMPLE")) {
190
                     layout.getLayoutControl().setTool("layoutaddrectangle");
191
             } else if (s.equals("POLYGON")) {
192
                     layout.getLayoutControl().setTool("layoutaddpolygon");
193
             } else if (s.equals("REMOVE")){
194
                     layout.getLayoutContext().delFFrameSelected();
195
                     layout.getLayoutControl().refresh();
196
             }
197
        layout.getModel().setModified(true);
198
   }
199

    
200

    
201
    public boolean isEnabled() {
202
            IWindow f = PluginServices.getMDIManager().getActiveWindow();
203

    
204
        if (f == null) {
205
            return false;
206
        }
207

    
208
        if (f instanceof Layout) {
209
            return ((Layout) f).getLayoutContext().isEditable();
210
        }
211

    
212
        return false;
213
        }
214

    
215

    
216
    public boolean isVisible() {
217
                IWindow f = PluginServices.getMDIManager().getActiveWindow();
218

    
219
                if (f == null) {
220
                        return false;
221
                }
222

    
223
                if (f instanceof Layout) {
224
                        return true;
225
                } else {
226
                        return false;
227
                }
228
        }
229
}