Revision 12154 trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/panels/TransparencyControl.java
TransparencyControl.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
import org.gvsig.raster.grid.GridTransparency; |
25 | 25 |
import org.gvsig.raster.util.TransparencyRange; |
26 |
import org.gvsig.rastertools.properties.dialog.RegistrableTabPanel; |
|
26 | 27 |
/** |
27 | 28 |
* Clase que hace de interfaz entre los objetos que contienen la informaci?n de |
28 | 29 |
* transparencia y el panel. |
... | ... | |
30 | 31 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
31 | 32 |
*/ |
32 | 33 |
public class TransparencyControl implements TranspByPixelEventListener { |
33 |
private GridTransparency transparency = null; |
|
34 |
private TransparencyPanel tPanel = null; |
|
34 |
private GridTransparency transparency = null;
|
|
35 |
private TransparencyPanel tPanel = null;
|
|
35 | 36 |
|
36 | 37 |
/** |
37 |
* Constructor
|
|
38 |
* Construye un TransparencyControl
|
|
38 | 39 |
* @param tp |
39 | 40 |
*/ |
40 | 41 |
public TransparencyControl(TransparencyPanel tp) { |
... | ... | |
42 | 43 |
tPanel.getPTranspByPixel().addValueChangedListener(this); |
43 | 44 |
} |
44 | 45 |
|
46 |
/** |
|
47 |
* Aqui se definen los parametros iniciales para la transparencia del panel |
|
48 |
* @param t |
|
49 |
*/ |
|
45 | 50 |
public void setTransparencyObject(GridTransparency t) { |
46 | 51 |
this.transparency = t; |
52 |
|
|
53 |
saveStatus(); |
|
54 |
|
|
47 | 55 |
setValuesFromGridTransparencyToPanel(); |
48 | 56 |
} |
49 | 57 |
|
... | ... | |
105 | 113 |
} |
106 | 114 |
|
107 | 115 |
/** |
108 |
* Acciones a ejecutar cuando se acepta
|
|
116 |
* Aplica y guarda los cambios del panel
|
|
109 | 117 |
*/ |
110 |
public void accept() { |
|
118 |
public void apply() { |
|
119 |
onlyApply(); |
|
120 |
saveStatus(); |
|
121 |
} |
|
122 |
|
|
123 |
/** |
|
124 |
* Aplicar los cambios sin guardar su estado |
|
125 |
*/ |
|
126 |
public void onlyApply() { |
|
111 | 127 |
setValuesFromPanelToGridTransparency(); |
112 | 128 |
} |
113 | 129 |
|
114 | 130 |
/** |
115 |
* Acciones a ejecutar cuando se aplica
|
|
131 |
* Guarda el estado actual del panel
|
|
116 | 132 |
*/ |
117 |
public void apply() { |
|
133 |
private void saveStatus() { |
|
134 |
RegistrableTabPanel.initialProperties.put("opacity", new Integer(transparency.getOpacity())); |
|
135 |
RegistrableTabPanel.initialProperties.put("transparencyActive", new Boolean(transparency.isTransparencyActive())); |
|
136 |
|
|
137 |
ArrayList newArray = new ArrayList(); |
|
138 |
for (int i = 0; i < transparency.getTransparencyRange().size(); i++) { |
|
139 |
newArray.add(transparency.getTransparencyRange().get(i)); |
|
140 |
} |
|
141 |
RegistrableTabPanel.initialProperties.put("transparencyRange", newArray); |
|
142 |
} |
|
143 |
|
|
144 |
/** |
|
145 |
* Deja la capa en el ?ltimo estado guardado y la refresca |
|
146 |
*/ |
|
147 |
public void restoreStatus() { |
|
148 |
transparency.setOpacity(((Integer) RegistrableTabPanel.initialProperties.get("opacity")).intValue()); |
|
149 |
transparency.setTransparencyActive(((Boolean) RegistrableTabPanel.initialProperties.get("transparencyActive")).booleanValue()); |
|
150 |
|
|
151 |
ArrayList newArray = (ArrayList) RegistrableTabPanel.initialProperties.get("transparencyRange"); |
|
152 |
transparency.clearListOfTransparencyRange(); |
|
153 |
for (int i = 0; i < newArray.size(); i++) { |
|
154 |
transparency.setTransparencyRange((TransparencyRange) newArray.get(i)); |
|
155 |
} |
|
156 |
|
|
157 |
if (tPanel.getLayer() != null) |
|
158 |
tPanel.getLayer().getMapContext().invalidate(); |
|
159 |
} |
|
160 |
|
|
161 |
/** |
|
162 |
* Acciones a ejecutar cuando se acepta |
|
163 |
*/ |
|
164 |
public void accept() { |
|
118 | 165 |
setValuesFromPanelToGridTransparency(); |
119 | 166 |
} |
120 | 167 |
|
... | ... | |
122 | 169 |
* Acciones a ejecutar cuando se cancela |
123 | 170 |
*/ |
124 | 171 |
public void cancel() { |
172 |
restoreStatus(); |
|
125 | 173 |
} |
126 | 174 |
|
127 | 175 |
/* |
... | ... | |
129 | 177 |
* @see org.gvsig.rastertools.properties.panels.TranspByPixelEventListener#actionPixelListChanged(java.util.EventObject) |
130 | 178 |
*/ |
131 | 179 |
public void actionPixelListChanged(EventObject e) { |
132 |
apply();
|
|
180 |
onlyApply();
|
|
133 | 181 |
} |
134 | 182 |
} |
Also available in: Unified diff