svn-gvsig-desktop / trunk / libraries / libRaster / src-test / org / gvsig / raster / dataset / TestBandList.java @ 12522
History | View | Annotate | Download (3.3 KB)
1 | 12252 | nacho | /*
|
---|---|---|---|
2 | * Created on 9-ago-2006
|
||
3 | *
|
||
4 | * To change the template for this generated file go to
|
||
5 | * Window>Preferences>Java>Code Generation>Code and Comments
|
||
6 | */
|
||
7 | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
8 | *
|
||
9 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
10 | *
|
||
11 | * This program is free software; you can redistribute it and/or
|
||
12 | * modify it under the terms of the GNU General Public License
|
||
13 | * as published by the Free Software Foundation; either version 2
|
||
14 | * of the License, or (at your option) any later version.
|
||
15 | *
|
||
16 | * This program is distributed in the hope that it will be useful,
|
||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
19 | * GNU General Public License for more details.
|
||
20 | *
|
||
21 | * You should have received a copy of the GNU General Public License
|
||
22 | * along with this program; if not, write to the Free Software
|
||
23 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
24 | */
|
||
25 | package org.gvsig.raster.dataset; |
||
26 | |||
27 | import junit.framework.TestCase; |
||
28 | |||
29 | import org.gvsig.raster.RasterLibrary; |
||
30 | |||
31 | /**
|
||
32 | *
|
||
33 | * @author Nacho Brodin (nachobrodin@gmail.com)
|
||
34 | *
|
||
35 | */
|
||
36 | public class TestBandList extends TestCase { |
||
37 | private BandList bandList = null; |
||
38 | |||
39 | static {
|
||
40 | RasterLibrary.wakeUp(); |
||
41 | } |
||
42 | |||
43 | public void start() { |
||
44 | this.setUp();
|
||
45 | this.testStack();
|
||
46 | } |
||
47 | |||
48 | public void setUp() { |
||
49 | System.err.println("TestBandList running..."); |
||
50 | bandList = new BandList();
|
||
51 | for(int i = 0; i < 5; i++) { |
||
52 | try {
|
||
53 | Band band = new Band("fileName", i, IBuffer.TYPE_BYTE); |
||
54 | bandList.addBand(band, i); |
||
55 | } catch(BandNotFoundInListException ex) {
|
||
56 | //No a?adimos la banda
|
||
57 | } |
||
58 | } |
||
59 | |||
60 | } |
||
61 | |||
62 | public void testStack(){ |
||
63 | bandList.clearDrawableBands(); |
||
64 | bandList.addDrawableBand(0, 1); |
||
65 | bandList.addDrawableBand(1, 4); |
||
66 | bandList.addDrawableBand(2, 3); |
||
67 | |||
68 | bandList.clearDrawableBands(); |
||
69 | bandList.addDrawableBand(0, 3); |
||
70 | bandList.addDrawableBand(1, 2); |
||
71 | bandList.addDrawableBand(2, 4); |
||
72 | bandList.addDrawableBand(3, 4); |
||
73 | print(); |
||
74 | } |
||
75 | |||
76 | private void test2() { |
||
77 | assertEquals(bandList.getBandCount(), 5);
|
||
78 | assertEquals(bandList.getDrawableBandsCount(), 4);
|
||
79 | for (int i = 0; i < bandList.getBandCount(); i++) { |
||
80 | |||
81 | assertEquals((((Band)bandList.getBand(i)).getDataType()), 0);
|
||
82 | assertEquals((((Band)bandList.getBand(i)).getFileName()), "fileName");
|
||
83 | assertEquals((((Band)bandList.getBand(i)).getPosition()), i); |
||
84 | } |
||
85 | } |
||
86 | |||
87 | /**
|
||
88 | *Muestra la lista de bandas en modo texto
|
||
89 | */
|
||
90 | public void print() { |
||
91 | System.out.println("BandCount: " + bandList.getBandCount()); |
||
92 | System.out.println("DrawableBandsCount: " + bandList.getDrawableBandsCount()); |
||
93 | for (int i = 0; i < bandList.getBandCount(); i++) { |
||
94 | System.out.println(""); |
||
95 | System.out.println("***********************"); |
||
96 | System.out.println("Band: " + i); |
||
97 | System.out.println("DataType: " + ((Band)bandList.getBand(i)).getDataType()); |
||
98 | System.out.println("FileName: " + ((Band)bandList.getBand(i)).getFileName()); |
||
99 | System.out.println("Position: " + ((Band)bandList.getBand(i)).getPosition()); |
||
100 | if(((Band)bandList.getBand(i)).getBufferBandListToDraw() != null) { |
||
101 | System.out.print("Band Dst: "); |
||
102 | for (int j = 0; j < ((Band)bandList.getBand(i)).getBufferBandListToDraw().length; j++) |
||
103 | System.out.print(((Band)bandList.getBand(i)).getBufferBandListToDraw()[j] + " "); |
||
104 | } |
||
105 | } |
||
106 | |||
107 | } |
||
108 | } |