Statistics
| Revision:

root / branches / v2_0_0_prep / libFMap_mapcontext / src / org / gvsig / fmap / mapcontext / layers / FLayerStatus.java @ 21200

History | View | Annotate | Download (7.45 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 20989 2008-05-28 11:05:57Z jmvivo $
47
* $Log$
48
* Revision 1.2  2007-03-06 17:08:55  caballero
49
* Exceptions
50
*
51
* Revision 1.1  2006/09/21 17:23:39  azabala
52
* First version in cvs
53
*
54
*
55
*/
56
package org.gvsig.fmap.mapcontext.layers;
57

    
58
import java.util.ArrayList;
59
import java.util.List;
60

    
61
import org.gvsig.exceptions.BaseException;
62

    
63

    
64
/**
65
 * <p>All layers in <i>libFMap</i> can be in a set of <i>states</i>, that their combination represent the <i>status</i> of a layer.</p>
66
 * 
67
 * <p><code>FLayerStatus</code> class supports the common status for all kind of {@link FLyrDefault FLyrDefault} layers.</p>
68
 * 
69
 * <p>This means that not necessarily all layers can stay in all possible status, it depends on its particular
70
 * nature.</p>
71
 * 
72
 * <p>Layer status states defined in <code>FLayerStatus</code> are:
73
 *  <ul>
74
 *  <li><i><b>Available</b></i>: the layer is available if the source of its data is on-line.</li>
75
 *  <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 
76
 *  layer will be called to be painted unless the necessary data would be unavailable; this situation is more frequent with layers of
77
 *  remote services.</li>
78
 *  <li><i><b>Active</b></i>: is active if it's selected at the TOC.</li>
79
 *  <li><i><b>Dirty</b></i>: is dirty if needs to be refreshed.</li>
80
 *  <li><i><b>In TOC</b></i>: if it's being listed in a TOC GUI.</li>
81
 *  <li><i><b>Editing</b></i>: if the layer it's being edited now.</li>
82
 *  <li><i><b>Writable</b></i>: if can be modified and saved the changes.</li>
83
 *  <li><i><b>Cache drawn layers</b></i>: if stores previous draws. This is useful to accelerate the draw of the layer.</li>
84
 *  <li><i><b>Driver loaded</b></i>: if driver for managing the layer has been loaded successfully.</li>
85
 *  </ul>
86
 * </p>
87
 * 
88
 * @see IFLayerStatus
89
 * 
90
 * @author azabala
91
 */
92
public class FLayerStatus implements IFLayerStatus {
93
        /**
94
         * <p>Layer's availability: the layer is available if the source of its data is on-line.</p>
95
         */
96
        public boolean available;
97
        
98
        /**
99
         * <p>Layer's visibility: the layer is visible if it's selected its <i>check box</i> associated in TOC. This implies that 
100
         *  layer will tried to be painted unless the necessary data would be unavailable; this situation is more frequent with layers of
101
         *  remote services.</p>
102
         */
103
        public boolean visible;
104
        
105
        /**
106
         * <p>The layer is active if it's selected at the TOC.</p>
107
         */
108
        public boolean active;
109
        
110
        /**
111
         * <p>One layer is dirty if needs to be refreshed.</p>
112
         */
113
        public boolean dirty;
114
        
115
        /**
116
         * <p>The layer is in TOC if it's being listed in a TOC GUI.</p>
117
         */
118
        public boolean inTOC;
119
        
120
        /**
121
         * <p>This parameter reports if the layer it's being edited now.</p>
122
         */
123
        public boolean editing;
124
        
125
        /**
126
         * <p>This parameter reports if the layer can be modified and saved the changes.</p>
127
         */
128
        public boolean writable;
129
        
130
        /**
131
         * <p>This state reports if the layer stores previous draws. That's useful to accelerate the draw of the layer.</p>
132
         */
133
        public boolean cacheDrawnLayers;
134

    
135
        
136
        /**
137
         * <p>List with the information of the driver errors produced working this layer.</p>
138
         */
139
        private ArrayList layerErrors;
140
                
141
        /**
142
         * <p>This state reports if the driver for managing the layer has been loaded successfully.</p>
143
         */
144
        private boolean driverLoaded=true;
145

    
146
        /**
147
         * <p>Creates an instance with the default status of a <code>FLyrDefault</code> layer:
148
         * <br>
149
         *  <ul>
150
         *  <li><b><i>Visible</i></b>: <code>true</code> .</li>
151
         *  <li><b><i>Active</i></b>: <code>false</code> .</li>
152
         *  <li><b><i>In TOC</i></b>: <code>true</code> .</li>
153
         *  <li><b><i>Editing</i></b>: <code>false</code> .</li>
154
         *  <li><b><i>Cache drawn layers</i></b>: <code>false</code> .</li>
155
         *  <li><b><i>Dirty</i></b>: <code>false</code> .</li>
156
         *  <li><b><i>Available</i></b>: <code>true</code> .</li>
157
         *  <li><b><i>Driver loaded</i></b>: <code>true</code> .</li>
158
         *  <li><b><i>Writable</i></b>: <code>false</code> .</li>
159
         *  <li>Without driver errors.</li>
160
         *  </ul>
161
         * </p>
162
         */
163
        public FLayerStatus(){
164
                this.layerErrors = new ArrayList();
165
                visible = true;
166
                active = false;
167
                inTOC = true;
168
                editing = false;
169
                cacheDrawnLayers = false;
170
                dirty = false;
171
                available = true;
172

    
173
                writable = false;
174

    
175
        }
176

    
177
        /**
178
         * <p>Stores information of an exception produced working with a driver of the layer.</p>
179
         * 
180
         * @param error the driver exception
181
         */
182
        public void addLayerError(BaseException error){
183
                layerErrors.add(error);
184
        }
185

    
186
        /**
187
         * <p>Gets the number of driver exceptions produced working with the layer.</p>
188
         * 
189
         * @return number of driver exceptions produced
190
         */
191
        public int getNumErrors(){
192
                return layerErrors.size();
193
        }
194

    
195
        /**
196
         * <p>Gets the information of the <i>nth</i> layer driver exception registered in the status.</p>
197
         * 
198
         * @param i ith layer exception registered
199
         * 
200
         * @return the <i>nth</i> layer driver exception registered
201
         */
202
        public BaseException getError(int i){
203
                return (BaseException) layerErrors.get(i);
204
        }
205

    
206
        /**
207
         * <p>Returns if there have been driver errors working with the layer.</p>
208
         * 
209
         * @return <code>true</code> if there have driver errors working with the layer; otherwise <code>false</code>
210
         */
211
        public boolean isOk(){
212
                return layerErrors.size() == 0;
213
        }
214

    
215
        /**
216
         * <p>Returns a list of errors produced in a layer working with its driver.</p>
217
         * 
218
         * @return list errors produced in a layer working with its driver
219
         */
220
        public List getErrors() {
221
                return layerErrors;
222
        }
223

    
224
        /**
225
         * <p>Returns if has been loaded successfully the driver for managing the layer.</p>
226
         * 
227
         * @return <code>true</code> if has been loaded successfully the driver for managing the layer; otherwise <code>false</code>
228
         */
229
        public boolean isDriverLoaded() {
230
                return driverLoaded;
231
        }
232

    
233
        /**
234
         * <p>Sets if has been loaded successfully the driver for managing the layer.</p>
235
         * 
236
         * @param driverLoaded <code>true</code> if has been loaded successfully the driver for managing the layer; otherwise <code>false</code>
237
         */
238
        public void setDriverLoaded(boolean driverLoaded) {
239
                this.driverLoaded = driverLoaded;
240
        }
241
}
242