svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / ProjectMap.java @ 6644
History | View | Annotate | Download (4.51 KB)
1 | 1222 | fernando | /* 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 | 1830 | fernando | import com.hardcode.gdbms.engine.data.driver.DriverException; |
44 | 1222 | fernando | |
45 | 1830 | fernando | import com.iver.cit.gvsig.fmap.layers.XMLException; |
46 | 1222 | fernando | import com.iver.cit.gvsig.gui.layout.Layout; |
47 | 3183 | caballero | import com.iver.cit.gvsig.gui.project.OpenException; |
48 | import com.iver.cit.gvsig.gui.project.SaveException; |
||
49 | 1222 | fernando | |
50 | import com.iver.utiles.XMLEntity; |
||
51 | |||
52 | import java.text.DateFormat; |
||
53 | |||
54 | import java.util.Date; |
||
55 | |||
56 | |||
57 | /**
|
||
58 | * DOCUMENT ME!
|
||
59 | *
|
||
60 | * @author Fernando Gonz?lez Cort?s
|
||
61 | */
|
||
62 | public class ProjectMap extends ProjectElement { |
||
63 | 2708 | fjp | public static int numMaps = 0; |
64 | 1222 | fernando | private Layout model;
|
65 | |||
66 | /**
|
||
67 | * DOCUMENT ME!
|
||
68 | *
|
||
69 | * @param baseName DOCUMENT ME!
|
||
70 | *
|
||
71 | * @return DOCUMENT ME!
|
||
72 | */
|
||
73 | public static ProjectMap createMap(String baseName) { |
||
74 | ProjectMap m = new ProjectMap();
|
||
75 | m.setName(baseName + " - " + numMaps);
|
||
76 | m.setCreationDate(DateFormat.getInstance().format(new Date())); |
||
77 | numMaps++; |
||
78 | |||
79 | return m;
|
||
80 | } |
||
81 | |||
82 | /**
|
||
83 | * @see com.iver.cit.gvsig.project.ProjectMap#getModel()
|
||
84 | */
|
||
85 | public Layout getModel() {
|
||
86 | return model;
|
||
87 | } |
||
88 | |||
89 | /**
|
||
90 | * @see com.iver.cit.gvsig.project.ProjectMap#setMapContext(com.iver.cit.gvsig.project.castor.XMLEntity)
|
||
91 | */
|
||
92 | public void setModel(Layout f) { |
||
93 | model = f; |
||
94 | f.setName(getName()); |
||
95 | 5029 | cesar | super.view = f;
|
96 | 1222 | fernando | } |
97 | |||
98 | /**
|
||
99 | * @see com.iver.cit.gvsig.project.ProjectElement#setName(java.lang.String)
|
||
100 | */
|
||
101 | public void setName(String string) { |
||
102 | super.setName(string);
|
||
103 | |||
104 | Layout m = getModel(); |
||
105 | |||
106 | if (m != null) { |
||
107 | m.setName(string); |
||
108 | } |
||
109 | } |
||
110 | |||
111 | /**
|
||
112 | * DOCUMENT ME!
|
||
113 | *
|
||
114 | * @return DOCUMENT ME!
|
||
115 | 3183 | caballero | * @throws SaveException
|
116 | 1830 | fernando | * @throws XMLException
|
117 | 1222 | fernando | *
|
118 | * @throws DriverException
|
||
119 | */
|
||
120 | 3183 | caballero | public XMLEntity getXMLEntity() throws SaveException { |
121 | 1222 | fernando | XMLEntity xml = super.getXMLEntity();
|
122 | 3183 | caballero | try{
|
123 | 1222 | fernando | //xml.putProperty("nameClass", this.getClass().getName());
|
124 | xml.putProperty("numMaps", numMaps);
|
||
125 | xml.addChild(model.getXMLEntity()); |
||
126 | 5029 | cesar | XMLEntity viewProperties = this.getViewInfoXMLEntity();
|
127 | if (viewProperties!=null) { //store the properties of the window |
||
128 | xml.addChild(viewProperties); |
||
129 | } |
||
130 | 3183 | caballero | }catch (Exception e) { |
131 | throw new SaveException(e,this.getClass().getName()); |
||
132 | } |
||
133 | 1222 | fernando | return xml;
|
134 | } |
||
135 | |||
136 | /**
|
||
137 | 3183 | caballero | * @throws OpenException
|
138 | 1222 | fernando | * @see com.iver.cit.gvsig.project.ProjectElement#setXMLEntity(com.iver.utiles.XMLEntity)
|
139 | */
|
||
140 | 3183 | caballero | public void setXMLEntity(XMLEntity xml, Project p) throws OpenException { |
141 | try {
|
||
142 | numMaps = xml.getIntProperty("numMaps");
|
||
143 | 5029 | cesar | for (int i=0; i<xml.getNumChild(); i++) |
144 | { |
||
145 | XMLEntity child = xml.getChild(i); |
||
146 | if (child.contains("className") && child.getStringProperty("className").equals(this.getClass().getName()) && child.contains("name") && child.getStringProperty("name").equals("ViewInfoProperties")) { |
||
147 | seedViewInfo = createViewInfoFromXMLEntity(child); |
||
148 | //PluginServices.getMDIManager().changeViewInfo(view, viewInfo);
|
||
149 | |||
150 | } |
||
151 | else if (child.contains("className") |
||
152 | && child.getStringProperty("className").equals("com.iver.cit.gvsig.gui.layout.Layout") |
||
153 | && child.contains("name")
|
||
154 | && child.getStringProperty("name").equals("layout")) { |
||
155 | setModel(Layout.createLayout(child,p)); |
||
156 | } |
||
157 | } |
||
158 | 3183 | caballero | } catch (Exception e) { |
159 | throw new OpenException(e,this.getClass().getName()); |
||
160 | } |
||
161 | 1222 | fernando | } |
162 | 2183 | fernando | |
163 | /**
|
||
164 | * @see com.iver.cit.gvsig.project.ProjectElement#setXMLEntity(com.iver.utiles.XMLEntity)
|
||
165 | */
|
||
166 | public void setXMLEntity03(XMLEntity xml, Project p) { |
||
167 | numMaps = xml.getIntProperty("numMaps");
|
||
168 | model = Layout.createLayout03(xml.getChild(0), p);
|
||
169 | } |
||
170 | 1222 | fernando | } |