Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / AtomicEvent.java @ 20098

History | View | Annotate | Download (5.8 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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 Ib??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
package com.iver.cit.gvsig.fmap;
42

    
43
import java.util.ArrayList;
44
import java.util.Iterator;
45

    
46
import com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent;
47
import com.iver.cit.gvsig.fmap.layers.LayerEvent;
48
import com.iver.cit.gvsig.fmap.layers.LegendEvent;
49
import com.iver.cit.gvsig.fmap.layers.SelectionEvent;
50

    
51

    
52
/**
53
 * <p>An atomic event represents a group of events that will be attended without any interruption.</p>
54
 * 
55
 * <p>This kind of events are created by the buffer of events of the {@link MapContext MapContext}.</p>
56
 */
57
public class AtomicEvent extends FMapEvent {
58
        /**
59
         * <p>Events that constitute this one.</p>
60
         */
61
        private ArrayList events;
62

    
63
        /**
64
         * <p>Creates a new instance of this kind of event.</p>
65
         *
66
         * @param fmapEvents events that will constitute this one
67
         */
68
        public AtomicEvent(ArrayList fmapEvents) {
69
                this.events = (ArrayList) fmapEvents.clone();
70
        }
71

    
72
        /**
73
         * <p>Returns the event at the specified position in the internal list.</p>
74
         *
75
         * @param index index of event to return
76
         *
77
         * @return event at the specified position in this list
78
         */
79
        public FMapEvent getEvent(int index) {
80
                return (FMapEvent) events.get(index);
81
        }
82

    
83
        /**
84
         * <p>Returns the number of events that constitute this one.</p>
85
         *
86
         * @return number of events that constitute this one
87
         */
88
        public int getEventCount() {
89
                return events.size();
90
        }
91

    
92
        /**
93
         * <p>Returns all legend events that constitute this one.</p>
94
         *
95
         * @return an array with all legend events that constitute this one
96
         */
97
        public LegendEvent[] getLegendEvents() {
98
                ArrayList ret = new ArrayList();
99

    
100
                for (Iterator iter = events.iterator(); iter.hasNext();) {
101
                        FMapEvent event = (FMapEvent) iter.next();
102

    
103
                        if (event instanceof LegendEvent) {
104
                                ret.add(event);
105
                        }
106
                }
107

    
108
                return (LegendEvent[]) ret.toArray(new LegendEvent[0]);
109
        }
110

    
111
        /**
112
         * <p>Returns all layer collection events that constitute this one.</p>
113
         *
114
         * @return an array with all layer collection events that constitute this one
115
         */
116
        public LayerCollectionEvent[] getLayerCollectionEvents() {
117
                ArrayList ret = new ArrayList();
118

    
119
                for (Iterator iter = events.iterator(); iter.hasNext();) {
120
                        FMapEvent event = (FMapEvent) iter.next();
121

    
122
                        if (event instanceof LayerCollectionEvent) {
123
                                ret.add(event);
124
                        }
125
                }
126

    
127
                return (LayerCollectionEvent[]) ret.toArray(new LayerCollectionEvent[0]);
128
        }
129

    
130
        /**
131
         * <p>Returns all vector layer selection events that constitute this one.</p>
132
         *
133
         * @return an array with all vector layer selection events that constitute this one
134
         */
135
        public SelectionEvent[] getSelectionEvents() {
136
                ArrayList ret = new ArrayList();
137

    
138
                for (Iterator iter = events.iterator(); iter.hasNext();) {
139
                        FMapEvent event = (FMapEvent) iter.next();
140

    
141
                        if (event instanceof SelectionEvent) {
142
                                ret.add(event);
143
                        }
144
                }
145

    
146
                return (SelectionEvent[]) ret.toArray(new SelectionEvent[0]);
147
        }
148

    
149
        /**
150
         * <p>Returns all extent events that constitute this one.</p>
151
         *
152
         * @return an array with all extent events that constitute this one
153
         */
154
        public ExtentEvent[] getExtentEvents() {
155
                ArrayList ret = new ArrayList();
156

    
157
                for (Iterator iter = events.iterator(); iter.hasNext();) {
158
                        FMapEvent event = (FMapEvent) iter.next();
159

    
160
                        if (event instanceof ExtentEvent) {
161
                                ret.add(event);
162
                        }
163
                }
164

    
165
                return (ExtentEvent[]) ret.toArray(new ExtentEvent[0]);
166
        }
167

    
168
        /**
169
         * <p>Returns all layer events that constitute this one.</p>
170
         *
171
         * @return an array with all layer events that constitute this one
172
         */
173
        public LayerEvent[] getLayerEvents() {
174
                ArrayList ret = new ArrayList();
175

    
176
                for (Iterator iter = events.iterator(); iter.hasNext();) {
177
                        FMapEvent event = (FMapEvent) iter.next();
178

    
179
                        if (event instanceof LayerEvent) {
180
                                ret.add(event);
181
                        }
182
                }
183

    
184
                return (LayerEvent[]) ret.toArray(new LayerEvent[0]);
185
        }
186

    
187
        /**
188
         * <p>Returns all color events that constitute this one.</p>
189
         *
190
         * @return an array with all color events that constitute this one
191
         */
192
        public ColorEvent[] getColorEvents() {
193
                ArrayList ret = new ArrayList();
194

    
195
                for (Iterator iter = events.iterator(); iter.hasNext();) {
196
                        FMapEvent event = (FMapEvent) iter.next();
197

    
198
                        if (event instanceof ColorEvent) {
199
                                ret.add(event);
200
                        }
201
                }
202

    
203
                return (ColorEvent[]) ret.toArray(new ColorEvent[0]);
204
        }
205

    
206
        /**
207
         * <p>Returns all projection events that constitute this one.</p>
208
         *
209
         * @return an array with all projection events that constitute this one
210
         */
211
        public ProjectionEvent[] getProjectionEvents() {
212
                ArrayList ret = new ArrayList();
213

    
214
                for (Iterator iter = events.iterator(); iter.hasNext();) {
215
                        FMapEvent event = (FMapEvent) iter.next();
216

    
217
                        if (event instanceof ProjectionEvent) {
218
                                ret.add(event);
219
                        }
220
                }
221

    
222
                return (ProjectionEvent[]) ret.toArray(new ProjectionEvent[0]);
223
        }
224
}