Statistics
| Revision:

gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.main / src / test / java / org / gvsig / fmap / dal / coverage / util / TransparencyRangeTest.java @ 2443

History | View | Annotate | Download (3.24 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.util;
23

    
24
import java.util.ArrayList;
25

    
26
import org.gvsig.fmap.dal.coverage.BaseTestCase;
27
import org.gvsig.fmap.dal.coverage.datastruct.TransparencyRange;
28
import org.gvsig.raster.impl.datastruct.TransparencyRangeImpl;
29
import org.gvsig.raster.impl.provider.DefaultRasterProvider;
30

    
31

    
32
/**
33
 * @author Nacho Brodin (nachobrodin@gmail.com)
34
 */
35
public class TransparencyRangeTest extends BaseTestCase {
36
                
37
        private TransparencyRange tr = new TransparencyRangeImpl();
38
        private TransparencyRange tr1 = new TransparencyRangeImpl();
39
        private TransparencyRange tr2 = new TransparencyRangeImpl();
40
        private TransparencyRange tr3 = new TransparencyRangeImpl();
41
        
42
    public void start() throws Exception {
43
                this.setUp();
44
                this.testStack();
45
        }
46
        
47
        protected void doSetUp() throws Exception {
48
                System.err.println("TransparencyRangeTest running...");
49
                
50
                try {
51
                        super.doSetUp();
52
                } catch (Exception e) {
53
                        e.printStackTrace();
54
                }
55
                
56
                //Simplificaciones entre dos intervalos
57
                
58
                tr.setRed(new int[]{3 , 5});
59
                tr.setGreen(new int[]{4 , 7});
60
                tr.setBlue(new int[]{1 , 5});
61
                tr.setAnd(true);
62
                tr.loadStrEntryFromValues();
63
                
64
                tr1.setRed(new int[]{4 , 7});
65
                tr1.setGreen(new int[]{3 , 5});
66
                tr1.setBlue(new int[]{2 , 4});
67
                tr1.setAnd(true);
68
                tr1.loadStrEntryFromValues();
69
                
70
                tr2.setRed(new int[]{5 , 10});
71
                tr2.setGreen(new int[]{10 , 15});
72
                tr2.setBlue(new int[]{5 , 14});
73
                tr2.setAnd(true);
74
                tr2.loadStrEntryFromValues();
75
                
76
                tr3.setRed(new int[]{6 , 12});
77
                tr3.setGreen(new int[]{14 , 20});
78
                tr3.setBlue(new int[]{16 , 24});
79
                tr3.setAnd(true);
80
                tr3.loadStrEntryFromValues();
81
        }
82
        
83
        public void testStack(){
84
                int[] r = tr.union(tr1.getRed(), DefaultRasterProvider.RED_BAND);
85
                int[] g = tr.union(tr1.getGreen(), DefaultRasterProvider.GREEN_BAND);
86
                int[] b = tr.union(tr1.getBlue(), DefaultRasterProvider.BLUE_BAND);
87
                
88
                assertEquals(r[0], 3);
89
                assertEquals(r[1], 7);
90
                assertEquals(g[0], 3);
91
                assertEquals(g[1], 7);
92
                assertEquals(b[0], 1);
93
                assertEquals(b[1], 5);
94
                
95
                //Simplificaciones de una lista de intervalos
96
                ArrayList<TransparencyRange> l = new ArrayList<TransparencyRange>();
97
                l.add(tr);
98
                l.add(tr1);
99
                l.add(tr2);
100
                l.add(tr3);
101
                
102
                /*Transparency t = new Transparency();
103
                t.setTransparencyRangeList(l);
104
                t.simplify();
105
                
106
                for (int i = 0; i < l.size(); i++)
107
                        System.out.println("Entrada: " + ((TransparencyRange)l.get(i)).getStrEntry());*/
108
        }
109
        
110
}