root / branches / v2_0_0_prep / libraries / libFMap_mapcontext / src / org / gvsig / fmap / mapcontext / layers / LayerCollectionEvent.java @ 38605
History | View | Annotate | Download (5.4 KB)
1 | 21200 | vcaballero | /* 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 org.gvsig.fmap.mapcontext.layers; |
||
42 | |||
43 | import org.gvsig.fmap.mapcontext.events.FMapEvent; |
||
44 | |||
45 | |||
46 | /**
|
||
47 | * <p>Event produced when a layer is been added or removed, or has been added or
|
||
48 | * removed, or its visibility or activation state has changed from a collection of layers.</p>
|
||
49 | *
|
||
50 | * @author Vicente Caballero Navarro
|
||
51 | */
|
||
52 | public class LayerCollectionEvent extends FMapEvent { |
||
53 | /**
|
||
54 | * <p>Identifies this event as a action on a layer that has been added.</p>
|
||
55 | */
|
||
56 | private final static int LAYER_ADDED = 0; |
||
57 | |||
58 | /**
|
||
59 | * <p>Identifies this event as a action on a layer that has been removed.</p>
|
||
60 | */
|
||
61 | private final static int LAYER_REMOVED = 2; |
||
62 | |||
63 | /**
|
||
64 | * <p>Identifies this event as a action on a layer that is being added.</p>
|
||
65 | */
|
||
66 | private final static int LAYER_ADDING = 3; |
||
67 | |||
68 | /**
|
||
69 | * <p>Identifies this event as a action on a layer that is being removed.</p>
|
||
70 | */
|
||
71 | private final static int LAYER_REMOVING = 5; |
||
72 | |||
73 | /**
|
||
74 | * <p>Identifies this event as a action of change of the activation status of a layer.</p>
|
||
75 | */
|
||
76 | private final static int LAYER_ACTIVATION_CHANGED = 6; |
||
77 | |||
78 | /**
|
||
79 | * <p>Identifies this event as a action of change of the visibility status of a layer.</p>
|
||
80 | */
|
||
81 | private final static int LAYER_VISIBILITY_CHANGED = 7; |
||
82 | |||
83 | /**
|
||
84 | * <p>Reference to the collection of layers.</p>
|
||
85 | */
|
||
86 | private FLayers layers;
|
||
87 | |||
88 | /**
|
||
89 | * <p>Reference to the layer which this layer notifies.</p>
|
||
90 | */
|
||
91 | private FLayer affected;
|
||
92 | |||
93 | /**
|
||
94 | * <p>Creates a new layer collection event notifying a "layer added" action.</p>
|
||
95 | *
|
||
96 | * @param lyr layer affected by the action
|
||
97 | *
|
||
98 | * @return a new layer collection event
|
||
99 | */
|
||
100 | public static LayerCollectionEvent createLayerAddedEvent(FLayer lyr){ |
||
101 | return new LayerCollectionEvent(lyr, LAYER_ADDED); |
||
102 | } |
||
103 | |||
104 | /**
|
||
105 | * <p>Creates a new layer collection event notifying a "layer removed" action.</p>
|
||
106 | *
|
||
107 | * @param lyr layer affected by the action
|
||
108 | *
|
||
109 | * @return a new layer collection event
|
||
110 | */
|
||
111 | public static LayerCollectionEvent createLayerRemovedEvent(FLayer lyr){ |
||
112 | return new LayerCollectionEvent(lyr, LAYER_REMOVED); |
||
113 | } |
||
114 | |||
115 | /**
|
||
116 | * <p>Creates a new layer collection event notifying a "layer adding" action.</p>
|
||
117 | *
|
||
118 | * @param lyr layer affected by the action
|
||
119 | *
|
||
120 | * @return a new layer collection event
|
||
121 | */
|
||
122 | public static LayerCollectionEvent createLayerAddingEvent(FLayer lyr){ |
||
123 | return new LayerCollectionEvent(lyr, LAYER_ADDING); |
||
124 | } |
||
125 | |||
126 | /**
|
||
127 | * <p>Creates a new layer collection event notifying a "layer removing" action.</p>
|
||
128 | *
|
||
129 | * @param lyr layer affected by the action
|
||
130 | *
|
||
131 | * @return a new layer collection event
|
||
132 | */
|
||
133 | public static LayerCollectionEvent createLayerRemovingEvent(FLayer lyr){ |
||
134 | return new LayerCollectionEvent(lyr, LAYER_REMOVING); |
||
135 | } |
||
136 | |||
137 | /**
|
||
138 | * <p>Creates a new layer collection event notifying a "layer activation changed" action.</p>
|
||
139 | *
|
||
140 | * @param lyr layer affected by the action
|
||
141 | *
|
||
142 | * @return a new layer collection event
|
||
143 | */
|
||
144 | public static LayerCollectionEvent createLayerActivationEvent(FLayer lyr){ |
||
145 | return new LayerCollectionEvent(lyr, LAYER_ACTIVATION_CHANGED); |
||
146 | } |
||
147 | |||
148 | /**
|
||
149 | * <p>Creates a new layer collection event notifying a "layer visibility changed" action.</p>
|
||
150 | *
|
||
151 | * @param lyr layer affected by the action
|
||
152 | *
|
||
153 | * @return a new layer collection event
|
||
154 | */
|
||
155 | public static LayerCollectionEvent createLayerVisibilityEvent(FLayer lyr){ |
||
156 | return new LayerCollectionEvent(lyr, LAYER_VISIBILITY_CHANGED); |
||
157 | } |
||
158 | |||
159 | /**
|
||
160 | * <p>Creates a new layer collection event of the specified type.</p>
|
||
161 | *
|
||
162 | * @param lyr layer affected by the action
|
||
163 | * @param eventType type of layer collection event
|
||
164 | *
|
||
165 | * @return a new layer collection event
|
||
166 | */
|
||
167 | protected LayerCollectionEvent(FLayer lyr, int eventType) { |
||
168 | layers = lyr.getParentLayer(); |
||
169 | affected = lyr; |
||
170 | setEventType(eventType); |
||
171 | } |
||
172 | |||
173 | /**
|
||
174 | * <p>Gets the collection of layers which the layer affected belongs.</p>
|
||
175 | *
|
||
176 | * @return the collection of layers affected
|
||
177 | */
|
||
178 | public FLayers getLayers() {
|
||
179 | return layers;
|
||
180 | } |
||
181 | |||
182 | /**
|
||
183 | * <p>Gets the layer that this event references.</p>
|
||
184 | *
|
||
185 | * @return the layer that this event references
|
||
186 | */
|
||
187 | public FLayer getAffectedLayer() {
|
||
188 | return affected;
|
||
189 | } |
||
190 | } |