Revision 20098 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/LayerPositionEvent.java
LayerPositionEvent.java | ||
---|---|---|
41 | 41 |
package com.iver.cit.gvsig.fmap.layers; |
42 | 42 |
|
43 | 43 |
/** |
44 |
* <p>The class <code>LayerPositionEvent</code> stores all necessary information |
|
45 |
* in relation with an event associated to a position event of the layer in the TOC. |
|
46 |
* |
|
44 |
* <p>Event produced when a layer has been or is being moved from a collection of layers.</p> |
|
45 |
* |
|
47 | 46 |
* @author Vicente Caballero Navarro |
48 | 47 |
*/ |
49 | 48 |
public class LayerPositionEvent extends LayerCollectionEvent { |
50 | 49 |
/** |
51 |
* Specifies the index that the layer had in case that the event is a |
|
52 |
* layerMoved. In case that the event is not a layerMoved, it will have |
|
53 |
* the same value as the index attribute. |
|
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> |
|
54 | 52 |
*/ |
55 | 53 |
private int oldPos; |
56 | 54 |
|
57 |
/** Indice de la capa en la coleccion */ |
|
55 |
/** |
|
56 |
* <p>The new index in the layer collection of the layer affected.</p> |
|
57 |
*/ |
|
58 | 58 |
private int newPos; |
59 | 59 |
|
60 |
/** |
|
61 |
* <p>Identifies this event as a action on a layer that is being moved.</p> |
|
62 |
*/ |
|
60 | 63 |
private final static int LAYER_MOVING = 4; |
61 | 64 |
|
65 |
/** |
|
66 |
* <p>Identifies this event as a action on a layer that has been moved.</p> |
|
67 |
*/ |
|
62 | 68 |
private final static int LAYER_MOVED = 1; |
63 | 69 |
|
64 | 70 |
/** |
65 |
* Creates a layer moved event when the layer has been moved. |
|
66 |
* @param lyr specific layer |
|
67 |
* @param oldp old position |
|
68 |
* @param newp new position |
|
69 |
* @return |
|
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 |
|
70 | 78 |
*/ |
71 | 79 |
public static LayerPositionEvent createLayerMovedEvent(FLayer lyr, int oldp, int newp){ |
72 | 80 |
return new LayerPositionEvent(lyr, oldp, newp, LAYER_MOVED); |
73 | 81 |
} |
82 |
|
|
74 | 83 |
/** |
75 |
* Creates a layer moved event when the layer is being moved. |
|
76 |
* @param lyr specific layer |
|
77 |
* @param oldp old position |
|
78 |
* @param newp new position |
|
79 |
* @return |
|
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 |
|
80 | 91 |
*/ |
81 | 92 |
public static LayerPositionEvent createLayerMovingEvent(FLayer lyr, int oldp, int newp){ |
82 | 93 |
return new LayerPositionEvent(lyr, oldp, newp, LAYER_MOVING); |
83 | 94 |
} |
84 | 95 |
|
85 | 96 |
/** |
86 |
* Constructor method.Creates a new LayerPositionEvent. |
|
87 |
* |
|
88 |
* @param lyr |
|
89 |
* @param oldp Old position. |
|
90 |
* @param newp New position. |
|
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 |
|
91 | 105 |
*/ |
92 | 106 |
private LayerPositionEvent(FLayer lyr, int oldp, int newp, int eventType) { |
93 | 107 |
super(lyr, eventType); |
... | ... | |
96 | 110 |
} |
97 | 111 |
|
98 | 112 |
/** |
99 |
* Returns the start position.
|
|
113 |
* <p>Gets the previous index of the affected layer in the layer collection.</p>
|
|
100 | 114 |
* |
101 |
* @return Start position.
|
|
115 |
* @return the previous index
|
|
102 | 116 |
*/ |
103 | 117 |
public int getOldPos() { |
104 | 118 |
return oldPos; |
105 | 119 |
} |
106 | 120 |
|
107 | 121 |
/** |
108 |
* Returns the destination position.
|
|
122 |
* <p>Gets the new index of the affected layer in the layer collection.</p>
|
|
109 | 123 |
* |
110 |
* @return destination position.
|
|
124 |
* @return the new index
|
|
111 | 125 |
*/ |
112 | 126 |
public int getNewPos() { |
113 | 127 |
return newPos; |
Also available in: Unified diff