root / branches / v2_0_0_prep / extensions / extRasterTools-SE / src-test / org / gvsig / fmap / raster / layers / FLyrRasterSETest.java @ 33331
History | View | Annotate | Download (3.58 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 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2009 {Iver T.I.} {Task}
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.fmap.raster.layers; |
29 |
|
30 |
import java.io.File; |
31 |
import java.util.List; |
32 |
|
33 |
import org.gvsig.fmap.raster.FmapRasterLibrary; |
34 |
import org.gvsig.raster.grid.GridTransparency; |
35 |
import org.gvsig.raster.grid.filter.enhancement.BrightnessContrastListManager; |
36 |
import org.gvsig.rastertools.BaseTest; |
37 |
import org.gvsig.tools.ToolsLocator; |
38 |
import org.gvsig.tools.locator.LocatorException; |
39 |
import org.gvsig.tools.persistence.PersistentState; |
40 |
import org.gvsig.tools.persistence.exception.PersistenceClassNotRegistered; |
41 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
42 |
import org.gvsig.tools.persistence.exception.PersistenceTypeNotSupportedException; |
43 |
import org.gvsig.tools.persistence.exception.PersistenceValidateExceptions; |
44 |
|
45 |
/**
|
46 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
47 |
*/
|
48 |
public class FLyrRasterSETest extends BaseTest { |
49 |
protected String byteImg = baseDir + "byte.tif"; |
50 |
|
51 |
@Override
|
52 |
protected void doSetUp() throws Exception { |
53 |
super.doSetUp();
|
54 |
new FmapRasterLibrary().postInitialize();
|
55 |
} |
56 |
|
57 |
public void testPersistent() throws PersistenceTypeNotSupportedException, PersistenceClassNotRegistered, PersistenceException, PersistenceValidateExceptions, LocatorException{ |
58 |
FLyrRasterSE layer1 = super.openLayer(new File(byteImg)); |
59 |
assertNotNull(layer1); |
60 |
|
61 |
IStatusRaster status = new StatusLayerRaster();
|
62 |
status.getFilters().add(BrightnessContrastListManager.createBrightnessFilter(100));
|
63 |
layer1.setStatus(status); |
64 |
|
65 |
PersistentState state = ToolsLocator.getPersistenceManager().getState( |
66 |
layer1); |
67 |
|
68 |
FLyrRasterSE layer2 = (FLyrRasterSE) ToolsLocator |
69 |
.getPersistenceManager().create(state); |
70 |
assertNotNull(layer2); |
71 |
|
72 |
assertEquals(layer1.getName(), layer2.getName()); |
73 |
assertEquals(layer1.getFile().getName(), layer2.getFile().getName()); |
74 |
|
75 |
IStatusRaster status1 = layer1.getStatus(); |
76 |
IStatusRaster status2 = layer2.getStatus(); |
77 |
assertNotNull(status); |
78 |
assertNotNull(status2); |
79 |
|
80 |
//Checking the filters
|
81 |
List filters1 = status.getFilters();
|
82 |
List filters2 = status.getFilters();
|
83 |
assertEquals(filters1.size(), filters2.size()); |
84 |
|
85 |
for (int i=0 ; i<filters1.size() ; i++){ |
86 |
assertTrue(i<filters2.size()); |
87 |
assertEquals(filters1.get(i), filters2.get(i)); |
88 |
} |
89 |
|
90 |
//Checking the opacity
|
91 |
GridTransparency transp1 = layer1.getRenderTransparency(); |
92 |
GridTransparency transp2 = layer2.getRenderTransparency(); |
93 |
assertNotNull(transp1); |
94 |
assertNotNull(transp2); |
95 |
assertEquals(transp1.getAlphaBandNumber(), transp2.getAlphaBandNumber()); |
96 |
assertEquals(transp1.getOpacity(), transp2.getOpacity()); |
97 |
assertEquals(transp1.getTransparencyRange().size(), transp2.getTransparencyRange().size()); |
98 |
} |
99 |
} |