gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.main / src / test / java / org / gvsig / fmap / dal / coverage / dataset / TestBandList.java @ 2443
History | View | Annotate | Download (3.63 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.fmap.dal.coverage.dataset; |
23 |
|
24 |
import junit.framework.TestCase; |
25 |
|
26 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
27 |
import org.gvsig.fmap.dal.coverage.datastruct.BandList; |
28 |
import org.gvsig.fmap.dal.coverage.datastruct.DatasetBand; |
29 |
import org.gvsig.fmap.dal.coverage.exception.BandNotFoundInListException; |
30 |
import org.gvsig.raster.impl.datastruct.BandListImpl; |
31 |
import org.gvsig.raster.impl.datastruct.DatasetBandImpl; |
32 |
/**
|
33 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
34 |
*/
|
35 |
public class TestBandList extends TestCase { |
36 |
private boolean showCode = false; |
37 |
private BandList bandList = null; |
38 |
|
39 |
public void start() throws Exception { |
40 |
this.setUp();
|
41 |
this.testStack();
|
42 |
} |
43 |
|
44 |
protected void setUp() throws Exception { |
45 |
System.err.println("TestBandList running..."); |
46 |
bandList = new BandListImpl();
|
47 |
for (int i = 0; i < 5; i++) { |
48 |
try {
|
49 |
DatasetBand band = new DatasetBandImpl("fileName", i, Buffer.TYPE_BYTE, 5); |
50 |
bandList.addBand(band, i); |
51 |
} catch (BandNotFoundInListException ex) {
|
52 |
// No a?adimos la banda
|
53 |
} |
54 |
} |
55 |
} |
56 |
|
57 |
public void testStack() { |
58 |
bandList.clearDrawableBands(); |
59 |
bandList.addDrawableBand(0, 1); |
60 |
bandList.addDrawableBand(1, 4); |
61 |
bandList.addDrawableBand(2, 3); |
62 |
|
63 |
bandList.clearDrawableBands(); |
64 |
bandList.addDrawableBand(0, 3); |
65 |
bandList.addDrawableBand(1, 2); |
66 |
bandList.addDrawableBand(2, 4); |
67 |
bandList.addDrawableBand(3, 4); |
68 |
if (showCode)
|
69 |
print(); |
70 |
} |
71 |
|
72 |
// private void test2() {
|
73 |
// assertEquals(bandList.getBandCount(), 5);
|
74 |
// assertEquals(bandList.getDrawableBandsCount(), 4);
|
75 |
// for (int i = 0; i < bandList.getBandCount(); i++) {
|
76 |
//
|
77 |
// assertEquals((((Band) bandList.getBand(i)).getDataType()), 0);
|
78 |
// assertEquals((((Band) bandList.getBand(i)).getFileName()), "fileName");
|
79 |
// assertEquals((((Band) bandList.getBand(i)).getPosition()), i);
|
80 |
// }
|
81 |
// }
|
82 |
|
83 |
/**
|
84 |
* Muestra la lista de bandas en modo texto
|
85 |
*/
|
86 |
public void print() { |
87 |
System.out.println("BandCount: " + bandList.getBandCount()); |
88 |
System.out.println("DrawableBandsCount: " + bandList.getDrawableBandsCount()); |
89 |
for (int i = 0; i < bandList.getBandCount(); i++) { |
90 |
System.out.println(""); |
91 |
System.out.println("***********************"); |
92 |
System.out.println("Band: " + i); |
93 |
System.out.println("DataType: " + ((DatasetBand) bandList.getBand(i)).getDataType()); |
94 |
System.out.println("FileName: " + ((DatasetBand) bandList.getBand(i)).getFileName()); |
95 |
System.out.println("Position: " + ((DatasetBand) bandList.getBand(i)).getPosition()); |
96 |
if (((DatasetBand) bandList.getBand(i)).getBufferBandListToDraw() != null) { |
97 |
System.out.print("Band Dst: "); |
98 |
for (int j = 0; j < ((DatasetBand) bandList.getBand(i)).getBufferBandListToDraw().length; j++) |
99 |
System.out.print(((DatasetBand) bandList.getBand(i)).getBufferBandListToDraw()[j] + " "); |
100 |
} |
101 |
} |
102 |
} |
103 |
} |