svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_mapcontext / src / org / gvsig / fmap / mapcontext / layers / LayerPositionEvent.java @ 35183
History | View | Annotate | Download (3.94 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 | |||
44 | /**
|
||
45 | * <p>Event produced when a layer has been or is being moved from a collection of layers.</p>
|
||
46 | *
|
||
47 | * @author Vicente Caballero Navarro
|
||
48 | */
|
||
49 | public class LayerPositionEvent extends LayerCollectionEvent { |
||
50 | /**
|
||
51 | * <p>If this event is a <i>LAYER_MOVED</i> type, stores the previous index of the affected layer in the layer
|
||
52 | * collection; otherwise its value will be the same as the <code>newPos</code> one.</p>
|
||
53 | */
|
||
54 | private int oldPos; |
||
55 | |||
56 | /**
|
||
57 | * <p>The new index in the layer collection of the layer affected.</p>
|
||
58 | */
|
||
59 | private int newPos; |
||
60 | |||
61 | /**
|
||
62 | * <p>Identifies this event as a action on a layer that is being moved.</p>
|
||
63 | */
|
||
64 | private final static int LAYER_MOVING = 4; |
||
65 | |||
66 | /**
|
||
67 | * <p>Identifies this event as a action on a layer that has been moved.</p>
|
||
68 | */
|
||
69 | private final static int LAYER_MOVED = 1; |
||
70 | |||
71 | /**
|
||
72 | * <p>Creates a new layer position event notifying a "layer moved" action.</p>
|
||
73 | *
|
||
74 | * @param lyr layer affected by the action
|
||
75 | * @param oldp previous index of the affected layer in the layer collection
|
||
76 | * @param newp new index of the affected layer in the layer collection
|
||
77 | *
|
||
78 | * @return a new layer position event
|
||
79 | */
|
||
80 | public static LayerPositionEvent createLayerMovedEvent(FLayer lyr, int oldp, int newp){ |
||
81 | return new LayerPositionEvent(lyr, oldp, newp, LAYER_MOVED); |
||
82 | } |
||
83 | |||
84 | /**
|
||
85 | * <p>Creates a new layer position event notifying a "layer moving" action.</p>
|
||
86 | *
|
||
87 | * @param lyr layer affected by the action
|
||
88 | * @param oldp previous index of the affected layer in the layer collection
|
||
89 | * @param newp new index of the affected layer in the layer collection
|
||
90 | *
|
||
91 | * @return a new layer position event
|
||
92 | */
|
||
93 | public static LayerPositionEvent createLayerMovingEvent(FLayer lyr, int oldp, int newp){ |
||
94 | return new LayerPositionEvent(lyr, oldp, newp, LAYER_MOVING); |
||
95 | } |
||
96 | |||
97 | /**
|
||
98 | * <p>Creates a new layer position event of the specified type.</p>
|
||
99 | *
|
||
100 | * @param lyr layer affected by the action
|
||
101 | * @param oldp previous index of the affected layer in the layer collection
|
||
102 | * @param newp new index of the affected layer in the layer collection
|
||
103 | * @param eventType type of layer collection event
|
||
104 | *
|
||
105 | * @return a new layer position event
|
||
106 | */
|
||
107 | private LayerPositionEvent(FLayer lyr, int oldp, int newp, int eventType) { |
||
108 | super(lyr, eventType);
|
||
109 | oldPos = oldp; |
||
110 | newPos = newp; |
||
111 | } |
||
112 | |||
113 | /**
|
||
114 | * <p>Gets the previous index of the affected layer in the layer collection.</p>
|
||
115 | *
|
||
116 | * @return the previous index
|
||
117 | */
|
||
118 | public int getOldPos() { |
||
119 | return oldPos;
|
||
120 | } |
||
121 | |||
122 | /**
|
||
123 | * <p>Gets the new index of the affected layer in the layer collection.</p>
|
||
124 | *
|
||
125 | * @return the new index
|
||
126 | */
|
||
127 | public int getNewPos() { |
||
128 | return newPos;
|
||
129 | } |
||
130 | } |