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 @ 44461

History | View | Annotate | Download (5.12 KB)

1 40559 jjdelcerro
/**
2
 * gvSIG. Desktop Geographic Information System.
3 40435 jjdelcerro
 *
4 40559 jjdelcerro
 * Copyright (C) 2007-2013 gvSIG Association.
5 40435 jjdelcerro
 *
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 40559 jjdelcerro
 * as published by the Free Software Foundation; either version 3
9 40435 jjdelcerro
 * 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 40559 jjdelcerro
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20 40435 jjdelcerro
 *
21 40559 jjdelcerro
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23 40435 jjdelcerro
 */
24
package org.gvsig.fmap.mapcontext.layers;
25
26 43253 fdiaz
import org.gvsig.fmap.mapcontext.events.FMapEventBase;
27 40435 jjdelcerro
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 43253 fdiaz
public class LayerCollectionEvent extends FMapEventBase {
36 40435 jjdelcerro
        /**
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 43253 fdiaz
56 40435 jjdelcerro
        /**
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 43253 fdiaz
61 40435 jjdelcerro
        /**
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 43253 fdiaz
         *
79 40435 jjdelcerro
         * @param lyr layer affected by the action
80 43253 fdiaz
         *
81 40435 jjdelcerro
         * @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 43253 fdiaz
         *
90 40435 jjdelcerro
         * @param lyr layer affected by the action
91 43253 fdiaz
         *
92 40435 jjdelcerro
         * @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 43253 fdiaz
         *
101 40435 jjdelcerro
         * @param lyr layer affected by the action
102 43253 fdiaz
         *
103 40435 jjdelcerro
         * @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 43253 fdiaz
         *
112 40435 jjdelcerro
         * @param lyr layer affected by the action
113 43253 fdiaz
         *
114 40435 jjdelcerro
         * @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 43253 fdiaz
         *
123 40435 jjdelcerro
         * @param lyr layer affected by the action
124 43253 fdiaz
         *
125 40435 jjdelcerro
         * @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 43253 fdiaz
         *
134 40435 jjdelcerro
         * @param lyr layer affected by the action
135 43253 fdiaz
         *
136 40435 jjdelcerro
         * @return a new layer collection event
137
         */
138
        public static LayerCollectionEvent createLayerVisibilityEvent(FLayer lyr){
139
                return new LayerCollectionEvent(lyr, LAYER_VISIBILITY_CHANGED);
140
        }
141 43253 fdiaz
142 40435 jjdelcerro
        /**
143
         * <p>Creates a new layer collection event of the specified type.</p>
144 43253 fdiaz
         *
145 40435 jjdelcerro
         * @param lyr layer affected by the action
146
         * @param eventType type of layer collection event
147 43253 fdiaz
         *
148 40435 jjdelcerro
         * @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
}