root / 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 / project / documents / layout / DefaultLayoutManager.java @ 36648
History | View | Annotate | Download (26.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.project.documents.layout; |
23 |
|
24 |
import java.awt.geom.AffineTransform; |
25 |
import java.util.Iterator; |
26 |
|
27 |
import javax.swing.ImageIcon; |
28 |
|
29 |
import org.slf4j.Logger; |
30 |
import org.slf4j.LoggerFactory; |
31 |
|
32 |
import org.gvsig.andami.PluginServices; |
33 |
import org.gvsig.andami.messages.NotificationManager; |
34 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
35 |
import org.gvsig.app.extension.AddLayer; |
36 |
import org.gvsig.app.project.ProjectManager; |
37 |
import org.gvsig.app.project.documents.AbstractDocument; |
38 |
import org.gvsig.app.project.documents.AbstractDocumentManager; |
39 |
import org.gvsig.app.project.documents.Document; |
40 |
import org.gvsig.app.project.documents.gui.WindowLayout; |
41 |
import org.gvsig.app.project.documents.layout.fframes.FFrame; |
42 |
import org.gvsig.app.project.documents.layout.fframes.FFrameBasicFactory; |
43 |
import org.gvsig.app.project.documents.layout.fframes.FFrameGraphics; |
44 |
import org.gvsig.app.project.documents.layout.fframes.FFrameGraphicsFactory; |
45 |
import org.gvsig.app.project.documents.layout.fframes.FFrameGridFactory; |
46 |
import org.gvsig.app.project.documents.layout.fframes.FFrameGroup; |
47 |
import org.gvsig.app.project.documents.layout.fframes.FFrameGroupFactory; |
48 |
import org.gvsig.app.project.documents.layout.fframes.FFrameLegend; |
49 |
import org.gvsig.app.project.documents.layout.fframes.FFrameLegendFactory; |
50 |
import org.gvsig.app.project.documents.layout.fframes.FFrameNorth; |
51 |
import org.gvsig.app.project.documents.layout.fframes.FFrameNorthFactory; |
52 |
import org.gvsig.app.project.documents.layout.fframes.FFrameOverView; |
53 |
import org.gvsig.app.project.documents.layout.fframes.FFrameOverViewFactory; |
54 |
import org.gvsig.app.project.documents.layout.fframes.FFramePicture; |
55 |
import org.gvsig.app.project.documents.layout.fframes.FFramePictureFactory; |
56 |
import org.gvsig.app.project.documents.layout.fframes.FFrameScaleBar; |
57 |
import org.gvsig.app.project.documents.layout.fframes.FFrameScaleBarFactory; |
58 |
import org.gvsig.app.project.documents.layout.fframes.FFrameSymbol; |
59 |
import org.gvsig.app.project.documents.layout.fframes.FFrameSymbolFactory; |
60 |
import org.gvsig.app.project.documents.layout.fframes.FFrameTable; |
61 |
import org.gvsig.app.project.documents.layout.fframes.FFrameTableFactory; |
62 |
import org.gvsig.app.project.documents.layout.fframes.FFrameText; |
63 |
import org.gvsig.app.project.documents.layout.fframes.FFrameTextFactory; |
64 |
import org.gvsig.app.project.documents.layout.fframes.FFrameView; |
65 |
import org.gvsig.app.project.documents.layout.fframes.FFrameViewFactory; |
66 |
import org.gvsig.app.project.documents.layout.fframes.FrameFactory; |
67 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
68 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameBoxDialog; |
69 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameGraphicsDialog; |
70 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameGroupDialog; |
71 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameLegendDialog; |
72 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameNorthDialog; |
73 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameOverViewDialog; |
74 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFramePictureDialog; |
75 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameScaleBarDialog; |
76 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameTextDialog; |
77 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameViewDialog; |
78 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFrameDialog; |
79 |
import org.gvsig.app.project.documents.layout.gui.DefaultLayoutPanel; |
80 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
81 |
import org.gvsig.app.project.documents.layout.gui.MapProperties; |
82 |
import org.gvsig.fmap.mapcontrol.MapControl; |
83 |
import org.gvsig.tools.ToolsLocator; |
84 |
import org.gvsig.tools.dynobject.DynStruct; |
85 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
86 |
import org.gvsig.tools.extensionpoint.ExtensionPoint.Extension; |
87 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
88 |
import org.gvsig.tools.persistence.PersistenceManager; |
89 |
import org.gvsig.utils.XMLEntity; |
90 |
|
91 |
/**
|
92 |
* Factory of maps.
|
93 |
*
|
94 |
* @author Vicente Caballero Navarro
|
95 |
*/
|
96 |
public class DefaultLayoutManager extends AbstractDocumentManager implements |
97 |
LayoutManager {
|
98 |
|
99 |
public static String TYPENAME = "project.document.layout"; |
100 |
|
101 |
static final Logger LOG = LoggerFactory |
102 |
.getLogger(DefaultLayoutManager.class); |
103 |
|
104 |
static final String KEY_LAYOUT_FFRAMEDIALOG = |
105 |
"app.project.documents.layout.fframes.gui";
|
106 |
static final String KEY_LAYOUT_FFRAME = |
107 |
"app.project.documents.layout.fframes";
|
108 |
|
109 |
private static final String PERSISTENCE_LAYOUT_DOCUMENT_DEFINITION_NAME = |
110 |
"LayoutDocument";
|
111 |
|
112 |
ExtensionPointManager extensionPoints = ToolsLocator |
113 |
.getExtensionPointManager(); |
114 |
|
115 |
private Boolean defaultShowGrid = null; |
116 |
private Boolean defaultAdjustToGrid = null; |
117 |
private Boolean defaultShowRulers = null; |
118 |
|
119 |
private DynStruct persistenceDefinition;
|
120 |
|
121 |
/**
|
122 |
* Returns image of button.
|
123 |
*
|
124 |
* @return Image button.
|
125 |
*/
|
126 |
public ImageIcon getIcon() { |
127 |
return PluginServices.getIconTheme().get("document-map-icon"); |
128 |
} |
129 |
|
130 |
/**
|
131 |
* Returns image of selected button.
|
132 |
*
|
133 |
* @return Image button.
|
134 |
*/
|
135 |
public ImageIcon getIconSelected() { |
136 |
return PluginServices.getIconTheme().get("document-map-icon-sel"); |
137 |
} |
138 |
|
139 |
/**
|
140 |
* Returns the name of registration in the point of extension.
|
141 |
*
|
142 |
* @return Name of registration
|
143 |
*/
|
144 |
public String getTypeName() { |
145 |
return TYPENAME;
|
146 |
} |
147 |
|
148 |
/**
|
149 |
* Returns the name of ProjectDocument.
|
150 |
*
|
151 |
* @return Name of ProjectDocument.
|
152 |
*/
|
153 |
public String getTitle() { |
154 |
return PluginServices.getText(this, "Mapa"); |
155 |
} |
156 |
|
157 |
public AbstractDocument createDocument() { |
158 |
return new DefaultLayoutDocument(this); |
159 |
} |
160 |
|
161 |
public Class getMainWindowClass() { |
162 |
return DefaultLayoutPanel.class;
|
163 |
} |
164 |
|
165 |
public IWindow getMainWindow(Document doc, WindowLayout layout) { |
166 |
LayoutPanel layoutPanel; |
167 |
layoutPanel = |
168 |
(LayoutPanel) PluginServices.getMDIManager().getSingletonWindow( |
169 |
getMainWindowClass(), doc); |
170 |
if (layoutPanel != null) { |
171 |
// The table window document is already created, return it.
|
172 |
return layoutPanel;
|
173 |
} |
174 |
|
175 |
layoutPanel = (LayoutPanel) this.createDocumentWindow(doc);
|
176 |
if (layout != null) { |
177 |
layoutPanel.setWindowLayout(layout); |
178 |
} |
179 |
layoutPanel.setLayoutManager(this);
|
180 |
layoutPanel.getLayoutControl().fullRect(); |
181 |
layoutPanel.getWindowInfo().setTitle( |
182 |
PluginServices.getText(this, "Mapa") + " : " |
183 |
+ layoutPanel.getName()); |
184 |
((AbstractDocument) doc).raiseEventCreateWindow(layoutPanel);
|
185 |
return layoutPanel;
|
186 |
} |
187 |
|
188 |
public IFFrameDialog createFFrameDialog(IFFrame fframe,
|
189 |
LayoutPanel layoutPanel, AffineTransform affineTransform) {
|
190 |
ExtensionPoint ep = extensionPoints.add(KEY_LAYOUT_FFRAMEDIALOG); |
191 |
|
192 |
try {
|
193 |
Object[] args = new Object[2]; |
194 |
args[0] = layoutPanel;
|
195 |
args[1] = fframe;
|
196 |
Object obj = ep.create(fframe.getName(), args);
|
197 |
if (obj != null) { |
198 |
IFFrameDialog fframedialog = (IFFrameDialog) obj; |
199 |
fframedialog.setRectangle(fframe |
200 |
.getBoundingBox(affineTransform)); |
201 |
return fframedialog;
|
202 |
} |
203 |
} catch (Exception e) { |
204 |
LOG.error("Error creating a FFrameDialog");
|
205 |
} |
206 |
return null; |
207 |
} |
208 |
|
209 |
public IFFrameDialog createFFrameDialog(IFFrame fframe,
|
210 |
LayoutPanel layoutPanel) { |
211 |
return createFFrameDialog(fframe, layoutPanel, layoutPanel
|
212 |
.getLayoutControl().getAT()); |
213 |
} |
214 |
|
215 |
/**
|
216 |
* Registers in the points of extension the Factory with alias.
|
217 |
*
|
218 |
* @param frameFactory
|
219 |
* FrameFactory to register.
|
220 |
* @param alias
|
221 |
* Alias.
|
222 |
*/
|
223 |
public void registerFrameFactory(FrameFactory frameFactory, String alias) { |
224 |
ExtensionPoint ep = |
225 |
ToolsLocator.getExtensionPointManager().add(KEY_LAYOUT_FFRAME); |
226 |
ep.append(frameFactory.getRegisterName(), "", frameFactory);
|
227 |
if (alias != null) { |
228 |
ep.addAlias(frameFactory.getRegisterName(), alias); |
229 |
} |
230 |
} |
231 |
|
232 |
/**
|
233 |
* Registers in the points of extension the Factory
|
234 |
*
|
235 |
* @param frameFactory
|
236 |
* FrameFactory to register.
|
237 |
*/
|
238 |
public void registerFrameFactory(FrameFactory frameFactory) { |
239 |
registerFrameFactory(frameFactory, null);
|
240 |
} |
241 |
|
242 |
@SuppressWarnings("unchecked") |
243 |
public IFFrame createFrame(String frameName) { |
244 |
|
245 |
Iterator<Extension> iterator =
|
246 |
ToolsLocator.getExtensionPointManager().get(KEY_LAYOUT_FFRAME) |
247 |
.iterator(); |
248 |
while (iterator.hasNext()) {
|
249 |
try {
|
250 |
FrameFactory frameFactory = |
251 |
(FrameFactory) iterator.next().create(); |
252 |
if (frameFactory.getRegisterName().equals(frameName)) {
|
253 |
IFFrame frame = frameFactory.createFrame(); |
254 |
if (frame == null) { |
255 |
return null; |
256 |
} |
257 |
frame.setFrameFactory(frameFactory); |
258 |
return frame;
|
259 |
} |
260 |
} catch (Exception e) { |
261 |
NotificationManager.addError(e); |
262 |
} |
263 |
} |
264 |
return null; |
265 |
} |
266 |
|
267 |
@SuppressWarnings("unchecked") |
268 |
public void registerFFrameDialog(String name, Class clazz) { |
269 |
if (!IFFrameDialog.class.isAssignableFrom(clazz)) {
|
270 |
throw new IllegalArgumentException(clazz.getName() |
271 |
+ " must implement the IFFrameDialog interface");
|
272 |
} |
273 |
ExtensionPoint extensionPoint = |
274 |
extensionPoints.add(KEY_LAYOUT_FFRAMEDIALOG, "");
|
275 |
extensionPoint.append(name, name, clazz); |
276 |
} |
277 |
|
278 |
public IWindow getPropertiesWindow(Document doc) { |
279 |
return new MapProperties((LayoutDocument) doc); |
280 |
} |
281 |
|
282 |
/**
|
283 |
* Registers in the points of extension the Factory with alias.
|
284 |
*
|
285 |
*/
|
286 |
public static void register() { |
287 |
DefaultLayoutManager factory = new DefaultLayoutManager();
|
288 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
289 |
manager.registerFactory(factory); |
290 |
|
291 |
ProjectManager.getInstance().registerDocumentFactory(factory); |
292 |
|
293 |
DefaultLayoutManager layoutManager = |
294 |
(DefaultLayoutManager) ProjectManager.getInstance() |
295 |
.getDocumentManager(DefaultLayoutManager.TYPENAME); |
296 |
|
297 |
// Register Frames
|
298 |
layoutManager.registerFrameFactory(new FFrameBasicFactory());
|
299 |
layoutManager.registerFrameFactory(new FFrameGraphicsFactory());
|
300 |
layoutManager.registerFrameFactory(new FFrameGroupFactory());
|
301 |
layoutManager.registerFrameFactory(new FFrameLegendFactory());
|
302 |
layoutManager.registerFrameFactory(new FFrameNorthFactory());
|
303 |
layoutManager.registerFrameFactory(new FFrameOverViewFactory());
|
304 |
layoutManager.registerFrameFactory(new FFramePictureFactory());
|
305 |
layoutManager.registerFrameFactory(new FFrameScaleBarFactory());
|
306 |
layoutManager.registerFrameFactory(new FFrameSymbolFactory());
|
307 |
layoutManager.registerFrameFactory(new FFrameTableFactory());
|
308 |
layoutManager.registerFrameFactory(new FFrameTextFactory());
|
309 |
layoutManager.registerFrameFactory(new FFrameViewFactory());
|
310 |
layoutManager.registerFrameFactory(new FFrameGridFactory());
|
311 |
|
312 |
// Register FFrameDialogs forms
|
313 |
layoutManager.registerFFrameDialog( |
314 |
FFrameGraphics.PERSISTENCE_DEFINITION_NAME, |
315 |
FFrameGraphicsDialog.class); |
316 |
layoutManager.registerFFrameDialog( |
317 |
FFrameSymbol.PERSISTENCE_DEFINITION_NAME, |
318 |
FFrameGraphicsDialog.class); |
319 |
layoutManager.registerFFrameDialog( |
320 |
FFrameGroup.PERSISTENCE_DEFINITION_NAME, FFrameGroupDialog.class); |
321 |
layoutManager.registerFFrameDialog( |
322 |
FFrameTable.PERSISTENCE_DEFINITION_NAME, FFrameBoxDialog.class); |
323 |
layoutManager.registerFFrameDialog( |
324 |
FFrameLegend.PERSISTENCE_DEFINITION_NAME, FFrameLegendDialog.class); |
325 |
layoutManager.registerFFrameDialog( |
326 |
FFramePicture.PERSISTENCE_DEFINITION_NAME, |
327 |
FFramePictureDialog.class); |
328 |
layoutManager.registerFFrameDialog( |
329 |
FFrameNorth.PERSISTENCE_DEFINITION_NAME, FFrameNorthDialog.class); |
330 |
layoutManager.registerFFrameDialog( |
331 |
FFrameScaleBar.PERSISTENCE_DEFINITION_NAME, |
332 |
FFrameScaleBarDialog.class); |
333 |
layoutManager.registerFFrameDialog( |
334 |
FFrameText.PERSISTENCE_DEFINITION_NAME, FFrameTextDialog.class); |
335 |
layoutManager.registerFFrameDialog( |
336 |
FFrameView.PERSISTENCE_DEFINITION_NAME, FFrameViewDialog.class); |
337 |
layoutManager.registerFFrameDialog( |
338 |
FFrameOverView.PERSISTENCE_DEFINITION_NAME, |
339 |
FFrameOverViewDialog.class); |
340 |
|
341 |
// ProjectFactory.getInstance().registerDocumentAction(TYPENAME,"copy",new
|
342 |
// CopyDocumentContextMenuAction());
|
343 |
// ProjectFactory.getInstance().registerDocumentAction(TYPENAME,"cut",new
|
344 |
// CutDocumentContextMenuAction());
|
345 |
// ProjectFactory.getInstance().registerDocumentAction(TYPENAME,"paste",new
|
346 |
// PasteDocumentContextMenuAction());
|
347 |
|
348 |
PluginServices.getIconTheme().registerDefault("document-map-icon",
|
349 |
AddLayer.class.getClassLoader().getResource("images/mapas.png"));
|
350 |
PluginServices.getIconTheme() |
351 |
.registerDefault( |
352 |
"document-map-icon-sel",
|
353 |
AddLayer.class.getClassLoader().getResource( |
354 |
"images/mapas_sel.png"));
|
355 |
PluginServices.getIconTheme().registerDefault("neresize-icon",
|
356 |
AddLayer.class.getClassLoader().getResource("images/NEResize.png"));
|
357 |
PluginServices.getIconTheme().registerDefault("eresize-icon",
|
358 |
AddLayer.class.getClassLoader().getResource("images/EResize.png"));
|
359 |
PluginServices.getIconTheme().registerDefault("nresize-icon",
|
360 |
AddLayer.class.getClassLoader().getResource("images/NResize.png"));
|
361 |
PluginServices.getIconTheme().registerDefault("move-icon",
|
362 |
AddLayer.class.getClassLoader().getResource("images/Move.png"));
|
363 |
PluginServices.getIconTheme().registerDefault("sereresize-icon",
|
364 |
AddLayer.class.getClassLoader().getResource("images/SEResize.png"));
|
365 |
PluginServices.getIconTheme() |
366 |
.registerDefault( |
367 |
"symboltag-icon",
|
368 |
AddLayer.class.getClassLoader().getResource( |
369 |
"images/symbolTag.gif"));
|
370 |
PluginServices.getIconTheme().registerDefault("move-icon",
|
371 |
AddLayer.class.getClassLoader().getResource("images/Move.png"));
|
372 |
PluginServices.getIconTheme().registerDefault("numero-icon",
|
373 |
AddLayer.class.getClassLoader().getResource("images/numero.png"));
|
374 |
PluginServices.getIconTheme().registerDefault("barra1-icon",
|
375 |
AddLayer.class.getClassLoader().getResource("images/barra1.png"));
|
376 |
PluginServices.getIconTheme().registerDefault("barra2-icon",
|
377 |
AddLayer.class.getClassLoader().getResource("images/barra2.png"));
|
378 |
PluginServices.getIconTheme().registerDefault("barra3-icon",
|
379 |
AddLayer.class.getClassLoader().getResource("images/barra3.png"));
|
380 |
PluginServices.getIconTheme().registerDefault("text-left-icon",
|
381 |
AddLayer.class.getClassLoader().getResource("images/left.PNG"));
|
382 |
PluginServices.getIconTheme().registerDefault("text-center-v-icon",
|
383 |
AddLayer.class.getClassLoader().getResource("images/centerV.PNG"));
|
384 |
PluginServices.getIconTheme().registerDefault("text-right-icon",
|
385 |
AddLayer.class.getClassLoader().getResource("images/right.PNG"));
|
386 |
PluginServices.getIconTheme().registerDefault( |
387 |
"left-rotation-icon",
|
388 |
AddLayer.class.getClassLoader().getResource( |
389 |
"images/leftrotation.png"));
|
390 |
PluginServices.getIconTheme().registerDefault("text-up-icon",
|
391 |
AddLayer.class.getClassLoader().getResource("images/up.PNG"));
|
392 |
PluginServices.getIconTheme().registerDefault("text-center-h-icon",
|
393 |
AddLayer.class.getClassLoader().getResource("images/centerH.PNG"));
|
394 |
PluginServices.getIconTheme().registerDefault("text-down-icon",
|
395 |
AddLayer.class.getClassLoader().getResource("images/down.PNG"));
|
396 |
PluginServices.getIconTheme().registerDefault("text-distup-icon",
|
397 |
AddLayer.class.getClassLoader().getResource("images/distUp.PNG"));
|
398 |
PluginServices.getIconTheme().registerDefault( |
399 |
"text-distcenterh-icon",
|
400 |
AddLayer.class.getClassLoader().getResource( |
401 |
"images/distCenterH.PNG"));
|
402 |
PluginServices.getIconTheme().registerDefault("text-distdown-icon",
|
403 |
AddLayer.class.getClassLoader().getResource("images/distDown.PNG"));
|
404 |
PluginServices.getIconTheme().registerDefault("text-distleft-icon",
|
405 |
AddLayer.class.getClassLoader().getResource("images/distLeft.PNG"));
|
406 |
PluginServices.getIconTheme().registerDefault( |
407 |
"text-distcenterv-icon",
|
408 |
AddLayer.class.getClassLoader().getResource( |
409 |
"images/distCenterV.PNG"));
|
410 |
PluginServices.getIconTheme() |
411 |
.registerDefault( |
412 |
"text-distright-icon",
|
413 |
AddLayer.class.getClassLoader().getResource( |
414 |
"images/distRight.PNG"));
|
415 |
PluginServices.getIconTheme() |
416 |
.registerDefault( |
417 |
"text-size-width-icon",
|
418 |
AddLayer.class.getClassLoader().getResource( |
419 |
"images/sizeWidth.PNG"));
|
420 |
PluginServices.getIconTheme().registerDefault( |
421 |
"text-size-height-icon",
|
422 |
AddLayer.class.getClassLoader() |
423 |
.getResource("images/sizeHeight.PNG"));
|
424 |
PluginServices.getIconTheme() |
425 |
.registerDefault( |
426 |
"text-size-other-icon",
|
427 |
AddLayer.class.getClassLoader().getResource( |
428 |
"images/sizeOther.PNG"));
|
429 |
PluginServices.getIconTheme().registerDefault( |
430 |
"text-space-right-icon",
|
431 |
AddLayer.class.getClassLoader() |
432 |
.getResource("images/spaceRight.PNG"));
|
433 |
PluginServices.getIconTheme().registerDefault("text-inlayout-icon",
|
434 |
AddLayer.class.getClassLoader().getResource("images/inLayout.PNG"));
|
435 |
|
436 |
// Tools
|
437 |
PluginServices.getIconTheme().registerDefault("rect-select-cursor",
|
438 |
MapControl.class.getResource("images/RectSelectCursor.gif"));
|
439 |
|
440 |
PluginServices.getIconTheme().registerDefault( |
441 |
"circle-cursor",
|
442 |
AddLayer.class.getClassLoader().getResource( |
443 |
"images/CircleCursor.png"));
|
444 |
PluginServices.getIconTheme().registerDefault( |
445 |
"line-cursor",
|
446 |
AddLayer.class.getClassLoader() |
447 |
.getResource("images/LineCursor.png"));
|
448 |
PluginServices.getIconTheme().registerDefault( |
449 |
"point-cursor",
|
450 |
AddLayer.class.getClassLoader().getResource( |
451 |
"images/PointCursor.png"));
|
452 |
PluginServices.getIconTheme().registerDefault( |
453 |
"poligon-cursor",
|
454 |
AddLayer.class.getClassLoader().getResource( |
455 |
"images/PoligonCursor.png"));
|
456 |
PluginServices.getIconTheme().registerDefault( |
457 |
"rectangle-cursor",
|
458 |
AddLayer.class.getClassLoader().getResource( |
459 |
"images/RectangleCursor.png"));
|
460 |
PluginServices.getIconTheme().registerDefault( |
461 |
"crux-cursor",
|
462 |
AddLayer.class.getClassLoader() |
463 |
.getResource("images/CruxCursor.png"));
|
464 |
PluginServices.getIconTheme().registerDefault( |
465 |
"layout-hand-icon",
|
466 |
AddLayer.class.getClassLoader() |
467 |
.getResource("images/LayoutHand.gif"));
|
468 |
PluginServices.getIconTheme().registerDefault( |
469 |
"zoom-in-cursor",
|
470 |
AddLayer.class.getClassLoader().getResource( |
471 |
"images/ZoomInCursor.gif"));
|
472 |
PluginServices.getIconTheme().registerDefault("hand-icon",
|
473 |
AddLayer.class.getClassLoader().getResource("images/Hand.gif"));
|
474 |
PluginServices.getIconTheme().registerDefault( |
475 |
"zoom-out-cursor",
|
476 |
AddLayer.class.getClassLoader().getResource( |
477 |
"images/ZoomOutCursor.gif"));
|
478 |
PluginServices.getIconTheme().registerDefault( |
479 |
"layout-zoom-in-cursor",
|
480 |
AddLayer.class.getClassLoader().getResource( |
481 |
"images/LayoutZoomInCursor.gif"));
|
482 |
PluginServices.getIconTheme().registerDefault( |
483 |
"layout-zoom-out-cursor",
|
484 |
AddLayer.class.getClassLoader().getResource( |
485 |
"images/LayoutZoomOutCursor.gif"));
|
486 |
PluginServices.getIconTheme().registerDefault( |
487 |
"right-rotation-icon",
|
488 |
AddLayer.class.getClassLoader().getResource( |
489 |
"images/rightrotation.png"));
|
490 |
PluginServices.getIconTheme().registerDefault("point-select-cursor",
|
491 |
MapControl.class.getResource("images/PointSelectCursor.gif"));
|
492 |
|
493 |
FFrame.initializeIcons(); |
494 |
FFrameTable.initializeIcons(); |
495 |
|
496 |
if (factory.persistenceDefinition == null) { |
497 |
factory.persistenceDefinition = |
498 |
manager.addDefinition(LayoutDocument.class, |
499 |
PERSISTENCE_LAYOUT_DOCUMENT_DEFINITION_NAME, |
500 |
"Table document Persistence definition", null, null); |
501 |
factory.persistenceDefinition.extend(manager |
502 |
.getDefinition(AbstractDocument.PERSISTENCE_DEFINITION_NAME));
|
503 |
|
504 |
factory.persistenceDefinition |
505 |
.addDynFieldObject(DefaultLayoutDocument.LAYOUTCONTEXT_OBJECT) |
506 |
.setClassOfValue(LayoutContext.class).setMandatory(false);
|
507 |
|
508 |
DefaultLayoutPanel.registerPersistent(); |
509 |
DefaultLayoutContext.registerPersistent(); |
510 |
|
511 |
} |
512 |
|
513 |
} |
514 |
|
515 |
/**
|
516 |
* Returns the priority of de ProjectDocument.
|
517 |
*
|
518 |
* @return Priority.
|
519 |
*/
|
520 |
public int getPriority() { |
521 |
return 2; |
522 |
} |
523 |
|
524 |
/**
|
525 |
* Inserts if the grid sould be show.
|
526 |
*
|
527 |
* @param showGrid
|
528 |
*/
|
529 |
public void setDefaultShowGrid(boolean showGrid) { |
530 |
defaultShowGrid = new Boolean(showGrid); |
531 |
} |
532 |
|
533 |
/**
|
534 |
* Inserts if the adjust togrid sould be actived.
|
535 |
*
|
536 |
* @param gridEnable
|
537 |
*/
|
538 |
public void setDefaultAdjustToGrid(boolean gridEnabled) { |
539 |
defaultAdjustToGrid = new Boolean(gridEnabled); |
540 |
} |
541 |
|
542 |
/**
|
543 |
* Inserts if the ruler sould be show.
|
544 |
*
|
545 |
* @param showRuler
|
546 |
*/
|
547 |
public void setDefaultShowRulers(boolean showRules) { |
548 |
defaultShowRulers = new Boolean(showRules); |
549 |
} |
550 |
|
551 |
/**
|
552 |
* Returns if the grid sould be show.
|
553 |
*
|
554 |
* @return True if the grid sould be show.
|
555 |
*/
|
556 |
public boolean getDefaultShowGrid() { |
557 |
if (defaultShowGrid == null) { |
558 |
XMLEntity xml = |
559 |
PluginServices.getPluginServices("org.gvsig.app")
|
560 |
.getPersistentXML(); |
561 |
if (xml.contains("DefaultShowLayoutGrid")) { |
562 |
defaultShowGrid = |
563 |
new Boolean(xml.getBooleanProperty("DefaultShowLayoutGrid")); |
564 |
} else {
|
565 |
// factory default is true
|
566 |
defaultShowGrid = new Boolean(true); |
567 |
} |
568 |
} |
569 |
return defaultShowGrid.booleanValue();
|
570 |
} |
571 |
|
572 |
/**
|
573 |
* Returns if the adjust to grid sould be actived.
|
574 |
*
|
575 |
* @return True if the adjust to grid sould be actived.
|
576 |
*/
|
577 |
public boolean getDefaultAdjustToGrid() { |
578 |
if (defaultAdjustToGrid == null) { |
579 |
XMLEntity xml = |
580 |
PluginServices.getPluginServices("org.gvsig.app")
|
581 |
.getPersistentXML(); |
582 |
if (xml.contains("DefaultEnableLayoutGrid")) { |
583 |
defaultAdjustToGrid = |
584 |
new Boolean( |
585 |
xml.getBooleanProperty("DefaultEnableLayoutGrid"));
|
586 |
} else {
|
587 |
// factory default is false
|
588 |
defaultAdjustToGrid = new Boolean(false); |
589 |
} |
590 |
} |
591 |
return defaultAdjustToGrid.booleanValue();
|
592 |
} |
593 |
|
594 |
/**
|
595 |
* Returns if the ruler sould be show.
|
596 |
*
|
597 |
* @return True if the ruler sould be show.
|
598 |
*/
|
599 |
public boolean getDefaultShowRulers() { |
600 |
if (defaultShowRulers == null) { |
601 |
XMLEntity xml = |
602 |
PluginServices.getPluginServices("org.gvsig.app")
|
603 |
.getPersistentXML(); |
604 |
if (xml.contains("DefaultShowLayoutRules")) { |
605 |
defaultShowRulers = |
606 |
new Boolean( |
607 |
xml.getBooleanProperty("DefaultShowLayoutRules"));
|
608 |
} else {
|
609 |
// factory default is true
|
610 |
defaultShowRulers = new Boolean(true); |
611 |
} |
612 |
} |
613 |
return defaultShowRulers.booleanValue();
|
614 |
} |
615 |
|
616 |
public DynStruct getDefinition(String className) { |
617 |
|
618 |
if (this.persistenceDefinition.getName().equalsIgnoreCase(className)) { |
619 |
return this.persistenceDefinition; |
620 |
} |
621 |
if (this.persistenceDefinition.getFullName() |
622 |
.equalsIgnoreCase(className)) { |
623 |
return this.persistenceDefinition; |
624 |
} |
625 |
if (this.getDocumentClass().getName().equals(className)) { |
626 |
return this.persistenceDefinition; |
627 |
} |
628 |
|
629 |
// Class theClass;
|
630 |
// try {
|
631 |
// theClass = (Class) Class.forName(className);
|
632 |
// } catch (ClassNotFoundException e) {
|
633 |
// return null;
|
634 |
// }
|
635 |
// if ( this.manages(theClass)){
|
636 |
// return this.persistenceDefinition;
|
637 |
// }
|
638 |
return null; |
639 |
} |
640 |
|
641 |
@SuppressWarnings("unchecked") |
642 |
protected Class getDocumentClass() { |
643 |
return DefaultLayoutDocument.class;
|
644 |
} |
645 |
|
646 |
public boolean manages(Object object) { |
647 |
return object instanceof LayoutDocument; |
648 |
} |
649 |
} |