svn-gvsig-desktop / branches / v10 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / FLayerStatus.java @ 13980
History | View | Annotate | Download (7.62 KB)
1 |
/*
|
---|---|
2 |
* Created on 01-sep-2006
|
3 |
*
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
5 |
*
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU General Public License
|
10 |
* as published by the Free Software Foundation; either version 2
|
11 |
* of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
21 |
*
|
22 |
* For more information, contact:
|
23 |
*
|
24 |
* Generalitat Valenciana
|
25 |
* Conselleria d'Infraestructures i Transport
|
26 |
* Av. Blasco Ib??ez, 50
|
27 |
* 46010 VALENCIA
|
28 |
* SPAIN
|
29 |
*
|
30 |
* +34 963862235
|
31 |
* gvsig@gva.es
|
32 |
* www.gvsig.gva.es
|
33 |
*
|
34 |
* or
|
35 |
*
|
36 |
* IVER T.I. S.A
|
37 |
* Salamanca 50
|
38 |
* 46005 Valencia
|
39 |
* Spain
|
40 |
*
|
41 |
* +34 963163400
|
42 |
* dac@iver.es
|
43 |
*/
|
44 |
/* CVS MESSAGES:
|
45 |
*
|
46 |
* $Id: FLayerStatus.java 13980 2007-09-24 12:03:13Z ppiqueras $
|
47 |
* $Log$
|
48 |
* Revision 1.1.2.4 2007-09-24 12:03:13 ppiqueras
|
49 |
* Translated comments to English language and add new ones.
|
50 |
*
|
51 |
* Revision 1.1.2.3 2007/02/21 08:57:28 fjp
|
52 |
* Bug con el driver loaded corregido. Afectaba a los eventos de capas
|
53 |
*
|
54 |
* Revision 1.1.2.2 2007/02/20 08:51:20 fjp
|
55 |
* Cambios para que el driver avise de cu?ndo a terminado de trabajar
|
56 |
*
|
57 |
* Revision 1.1.2.1 2006/11/15 04:11:12 jjdelcerro
|
58 |
* *** empty log message ***
|
59 |
*
|
60 |
* Revision 1.1 2006/09/21 17:23:39 azabala
|
61 |
* First version in cvs
|
62 |
*
|
63 |
*
|
64 |
*/
|
65 |
package com.iver.cit.gvsig.fmap.layers; |
66 |
|
67 |
import java.util.ArrayList; |
68 |
import java.util.List; |
69 |
|
70 |
import com.iver.cit.gvsig.fmap.DriverException; |
71 |
|
72 |
/**
|
73 |
* <p>All <i>fmap</i> layers can be in a set of states, that their combination represent the status of a layer.</p>
|
74 |
*
|
75 |
* <p>The <code>FLayerStatus</code> class supports the common status for all kind of {@link FLyrDefault FLyrDefault} layers.</p>
|
76 |
*
|
77 |
* <p>This means that not necessarily all layers can stay in all possible status, it depends on its particular
|
78 |
* constitution.</p>
|
79 |
*
|
80 |
* <p>Layer status states defined:
|
81 |
* <ul>
|
82 |
* <li><i><b>Available</b></i>: the layer is available if the source of its data is on-line.</li>
|
83 |
* <li><i><b>Visible</b></i>: one layer is visible if it's selected its <i>check box</i> associated in TOC. This implies that
|
84 |
* layer will tried to be painted unless the necessary data would be unavailable; this situation is more frequent with layers of
|
85 |
* remote services.</li>
|
86 |
* <li><i><b>Active</b></i>: the layer is active if it's selected at the TOC.</li>
|
87 |
* <li><i><b>Dirty</b></i>: one layer is dirty if needs to be refreshed.</li>
|
88 |
* <li><i><b>In TOC</b></i>: the layer is in TOC if it's at the view's TOC's tree of layers.</li>
|
89 |
* <li><i><b>Editing</b></i>: if the layer it's being edited now.</li>
|
90 |
* <li><i><b>Writable</b></i>: if can be modified and saved the changes.</li>
|
91 |
* <li><i><b>Cache drawn layers</b></i>: this state reports if the layer stores previous draws. This is useful to accelerate the draw of the layer.</li>
|
92 |
* <li><i><b>Driver loaded</b></i>: this state reports if the driver for managing the layer has been loaded successfully.</li>
|
93 |
* </ul>
|
94 |
* </p>
|
95 |
*
|
96 |
* @see IFLayerStatus
|
97 |
*
|
98 |
* @author azabala
|
99 |
*/
|
100 |
public class FLayerStatus implements IFLayerStatus { |
101 |
/**
|
102 |
* <p>Layer's availability: the layer is available if the source of its data is on-line.</p>
|
103 |
*/
|
104 |
public boolean available; |
105 |
|
106 |
/**
|
107 |
* <p>Layer's visibility: the layer is visible if it's selected its <i>check box</i> associated in TOC. This implies that
|
108 |
* layer will tried to be painted unless the necessary data would be unavailable; this situation is more frequent with layers of
|
109 |
* remote services.</p>
|
110 |
*/
|
111 |
public boolean visible; |
112 |
|
113 |
/**
|
114 |
* <p>The layer is active if it's selected at the TOC.</p>
|
115 |
*/
|
116 |
public boolean active; |
117 |
|
118 |
/**
|
119 |
* <p>One layer is dirty if needs to be refreshed.</p>
|
120 |
*/
|
121 |
public boolean dirty; |
122 |
|
123 |
/**
|
124 |
* <p>The layer is in TOC if it's at the view's TOC's tree of layers.</p>
|
125 |
*/
|
126 |
public boolean inTOC; |
127 |
|
128 |
/**
|
129 |
* <p>This parameter reports if the layer it's being edited now.</p>
|
130 |
*/
|
131 |
public boolean editing; |
132 |
|
133 |
/**
|
134 |
* <p>This parameter reports if the layer can be modified and saved the changes.</p>
|
135 |
*/
|
136 |
public boolean writable; |
137 |
|
138 |
/**
|
139 |
* <p>This state reports if the layer stores previous draws. That's useful to accelerate the draw of the layer.</p>
|
140 |
*/
|
141 |
public boolean cacheDrawnLayers; |
142 |
|
143 |
/**
|
144 |
* <p>This state reports if the driver for managing the layer has been loaded successfully.</p>
|
145 |
*/
|
146 |
private boolean driverLoaded; |
147 |
|
148 |
/**
|
149 |
*
|
150 |
*/
|
151 |
public boolean enabled; |
152 |
|
153 |
/**
|
154 |
* <p>List with the information of the driver errors produced working this layer.</p>
|
155 |
*/
|
156 |
private ArrayList layerErrors; |
157 |
|
158 |
/**
|
159 |
* <p>Creates an instance with the default status of a {@link FLyrDefault FLyrDefault} layer:
|
160 |
* <ul>
|
161 |
* <li><b><i>Visible</i></b>: <code>true</code> .</li>
|
162 |
* <li><b><i>Active</i></b>: <code>false</code> .</li>
|
163 |
* <li><b><i>In TOC</i></b>: <code>true</code> .</li>
|
164 |
* <li><b><i>Editing</i></b>: <code>false</code> .</li>
|
165 |
* <li><b><i>Cache drawn layers</i></b>: <code>false</code> .</li>
|
166 |
* <li><b><i>Dirty</i></b>: <code>false</code> .</li>
|
167 |
* <li><b><i>Available</i></b>: <code>true</code> .</li>
|
168 |
* <li><b><i>Driver loaded</i></b>: <code>true</code> .</li>
|
169 |
* <li><b><i>Writable</i></b>: <code>false</code> .</li>
|
170 |
* <li>Without driver errors.</li>
|
171 |
* </ul>
|
172 |
* </p>
|
173 |
*/
|
174 |
public FLayerStatus(){
|
175 |
this.layerErrors = new ArrayList(); |
176 |
visible = true;
|
177 |
active = false;
|
178 |
inTOC = true;
|
179 |
editing = false;
|
180 |
cacheDrawnLayers = false;
|
181 |
dirty = false;
|
182 |
available = true;
|
183 |
driverLoaded = true;
|
184 |
writable = false;
|
185 |
|
186 |
} |
187 |
|
188 |
/**
|
189 |
* <p>Stores information of an exception produced working with a driver of the layer.</p>
|
190 |
*
|
191 |
* @param error the driver exception
|
192 |
*/
|
193 |
public void addLayerError(DriverException error){ |
194 |
layerErrors.add(error); |
195 |
} |
196 |
|
197 |
/**
|
198 |
* <p>Gets the number of driver exceptions produced working with the layer.</p>
|
199 |
*
|
200 |
* @return number of driver exceptions produced
|
201 |
*/
|
202 |
public int getNumErrors(){ |
203 |
return layerErrors.size();
|
204 |
} |
205 |
|
206 |
/**
|
207 |
* <p>Gets the information of the <i>nth</i> layer driver exception registered in the status.</p>
|
208 |
*
|
209 |
* @param i ith layer exception registered
|
210 |
*
|
211 |
* @return the <i>nth</i> layer driver exception registered
|
212 |
*/
|
213 |
public DriverException getError(int i){ |
214 |
return (DriverException) layerErrors.get(i);
|
215 |
} |
216 |
|
217 |
/**
|
218 |
* <p>Returns if there have been driver errors working with the layer.</p>
|
219 |
*
|
220 |
* @return <code>true</code> if there have driver errors working with the layer; <code>false</code> otherwise
|
221 |
*/
|
222 |
public boolean isOk(){ |
223 |
return layerErrors.size() == 0; |
224 |
} |
225 |
|
226 |
/**
|
227 |
* <p>Returns a list with the driver errors produced in a layer.</p>
|
228 |
*
|
229 |
* @return list with the driver errors produced in a layer
|
230 |
*/
|
231 |
public List getErrors() { |
232 |
return layerErrors;
|
233 |
} |
234 |
|
235 |
/**
|
236 |
* <p>Returns if has been loaded successfully the driver for managing the layer.</p>
|
237 |
*
|
238 |
* @return <code>true</code> if has been loaded successfully the driver for managing the layer; <code>false</code> otherwise
|
239 |
*/
|
240 |
public boolean isDriverLoaded() { |
241 |
return driverLoaded;
|
242 |
} |
243 |
|
244 |
/**
|
245 |
* <p>Sets if has been loaded successfully the driver for managing the layer.</p>
|
246 |
*
|
247 |
* @param driverLoaded <code>true</code> if has been loaded successfully the driver for managing the layer; <code>false</code> otherwise
|
248 |
*/
|
249 |
public void setDriverLoaded(boolean driverLoaded) { |
250 |
this.driverLoaded = driverLoaded;
|
251 |
} |
252 |
} |