svn-gvsig-desktop / tags / v10_RC2c / applications / appgvSIG / src / com / iver / cit / gvsig / project / ProjectMap.java @ 8745
History | View | Annotate | Download (5.64 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; |
42 |
|
43 |
import java.text.DateFormat; |
44 |
import java.util.Date; |
45 |
|
46 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
47 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
48 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
49 |
import com.iver.cit.gvsig.gui.layout.Layout; |
50 |
import com.iver.cit.gvsig.gui.project.OpenException; |
51 |
import com.iver.cit.gvsig.gui.project.SaveException; |
52 |
import com.iver.utiles.XMLEntity; |
53 |
|
54 |
|
55 |
/**
|
56 |
* DOCUMENT ME!
|
57 |
*
|
58 |
* @author Fernando Gonz?lez Cort?s
|
59 |
*/
|
60 |
public class ProjectMap extends ProjectElement { |
61 |
public static int numMaps = 0; |
62 |
private Layout model;
|
63 |
|
64 |
/**
|
65 |
* DOCUMENT ME!
|
66 |
*
|
67 |
* @param baseName DOCUMENT ME!
|
68 |
*
|
69 |
* @return DOCUMENT ME!
|
70 |
*/
|
71 |
public static ProjectMap createMap(String baseName) { |
72 |
ProjectMap m = new ProjectMap();
|
73 |
m.setName(baseName + " - " + numMaps);
|
74 |
m.setCreationDate(DateFormat.getInstance().format(new Date())); |
75 |
numMaps++; |
76 |
|
77 |
return m;
|
78 |
} |
79 |
|
80 |
/**
|
81 |
* @see com.iver.cit.gvsig.project.ProjectMap#getModel()
|
82 |
*/
|
83 |
public Layout getModel() {
|
84 |
return model;
|
85 |
} |
86 |
|
87 |
/**
|
88 |
* @see com.iver.cit.gvsig.project.ProjectMap#setMapContext(com.iver.cit.gvsig.project.castor.XMLEntity)
|
89 |
*/
|
90 |
public void setModel(Layout f) { |
91 |
model = f; |
92 |
f.setName(getName()); |
93 |
super.window = f;
|
94 |
} |
95 |
|
96 |
/**
|
97 |
* @see com.iver.cit.gvsig.project.ProjectElement#setName(java.lang.String)
|
98 |
*/
|
99 |
public void setName(String string) { |
100 |
super.setName(string);
|
101 |
|
102 |
Layout m = getModel(); |
103 |
|
104 |
if (m != null) { |
105 |
m.setName(string); |
106 |
} |
107 |
} |
108 |
|
109 |
/**
|
110 |
* DOCUMENT ME!
|
111 |
*
|
112 |
* @return DOCUMENT ME!
|
113 |
* @throws SaveException
|
114 |
* @throws XMLException
|
115 |
*
|
116 |
* @throws DriverException
|
117 |
*/
|
118 |
public XMLEntity getXMLEntity() throws SaveException { |
119 |
XMLEntity xml = super.getXMLEntity();
|
120 |
try{
|
121 |
//xml.putProperty("nameClass", this.getClass().getName());
|
122 |
xml.putProperty("numMaps", numMaps);
|
123 |
xml.addChild(model.getXMLEntity()); |
124 |
}catch (Exception e) { |
125 |
throw new SaveException(e,this.getClass().getName()); |
126 |
} |
127 |
return xml;
|
128 |
} |
129 |
|
130 |
/**
|
131 |
* @throws OpenException
|
132 |
* @see com.iver.cit.gvsig.project.ProjectElement#setXMLEntity(com.iver.utiles.XMLEntity)
|
133 |
*/
|
134 |
public void setXMLEntity(XMLEntity xml, Project p) throws OpenException { |
135 |
try {
|
136 |
numMaps = xml.getIntProperty("numMaps");
|
137 |
for (int i=0; i<xml.getChildrenCount(); i++) |
138 |
{ |
139 |
XMLEntity child = xml.getChild(i); |
140 |
if (child.contains("className") |
141 |
&& child.getStringProperty("className").equals("com.iver.cit.gvsig.gui.layout.Layout") |
142 |
&& child.contains("name")
|
143 |
&& child.getStringProperty("name").equals("layout")) { |
144 |
setModel(Layout.createLayout(child,p)); |
145 |
} |
146 |
} |
147 |
} catch (Exception e) { |
148 |
throw new OpenException(e,this.getClass().getName()); |
149 |
} |
150 |
} |
151 |
|
152 |
/**
|
153 |
* @see com.iver.cit.gvsig.project.ProjectElement#setXMLEntity(com.iver.utiles.XMLEntity)
|
154 |
*/
|
155 |
public void setXMLEntity03(XMLEntity xml, Project p) { |
156 |
numMaps = xml.getIntProperty("numMaps");
|
157 |
model = Layout.createLayout03(xml.getChild(0), p);
|
158 |
} |
159 |
|
160 |
// public int computeSignature() {
|
161 |
// int result = 17;
|
162 |
//
|
163 |
// Class clazz = getClass();
|
164 |
// Field[] fields = clazz.getDeclaredFields();
|
165 |
// for (int i = 0; i < fields.length; i++) {
|
166 |
// try {
|
167 |
// String type = fields[i].getType().getName();
|
168 |
// if (type.equals("boolean")) {
|
169 |
// result += 37 + ((fields[i].getBoolean(this)) ? 1 : 0);
|
170 |
// } else if (type.equals("java.lang.String")) {
|
171 |
// Object v = fields[i].get(this);
|
172 |
// if (v == null) {
|
173 |
// result += 37;
|
174 |
// continue;
|
175 |
// }
|
176 |
// char[] chars = ((String) v).toCharArray();
|
177 |
// for (int j = 0; j < chars.length; j++) {
|
178 |
// result += 37 + (int) chars[i];
|
179 |
// }
|
180 |
// } else if (type.equals("byte")) {
|
181 |
// result += 37 + (int) fields[i].getByte(this);
|
182 |
// } else if (type.equals("char")) {
|
183 |
// result += 37 + (int) fields[i].getChar(this);
|
184 |
// } else if (type.equals("short")) {
|
185 |
// result += 37 + (int) fields[i].getShort(this);
|
186 |
// } else if (type.equals("int")) {
|
187 |
// result += 37 + fields[i].getInt(this);
|
188 |
// } else if (type.equals("long")) {
|
189 |
// long f = fields[i].getLong(this) ;
|
190 |
// result += 37 + (f ^ (f >>> 32));
|
191 |
// } else if (type.equals("float")) {
|
192 |
// result += 37 + Float.floatToIntBits(fields[i].getFloat(this));
|
193 |
// } else if (type.equals("double")) {
|
194 |
// long f = Double.doubleToLongBits(fields[i].getDouble(this));
|
195 |
// result += 37 + (f ^ (f >>> 32));
|
196 |
// } else {
|
197 |
// Object obj = fields[i].get(this);
|
198 |
// result += 37 + ((obj != null)? obj.hashCode() : 0);
|
199 |
// }
|
200 |
// } catch (Exception e) { e.printStackTrace(); }
|
201 |
//
|
202 |
// }
|
203 |
// return result;
|
204 |
// }
|
205 |
} |