Revision 24170

View differences:

trunk/libraries/libRaster/src/org/gvsig/raster/grid/render/VisualPropertyEvent.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.grid.render;
20

  
21
import java.util.EventObject;
22

  
23
/**
24
 * Evento de una propiedad cuando esta cambia
25
 * 
26
 * 07/01/2008
27
 * @author Nacho Brodin (nachobrodin@gmail.com)
28
 */
29
public class VisualPropertyEvent extends EventObject {
30
	private static final long serialVersionUID = -1649548367781607532L;
31
	private String name = null;
32
	private Object value = null;
33

  
34
	/**
35
	 * Constructor. Se asignan los valores de nombre y valor de la 
36
	 * propiedad que ha disparado el evento.
37
	 * @param source Objeto fuente
38
	 * @param name Nombre de la propiedad
39
	 * @param value Valor de la propiedad
40
	 */
41
	public VisualPropertyEvent(Object source) {
42
		super(source);
43
	}
44

  
45
	/**
46
	 * Obtiene el nombre de la propiedad que dispar? el evento
47
	 * @return cadena con el nombre de la propiedad que dispar? el evento
48
	 */
49
	public String getName() {
50
		return name;
51
	}
52
	
53
	/**
54
	 * Obtiene el valor de la propiedad antes de que se modificara.
55
	 * @return Object con el valor de la propiedad que dispar? el evento
56
	 */
57
	public Object getValue() {
58
		return value;
59
	}
60
}
trunk/libraries/libRaster/src/org/gvsig/raster/grid/render/Rendering.java
24 24
import java.awt.geom.AffineTransform;
25 25
import java.awt.geom.NoninvertibleTransformException;
26 26
import java.awt.geom.Point2D;
27
import java.util.ArrayList;
27 28

  
28 29
import org.gvsig.raster.buffer.BufferFactory;
29 30
import org.gvsig.raster.dataset.IBuffer;
......
36 37
import org.gvsig.raster.datastruct.ViewPortData;
37 38
import org.gvsig.raster.grid.Grid;
38 39
import org.gvsig.raster.grid.GridTransparency;
40
import org.gvsig.raster.grid.filter.FilterListChangeEvent;
41
import org.gvsig.raster.grid.filter.FilterListChangeListener;
39 42
import org.gvsig.raster.grid.filter.RasterFilter;
40 43
import org.gvsig.raster.grid.filter.RasterFilterList;
41 44
import org.gvsig.raster.grid.filter.bands.ColorTableFilter;
45
import org.gvsig.raster.util.PropertyEvent;
46
import org.gvsig.raster.util.PropertyListener;
42 47
import org.gvsig.raster.util.RasterUtilities;
43 48
/**
44 49
 * Esta clase se encarga de la gesti?n del dibujado de datos le?dos desde la capa
......
61 66
 *
62 67
 * @author Nacho Brodin (nachobrodin@gmail.com)
63 68
 */
