Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / extension / LayoutInsertToolsExtension.java @ 31496

History | View | Annotate | Download (7.2 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 org.gvsig.app.extension;
42

    
43
import org.gvsig.andami.PluginServices;
44
import org.gvsig.andami.plugins.Extension;
45
import org.gvsig.andami.ui.mdiManager.IWindow;
46
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
47
import org.slf4j.Logger;
48
import org.slf4j.LoggerFactory;
49

    
50

    
51

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

    
63

    
64
    public void initialize() {
65
                // TODO Auto-generated method stub
66
            registerIcons();
67
        }
68

    
69
    private void registerIcons(){
70

    
71
            PluginServices.getIconTheme().registerDefault(
72
                            "view-select-geometry",
73
                                this.getClass().getClassLoader().getResource("images/Select.png")
74
                        );
75

    
76
            PluginServices.getIconTheme().registerDefault(
77
                            "layout-insert-text",
78
                                this.getClass().getClassLoader().getResource("images/MapaTexto.png")
79
                        );
80

    
81
            PluginServices.getIconTheme().registerDefault(
82
                            "layout-insert-point",
83
                                this.getClass().getClassLoader().getResource("images/Point.png")
84
                        );
85

    
86
            PluginServices.getIconTheme().registerDefault(
87
                            "layout-insert-polygon",
88
                                this.getClass().getClassLoader().getResource("images/Rectangle.png")
89
                        );
90

    
91
            PluginServices.getIconTheme().registerDefault(
92
                            "layout-insert-circle",
93
                                this.getClass().getClassLoader().getResource("images/Circle.png")
94
                        );
95

    
96

    
97
            PluginServices.getIconTheme().registerDefault(
98
                            "layout-insert-line",
99
                                this.getClass().getClassLoader().getResource("images/Rect.png")
100
                        );
101

    
102
            PluginServices.getIconTheme().registerDefault(
103
                            "layout-insert-polyline",
104
                                this.getClass().getClassLoader().getResource("images/Line.png")
105
                        );
106

    
107
            PluginServices.getIconTheme().registerDefault(
108
                            "layout-insert-poligon",
109
                                this.getClass().getClassLoader().getResource("images/Polygon.png")
110
                        );
111

    
112
            PluginServices.getIconTheme().registerDefault(
113
                            "layout-insert-image",
114
                                this.getClass().getClassLoader().getResource("images/MapaImagen.png")
115
                        );
116

    
117
            PluginServices.getIconTheme().registerDefault(
118
                            "layout-insert-view",
119
                                this.getClass().getClassLoader().getResource("images/MapaVista.png")
120
                        );
121

    
122
            PluginServices.getIconTheme().registerDefault(
123
                            "layout-insert-locator",
124
                                this.getClass().getClassLoader().getResource("images/MapaLocalizador.png")
125
                        );
126

    
127
            PluginServices.getIconTheme().registerDefault(
128
                            "layout-insert-legend",
129
                                this.getClass().getClassLoader().getResource("images/MapaLeyenda.png")
130
                        );
131

    
132
            PluginServices.getIconTheme().registerDefault(
133
                            "layout-insert-scalebar",
134
                                this.getClass().getClassLoader().getResource("images/MapaEscala.png")
135
                        );
136

    
137
            PluginServices.getIconTheme().registerDefault(
138
                            "layout-insert-north",
139
                                this.getClass().getClassLoader().getResource("images/MapaNorth.png")
140
                        );
141

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

    
153
    public void execute(String s) {
154
             layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
155

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

    
203

    
204
    public boolean isEnabled() {
205
            IWindow f = PluginServices.getMDIManager().getActiveWindow();
206

    
207
        if (f == null) {
208
            return false;
209
        }
210

    
211
        if (f instanceof LayoutPanel) {
212
            return ((LayoutPanel) f).getLayoutContext().isEditable();
213
        }
214

    
215
        return false;
216
        }
217

    
218

    
219
    public boolean isVisible() {
220
                IWindow f = PluginServices.getMDIManager().getActiveWindow();
221

    
222
                if (f == null) {
223
                        return false;
224
                }
225

    
226
                if (f instanceof LayoutPanel) {
227
                        return true;
228
                } else {
229
                        return false;
230
                }
231
        }
232
}