Statistics
| Revision:

svn-gvsig-desktop / tags / v2_0_0_Build_2061 / applications / appgvSIG / src / org / gvsig / app / project / documents / view / DefaultViewDocument.java @ 39427

History | View | Annotate | Download (3.75 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
                
82
                /*
83
                 * Not very elegant but we are forcing meters if projected
84
                 */
85
                if (viewMapContext.getProjection().isProjected()) {
86
                    vp.setMapUnits(1);
87
                } else {
88
            vp.setMapUnits(8);
89
                }
90
                
91
                
92
                this.setMapContext(viewMapContext);
93
                
94
                MapContext overviewMapContext = new MapContext(
95
                                new ViewPort( viewMapContext.getProjection() )
96
                );
97
                vp = viewMapContext.getViewPort();
98
                vp.setBackColor(preferences.getDefaultViewBackColor());
99
                this.setMapOverViewContext(overviewMapContext);
100
        }
101
        
102
        public void saveToState(PersistentState state) throws PersistenceException {
103
                super.saveToState(state);
104
        }
105
        
106
        public void loadFromState(PersistentState state) throws PersistenceException {
107
                super.loadFromState(state);
108
        }
109

    
110
        public String exportDocumentAsText() {
111
                // FIXME: jjdc PersistentManager getStateAsText o similar
112
//                 PersistenceManager manager = ToolsLocator.getPersistenceManager();
113
//                 PersistentState state = manager.getState(this);
114
//                 return manager.getStateAsText(state);
115
                return null;
116
        }
117

    
118
        public void setStateFromText(String text) {
119
                // FIXME: jjdc PersistentManager getStateFromText o similar
120
//                 PersistenceManager manager = ToolsLocator.getPersistenceManager();
121
//                 PersistentState state = manager.getStateFromText(text);
122
//                 this.loadFromState(state);
123
        }
124

    
125
        
126
}