svn-gvsig-desktop / branches / v10 / extensions / extPublish / src / org / gvsig / publish / infoproject / ViewInfo.java @ 19900
History | View | Annotate | Download (6.25 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.awt.geom.Rectangle2D; |
47 |
import java.util.ArrayList; |
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 |
private IProjectInfo iproject = null; |
71 |
/**
|
72 |
* Default Constructor
|
73 |
*/
|
74 |
public ViewInfo(ProjectView view, IProjectInfo projectInfo){
|
75 |
this.iproject = projectInfo;
|
76 |
this.view = view;
|
77 |
FLayers lyrs = this.view.getMapContext().getLayers();
|
78 |
this.layers = new LayerInfo[lyrs.getLayersCount()]; |
79 |
for (int i=0; i < lyrs.getLayersCount(); i++){ |
80 |
FLayer lyr = lyrs.getLayer(i); |
81 |
LayerInfo lyrinf = new LayerInfo(lyr,view, this, null); |
82 |
this.layers[i] = lyrinf;
|
83 |
} |
84 |
} |
85 |
/**
|
86 |
* Constructor with filter
|
87 |
* @param v
|
88 |
* @param projectInfo
|
89 |
* @param filter
|
90 |
*/
|
91 |
public ViewInfo(ProjectView v, ProjectInfo projectInfo,
|
92 |
FilterProjectInfo filter) { |
93 |
this(v,projectInfo);
|
94 |
if (filter != null){ |
95 |
//check filter
|
96 |
if (filter.isGroupedLayers()==false){ |
97 |
LayersIterator it = new LayersIterator(this.view.getMapContext().getLayers()); |
98 |
ArrayList aux = new ArrayList(); |
99 |
while (it.hasNext()){
|
100 |
FLayer l = it.nextLayer(); |
101 |
if (l instanceof FLayers == false){ |
102 |
aux.add(l); |
103 |
//System.err.println("Layer " + l.getName());
|
104 |
} |
105 |
} |
106 |
this.layers = new LayerInfo[aux.size()]; |
107 |
for (int i=0; i < aux.size(); i++){ |
108 |
FLayer lyr = (FLayer) aux.get(i); |
109 |
LayerInfo lyrinf = new LayerInfo(lyr,view, this, null); |
110 |
this.layers[i] = lyrinf;
|
111 |
} |
112 |
} |
113 |
} |
114 |
} |
115 |
/**
|
116 |
* @see ViewInf.getComment()
|
117 |
*/
|
118 |
public String getComment() { |
119 |
|
120 |
return this.view.getComment(); |
121 |
} |
122 |
/**
|
123 |
* @see ViewInf.getCreationDate()
|
124 |
*/
|
125 |
public String getCreationDate() { |
126 |
|
127 |
return this.view.getCreationDate(); |
128 |
} |
129 |
/**
|
130 |
* @see ViewInf.getMaxX()
|
131 |
*/
|
132 |
public double getMaxX() { |
133 |
double aux=0; |
134 |
try {
|
135 |
aux = this.view.getMapContext().getFullExtent().getMaxX();
|
136 |
} catch (DriverException e) {
|
137 |
PluginServices.getLogger().error("Can't get View MaX", e);
|
138 |
} |
139 |
return aux;
|
140 |
/*String aux = null;
|
141 |
try {
|
142 |
aux = Double.toString(this.view.getMapContext().getFullExtent().getMaxX());
|
143 |
} catch (DriverException e) {
|
144 |
PluginServices.getLogger().error("Can't get View MaX", e);
|
145 |
}
|
146 |
return aux;
|
147 |
*/
|
148 |
} |
149 |
/**
|
150 |
* @see ViewInf.getMaxY()
|
151 |
*/
|
152 |
public double getMaxY() { |
153 |
double aux=0; |
154 |
try {
|
155 |
aux = this.view.getMapContext().getFullExtent().getMaxY();
|
156 |
} catch (DriverException e) {
|
157 |
PluginServices.getLogger().error("Can't get View MaxY", e);
|
158 |
} |
159 |
return aux;
|
160 |
} |
161 |
/**
|
162 |
* @see ViewInf.getMinX()
|
163 |
*/
|
164 |
public double getMinX() { |
165 |
double aux=0; |
166 |
try {
|
167 |
aux = this.view.getMapContext().getFullExtent().getMinX();
|
168 |
} catch (DriverException e) {
|
169 |
PluginServices.getLogger().error("Can't get View MinX", e);
|
170 |
} |
171 |
return aux;
|
172 |
} |
173 |
/**
|
174 |
* @see ViewInf.getMinY()
|
175 |
*/
|
176 |
public double getMinY() { |
177 |
double aux=0; |
178 |
try {
|
179 |
aux = this.view.getMapContext().getFullExtent().getMinY();
|
180 |
} catch (DriverException e) {
|
181 |
PluginServices.getLogger().error("Can't get View MinY", e);
|
182 |
} |
183 |
return aux;
|
184 |
} |
185 |
/**
|
186 |
* @see ViewInf.getName()
|
187 |
*/
|
188 |
public String getName() { |
189 |
|
190 |
return this.view.getName(); |
191 |
} |
192 |
/**
|
193 |
* @see ViewInf.getOwner()
|
194 |
*/
|
195 |
public String getOwner() { |
196 |
|
197 |
return this.view.getOwner(); |
198 |
} |
199 |
/**
|
200 |
* @see ViewInf.getSRS()
|
201 |
*/
|
202 |
public String getEPSG() { |
203 |
|
204 |
return this.view.getMapContext().getProjection().getAbrev(); |
205 |
} |
206 |
/**
|
207 |
* @see ViewInfo.IgetLayers()
|
208 |
*/
|
209 |
public ILayerInfo[] getLayers() { |
210 |
/*FLayers layers = this.view.getMapContext().getLayers();
|
211 |
LayerInfo[] res = new LayerInfo[layers.getLayersCount()];
|
212 |
for (int i=0; i < layers.getLayersCount(); i++){
|
213 |
FLayer lyr = layers.getLayer(i);
|
214 |
LayerInfo lyrinf = new DefaultLayerInfo(lyr);
|
215 |
res[i] = lyrinf;
|
216 |
}
|
217 |
return res;*/
|
218 |
return this.layers; |
219 |
} |
220 |
public String toString(){ |
221 |
return getName();
|
222 |
} |
223 |
/*
|
224 |
* (non-Javadoc)
|
225 |
* @see org.gvsig.publish.infoProject.IViewInfo#getLayerInfoByName(java.lang.String)
|
226 |
*/
|
227 |
public ILayerInfo findLayer(String layerName) { |
228 |
ILayerInfo[] ilayers = getLayers();
|
229 |
for (int i = 0; i < ilayers.length; i++){ |
230 |
ILayerInfo target = ilayers[i].findLayer(layerName); |
231 |
if (target != null){ |
232 |
return target;
|
233 |
} |
234 |
} |
235 |
return null; |
236 |
} |
237 |
public Rectangle2D getBBox() { |
238 |
Rectangle2D aux = null; |
239 |
try {
|
240 |
aux = this.view.getMapContext().getFullExtent();
|
241 |
} catch (DriverException e) {
|
242 |
PluginServices.getLogger().error("ERROR ViewInfo: Can't get Full extent", e);
|
243 |
} |
244 |
return aux;
|
245 |
} |
246 |
|
247 |
public IProjectInfo getProjectInfo() {
|
248 |
|
249 |
return iproject;
|
250 |
} |
251 |
|
252 |
} |