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 / events / AtomicEvent.java @ 40559

History | View | Annotate | Download (5.83 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.events;
25

    
26
import java.util.ArrayList;
27
import java.util.Iterator;
28

    
29
import org.gvsig.fmap.mapcontext.MapContext;
30
import org.gvsig.fmap.mapcontext.layers.LayerCollectionEvent;
31
import org.gvsig.fmap.mapcontext.layers.LayerEvent;
32
import org.gvsig.fmap.mapcontext.layers.SelectionEvent;
33
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendEvent;
34

    
35

    
36

    
37

    
38
/**
39
 * <p>An atomic event represents a group of events that will be attended without any interruption.</p>
40
 * 
41
 * <p>This kind of events are created by the buffer of events of the {@link MapContext MapContext}.</p>
42
 */
43
public class AtomicEvent extends FMapEvent {
44
        /**
45
         * <p>Events that constitute this one.</p>
46
         */
47
        private ArrayList events;
48

    
49
        /**
50
         * <p>Creates a new instance of this kind of event.</p>
51
         *
52
         * @param fmapEvents events that will constitute this one
53
         */
54
        public AtomicEvent(ArrayList fmapEvents) {
55
                this.events = (ArrayList) fmapEvents.clone();
56
        }
57

    
58
        /**
59
         * <p>Returns the event at the specified position in the internal list.</p>
60
         *
61
         * @param index index of event to return
62
         *
63
         * @return event at the specified position in this list
64
         */
65
        public FMapEvent getEvent(int index) {
66
                return (FMapEvent) events.get(index);
67
        }
68

    
69
        /**
70
         * <p>Returns the number of events that constitute this one.</p>
71
         *
72
         * @return number of events that constitute this one
73
         */
74
        public int getEventCount() {
75
                return events.size();
76
        }
77

    
78
        /**
79
         * <p>Returns all legend events that constitute this one.</p>
80
         *
81
         * @return an array with all legend events that constitute this one
82
         */
83
        public LegendEvent[] getLegendEvents() {
84
                ArrayList ret = new ArrayList();
85

    
86
                for (Iterator iter = events.iterator(); iter.hasNext();) {
87
                        FMapEvent event = (FMapEvent) iter.next();
88

    
89
                        if (event instanceof LegendEvent) {
90
                                ret.add(event);
91
                        }
92
                }
93

    
94
                return (LegendEvent[]) ret.toArray(new LegendEvent[0]);
95
        }
96

    
97
        /**
98
         * <p>Returns all layer collection events that constitute this one.</p>
99
         *
100
         * @return an array with all layer collection events that constitute this one
101
         */
102
        public LayerCollectionEvent[] getLayerCollectionEvents() {
103
                ArrayList ret = new ArrayList();
104

    
105
                for (Iterator iter = events.iterator(); iter.hasNext();) {
106
                        FMapEvent event = (FMapEvent) iter.next();
107

    
108
                        if (event instanceof LayerCollectionEvent) {
109
                                ret.add(event);
110
                        }
111
                }
112

    
113
                return (LayerCollectionEvent[]) ret.toArray(new LayerCollectionEvent[0]);
114
        }
115

    
116
        /**
117
         * <p>Returns all vector layer selection events that constitute this one.</p>
118
         *
119
         * @return an array with all vector layer selection events that constitute this one
120
         */
121
        public SelectionEvent[] getSelectionEvents() {
122
                ArrayList ret = new ArrayList();
123

    
124
                for (Iterator iter = events.iterator(); iter.hasNext();) {
125
                        FMapEvent event = (FMapEvent) iter.next();
126

    
127
                        if (event instanceof SelectionEvent) {
128
                                ret.add(event);
129
                        }
130
                }
131

    
132
                return (SelectionEvent[]) ret.toArray(new SelectionEvent[0]);
133
        }
134

    
135
        /**
136
         * <p>Returns all extent events that constitute this one.</p>
137
         *
138
         * @return an array with all extent events that constitute this one
139
         */
140
        public ExtentEvent[] getExtentEvents() {
141
                ArrayList ret = new ArrayList();
142

    
143
                for (Iterator iter = events.iterator(); iter.hasNext();) {
144
                        FMapEvent event = (FMapEvent) iter.next();
145

    
146
                        if (event instanceof ExtentEvent) {
147
                                ret.add(event);
148
                        }
149
                }
150

    
151
                return (ExtentEvent[]) ret.toArray(new ExtentEvent[0]);
152
        }
153

    
154
        /**
155
         * <p>Returns all layer events that constitute this one.</p>
156
         *
157
         * @return an array with all layer events that constitute this one
158
         */
159
        public LayerEvent[] getLayerEvents() {
160
                ArrayList ret = new ArrayList();
161

    
162
                for (Iterator iter = events.iterator(); iter.hasNext();) {
163
                        FMapEvent event = (FMapEvent) iter.next();
164

    
165
                        if (event instanceof LayerEvent) {
166
                                ret.add(event);
167
                        }
168
                }
169

    
170
                return (LayerEvent[]) ret.toArray(new LayerEvent[0]);
171
        }
172

    
173
        /**
174
         * <p>Returns all color events that constitute this one.</p>
175
         *
176
         * @return an array with all color events that constitute this one
177
         */
178
        public ColorEvent[] getColorEvents() {
179
                ArrayList ret = new ArrayList();
180

    
181
                for (Iterator iter = events.iterator(); iter.hasNext();) {
182
                        FMapEvent event = (FMapEvent) iter.next();
183

    
184
                        if (event instanceof ColorEvent) {
185
                                ret.add(event);
186
                        }
187
                }
188

    
189
                return (ColorEvent[]) ret.toArray(new ColorEvent[0]);
190
        }
191

    
192
        /**
193
         * <p>Returns all projection events that constitute this one.</p>
194
         *
195
         * @return an array with all projection events that constitute this one
196
         */
197
        public ProjectionEvent[] getProjectionEvents() {
198
                ArrayList ret = new ArrayList();
199

    
200
                for (Iterator iter = events.iterator(); iter.hasNext();) {
201
                        FMapEvent event = (FMapEvent) iter.next();
202

    
203
                        if (event instanceof ProjectionEvent) {
204
                                ret.add(event);
205
                        }
206
                }
207

    
208
                return (ProjectionEvent[]) ret.toArray(new ProjectionEvent[0]);
209
        }
210
}