Revision 999 org.gvsig.raster.cache/trunk/org.gvsig.raster.cache/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/buffer/impl/BufferParamImpl.java

View differences:

BufferParamImpl.java
1 1
package org.gvsig.raster.cache.buffer.impl;
2 2

  
3
import java.io.IOException;
4

  
3 5
import org.gvsig.raster.cache.buffer.Buffer;
6
import org.gvsig.raster.cache.buffer.BufferDataSource;
4 7
import org.gvsig.raster.cache.buffer.BufferParam;
8
import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
9
import org.gvsig.raster.cache.buffer.impl.io.BufferMultiDataSourceImpl;
5 10

  
6 11
/**
7 12
 * Buffer parameters. This class contains generic parameters. 
......
13 18
public class BufferParamImpl extends PxTileImpl implements BufferParam {
14 19
	private static final long serialVersionUID = 1L;
15 20
	private int               accessType       = Buffer.READ_WRITE;
21
	private int[]             bands            = null;
16 22

  
17 23
	/**
18
	 * Set size and position values
24
	 * Constructor
19 25
	 * @param  w
20 26
	 *         Width
21 27
	 * @param  h
......
26 32
	}
27 33
	
28 34
	/**
35
	 * Constructor
36
	 * @param  file
37
	 *         file name
38
	 * @param  x
39
	 *         X position
40
	 * @param  y
41
	 *         Y position
42
	 * @param  w
43
	 *         Width
44
	 * @param  h
45
	 *         Height
46
	 * @param  bands
47
	 *         bands to load in the buffer
48
	 * @throws IOException 
49
	 */
50
	public BufferParamImpl(String file, int x, int y, int w, int h, int[] bands) throws IOException {
51
		super(x, y, w, h);
52
		PxTileImpl pxTile = new PxTileImpl(x, y, w, h);
53
		BufferDataSourceImpl datasource = new BufferDataSourceImpl(file, pxTile);
54
		setDataSource(datasource);
55
		if(bands == null) {
56
			int bandCount = getDataSource().getBandCount();
57
			this.bands = new int[bandCount];
58
			for (int i = 0; i < bandCount; i++) {
59
				this.bands[i] = i;
60
			}
61
		} else
62
			this.bands = bands;
63
		setBandCount(this.bands.length);
64
		accessType = Buffer.READ_ONLY;
65
	}
66
	
67
	/**
68
	 * Constructor for multifiles
69
	 * @param  file
70
	 *         file name
71
	 * @param  x
72
	 *         X position
73
	 * @param  y
74
	 *         Y position
75
	 * @param  w
76
	 *         Width in pixels
77
	 * @param  h
78
	 *         Height in pixels
79
	 * @param  bands
80
	 *         bands to load in the buffer. It can be null. In this case all bands will be used
81
	 * @throws IOException 
82
	 */
83
	public BufferParamImpl(String[] file, int x, int y, int w, int h, int[] bands) throws IOException {
84
		super(x, y, w, h);
85
		PxTileImpl pxTile = new PxTileImpl(x, y, w, h);
86
		BufferDataSource datasource = new BufferMultiDataSourceImpl(file, pxTile);
87
		setDataSource(datasource);
88
		
89
		if(bands == null) {
90
			int bandCount = getDataSource().getBandCount();
91
			this.bands = new int[bandCount];
92
			for (int i = 0; i < bandCount; i++) {
93
				this.bands[i] = i;
94
			}
95
		} else
96
			this.bands = bands;
97
		setBandCount(this.bands.length);
98
		accessType = Buffer.READ_ONLY;
99
	}
100
	
101
	/**
29 102
	 * Creates a parameter object for building a buffer. The buffer type is read-write.
30 103
	 * This type could be changed after the creation of a {@link BufferParam} object.
31 104
	 * @param  w
......
45 118
	}
46 119
	
47 120
	/*
121
	 * 
48 122
	 * (non-Javadoc)
49 123
	 * @see org.gvsig.raster.cache.buffer.BufferParam#setAccessType(int)
50 124
	 */
......
59 133
	public int getAccessType() {
60 134
		return accessType;
61 135
	}
136

  
137
	/*
138
	 * (non-Javadoc)
139
	 * @see org.gvsig.raster.cache.buffer.BufferParam#setFile(java.lang.String)
140
	 */
141
	public void setBandList(int[] bands) {
142
		this.bands = bands;
143
	}
144

  
145
	/*
146
	 * (non-Javadoc)
147
	 * @see org.gvsig.raster.cache.buffer.BufferParam#getFile()
148
	 */
149
	public int[] getBandList() {
150
		return bands;
151
	}
62 152
}

Also available in: Unified diff