svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / view / DefaultViewDocument.java @ 33275
History | View | Annotate | Download (3.99 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2009 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 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2004-2009 IVER TI
|
26 |
*
|
27 |
*/
|
28 |
package org.gvsig.app.project.documents.view; |
29 |
|
30 |
import org.gvsig.app.ApplicationLocator; |
31 |
import org.gvsig.app.project.ProjectPreferences; |
32 |
import org.gvsig.app.project.documents.DocumentManager; |
33 |
import org.gvsig.fmap.mapcontext.MapContext; |
34 |
import org.gvsig.fmap.mapcontext.ViewPort; |
35 |
import org.gvsig.tools.ToolsLocator; |
36 |
import org.gvsig.tools.dynobject.DynStruct; |
37 |
import org.gvsig.tools.persistence.PersistenceManager; |
38 |
import org.gvsig.tools.persistence.PersistentState; |
39 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
40 |
|
41 |
|
42 |
|
43 |
/**
|
44 |
* Clase que representa una vista del proyecto
|
45 |
*
|
46 |
* @author 2004-2005 Fernando Gonz?lez Cort?s
|
47 |
* @author 2006-2009 Jose Manuel Vivo
|
48 |
* @author 2005- Vicente Caballero
|
49 |
* @author 2009- Joaquin del Cerro
|
50 |
*
|
51 |
*/
|
52 |
|
53 |
public class DefaultViewDocument extends BaseViewDocument { |
54 |
|
55 |
/**
|
56 |
*
|
57 |
*/
|
58 |
private static final long serialVersionUID = 676711512482334764L; |
59 |
|
60 |
public static final String PERSISTENCE_DEFINITION_NAME = "DefaultViewDocument"; |
61 |
|
62 |
|
63 |
public DefaultViewDocument() {
|
64 |
this(null); |
65 |
} |
66 |
|
67 |
public DefaultViewDocument(DocumentManager factory) {
|
68 |
super(factory);
|
69 |
|
70 |
ViewPort vp; |
71 |
|
72 |
ProjectPreferences preferences = (ProjectPreferences) ApplicationLocator.getManager().getPreferences("project");
|
73 |
|
74 |
MapContext viewMapContext = new MapContext(
|
75 |
new ViewPort( preferences.getDefaultProjection() )
|
76 |
); |
77 |
vp = viewMapContext.getViewPort(); |
78 |
vp.setBackColor(preferences.getDefaultViewBackColor()); |
79 |
vp.setDistanceUnits(preferences.getDefaultDistanceUnits()); |
80 |
vp.setDistanceArea(preferences.getDefaultDistanceArea()); |
81 |
vp.setMapUnits(preferences.getDefaultMapUnits()); |
82 |
this.setMapContext(viewMapContext);
|
83 |
|
84 |
MapContext overviewMapContext = new MapContext(
|
85 |
new ViewPort( viewMapContext.getProjection() )
|
86 |
); |
87 |
vp = viewMapContext.getViewPort(); |
88 |
vp.setBackColor(preferences.getDefaultViewBackColor()); |
89 |
this.setMapOverViewContext(overviewMapContext);
|
90 |
} |
91 |
|
92 |
public void saveToState(PersistentState state) throws PersistenceException { |
93 |
super.saveToState(state);
|
94 |
} |
95 |
|
96 |
public void loadFromState(PersistentState state) throws PersistenceException { |
97 |
super.loadFromState(state);
|
98 |
} |
99 |
|
100 |
public static void registerPersistent() { |
101 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
102 |
DynStruct definition = manager.addDefinition( |
103 |
DefaultViewDocument.class, |
104 |
PERSISTENCE_DEFINITION_NAME, |
105 |
"Default view document persistence definition",
|
106 |
null,
|
107 |
null
|
108 |
); |
109 |
definition.extend(manager.getDefinition(BaseViewDocument.PERSISTENCE_DEFINITION_NAME)); |
110 |
} |
111 |
|
112 |
|
113 |
public String exportDocumentAsText() { |
114 |
// FIXME: jjdc PersistentManager getStateAsText o similar
|
115 |
// PersistenceManager manager = ToolsLocator.getPersistenceManager();
|
116 |
// PersistentState state = manager.getState(this);
|
117 |
// return manager.getStateAsText(state);
|
118 |
return null; |
119 |
} |
120 |
|
121 |
public void setStateFromText(String text) { |
122 |
// FIXME: jjdc PersistentManager getStateFromText o similar
|
123 |
// PersistenceManager manager = ToolsLocator.getPersistenceManager();
|
124 |
// PersistentState state = manager.getStateFromText(text);
|
125 |
// this.loadFromState(state);
|
126 |
} |
127 |
|
128 |
|
129 |
} |