svn-gvsig-desktop / branches / org.gvsig.desktop-2018a / org.gvsig.desktop.library / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.buffer.impl / src / main / java / org / gvsig / raster / lib / buffer / impl / AbstractClippedBand.java @ 43803
History | View | Annotate | Download (2.85 KB)
1 |
package org.gvsig.raster.lib.buffer.impl; |
---|---|
2 |
|
3 |
import org.gvsig.raster.lib.buffer.api.Band; |
4 |
import org.gvsig.raster.lib.buffer.api.BandInfo; |
5 |
import org.gvsig.raster.lib.buffer.api.Buffer; |
6 |
import org.gvsig.raster.lib.buffer.impl.exceptions.CopyFromBandException; |
7 |
import org.gvsig.tools.ToolsLocator; |
8 |
import org.gvsig.tools.dispose.DisposableManager; |
9 |
import org.gvsig.tools.dispose.DisposeUtils; |
10 |
import org.gvsig.tools.exception.BaseException; |
11 |
|
12 |
|
13 |
/**
|
14 |
* @author fdiaz
|
15 |
*
|
16 |
*/
|
17 |
public abstract class AbstractClippedBand extends AbstractBand implements Band { |
18 |
protected Band band;
|
19 |
protected int firstRow; |
20 |
protected int firstColumn; |
21 |
|
22 |
/**
|
23 |
* @param buffer
|
24 |
* @param band
|
25 |
*/
|
26 |
public AbstractClippedBand(Buffer buffer, Band band) { |
27 |
if (buffer instanceof ClippedBuffer) { |
28 |
ClippedBuffer clippedBuffer = (ClippedBuffer) buffer; |
29 |
|
30 |
DisposableManager disposableManager = ToolsLocator.getDisposableManager(); |
31 |
disposableManager.bind(band); |
32 |
this.band = band;
|
33 |
|
34 |
this.rows = clippedBuffer.getRows();
|
35 |
this.columns = clippedBuffer.getColumns();
|
36 |
this.firstRow = clippedBuffer.getFirstRow();
|
37 |
this.firstColumn = clippedBuffer.getFirstColumn();
|
38 |
this.noData = this.band.getNoData(); |
39 |
} else {
|
40 |
throw new IllegalArgumentException("buffer isn't a ClippedBuffer"); |
41 |
} |
42 |
} |
43 |
|
44 |
@Override
|
45 |
public BandInfo getBandInfo() {
|
46 |
return this.band.getBandInfo(); |
47 |
} |
48 |
|
49 |
@Override
|
50 |
public int getDataType() { |
51 |
return this.band.getDataType(); |
52 |
} |
53 |
|
54 |
@Override
|
55 |
public Object get(int row, int column) { |
56 |
int bandRow = row + firstRow;
|
57 |
int bandColumn = column + firstColumn;
|
58 |
return this.band.get(bandRow, bandColumn); |
59 |
} |
60 |
|
61 |
@Override
|
62 |
protected void doSet(int row, int column, Object value) { |
63 |
throw new UnsupportedOperationException("Can't write in a clipped band."); |
64 |
} |
65 |
|
66 |
@Override
|
67 |
protected void doFill(Object value) { |
68 |
throw new UnsupportedOperationException("Can't write in a clipped band."); |
69 |
} |
70 |
|
71 |
@Override
|
72 |
protected void doCopyFrom(Band source) throws CopyFromBandException { |
73 |
throw new UnsupportedOperationException("Can't write in a clipped band."); |
74 |
} |
75 |
|
76 |
@Override
|
77 |
protected void doCopyFrom(Band source, int row, int column) throws CopyFromBandException { |
78 |
throw new UnsupportedOperationException("Can't write in a clipped band."); |
79 |
} |
80 |
|
81 |
@Override
|
82 |
protected void doPutRow(int row, Object rowBuffer) { |
83 |
throw new UnsupportedOperationException("Can't write in a clipped band."); |
84 |
} |
85 |
|
86 |
@Override
|
87 |
public boolean isReadOnly() { |
88 |
return true; |
89 |
} |
90 |
|
91 |
// ?es necesario? ?es conveniente?
|
92 |
@Override
|
93 |
public void doDispose() throws BaseException { |
94 |
super.doDispose();
|
95 |
DisposeUtils.dispose(band); |
96 |
band = null;
|
97 |
} |
98 |
} |