gvsig-raster / org.gvsig.raster.cache / trunk / org.gvsig.raster.cache / org.gvsig.raster.cache.lib.impl / deprecated / buffer / impl / memory / FloatBand.java @ 1939
History | View | Annotate | Download (2.27 KB)
1 |
package org.gvsig.raster.cache.buffer.impl.memory; |
---|---|
2 |
|
3 |
import org.gvsig.raster.cache.buffer.Buffer; |
4 |
|
5 |
|
6 |
/**
|
7 |
* Clase que representa una banda float de un buffer de memoria
|
8 |
*
|
9 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
10 |
*/
|
11 |
public class FloatBand extends MemoryBand { |
12 |
public float[][] buf = null; |
13 |
|
14 |
public FloatBand(int width, int height, int nBand, boolean malloc){ |
15 |
super(width, height, nBand);
|
16 |
this.setDataType(Buffer.TYPE_FLOAT); |
17 |
if(malloc)
|
18 |
buf = new float[height][width]; |
19 |
} |
20 |
|
21 |
/*
|
22 |
* (non-Javadoc)
|
23 |
* @see org.gvsig.raster.buffer.RasterBand#assign(float)
|
24 |
*/
|
25 |
public void assign(float value) { |
26 |
for (int i = 0; i < buf.length; i++) { |
27 |
for (int j = 0; j < buf[i].length; j++) { |
28 |
buf[i][j] = value; |
29 |
} |
30 |
} |
31 |
} |
32 |
|
33 |
/*
|
34 |
* (non-Javadoc)
|
35 |
* @see org.gvsig.raster.buffer.RasterBand#getFloatBlock(int)
|
36 |
*/
|
37 |
public float[][] getFloatBlock(int block) { |
38 |
return buf;
|
39 |
} |
40 |
|
41 |
/*
|
42 |
* (non-Javadoc)
|
43 |
* @see org.gvsig.raster.buffer.IRasterBand#setFloatBlock(float[][], int)
|
44 |
*/
|
45 |
public void setFloatBlock(float[][] data, int block) { |
46 |
this.buf = data;
|
47 |
} |
48 |
|
49 |
/*
|
50 |
* (non-Javadoc)
|
51 |
* @see org.gvsig.raster.buffer.RasterBand#getFloatLine(int)
|
52 |
*/
|
53 |
public float[] getFloatLine(int line) { |
54 |
return buf[line];
|
55 |
} |
56 |
|
57 |
/*
|
58 |
* (non-Javadoc)
|
59 |
* @see org.gvsig.raster.buffer.RasterBand#getElemFloat(int, int)
|
60 |
*/
|
61 |
public float getElemFloat(int line, int col) { |
62 |
return buf[line][col];
|
63 |
} |
64 |
|
65 |
/*
|
66 |
* (non-Javadoc)
|
67 |
* @see org.gvsig.raster.buffer.RasterBand#setFloatLine(float[], int)
|
68 |
*/
|
69 |
public void setFloatLine(float[] data, int line) { |
70 |
buf[line] = data; |
71 |
} |
72 |
|
73 |
/*
|
74 |
* (non-Javadoc)
|
75 |
* @see org.gvsig.raster.buffer.RasterBand#setElem(int, int, float)
|
76 |
*/
|
77 |
public void setElem(int line, int col, float data) { |
78 |
buf[line][col] = data; |
79 |
} |
80 |
|
81 |
/*
|
82 |
* (non-Javadoc)
|
83 |
* @see org.fv.raster.buffer.memory.MemoryBand#free()
|
84 |
*/
|
85 |
public void free() { |
86 |
buf = null;
|
87 |
} |
88 |
|
89 |
/*
|
90 |
* (non-Javadoc)
|
91 |
* @see org.fv.raster.buffer.memory.MemoryBand#clone()
|
92 |
*/
|
93 |
public MemoryBand clone() {
|
94 |
if(buf == null) |
95 |
return new FloatBand(getWidth(), getHeight(), getBandNumber(), false); |
96 |
FloatBand fb = new FloatBand(getWidth(), getHeight(), getBandNumber(), true); |
97 |
for(int row = 0; row < buf.length; row ++) { |
98 |
for(int col = 0; col < buf[0].length; col ++) { |
99 |
fb.setElem(row, col, buf[row][col]); |
100 |
} |
101 |
} |
102 |
return fb;
|
103 |
} |
104 |
} |