gvsig-raster / org.gvsig.raster.cache / trunk / org.gvsig.raster.cache / org.gvsig.raster.cache.lib.impl / src / main / java / org / gvsig / raster / cache / buffer / impl / rocache / ByteBand.java @ 991
History | View | Annotate | Download (1.74 KB)
1 |
package org.gvsig.raster.cache.buffer.impl.rocache; |
---|---|
2 |
|
3 |
import java.util.ArrayList; |
4 |
|
5 |
import org.gvsig.raster.cache.buffer.BufferDataSource; |
6 |
import org.gvsig.raster.cache.buffer.Buffer; |
7 |
import org.gvsig.raster.cache.buffer.PxTile; |
8 |
import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException; |
9 |
|
10 |
/**
|
11 |
* This class represent a byte band loaded in memory.
|
12 |
*
|
13 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
14 |
*/
|
15 |
public class ByteBand extends ReadOnlyCacheBand { |
16 |
|
17 |
public ByteBand(ArrayList<PxTile> stripeList, |
18 |
BufferDataSource dataSource, int offset, int bitsPag, int band, |
19 |
int width, int height) { |
20 |
super(stripeList, dataSource, offset, bitsPag, band, width, height, Buffer.TYPE_BYTE); |
21 |
} |
22 |
|
23 |
/*
|
24 |
* (non-Javadoc)
|
25 |
* @see org.gvsig.raster.buffer.IRasterBand#getByteBlock(int)
|
26 |
*/
|
27 |
public byte[][] getByteBlock(int block){ |
28 |
if(block != loadedPage)
|
29 |
loadOrSwapPage(block); |
30 |
return page.getBand(0).getByteBlock(block); |
31 |
} |
32 |
|
33 |
/*
|
34 |
* (non-Javadoc)
|
35 |
* @see org.gvsig.raster.buffer.IRasterBand#getElemByte(int, int)
|
36 |
*/
|
37 |
public byte getElemByte(int line, int col) { |
38 |
int pag = line >> bitsPag;
|
39 |
if(pag != loadedPage)
|
40 |
loadOrSwapPage(pag); |
41 |
return page.getElemByte(line & offset, col, 0); |
42 |
} |
43 |
|
44 |
/*
|
45 |
* (non-Javadoc)
|
46 |
* @see org.gvsig.raster.buffer.IRasterBand#getByteLine(int)
|
47 |
*/
|
48 |
public byte[] getByteLine(int line) throws OperationNotSupportedException { |
49 |
int pag = line >> bitsPag;
|
50 |
if(pag != loadedPage)
|
51 |
loadOrSwapPage(pag); |
52 |
return page.getLineByte(line & offset)[0]; |
53 |
} |
54 |
|
55 |
/*
|
56 |
* (non-Javadoc)
|
57 |
* @see java.lang.Object#clone()
|
58 |
*/
|
59 |
public Object clone() { |
60 |
BufferDataSource ds = dataSource.clone(); |
61 |
ByteBand result = new ByteBand(stripeList,
|
62 |
ds, |
63 |
offset, |
64 |
bitsPag, |
65 |
nBand, |
66 |
getWidth(), |
67 |
getHeight()); |
68 |
return result;
|
69 |
} |
70 |
} |