64
public class Rendering {
69
public class Rendering implements PropertyListener, FilterListChangeListener {
65 70

  
66 71
	/**
67 72
	 * Grid para la gesti?n del buffer
68 73
	 */
69
	private Grid             grid             = null;
74
	private Grid             grid                     = null;
70 75
	/**
71 76
	 * Fuente de datos para el renderizado
72 77
	 */
73
	private BufferFactory    bufferFactory    = null;
78
	private BufferFactory    bufferFactory            = null;
74 79
	/**
75 80
	 * Objeto sobre el cual se hace el renderizado
76 81
	 */
77
	private Image            geoImage         = null;
82
	private Image            geoImage                 = null;
78 83
	/**
79 84
	 * N?mero de bandas a renderizar y en el orden que se har?. Esto es asignado
80 85
	 * por el usuario de la renderizaci?n.
81 86
	 */
82
	private int[]            renderBands      = { 0, 1, 2 };
87
	private int[]            renderBands              = { 0, 1, 2 };
83 88
	/**
84 89
	 * Tiene el comportamiento cuando se tiene un raster con una. Dice si en las
85 90
	 * otras bandas a renderizar se replica la banda existente o se ponen a 0.
86 91
	 */
87
	private boolean          replicateBand    = false;
92
	private boolean          replicateBand            = false;
88 93

  
89
	private ImageDrawer      drawer           = null;
94
	private ImageDrawer      drawer                   = null;
90 95
	/**
91 96
	 * Ultima transparencia aplicada en la visualizaci?n que es obtenida desde el
92 97
	 * grid
93 98
	 */
94
	private GridTransparency lastTransparency = null;
99
	private GridTransparency lastTransparency         = null;
95 100
	/**
96 101
	 * Lista de filtros aplicada en la renderizaci?n
97 102
	 */
98
	private RasterFilterList filterList       = null;
103
	private RasterFilterList filterList               = null;
99 104

  
100
	private IBuffer          lastRenderBuffer = null;
105
	private IBuffer          lastRenderBuffer         = null;
101 106

  
102 107
	/**
103 108
	 * Ancho y alto del objeto Image en una petici?n de dibujado a un raster
......
106 111
	private double           widthImage, heightImage;
107 112

  
108 113
	private Point2D          ulPxRequest, lrPxRequest;
114
	
115
	/**
116
	 * Array de listeners que ser?n informados cuando cambia una propiedad en la visualizaci?n
117
	 */
118
	private ArrayList        visualPropertyListener   = new ArrayList();
109 119

  
110 120
	/**
111 121
	 * Constructor
......
184 194
			}
185 195
		}
186 196
	}
197
	
198
	/**
199
	 * Asigna un listener a la lista que ser? informado cuando cambie una
200
	 * propiedad visual en la renderizaci?n. 
201
	 * @param listener VisualPropertyListener
202
	 */
203
	public void addVisualPropertyListener(VisualPropertyListener listener) {
204
		visualPropertyListener.add(listener);
205
	}
206
	
207
	/**
208
	 * M?todo llamado cuando hay un cambio en una propiedad de visualizaci?n
209
	 */
210
	private void callVisualPropertyChanged(Object obj) {
211
		for (int i = 0; i < visualPropertyListener.size(); i++) {
212
			VisualPropertyEvent ev = new VisualPropertyEvent(obj);
213
			((VisualPropertyListener)visualPropertyListener.get(i)).visualPropertyValueChanged(ev);
214
		}
215
	}
187 216

  
188 217
	/**
189 218
	 * Dibuja el raster sobre el Graphics. Para ello debemos de pasar el viewPort que corresponde a la
......
231 260
		double[] step = null;
232 261

  
233 262
		if (bufferFactory != null) {
234
			if (lastTransparency == null)
263
			if (lastTransparency == null) {
235 264
				lastTransparency = new GridTransparency(bufferFactory.getDataSource().getTransparencyFilesStatus());
265
				lastTransparency.addPropertyListener(this);
266
			}
236 267
			// Asignamos la banda de transparencia si existe esta
237 268
			if (bufferFactory.getDataSource().getTransparencyFilesStatus().getAlphaBandNumber() != -1) {
238 269
				bufferFactory.setSupersamplingLoadingBuffer(false); // Desactivamos el supersampleo en la carga del buffer.
......
437 468
		 * @param renderBands: bandas y su posici?n
438 469
		 */
439 470
	public void setRenderBands(int[] renderBands) {
471
		if(	renderBands[0] != this.renderBands[0] || 
472
			renderBands[1] != this.renderBands[1] || 
473
			renderBands[2] != this.renderBands[2])
474
			callVisualPropertyChanged(renderBands);
440 475
		this.renderBands = renderBands;
441 476
		if (filterList != null) {
442 477
			for (int i = 0; i < filterList.lenght(); i++)
......
483 518
	 */
484 519
	public void setLastTransparency(GridTransparency lastTransparency) {
485 520
		this.lastTransparency = lastTransparency;
521
		this.lastTransparency.addPropertyListener(this);
486 522
		if (getFilterList() != null)
487 523
			getFilterList().addEnvParam("Transparency", lastTransparency);
488 524
	}
......
517 553
	 */
518 554
	public void setFilterList(RasterFilterList filterList) {
519 555
		this.filterList = filterList;
556
		this.filterList.addFilterListListener(this);
520 557
	}
521 558

  
522 559
	/**
......
542 579
	public void setBufferFactory(BufferFactory bf) {
543 580
		this.bufferFactory = bf;
544 581
	}
582

  
583
	/**
584
	 * Evento activado cuando cambia una propiedad de transparencia.
585
	 */
586
	public void actionValueChanged(PropertyEvent e) {
587
		callVisualPropertyChanged(new VisualPropertyEvent(e.getSource()));
588
	}
589

  
590
	/**
591
	 * Evento activado cuando cambia la lista de filtros.
592
	 */
593
	public void filterListChanged(FilterListChangeEvent e) {
594
		callVisualPropertyChanged(new VisualPropertyEvent(e.getSource()));
595
	}
545 596
}
trunk/libraries/libRaster/src/org/gvsig/raster/grid/render/VisualPropertyListener.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.grid.render;
20

  
21
import java.util.EventListener;
22

  
23
/**
24
 * Listener con los eventos que puede disparar una propiedad cuando esta cambia. 
25
 * 
26
 * 07/01/2008
27
 * @author Nacho Brodin (nachobrodin@gmail.com)
28
 */
29
public interface VisualPropertyListener extends EventListener {
30
	/**
31
	 * Evento que se dispara cuando cambia el valor de la propiedad.
32
	 * @param e
33
	 */
34
	public void visualPropertyValueChanged(VisualPropertyEvent e);
35
}

Also available in: Unified diff