svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / view / DefaultViewDocument.java @ 40558
History | View | Annotate | Download (4.69 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
/* gvSIG. Geographic Information System of the Valencian Government
|
25 |
*
|
26 |
* Copyright (C) 2007-2009 Infrastructures and Transports Department
|
27 |
* of the Valencian Government (CIT)
|
28 |
*
|
29 |
* This program is free software; you can redistribute it and/or
|
30 |
* modify it under the terms of the GNU General Public License
|
31 |
* as published by the Free Software Foundation; either version 2
|
32 |
* of the License, or (at your option) any later version.
|
33 |
*
|
34 |
* This program is distributed in the hope that it will be useful,
|
35 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
36 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
37 |
* GNU General Public License for more details.
|
38 |
*
|
39 |
* You should have received a copy of the GNU General Public License
|
40 |
* along with this program; if not, write to the Free Software
|
41 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
42 |
* MA 02110-1301, USA.
|
43 |
*
|
44 |
*/
|
45 |
|
46 |
/*
|
47 |
* AUTHORS (In addition to CIT):
|
48 |
* 2004-2009 IVER TI
|
49 |
*
|
50 |
*/
|
51 |
package org.gvsig.app.project.documents.view; |
52 |
|
53 |
import org.gvsig.app.ApplicationLocator; |
54 |
import org.gvsig.app.project.ProjectPreferences; |
55 |
import org.gvsig.app.project.documents.DocumentManager; |
56 |
import org.gvsig.fmap.mapcontext.MapContext; |
57 |
import org.gvsig.fmap.mapcontext.ViewPort; |
58 |
import org.gvsig.tools.ToolsLocator; |
59 |
import org.gvsig.tools.dynobject.DynStruct; |
60 |
import org.gvsig.tools.persistence.PersistenceManager; |
61 |
import org.gvsig.tools.persistence.PersistentState; |
62 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
63 |
|
64 |
|
65 |
|
66 |
/**
|
67 |
* Clase que representa una vista del proyecto
|
68 |
*
|
69 |
* @author 2004-2005 Fernando Gonz?lez Cort?s
|
70 |
* @author 2006-2009 Jose Manuel Vivo
|
71 |
* @author 2005- Vicente Caballero
|
72 |
* @author 2009- Joaquin del Cerro
|
73 |
*
|
74 |
*/
|
75 |
|
76 |
public class DefaultViewDocument extends BaseViewDocument { |
77 |
|
78 |
/**
|
79 |
*
|
80 |
*/
|
81 |
private static final long serialVersionUID = 676711512482334764L; |
82 |
|
83 |
public static final String PERSISTENCE_DEFINITION_NAME = "DefaultViewDocument"; |
84 |
|
85 |
|
86 |
public DefaultViewDocument() {
|
87 |
this(null); |
88 |
} |
89 |
|
90 |
public DefaultViewDocument(DocumentManager factory) {
|
91 |
super(factory);
|
92 |
|
93 |
ViewPort vp; |
94 |
|
95 |
ProjectPreferences preferences = (ProjectPreferences) ApplicationLocator.getManager().getPreferences("project");
|
96 |
|
97 |
MapContext viewMapContext = new MapContext(
|
98 |
new ViewPort( preferences.getDefaultProjection() )
|
99 |
); |
100 |
vp = viewMapContext.getViewPort(); |
101 |
vp.setBackColor(preferences.getDefaultViewBackColor()); |
102 |
vp.setDistanceUnits(preferences.getDefaultDistanceUnits()); |
103 |
vp.setDistanceArea(preferences.getDefaultDistanceArea()); |
104 |
|
105 |
/*
|
106 |
* Not very elegant but we are forcing meters if projected
|
107 |
*/
|
108 |
if (viewMapContext.getProjection().isProjected()) {
|
109 |
vp.setMapUnits(1);
|
110 |
} else {
|
111 |
vp.setMapUnits(8);
|
112 |
} |
113 |
|
114 |
|
115 |
this.setMapContext(viewMapContext);
|
116 |
|
117 |
MapContext overviewMapContext = new MapContext(
|
118 |
new ViewPort( viewMapContext.getProjection() )
|
119 |
); |
120 |
vp = viewMapContext.getViewPort(); |
121 |
vp.setBackColor(preferences.getDefaultViewBackColor()); |
122 |
this.setMapOverViewContext(overviewMapContext);
|
123 |
} |
124 |
|
125 |
public void saveToState(PersistentState state) throws PersistenceException { |
126 |
super.saveToState(state);
|
127 |
} |
128 |
|
129 |
public void loadFromState(PersistentState state) throws PersistenceException { |
130 |
super.loadFromState(state);
|
131 |
} |
132 |
|
133 |
public String exportDocumentAsText() { |
134 |
// FIXME: jjdc PersistentManager getStateAsText o similar
|
135 |
// PersistenceManager manager = ToolsLocator.getPersistenceManager();
|
136 |
// PersistentState state = manager.getState(this);
|
137 |
// return manager.getStateAsText(state);
|
138 |
return null; |
139 |
} |
140 |
|
141 |
public void setStateFromText(String text) { |
142 |
// FIXME: jjdc PersistentManager getStateFromText o similar
|
143 |
// PersistenceManager manager = ToolsLocator.getPersistenceManager();
|
144 |
// PersistentState state = manager.getStateFromText(text);
|
145 |
// this.loadFromState(state);
|
146 |
} |
147 |
|
148 |
|
149 |
} |