svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.app.document.layout.app / org.gvsig.app.document.layout.app.mainplugin / src / main / java / org / gvsig / app / extension / LayoutInsertToolsExtension.java @ 36695
History | View | Annotate | Download (10.6 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.extension; |
23 |
|
24 |
import org.slf4j.Logger; |
25 |
import org.slf4j.LoggerFactory; |
26 |
|
27 |
import org.gvsig.andami.PluginServices; |
28 |
import org.gvsig.andami.plugins.Extension; |
29 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
30 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
31 |
|
32 |
/**
|
33 |
* Extensi?n para editar los v?rtices de las geometr?as a?adidas en un
|
34 |
* FFrameGraphics.
|
35 |
*
|
36 |
* @author Vicente Caballero Navarro
|
37 |
*/
|
38 |
public class LayoutInsertToolsExtension extends Extension { |
39 |
|
40 |
private static final Logger logger = LoggerFactory |
41 |
.getLogger(LayoutInsertToolsExtension.class); |
42 |
|
43 |
private LayoutPanel layout = null; |
44 |
|
45 |
public void initialize() { |
46 |
// TODO Auto-generated method stub
|
47 |
registerIcons(); |
48 |
} |
49 |
|
50 |
private void registerIcons() { |
51 |
|
52 |
PluginServices.getIconTheme().registerDefault( |
53 |
"layout-insert-text",
|
54 |
this.getClass().getClassLoader()
|
55 |
.getResource("images/MapaTexto.png"));
|
56 |
|
57 |
PluginServices.getIconTheme().registerDefault("layout-insert-point",
|
58 |
this.getClass().getClassLoader().getResource("images/Point.png")); |
59 |
|
60 |
PluginServices.getIconTheme().registerDefault( |
61 |
"layout-insert-polygon",
|
62 |
this.getClass().getClassLoader()
|
63 |
.getResource("images/Rectangle.png"));
|
64 |
|
65 |
PluginServices.getIconTheme().registerDefault("layout-insert-circle",
|
66 |
this.getClass().getClassLoader().getResource("images/Circle.png")); |
67 |
|
68 |
PluginServices.getIconTheme().registerDefault("layout-insert-line",
|
69 |
this.getClass().getClassLoader().getResource("images/Rect.png")); |
70 |
|
71 |
PluginServices.getIconTheme().registerDefault("layout-insert-polyline",
|
72 |
this.getClass().getClassLoader().getResource("images/Line.png")); |
73 |
|
74 |
PluginServices.getIconTheme().registerDefault("layout-insert-poligon",
|
75 |
this.getClass().getClassLoader().getResource("images/Polygon.png")); |
76 |
|
77 |
PluginServices.getIconTheme().registerDefault( |
78 |
"layout-insert-image",
|
79 |
this.getClass().getClassLoader()
|
80 |
.getResource("images/MapaImagen.png"));
|
81 |
|
82 |
PluginServices.getIconTheme().registerDefault( |
83 |
"layout-insert-view",
|
84 |
this.getClass().getClassLoader()
|
85 |
.getResource("images/MapaVista.png"));
|
86 |
|
87 |
PluginServices.getIconTheme().registerDefault( |
88 |
"layout-insert-locator",
|
89 |
this.getClass().getClassLoader()
|
90 |
.getResource("images/MapaLocalizador.png"));
|
91 |
|
92 |
PluginServices.getIconTheme().registerDefault( |
93 |
"layout-insert-legend",
|
94 |
this.getClass().getClassLoader()
|
95 |
.getResource("images/MapaLeyenda.png"));
|
96 |
|
97 |
PluginServices.getIconTheme().registerDefault( |
98 |
"layout-insert-scalebar",
|
99 |
this.getClass().getClassLoader()
|
100 |
.getResource("images/MapaEscala.png"));
|
101 |
|
102 |
PluginServices.getIconTheme().registerDefault( |
103 |
"layout-insert-north",
|
104 |
this.getClass().getClassLoader()
|
105 |
.getResource("images/MapaNorth.png"));
|
106 |
|
107 |
PluginServices.getIconTheme().registerDefault("layout-insert-box",
|
108 |
this.getClass().getClassLoader().getResource("images/box.png")); |
109 |
|
110 |
PluginServices.getIconTheme().registerDefault("remove-selection",
|
111 |
this.getClass().getClassLoader().getResource("images/remove.png")); |
112 |
} |
113 |
|
114 |
public void execute(String s) { |
115 |
layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
116 |
|
117 |
logger.debug("Comand : " + s);
|
118 |
boolean insertGroupPosibility = false; |
119 |
if (s.equals("SELECT")) { |
120 |
layout.getLayoutControl().setTool("layoutselect");
|
121 |
} else
|
122 |
if (s.equals("RECTANGLEVIEW")) { |
123 |
layout.getLayoutControl().setTool("layoutaddview");
|
124 |
insertGroupPosibility = true;
|
125 |
} else
|
126 |
if (s.equals("RECTANGLEOVERVIEW")) { |
127 |
layout.getLayoutControl().setTool("layoutaddoverview");
|
128 |
insertGroupPosibility = true;
|
129 |
} else
|
130 |
if (s.equals("RECTANGLEPICTURE")) { |
131 |
layout.getLayoutControl().setTool("layoutaddpicture");
|
132 |
insertGroupPosibility = true;
|
133 |
} else
|
134 |
if (s.equals("RECTANGLESCALEBAR")) { |
135 |
layout.getLayoutControl().setTool("layoutaddscale");
|
136 |
insertGroupPosibility = true;
|
137 |
} else
|
138 |
if (s.equals("RECTANGLELEGEND")) { |
139 |
layout.getLayoutControl().setTool( |
140 |
"layoutaddlegend");
|
141 |
insertGroupPosibility = true;
|
142 |
} else
|
143 |
if (s.equals("RECTANGLETEXT")) { |
144 |
layout.getLayoutControl().setTool( |
145 |
"layoutaddtext");
|
146 |
insertGroupPosibility = true;
|
147 |
} else
|
148 |
if (s.equals("RECTANGLENORTH")) { |
149 |
layout.getLayoutControl().setTool( |
150 |
"layoutaddnorth");
|
151 |
insertGroupPosibility = true;
|
152 |
} else
|
153 |
if (s.equals("RECTANGLEBOX")) { |
154 |
layout.getLayoutControl().setTool( |
155 |
"layoutaddbox");
|
156 |
insertGroupPosibility = true;
|
157 |
} else
|
158 |
if (s.equals("POINT")) { |
159 |
layout.getLayoutControl() |
160 |
.setTool("layoutaddpoint");
|
161 |
} else
|
162 |
if (s.equals("LINE")) { |
163 |
layout.getLayoutControl() |
164 |
.setTool( |
165 |
"layoutaddline");
|
166 |
} else
|
167 |
if (s.equals("POLYLINE")) { |
168 |
layout |
169 |
.getLayoutControl() |
170 |
.setTool( |
171 |
"layoutaddpolyline");
|
172 |
} else
|
173 |
if (s.equals("CIRCLE")) { |
174 |
layout |
175 |
.getLayoutControl() |
176 |
.setTool( |
177 |
"layoutaddcircle");
|
178 |
} else
|
179 |
if (s
|
180 |
.equals("RECTANGLESIMPLE")) {
|
181 |
layout |
182 |
.getLayoutControl() |
183 |
.setTool( |
184 |
"layoutaddrectangle");
|
185 |
} else
|
186 |
if (s
|
187 |
.equals("POLYGON")) {
|
188 |
layout |
189 |
.getLayoutControl() |
190 |
.setTool( |
191 |
"layoutaddpolygon");
|
192 |
} else
|
193 |
if (s
|
194 |
.equals("REMOVE")) {
|
195 |
layout |
196 |
.getLayoutContext() |
197 |
.delFFrameSelected(); |
198 |
layout |
199 |
.getLayoutControl() |
200 |
.refresh(); |
201 |
} |
202 |
layout.getDocument().setModified(true);
|
203 |
} |
204 |
|
205 |
public boolean isEnabled() { |
206 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
207 |
|
208 |
if (f == null) { |
209 |
return false; |
210 |
} |
211 |
|
212 |
if (f instanceof LayoutPanel) { |
213 |
return ((LayoutPanel) f).getLayoutContext().isEditable();
|
214 |
} |
215 |
|
216 |
return false; |
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 |
} |