root / branches / v10 / extensions / extPublish / src / org / gvsig / publish / infoProject / ViewInfo.java @ 13962
History | View | Annotate | Download (4.99 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004-2006 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 Iba?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 |
/**
|
42 |
* @author Jos? Vicente Hig?n (josevicente.higon@iver.es)
|
43 |
*/
|
44 |
package org.gvsig.publish.infoProject; |
45 |
|
46 |
import java.util.ArrayList; |
47 |
|
48 |
|
49 |
import com.iver.andami.PluginServices; |
50 |
import com.iver.cit.gvsig.fmap.DriverException; |
51 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
52 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
53 |
import com.iver.cit.gvsig.fmap.layers.LayersIterator; |
54 |
import com.iver.cit.gvsig.project.documents.view.ProjectView; |
55 |
|
56 |
|
57 |
|
58 |
/**
|
59 |
* This class represents the information about a gvSIG view
|
60 |
*
|
61 |
* TODO: Now we are writing the exceptions in the logfile, we must create
|
62 |
* our own exception in order to show to the user (gui).
|
63 |
*
|
64 |
* @author Jos? Vicente Hig?n (josevicente.higon@iver.es)
|
65 |
*
|
66 |
*/
|
67 |
public class ViewInfo implements IViewInfo { |
68 |
private ProjectView view = null; |
69 |
private ILayerInfo[] layers = null; |
70 |
/**
|
71 |
* Constructor
|
72 |
*/
|
73 |
public ViewInfo(ProjectView view){
|
74 |
this.view = view;
|
75 |
/*LayersIterator it = new LayersIterator(view.getMapContext().getLayers());
|
76 |
//move one position
|
77 |
it.nextLayer();
|
78 |
ArrayList list = new ArrayList();
|
79 |
while (it.hasNext()){
|
80 |
list.add(it.nextLayer());
|
81 |
}
|
82 |
if (list.size()> 0){
|
83 |
this.layers = new LayerInfo[list.size()];
|
84 |
for ( int i = 0; i < list.size(); i++){
|
85 |
this.layers[i] = new LayerInfo((FLayer)list.get(i));
|
86 |
}
|
87 |
}*/
|
88 |
|
89 |
FLayers lyrs = this.view.getMapContext().getLayers();
|
90 |
this.layers = new LayerInfo[lyrs.getLayersCount()]; |
91 |
for (int i=0; i < lyrs.getLayersCount(); i++){ |
92 |
FLayer lyr = lyrs.getLayer(i); |
93 |
LayerInfo lyrinf = new LayerInfo(lyr);
|
94 |
this.layers[i] = lyrinf;
|
95 |
} |
96 |
} |
97 |
/**
|
98 |
* @see ViewInf.getComment()
|
99 |
*/
|
100 |
public String getComment() { |
101 |
|
102 |
return this.view.getComment(); |
103 |
} |
104 |
/**
|
105 |
* @see ViewInf.getCreationDate()
|
106 |
*/
|
107 |
public String getCreationDate() { |
108 |
|
109 |
return this.view.getCreationDate(); |
110 |
} |
111 |
/**
|
112 |
* @see ViewInf.getMaxX()
|
113 |
*/
|
114 |
public double getMaxX() { |
115 |
double aux=0; |
116 |
try {
|
117 |
aux = this.view.getMapContext().getFullExtent().getMaxX();
|
118 |
} catch (DriverException e) {
|
119 |
PluginServices.getLogger().error("Can't get View MaX", e);
|
120 |
} |
121 |
return aux;
|
122 |
/*String aux = null;
|
123 |
try {
|
124 |
aux = Double.toString(this.view.getMapContext().getFullExtent().getMaxX());
|
125 |
} catch (DriverException e) {
|
126 |
PluginServices.getLogger().error("Can't get View MaX", e);
|
127 |
}
|
128 |
return aux;
|
129 |
*/
|
130 |
} |
131 |
/**
|
132 |
* @see ViewInf.getMaxY()
|
133 |
*/
|
134 |
public double getMaxY() { |
135 |
double aux=0; |
136 |
try {
|
137 |
aux = this.view.getMapContext().getFullExtent().getMaxY();
|
138 |
} catch (DriverException e) {
|
139 |
PluginServices.getLogger().error("Can't get View MaxY", e);
|
140 |
} |
141 |
return aux;
|
142 |
} |
143 |
/**
|
144 |
* @see ViewInf.getMinX()
|
145 |
*/
|
146 |
public double getMinX() { |
147 |
double aux=0; |
148 |
try {
|
149 |
aux = this.view.getMapContext().getFullExtent().getMinX();
|
150 |
} catch (DriverException e) {
|
151 |
PluginServices.getLogger().error("Can't get View MinX", e);
|
152 |
} |
153 |
return aux;
|
154 |
} |
155 |
/**
|
156 |
* @see ViewInf.getMinY()
|
157 |
*/
|
158 |
public double getMinY() { |
159 |
double aux=0; |
160 |
try {
|
161 |
aux = this.view.getMapContext().getFullExtent().getMinY();
|
162 |
} catch (DriverException e) {
|
163 |
PluginServices.getLogger().error("Can't get View MinY", e);
|
164 |
} |
165 |
return aux;
|
166 |
} |
167 |
/**
|
168 |
* @see ViewInf.getName()
|
169 |
*/
|
170 |
public String getName() { |
171 |
|
172 |
return this.view.getName(); |
173 |
} |
174 |
/**
|
175 |
* @see ViewInf.getOwner()
|
176 |
*/
|
177 |
public String getOwner() { |
178 |
|
179 |
return this.view.getOwner(); |
180 |
} |
181 |
/**
|
182 |
* @see ViewInf.getSRS()
|
183 |
*/
|
184 |
public String getSRS() { |
185 |
|
186 |
return this.view.getMapContext().getProjection().getAbrev(); |
187 |
} |
188 |
/**
|
189 |
* @see ViewInfo.IgetLayers()
|
190 |
*/
|
191 |
public ILayerInfo[] getLayers() { |
192 |
/*FLayers layers = this.view.getMapContext().getLayers();
|
193 |
LayerInfo[] res = new LayerInfo[layers.getLayersCount()];
|
194 |
for (int i=0; i < layers.getLayersCount(); i++){
|
195 |
FLayer lyr = layers.getLayer(i);
|
196 |
LayerInfo lyrinf = new DefaultLayerInfo(lyr);
|
197 |
res[i] = lyrinf;
|
198 |
}
|
199 |
return res;*/
|
200 |
return this.layers; |
201 |
} |
202 |
public String toString(){ |
203 |
return getName();
|
204 |
} |
205 |
} |