gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.fmap / src / main / java / org / gvsig / raster / util / LayerVisualStatusList.java @ 723
History | View | Annotate | Download (4.2 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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 2
|
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 |
*/
|
22 |
package org.gvsig.raster.util; |
23 |
|
24 |
import java.util.ArrayList; |
25 |
|
26 |
import org.gvsig.fmap.dal.coverage.grid.GridTransparency; |
27 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilter; |
28 |
import org.gvsig.fmap.dal.coverage.grid.render.Render; |
29 |
import org.gvsig.fmap.dal.coverage.store.props.Transparency; |
30 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
31 |
import org.gvsig.raster.fmap.layers.IRasterLayerActions; |
32 |
|
33 |
/**
|
34 |
* Clase para almacenar estados visuales de una capa raster. Estos estados deben ser locales
|
35 |
* a cada funcionalidad para que no interfieran entre ellos. Luego es posible tener una lista de
|
36 |
* estados globales para restaurar el que nos convenga.
|
37 |
* 07/10/2008
|
38 |
* @author Nacho Brodin nachobrodin@gmail.com
|
39 |
*/
|
40 |
public class LayerVisualStatusList { |
41 |
private ArrayList<LayerVisualStatus> list = new ArrayList<LayerVisualStatus>(); |
42 |
|
43 |
/**
|
44 |
* Clase que contiene el estado visual de una capa raster.
|
45 |
* 07/10/2008
|
46 |
* @author Nacho Brodin nachobrodin@gmail.com
|
47 |
*/
|
48 |
public class LayerVisualStatus { |
49 |
private ArrayList<RasterFilter> filterStatus = null; |
50 |
private Transparency transparency = null; |
51 |
|
52 |
/**
|
53 |
* Obtiene el estado de la lista de filtros
|
54 |
* @return Array con el estado de la lista de filtros
|
55 |
*/
|
56 |
public ArrayList<RasterFilter> getFilterStatus() { |
57 |
return filterStatus;
|
58 |
} |
59 |
|
60 |
/**
|
61 |
* Asigna el estado de la lista de filtros
|
62 |
* @return Array con el estado de la lista de filtros
|
63 |
*/
|
64 |
public void setFilterStatus(ArrayList<RasterFilter> filterStatus) { |
65 |
this.filterStatus = filterStatus;
|
66 |
} |
67 |
|
68 |
/**
|
69 |
* Obtiene el estado de la transparencia
|
70 |
* @return Transparency
|
71 |
*/
|
72 |
public Transparency getTransparency() { |
73 |
return transparency;
|
74 |
} |
75 |
|
76 |
/**
|
77 |
* Asigna el estado de la transparencia
|
78 |
* @param Transparency
|
79 |
*/
|
80 |
public void setTransparency(Transparency transparency) { |
81 |
this.transparency = transparency;
|
82 |
} |
83 |
} |
84 |
|
85 |
/**
|
86 |
* Limpia la pila de elementos
|
87 |
*/
|
88 |
public void clear() { |
89 |
list.clear(); |
90 |
} |
91 |
|
92 |
/**
|
93 |
* Salva un estado al final de la lista
|
94 |
* @param status
|
95 |
*/
|
96 |
public void add(LayerVisualStatus status) { |
97 |
list.add(status); |
98 |
} |
99 |
|
100 |
/**
|
101 |
* Recupera el ?ltimo estado introducido en la lista
|
102 |
* @return StatusLayer
|
103 |
*/
|
104 |
public LayerVisualStatus getLast() {
|
105 |
return (LayerVisualStatus)list.get(list.size() - 1); |
106 |
} |
107 |
|
108 |
/**
|
109 |
* Recupera el estado de la posici?n i
|
110 |
* @return StatusLayer
|
111 |
*/
|
112 |
public LayerVisualStatus get(int i) { |
113 |
return (LayerVisualStatus)list.get(i);
|
114 |
} |
115 |
|
116 |
|
117 |
/**
|
118 |
* Saca de la lista el ?ltimo estado y lo asigna a la capa indicada.
|
119 |
* @param lyr Capa raster
|
120 |
*/
|
121 |
public void restoreVisualStatus(FLyrRaster lyr) { |
122 |
Render rendering = lyr.getRender(); |
123 |
LayerVisualStatus status = getLast(); |
124 |
if(status != null) { |
125 |
if(rendering.getFilterList() != null) |
126 |
rendering.getFilterList().setStatus(status.filterStatus); |
127 |
lyr.getRender().setLastTransparency(status.transparency); |
128 |
if(((IRasterLayerActions)lyr).isActionEnabled(IRasterLayerActions.REMOTE_ACTIONS))
|
129 |
lyr.getRender().getFilterList().setStatus(status.filterStatus); |
130 |
} |
131 |
} |
132 |
|
133 |
/**
|
134 |
* Obtiene de la capa su estado de visualizaci?n y lo salva en la lista
|
135 |
* @param lyr Capa raster
|
136 |
*/
|
137 |
public void getVisualStatus(FLyrRaster lyr) { |
138 |
LayerVisualStatus status = new LayerVisualStatus();
|
139 |
status.transparency = lyr.getRender().getLastTransparency(); |
140 |
status.filterStatus = lyr.getRender().getFilterList().getStatusCloned(); |
141 |
add(status); |
142 |
} |
143 |
} |