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

History | View | Annotate | Download (5.13 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;
25

    
26
import org.gvsig.fmap.mapcontext.events.FMapEvent;
27

    
28

    
29
/**
30
 * <p>Event produced when a layer is been added or removed, or has been added or
31
 *  removed, or its visibility or activation state has changed from a collection of layers.</p>
32
 *
33
 * @author Vicente Caballero Navarro
34
 */
35
public class LayerCollectionEvent extends FMapEvent {
36
        /**
37
         * <p>Identifies this event as a action on a layer that has been added.</p>
38
         */
39
    public final static int LAYER_ADDED = 0;
40

    
41
        /**
42
         * <p>Identifies this event as a action on a layer that has been removed.</p>
43
         */
44
        public final static int LAYER_REMOVED = 2;
45

    
46
        /**
47
         * <p>Identifies this event as a action on a layer that is being added.</p>
48
         */
49
        public final static int LAYER_ADDING = 3;
50

    
51
        /**
52
         * <p>Identifies this event as a action on a layer that is being removed.</p>
53
         */
54
        public final static int LAYER_REMOVING = 5;
55
        
56
        /**
57
         * <p>Identifies this event as a action of change of the activation status of a layer.</p>
58
         */
59
        public final static int LAYER_ACTIVATION_CHANGED = 6;
60
        
61
        /**
62
         * <p>Identifies this event as a action of change of the visibility status of a layer.</p>
63
         */
64
        public final static int LAYER_VISIBILITY_CHANGED = 7;
65

    
66
        /**
67
         * <p>Reference to the collection of layers.</p>
68
         */
69
        private FLayers layers;
70

    
71
        /**
72
         * <p>Reference to the layer which this layer notifies.</p>
73
         */
74
        private FLayer affected;
75

    
76
        /**
77
         * <p>Creates a new layer collection event notifying a "layer added" action.</p>
78
         * 
79
         * @param lyr layer affected by the action
80
         * 
81
         * @return a new layer collection event
82
         */
83
        public static LayerCollectionEvent createLayerAddedEvent(FLayer lyr){
84
                return new LayerCollectionEvent(lyr, LAYER_ADDED);
85
        }
86

    
87
        /**
88
         * <p>Creates a new layer collection event notifying a "layer removed" action.</p>
89
         * 
90
         * @param lyr layer affected by the action
91
         * 
92
         * @return a new layer collection event
93
         */
94
        public static LayerCollectionEvent createLayerRemovedEvent(FLayer lyr){
95
                return new LayerCollectionEvent(lyr, LAYER_REMOVED);
96
        }
97

    
98
        /**
99
         * <p>Creates a new layer collection event notifying a "layer adding" action.</p>
100
         * 
101
         * @param lyr layer affected by the action
102
         * 
103
         * @return a new layer collection event
104
         */
105
        public static LayerCollectionEvent createLayerAddingEvent(FLayer lyr){
106
                return new LayerCollectionEvent(lyr, LAYER_ADDING);
107
        }
108

    
109
        /**
110
         * <p>Creates a new layer collection event notifying a "layer removing" action.</p>
111
         * 
112
         * @param lyr layer affected by the action
113
         * 
114
         * @return a new layer collection event
115
         */
116
        public static LayerCollectionEvent createLayerRemovingEvent(FLayer lyr){
117
                return new LayerCollectionEvent(lyr, LAYER_REMOVING);
118
        }
119

    
120
        /**
121
         * <p>Creates a new layer collection event notifying a "layer activation changed" action.</p>
122
         * 
123
         * @param lyr layer affected by the action
124
         * 
125
         * @return a new layer collection event
126
         */
127
        public static LayerCollectionEvent createLayerActivationEvent(FLayer lyr){
128
                return new LayerCollectionEvent(lyr, LAYER_ACTIVATION_CHANGED);
129
        }
130

    
131
        /**
132
         * <p>Creates a new layer collection event notifying a "layer visibility changed" action.</p>
133
         * 
134
         * @param lyr layer affected by the action
135
         * 
136
         * @return a new layer collection event
137
         */
138
        public static LayerCollectionEvent createLayerVisibilityEvent(FLayer lyr){
139
                return new LayerCollectionEvent(lyr, LAYER_VISIBILITY_CHANGED);
140
        }
141
        
142
        /**
143
         * <p>Creates a new layer collection event of the specified type.</p>
144
         * 
145
         * @param lyr layer affected by the action
146
         * @param eventType type of layer collection event
147
         * 
148
         * @return a new layer collection event
149
         */
150
        protected LayerCollectionEvent(FLayer lyr, int eventType) {
151
                layers = lyr.getParentLayer();
152
                affected = lyr;
153
                setEventType(eventType);
154
        }
155

    
156
        /**
157
         * <p>Gets the collection of layers which the layer affected belongs.</p>
158
         *
159
         * @return the collection of layers affected
160
         */
161
        public FLayers getLayers() {
162
                return layers;
163
        }
164

    
165
        /**
166
         * <p>Gets the layer that this event references.</p>
167
         *
168
         * @return the layer that this event references
169
         */
170
        public FLayer getAffectedLayer() {
171
                return affected;
172
        }
173
}