Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / LayoutInsertToolsExtension.java @ 28861

History | View | Annotate | Download (7.17 KB)

1 6393 caballero
/* 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 28033 cordinyana
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
45 6393 caballero
46
import com.iver.andami.PluginServices;
47
import com.iver.andami.plugins.Extension;
48 6877 cesar
import com.iver.andami.ui.mdiManager.IWindow;
49 9392 caballero
import com.iver.cit.gvsig.project.documents.layout.gui.Layout;
50 6393 caballero
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 28033 cordinyana
    private static final Logger logger = LoggerFactory
59
            .getLogger(LayoutInsertToolsExtension.class);
60
61 6393 caballero
    private Layout layout = null;
62
63
64
    public void initialize() {
65
                // TODO Auto-generated method stub
66 14821 jmvivo
            registerIcons();
67 6393 caballero
        }
68
69 14821 jmvivo
    private void registerIcons(){
70 6393 caballero
71 15640 jmvivo
            PluginServices.getIconTheme().registerDefault(
72 14821 jmvivo
                            "view-select-geometry",
73
                                this.getClass().getClassLoader().getResource("images/Select.png")
74
                        );
75
76 15640 jmvivo
            PluginServices.getIconTheme().registerDefault(
77 14821 jmvivo
                            "layout-insert-text",
78
                                this.getClass().getClassLoader().getResource("images/MapaTexto.png")
79
                        );
80
81 15640 jmvivo
            PluginServices.getIconTheme().registerDefault(
82 14821 jmvivo
                            "layout-insert-point",
83
                                this.getClass().getClassLoader().getResource("images/Point.png")
84
                        );
85
86 15640 jmvivo
            PluginServices.getIconTheme().registerDefault(
87 14821 jmvivo
                            "layout-insert-polygon",
88
                                this.getClass().getClassLoader().getResource("images/Rectangle.png")
89
                        );
90
91 15640 jmvivo
            PluginServices.getIconTheme().registerDefault(
92 14821 jmvivo
                            "layout-insert-circle",
93
                                this.getClass().getClassLoader().getResource("images/Circle.png")
94
                        );
95
96
97 15640 jmvivo
            PluginServices.getIconTheme().registerDefault(
98 14821 jmvivo
                            "layout-insert-line",
99
                                this.getClass().getClassLoader().getResource("images/Rect.png")
100
                        );
101
102 15640 jmvivo
            PluginServices.getIconTheme().registerDefault(
103 14821 jmvivo
                            "layout-insert-polyline",
104
                                this.getClass().getClassLoader().getResource("images/Line.png")
105
                        );
106
107 15640 jmvivo
            PluginServices.getIconTheme().registerDefault(
108 14821 jmvivo
                            "layout-insert-poligon",
109
                                this.getClass().getClassLoader().getResource("images/Polygon.png")
110
                        );
111
112 15640 jmvivo
            PluginServices.getIconTheme().registerDefault(
113 14821 jmvivo
                            "layout-insert-image",
114
                                this.getClass().getClassLoader().getResource("images/MapaImagen.png")
115
                        );
116
117 15640 jmvivo
            PluginServices.getIconTheme().registerDefault(
118 14821 jmvivo
                            "layout-insert-view",
119
                                this.getClass().getClassLoader().getResource("images/MapaVista.png")
120
                        );
121
122 15640 jmvivo
            PluginServices.getIconTheme().registerDefault(
123 14821 jmvivo
                            "layout-insert-locator",
124
                                this.getClass().getClassLoader().getResource("images/MapaLocalizador.png")
125
                        );
126
127 15640 jmvivo
            PluginServices.getIconTheme().registerDefault(
128 14821 jmvivo
                            "layout-insert-legend",
129
                                this.getClass().getClassLoader().getResource("images/MapaLeyenda.png")
130
                        );
131
132 15640 jmvivo
            PluginServices.getIconTheme().registerDefault(
133 14821 jmvivo
                            "layout-insert-scalebar",
134
                                this.getClass().getClassLoader().getResource("images/MapaEscala.png")
135
                        );
136
137 15640 jmvivo
            PluginServices.getIconTheme().registerDefault(
138 14821 jmvivo
                            "layout-insert-north",
139
                                this.getClass().getClassLoader().getResource("images/MapaNorth.png")
140
                        );
141
142 15640 jmvivo
            PluginServices.getIconTheme().registerDefault(
143 14821 jmvivo
                            "layout-insert-box",
144
                                this.getClass().getClassLoader().getResource("images/box.png")
145
                        );
146 15640 jmvivo
147
            PluginServices.getIconTheme().registerDefault(
148
                            "remove-selection",
149
                                this.getClass().getClassLoader().getResource("images/remove.png")
150
                        );
151 14821 jmvivo
    }
152
153 6393 caballero
    public void execute(String s) {
154 6880 cesar
             layout = (Layout) PluginServices.getMDIManager().getActiveWindow();
155 6393 caballero
156
         logger.debug("Comand : " + s);
157
         boolean insertGroupPosibility=false;
158 9189 caballero
        if (s.equals("SELECT")) {
159 9392 caballero
             layout.getLayoutControl().setTool("layoutselect");
160 9189 caballero
        } else if (s.equals("RECTANGLEVIEW")) {
161 9392 caballero
                     layout.getLayoutControl().setTool("layoutaddview");
162 6393 caballero
                     insertGroupPosibility=true;
163 9189 caballero
             } else if (s.equals("RECTANGLEOVERVIEW")) {
164 9392 caballero
                     layout.getLayoutControl().setTool("layoutaddoverview");
165 9189 caballero
                     insertGroupPosibility=true;
166 6393 caballero
             } else if (s.equals("RECTANGLEPICTURE")) {
167 9392 caballero
                     layout.getLayoutControl().setTool("layoutaddpicture");
168 6393 caballero
                     insertGroupPosibility=true;
169
             } else if (s.equals("RECTANGLESCALEBAR")) {
170 9392 caballero
                     layout.getLayoutControl().setTool("layoutaddscale");
171 6393 caballero
                     insertGroupPosibility=true;
172
             } else if (s.equals("RECTANGLELEGEND")) {
173 9392 caballero
                     layout.getLayoutControl().setTool("layoutaddlegend");
174 6393 caballero
                     insertGroupPosibility=true;
175
             } else if (s.equals("RECTANGLETEXT")) {
176 9392 caballero
                     layout.getLayoutControl().setTool("layoutaddtext");
177 6393 caballero
                     insertGroupPosibility=true;
178
             } else if (s.equals("RECTANGLENORTH")) {
179 9392 caballero
                     layout.getLayoutControl().setTool("layoutaddnorth");
180 6393 caballero
                     insertGroupPosibility=true;
181
             } else if (s.equals("RECTANGLEBOX")) {
182 9392 caballero
                     layout.getLayoutControl().setTool("layoutaddbox");
183 6393 caballero
                     insertGroupPosibility=true;
184
             } else if (s.equals("POINT")) {
185 9392 caballero
                     layout.getLayoutControl().setTool("layoutaddpoint");
186 6393 caballero
             } else if (s.equals("LINE")) {
187 9392 caballero
                     layout.getLayoutControl().setTool("layoutaddline");
188 6393 caballero
             } else if (s.equals("POLYLINE")) {
189 9392 caballero
                     layout.getLayoutControl().setTool("layoutaddpolyline");
190 6393 caballero
             } else if (s.equals("CIRCLE")) {
191 9392 caballero
                     layout.getLayoutControl().setTool("layoutaddcircle");
192 6393 caballero
             } else if (s.equals("RECTANGLESIMPLE")) {
193 9392 caballero
                     layout.getLayoutControl().setTool("layoutaddrectangle");
194 6393 caballero
             } else if (s.equals("POLYGON")) {
195 9392 caballero
                     layout.getLayoutControl().setTool("layoutaddpolygon");
196 6393 caballero
             } else if (s.equals("REMOVE")){
197 9392 caballero
                     layout.getLayoutContext().delFFrameSelected();
198
                     layout.getLayoutControl().refresh();
199 6393 caballero
             }
200 9532 caballero
        layout.getModel().setModified(true);
201 6393 caballero
   }
202
203
204
    public boolean isEnabled() {
205 6880 cesar
            IWindow f = PluginServices.getMDIManager().getActiveWindow();
206 6393 caballero
207
        if (f == null) {
208
            return false;
209
        }
210
211
        if (f instanceof Layout) {
212 9392 caballero
            return ((Layout) f).getLayoutContext().isEditable();
213 6393 caballero
        }
214
215
        return false;
216
        }
217
218
219
    public boolean isVisible() {
220 6880 cesar
                IWindow f = PluginServices.getMDIManager().getActiveWindow();
221 6393 caballero
222
                if (f == null) {
223
                        return false;
224
                }
225
226
                if (f instanceof Layout) {
227
                        return true;
228
                } else {
229
                        return false;
230
                }
231
        }
232
}