Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.mapcontext / org.gvsig.fmap.mapcontext.api / src / main / java / org / gvsig / fmap / mapcontext / layers / operations / LayerCollection.java @ 40559

History | View | Annotate | Download (8.04 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.mapcontext.layers.operations;
25

    
26
import java.awt.Graphics2D;
27

    
28
import org.gvsig.fmap.mapcontext.ViewPort;
29
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
30
import org.gvsig.fmap.mapcontext.layers.CancelationException;
31
import org.gvsig.fmap.mapcontext.layers.FLayer;
32
import org.gvsig.fmap.mapcontext.layers.LayerCollectionListener;
33

    
34

    
35

    
36
/**
37
 * <p>Interface with methods for a collection of layers.</p>
38
 */
39
public interface LayerCollection extends LayersVisitable {
40

    
41
        /**
42
         * Value used to specify the insertion at the beginning.
43
         */
44
        public final static int BEGIN = 0;
45
        /**
46
         * Value used to specify the insertion at the end.
47
         */
48
        public final static int END = 1;
49
        /**
50
         * Value used to specify the insertion before an element.
51
         */
52
        public final static int BEFORE = 2;
53
        /**
54
         * Value used to specify the insertion after an element.
55
         */
56
        public final static int AFTER = 3;
57

    
58
        /**
59
         * <p>Adds a listener of events produced on a collection of layers.</p>
60
         *
61
         * @param listener a <code>LayerCollectionListener</code>
62
         *
63
         * @see #removeLayerCollectionListener(LayerCollectionListener)
64
         */
65
        public void addLayerCollectionListener(LayerCollectionListener listener);
66

    
67
        /**
68
         * <p>Removes a listener of events produced on a collection of layers.</p>
69
         *
70
         * @param listener a <code>LayerCollectionListener</code>
71
         *
72
         * @see #addLayerCollectionListener(LayerCollectionListener)
73
         */
74
        public void removeLayerCollectionListener(LayerCollectionListener listener);
75

    
76
        /**
77
         * <p>Adds a new layer to this collection.</p>
78
         *
79
         * @param layer the new layer
80
         *
81
         * @throws CancelationException any exception produced during the cancellation of the driver.
82
         * @throws LoadLayerException any exception produced loading the layer.
83
         *
84
         * @see #removeLayer(FLayer)
85
         * @see #removeLayer(int)
86
         * @see #removeLayer(String)
87
         */
88
        public void addLayer(FLayer layer) throws CancelationException, LoadLayerException;
89

    
90
        /**
91
         * <p>Adds a new layer to this collection before or after an element if supplied, 
92
         * and if not at the beginning or end of the collection.</p>.</p>
93
         *
94
         * @param layer a FLayer to move
95
         * @param group a LayerCollection in which the layer has to be moved
96
         * @param where the position parameter. The valid values are:<br>
97
         *         0 = BEGIN (first position)<br>
98
         *         1 = END (last position)<br>
99
         *         2 = BEFORE (before target layer)<br>
100
         *         3 = AFTER (after target layer)<br>
101
         * 
102
         * @param adjoiningLayer a FLayer a layer adjacent to where to insert the layer.
103
         *
104
         * @throws CancelationException any exception produced during the cancellation of the driver.
105
         * @throws LoadLayerException any exception produced loading the layer.
106
         *
107
         * @see #moveTo(FLayer, LayerCollection, int, FLayer)
108
         */
109
        public void addLayer(FLayer layer, int where, FLayer adjoiningLayer) throws LayerNotFoundInCollectionException ;
110

    
111
        /**
112
         * <p>Moves a layer of the collection to another position in internal list. It doesn't consider sub-nodes of layers.</p>
113
         *
114
         * @param from origin position
115
         * @param to destination position
116
         *
117
         * @throws CancelationException any exception produced during the cancellation of the driver.
118
         */
119
        public void moveTo(int from, int to) throws CancelationException;
120

    
121
        /**
122
         * <p>Removes a layer from this collection.</p>
123
         *
124
         * @param lyr a layer
125
         *
126
         * @throws CancelationException any exception produced during the cancellation of the driver.
127
         *
128
         * @see #removeLayer(int)
129
         * @see #removeLayer(String)
130
         * @see #addLayer(FLayer)
131
         */
132
        public void removeLayer(FLayer lyr) throws CancelationException;
133

    
134
        /**
135
         * <p>Removes a layer using its identifier.</p>
136
         *
137
         * @param idLayer layer identifier
138
         *
139
         * @see #removeLayer(FLayer)
140
         * @see #removeLayer(String)
141
         * @see #addLayer(FLayer)
142
         */
143
        public void removeLayer(int idLayer);
144

    
145
        /**
146
         * <p>Removes a layer using its name.</p>
147
         *
148
         * @param layerName the name of the layer
149
         *
150
         * @see #removeLayer(FLayer)
151
         * @see #removeLayer(int)
152
         * @see #addLayer(FLayer)
153
         */
154
        public void removeLayer(String layerName);
155

    
156
        /**
157
         * <p>Returns an array with all visible layers in this collection.</p>
158
         *
159
         * @return array with first-level visible layer nodes, or <code>null</code> if no there is no layer visible
160
         *
161
         * @see #setAllVisibles(boolean)
162
         */
163
        public FLayer[] getVisibles();
164

    
165
        /**
166
         * <p>Returns an array with all active layers in this collection.</p>
167
         *
168
         * @return array with first-level active layer nodes, or <code>null</code> if no there is no layer actived
169
         *
170
         * @see #setAllActives(boolean)
171
         */
172
        public FLayer[] getActives();
173

    
174
        /**
175
         * <p>Returns the ith-output directed son (from bottom up) of this collection.</p>
176
         *
177
         * @param index index of the ith-output layer in this collection.
178
         *
179
         * @return a layer
180
         *
181
         * @see #getLayer(String)
182
         */
183
        public FLayer getLayer(int index);
184

    
185
        /**
186
         * <p>Returns a first-level layer of this collection, using its name.</p>
187
         *
188
         * @param layerName name of a layer of this collection
189
         *
190
         * @return a layer
191
         *
192
         * @see #getLayer(int)
193
         */
194
        public FLayer getLayer(String layerName);
195

    
196
        /**
197
         * <p>Returns the number of layers that are at the first level inside this one.</p>
198
         *
199
         * <p>Doesn't counts the sublayers (of <code>FLayers</code> subnodes).</p>
200
         *
201
         * @return number >= 0 with layers that are at the same first-level
202
         *
203
         * @see #getLayer(int)
204
         * @see #getLayer(String)
205
         */
206
        public int getLayersCount();
207

    
208
        /**
209
         * <p>Changes the status of all layers to active or inactive.</p>
210
         *
211
         * @param active a boolean value
212
         *
213
         * @see #getActives()
214
         */
215
        public void setAllActives(boolean active);
216

    
217
        /**
218
         * <p>Changes the status of all layers to visible or invisible.</p>
219
         *
220
         * @param visible a boolean value
221
         *
222
         * @see #getVisibles()
223
         */
224
        public void setAllVisibles(boolean visible);
225

    
226

    
227
        public void beginDraw(Graphics2D g, ViewPort viewPort);
228
        public void endDraw(Graphics2D g, ViewPort viewPort);
229
        
230
        /**
231
         * <p>Moves a layer from this collection to another collection 
232
         * before or after an element if supplied, 
233
         * and if not at the beginning or end of the collection.</p>
234
         *
235
         * @param layer a FLayer to move
236
         * @param group a LayerCollection in which the layer has to be moved
237
         * @param where the position parameter. The valid values are:<br>
238
         *         0 = BEGIN (first position)<br>
239
         *         1 = END (last position)<br>
240
         *         2 = BEFORE (before target layer)<br>
241
         *         3 = AFTER (after target layer)<br>
242
         * 
243
         * @param adjoiningLayer a FLayer a layer adjacent to where to insert the layer.
244
         * @throws LayerNotFoundInCollectionException 
245
         * 
246
         * @see #addLayer(FLayer, int, FLayer)
247
         */
248
        public void move(FLayer layer, LayerCollection group, int where, FLayer adjoiningLayer) throws LayerNotFoundInCollectionException;
249

    
250
        /**
251
         * <p>Moves a layer from this collection to the end of another collection.</p>
252
         *
253
         * @param layer a FLayer to move
254
         * @param group a LayerCollection in which the layer has to be moved
255
         * @throws LayerNotFoundInCollectionException 
256
         *
257
         */
258
        public void move(FLayer layer, LayerCollection group);
259

    
260

    
261
}