Statistics
| Revision:

svn-gvsig-desktop / branches / v10 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / LayerPositionEvent.java @ 20100

History | View | Annotate | Download (3.81 KB)

1
/* 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 com.iver.cit.gvsig.fmap.layers;
42

    
43
/**
44
 * <p>Event produced when a layer has been or is being moved from a collection of layers.</p>
45
 *
46
 * @author Vicente Caballero Navarro
47
 */
48
public class LayerPositionEvent extends LayerCollectionEvent {
49
        /**
50
         * <p>If this event is a <i>LAYER_MOVED</i> type, stores the previous index of the affected layer in the layer
51
         *  collection; otherwise its value will be the same as the <code>newPos</code> one.</p>
52
         */
53
        private int oldPos;
54

    
55
        /**
56
         * <p>The new index in the layer collection of the layer affected.</p>
57
         */
58
        private int newPos;
59

    
60
        /**
61
         * <p>Identifies this event as a action on a layer that is being moved.</p>
62
         */
63
        private final static int LAYER_MOVING = 4;
64

    
65
        /**
66
         * <p>Identifies this event as a action on a layer that has been moved.</p>
67
         */
68
        private final static int LAYER_MOVED = 1;
69

    
70
        /**
71
         * <p>Creates a new layer position event notifying a "layer moved" action.</p>
72
         * 
73
         * @param lyr layer affected by the action
74
         * @param oldp previous index of the affected layer in the layer collection
75
         * @param newp new index of the affected layer in the layer collection
76
         * 
77
         * @return a new layer position event
78
         */
79
        public static LayerPositionEvent createLayerMovedEvent(FLayer lyr, int oldp, int newp){
80
                return new LayerPositionEvent(lyr, oldp, newp, LAYER_MOVED);
81
        }
82

    
83
        /**
84
         * <p>Creates a new layer position event notifying a "layer moving" action.</p>
85
         * 
86
         * @param lyr layer affected by the action
87
         * @param oldp previous index of the affected layer in the layer collection
88
         * @param newp new index of the affected layer in the layer collection
89
         * 
90
         * @return a new layer position event
91
         */
92
        public static LayerPositionEvent createLayerMovingEvent(FLayer lyr, int oldp, int newp){
93
                return new LayerPositionEvent(lyr, oldp, newp, LAYER_MOVING);
94
        }
95

    
96
        /**
97
         * <p>Creates a new layer position event of the specified type.</p>
98
         * 
99
         * @param lyr layer affected by the action
100
         * @param oldp previous index of the affected layer in the layer collection
101
         * @param newp new index of the affected layer in the layer collection
102
         * @param eventType type of layer collection event
103
         * 
104
         * @return a new layer position event
105
         */
106
        private LayerPositionEvent(FLayer lyr, int oldp, int newp, int eventType) {
107
                super(lyr, eventType);
108
                oldPos = oldp;
109
                newPos = newp;
110
        }
111

    
112
        /**
113
         * <p>Gets the previous index of the affected layer in the layer collection.</p>
114
         *
115
         * @return the previous index
116
         */
117
        public int getOldPos() {
118
                return oldPos;
119
        }
120

    
121
        /**
122
         * <p>Gets the new index of the affected layer in the layer collection.</p>
123
         *
124
         * @return the new index
125
         */
126
        public int getNewPos() {
127
                return newPos;
128
        }
129
}