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

History | View | Annotate | Download (3.67 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

    
27
/**
28
 * <p>Event produced when a layer has been or is being moved from a collection of layers.</p>
29
 *
30
 * @author Vicente Caballero Navarro
31
 */
32
public class LayerPositionEvent extends LayerCollectionEvent {
33
        /**
34
         * <p>If this event is a <i>LAYER_MOVED</i> type, stores the previous index of the affected layer in the layer
35
         *  collection; otherwise its value will be the same as the <code>newPos</code> one.</p>
36
         */
37
        private int oldPos;
38

    
39
        /**
40
         * <p>The new index in the layer collection of the layer affected.</p>
41
         */
42
        private int newPos;
43

    
44
        /**
45
         * <p>Identifies this event as a action on a layer that is being moved.</p>
46
         */
47
        private final static int LAYER_MOVING = 4;
48

    
49
        /**
50
         * <p>Identifies this event as a action on a layer that has been moved.</p>
51
         */
52
        private final static int LAYER_MOVED = 1;
53

    
54
        /**
55
         * <p>Creates a new layer position event notifying a "layer moved" action.</p>
56
         * 
57
         * @param lyr layer affected by the action
58
         * @param oldp previous index of the affected layer in the layer collection
59
         * @param newp new index of the affected layer in the layer collection
60
         * 
61
         * @return a new layer position event
62
         */
63
        public static LayerPositionEvent createLayerMovedEvent(FLayer lyr, int oldp, int newp){
64
                return new LayerPositionEvent(lyr, oldp, newp, LAYER_MOVED);
65
        }
66

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

    
80
        /**
81
         * <p>Creates a new layer position event of the specified type.</p>
82
         * 
83
         * @param lyr layer affected by the action
84
         * @param oldp previous index of the affected layer in the layer collection
85
         * @param newp new index of the affected layer in the layer collection
86
         * @param eventType type of layer collection event
87
         * 
88
         * @return a new layer position event
89
         */
90
        private LayerPositionEvent(FLayer lyr, int oldp, int newp, int eventType) {
91
                super(lyr, eventType);
92
                oldPos = oldp;
93
                newPos = newp;
94
        }
95

    
96
        /**
97
         * <p>Gets the previous index of the affected layer in the layer collection.</p>
98
         *
99
         * @return the previous index
100
         */
101
        public int getOldPos() {
102
                return oldPos;
103
        }
104

    
105
        /**
106
         * <p>Gets the new index of the affected layer in the layer collection.</p>
107
         *
108
         * @return the new index
109
         */
110
        public int getNewPos() {
111
                return newPos;
112
        }
113
}