Revision 23813
trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/util/VisualStatusLayerStack.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2007 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 |
package org.gvsig.raster.util; |
|
20 |
|
|
21 |
import java.util.ArrayList; |
|
22 |
|
|
23 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
|
24 |
import org.gvsig.raster.grid.GridTransparency; |
|
25 |
import org.gvsig.raster.grid.render.Rendering; |
|
26 |
|
|
27 |
/** |
|
28 |
* Clase para almacenar estados visuales de una capa raster. Estos estados deben ser locales |
|
29 |
* a cada funcionalidad para que no interfieran entre ellos. Luego es posible tener una lista de |
|
30 |
* estados globales para restaurar el que nos convenga. |
|
31 |
* 07/10/2008 |
|
32 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
33 |
*/ |
|
34 |
public class VisualStatusLayerStack { |
|
35 |
private ArrayList list = new ArrayList(); |
|
36 |
|
|
37 |
/** |
|
38 |
* Clase que contiene el estado visual de una capa raster. |
|
39 |
* 07/10/2008 |
|
40 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
41 |
*/ |
|
42 |
public class StatusLayer { |
|
43 |
private ArrayList filterStatus = null; |
|
44 |
private GridTransparency transparency = null; |
|
45 |
|
|
46 |
/** |
|
47 |
* Obtiene el estado de la lista de filtros |
|
48 |
* @return Array con el estado de la lista de filtros |
|
49 |
*/ |
|
50 |
public ArrayList getFilterStatus() { |
|
51 |
return filterStatus; |
|
52 |
} |
|
53 |
|
|
54 |
/** |
|
55 |
* Asigna el estado de la lista de filtros |
|
56 |
* @return Array con el estado de la lista de filtros |
|
57 |
*/ |
|
58 |
public void setFilterStatus(ArrayList filterStatus) { |
|
59 |
this.filterStatus = filterStatus; |
|
60 |
} |
|
61 |
|
|
62 |
/** |
|
63 |
* Obtiene el estado de la transparencia |
|
64 |
* @return GridTransparency |
|
65 |
*/ |
|
66 |
public GridTransparency getTransparency() { |
|
67 |
return transparency; |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* Asigna el estado de la transparencia |
|
72 |
* @param GridTransparency |
|
73 |
*/ |
|
74 |
public void setTransparency(GridTransparency transparency) { |
|
75 |
this.transparency = transparency; |
|
76 |
} |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* Limpia la pila de elementos |
|
81 |
*/ |
|
82 |
public void clear() { |
|
83 |
list.clear(); |
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* Salva un estado al final de la lista |
|
88 |
* @param status |
|
89 |
*/ |
|
90 |
public void add(StatusLayer status) { |
|
91 |
list.add(status); |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* Recupera el ?ltimo estado introducido en la lista |
|
96 |
* @return StatusLayer |
|
97 |
*/ |
|
98 |
public StatusLayer getLast() { |
|
99 |
return (StatusLayer)list.get(list.size() - 1); |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* Recupera el estado de la posici?n i |
|
104 |
* @return StatusLayer |
|
105 |
*/ |
|
106 |
public StatusLayer get(int i) { |
|
107 |
return (StatusLayer)list.get(i); |
|
108 |
} |
|
109 |
|
|
110 |
|
|
111 |
/** |
|
112 |
* Saca de la lista el ?ltimo estado y lo asigna a la capa indicada. |
|
113 |
* @param lyr Capa raster |
|
114 |
*/ |
|
115 |
public void getLastToLayer(FLyrRasterSE lyr) { |
|
116 |
Rendering rendering = lyr.getRender(); |
|
117 |
StatusLayer status = getLast(); |
|
118 |
if(status != null) { |
|
119 |
if(rendering.getFilterList() != null) |
|
120 |
rendering.getFilterList().setStatus(status.filterStatus); |
|
121 |
lyr.getRender().setLastTransparency(status.transparency); |
|
122 |
} |
|
123 |
} |
|
124 |
|
|
125 |
/** |
|
126 |
* Obtiene de la capa su estado de visualizaci?n y lo salva en la lista |
|
127 |
* @param lyr Capa raster |
|
128 |
*/ |
|
129 |
public void setFromLayer(FLyrRasterSE lyr) { |
|
130 |
StatusLayer status = new StatusLayer(); |
|
131 |
status.transparency = lyr.getRenderTransparency(); |
|
132 |
status.filterStatus = lyr.getRenderFilterList().getStatusCloned(); |
|
133 |
add(status); |
|
134 |
} |
|
135 |
} |
Also available in: Unified diff