Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / ProjectView.java @ 7738

History | View | Annotate | Download (7.11 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.project.documents.view;
42

    
43
import com.iver.andami.PluginServices;
44
import com.iver.andami.ui.mdiManager.IWindow;
45
import com.iver.cit.gvsig.fmap.DriverException;
46
import com.iver.cit.gvsig.fmap.MapContext;
47
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
48
import com.iver.cit.gvsig.fmap.layers.XMLException;
49
import com.iver.cit.gvsig.project.Project;
50
import com.iver.cit.gvsig.project.documents.exceptions.OpenException;
51
import com.iver.cit.gvsig.project.documents.exceptions.SaveException;
52
import com.iver.cit.gvsig.project.documents.view.gui.ViewProperties;
53
import com.iver.utiles.XMLEntity;
54

    
55

    
56
/**
57
 * Clase que representa una vista del proyecto
58
 *
59
 * @author Fernando Gonz?lez Cort?s
60
 */
61
public class ProjectView extends ProjectViewBase {
62
        public static int numViews = 0;
63

    
64
        //public static int METROS = 0;
65
        //public static int KILOMETROS = 1;
66
        //public static int[] unidades = new int[] { METROS, KILOMETROS };
67
        ///private Color backgroundColor = new Color(255, 255, 255);
68

    
69
        /**
70
         * DOCUMENT ME!
71
         *
72
         * @return DOCUMENT ME!
73
         * @throws XMLException
74
         * @throws SaveException
75
         */
76
        public XMLEntity getXMLEntity() throws SaveException {
77
                XMLEntity xml = super.getXMLEntity();
78
                //xml.putProperty("nameClass", this.getClass().getName());
79
                try{
80
                xml.putProperty("numViews", numViews);
81
                xml.putProperty("m_selectedField", m_selectedField);
82
                xml.putProperty("m_typeLink", m_typeLink);
83
                xml.putProperty("m_extLink", m_extLink);
84
                xml.addChild(mapContext.getXMLEntity());
85

    
86
                if (mapOverViewContext != null) {
87
                        if (mapOverViewContext.getViewPort() != null) {
88
                                xml.putProperty("mapOverView", true);
89
                                xml.addChild(mapOverViewContext.getXMLEntity());
90
                        } else {
91
                                xml.putProperty("mapOverView", false);
92
                        }
93
                } else {
94
                        xml.putProperty("mapOverView", false);
95
                }
96
                }catch (Exception e) {
97
                        throw new SaveException(e,this.getClass().getName());
98
                }
99
                return xml;
100
        }
101

    
102
        /**
103
         * DOCUMENT ME!
104
         *
105
         * @param xml DOCUMENT ME!
106
         * @param p DOCUMENT ME!
107
         * @throws XMLException
108
         * @throws DriverException
109
         * @throws DriverIOException
110
         *
111
         * @see com.iver.cit.gvsig.project.documents.ProjectDocument#setXMLEntity(com.iver.utiles.XMLEntity)
112
         */
113
        public void setXMLEntity03(XMLEntity xml, Project p)
114
                throws XMLException, DriverException, DriverIOException {
115
                numViews = xml.getIntProperty("numViews");
116
                m_selectedField = xml.getStringProperty("m_selectedField");
117
                m_typeLink = xml.getIntProperty("m_typeLink");
118
                m_extLink = xml.getStringProperty("m_extLink");
119
                setMapContext(MapContext.createFromXML03(xml.getChild(0)));
120

    
121
                if (xml.getBooleanProperty("mapOverView")) {
122
                        setMapOverViewContext(MapContext.createFromXML03(xml.getChild(1)));
123
                }
124

    
125
        }
126

    
127
        /**
128
         * DOCUMENT ME!
129
         *
130
         * @param xml DOCUMENT ME!
131
         * @param p DOCUMENT ME!
132
         * @throws XMLException
133
         * @throws DriverException
134
         * @throws DriverIOException
135
         * @throws OpenException
136
         *
137
         * @see com.iver.cit.gvsig.project.documents.ProjectDocument#setXMLEntity(com.iver.utiles.XMLEntity)
138
         */
139
        public void setXMLEntity(XMLEntity xml, Project p)
140
                throws XMLException, DriverException, DriverIOException, OpenException {
141
                try{
142
                        int currentChild=0;
143
                        numViews = xml.getIntProperty("numViews");
144
                        m_selectedField = xml.getStringProperty("m_selectedField");
145
                        m_typeLink = xml.getIntProperty("m_typeLink");
146
                        m_extLink = xml.getStringProperty("m_extLink");
147

    
148
                        setMapContext(MapContext.createFromXML(xml.getChild(currentChild)));
149
                        currentChild++;
150
                        if (xml.getBooleanProperty("mapOverView")) {
151
                                setMapOverViewContext(MapContext.createFromXML(xml.getChild(currentChild)));
152
                                currentChild++;
153
                        }
154
                        showErrors();
155
                }catch (Exception e) {
156
                        throw new OpenException(e,this.getClass().getName());
157
                }
158
        }
159

    
160
        /**
161
         * DOCUMENT ME!
162
         *
163
         * @param p DOCUMENT ME!
164
         *
165
         * @return DOCUMENT ME!
166
         * @throws XMLException
167
         * @throws DriverException
168
         * @throws DriverIOException
169
         * @throws OpenException
170
         */
171
        /*public ProjectView cloneProjectView(Project p)
172
                throws XMLException, DriverException, DriverIOException, OpenException {
173
                return (ProjectView) createFromXML(getXMLEntity(), p);
174
        }
175
*/
176

    
177
        public String getFrameName() {
178
                return PluginServices.getText(this,"Vista");
179
        }
180
        public IWindow createWindow() {
181
                com.iver.cit.gvsig.project.documents.view.gui.View view = new com.iver.cit.gvsig.project.documents.view.gui.View();
182
                view.setModel(this);
183
                return view;
184
        }
185

    
186
        public IWindow getProperties() {
187
                return new ViewProperties(this);
188
        }
189

    
190
//        public int computeSignature() {
191
//                int result = 17;
192
//
193
//                Class clazz = getClass();
194
//                Field[] fields = clazz.getDeclaredFields();
195
//                for (int i = 0; i < fields.length; i++) {
196
//                        try {
197
//                                String type = fields[i].getType().getName();
198
//                                if (type.equals("boolean")) {
199
//                                        result += 37 + ((fields[i].getBoolean(this)) ? 1 : 0);
200
//                                } else if (type.equals("java.lang.String")) {
201
//                                        Object v = fields[i].get(this);
202
//                                        if (v == null) {
203
//                                                result += 37;
204
//                                                continue;
205
//                                        }
206
//                                        char[] chars = ((String) v).toCharArray();
207
//                                        for (int j = 0; j < chars.length; j++) {
208
//                                                result += 37 + (int) chars[i];
209
//                                        }
210
//                                } else if (type.equals("byte")) {
211
//                                        result += 37 + (int) fields[i].getByte(this);
212
//                                } else if (type.equals("char")) {
213
//                                        result += 37 + (int) fields[i].getChar(this);
214
//                                } else if (type.equals("short")) {
215
//                                        result += 37 + (int) fields[i].getShort(this);
216
//                                } else if (type.equals("int")) {
217
//                                        result += 37 + fields[i].getInt(this);
218
//                                } else if (type.equals("long")) {
219
//                                        long f = fields[i].getLong(this) ;
220
//                                        result += 37 + (f ^ (f >>> 32));
221
//                                } else if (type.equals("float")) {
222
//                                        result += 37 + Float.floatToIntBits(fields[i].getFloat(this));
223
//                                } else if (type.equals("double")) {
224
//                                        long f = Double.doubleToLongBits(fields[i].getDouble(this));
225
//                                        result += 37 + (f ^ (f >>> 32));
226
//                                } else {
227
//                                        Object obj = fields[i].get(this);
228
//                                        result += 37 + ((obj != null)? obj.hashCode() : 0);
229
//                                }
230
//                        } catch (Exception e) { e.printStackTrace(); }
231
//
232
//                }
233
//                return result;
234
//        }
235
}