Statistics
| Revision:

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 @ 40596

History | View | Annotate | Download (3.76 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

    
25
package org.gvsig.app.project.documents.view;
26

    
27
import org.gvsig.app.ApplicationLocator;
28
import org.gvsig.app.project.ProjectPreferences;
29
import org.gvsig.app.project.documents.DocumentManager;
30
import org.gvsig.fmap.mapcontext.MapContext;
31
import org.gvsig.fmap.mapcontext.ViewPort;
32
import org.gvsig.tools.ToolsLocator;
33
import org.gvsig.tools.dynobject.DynStruct;
34
import org.gvsig.tools.persistence.PersistenceManager;
35
import org.gvsig.tools.persistence.PersistentState;
36
import org.gvsig.tools.persistence.exception.PersistenceException;
37

    
38

    
39

    
40
/**
41
 * Clase que representa una vista del proyecto
42
 *
43
 * @author 2004-2005 Fernando Gonz?lez Cort?s
44
 * @author 2006-2009 Jose Manuel Vivo
45
 * @author 2005-         Vicente Caballero
46
 * @author 2009-         Joaquin del Cerro
47
 * 
48
 */
49

    
50
public class DefaultViewDocument extends BaseViewDocument {
51

    
52
        /**
53
         * 
54
         */
55
        private static final long serialVersionUID = 676711512482334764L;
56

    
57
        public static final String PERSISTENCE_DEFINITION_NAME = "DefaultViewDocument";
58
        
59

    
60
        public DefaultViewDocument() {
61
                this(null);
62
        }
63
        
64
        public DefaultViewDocument(DocumentManager factory) {
65
                super(factory); 
66

    
67
                ViewPort vp;
68
        
69
                ProjectPreferences preferences = (ProjectPreferences) ApplicationLocator.getManager().getPreferences("project");
70
            
71
            MapContext viewMapContext = new MapContext(
72
                                new ViewPort( preferences.getDefaultProjection() )
73
                );
74
                vp = viewMapContext.getViewPort();
75
                vp.setBackColor(preferences.getDefaultViewBackColor());
76
                vp.setDistanceUnits(preferences.getDefaultDistanceUnits());
77
                vp.setDistanceArea(preferences.getDefaultDistanceArea());
78
                
79
                /*
80
                 * Not very elegant but we are forcing meters if projected
81
                 */
82
                if (viewMapContext.getProjection().isProjected()) {
83
                    vp.setMapUnits(1);
84
                } else {
85
            vp.setMapUnits(8);
86
                }
87
                
88
                
89
                this.setMapContext(viewMapContext);
90
                
91
                MapContext overviewMapContext = new MapContext(
92
                                new ViewPort( viewMapContext.getProjection() )
93
                );
94
                vp = viewMapContext.getViewPort();
95
                vp.setBackColor(preferences.getDefaultViewBackColor());
96
                this.setMapOverViewContext(overviewMapContext);
97
        }
98
        
99
        public void saveToState(PersistentState state) throws PersistenceException {
100
                super.saveToState(state);
101
        }
102
        
103
        public void loadFromState(PersistentState state) throws PersistenceException {
104
                super.loadFromState(state);
105
        }
106

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

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

    
122
        
123
}