svn-gvsig-desktop / branches / org.gvsig.desktop-2018a / org.gvsig.desktop.library / org.gvsig.fmap.mapcontext.swing / org.gvsig.fmap.mapcontext.swing.impl / src / main / java / org / gvsig / fmap / mapcontext / raster / swing / impl / bands / RasterStoreBand.java @ 43876
History | View | Annotate | Download (4.13 KB)
1 |
/* gvSIG. Desktop Geographic Information System.
|
---|---|
2 |
*
|
3 |
* Copyright ? 2007-2017 gvSIG Association
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
18 |
* MA 02110-1301, USA.
|
19 |
*
|
20 |
* For any additional information, do not hesitate to contact us
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
22 |
*/
|
23 |
package org.gvsig.fmap.mapcontext.raster.swing.impl.bands; |
24 |
|
25 |
import org.slf4j.Logger; |
26 |
import org.slf4j.LoggerFactory; |
27 |
|
28 |
import org.gvsig.fmap.dal.exception.DataException; |
29 |
import org.gvsig.fmap.dal.raster.RasterStore; |
30 |
import org.gvsig.raster.lib.buffer.api.NoData; |
31 |
import org.gvsig.tools.dispose.DisposeUtils; |
32 |
import org.gvsig.tools.dispose.impl.AbstractDisposable; |
33 |
import org.gvsig.tools.exception.BaseException; |
34 |
|
35 |
|
36 |
/**
|
37 |
* @author fdiaz
|
38 |
*
|
39 |
*/
|
40 |
public class RasterStoreBand extends AbstractDisposable{ |
41 |
|
42 |
private static final Logger LOG = LoggerFactory.getLogger(RasterStoreBand.class); |
43 |
|
44 |
private RasterStore store;
|
45 |
private int band; |
46 |
private String bandName; |
47 |
private Number noDataNumber; |
48 |
private String bandColorInterpretation; |
49 |
private int dataType; |
50 |
|
51 |
/**
|
52 |
* @param store
|
53 |
*/
|
54 |
public RasterStoreBand(RasterStore store) {
|
55 |
this.store = store;
|
56 |
DisposeUtils.bind(this.store);
|
57 |
this.setBand(0); |
58 |
initializeNoData(); |
59 |
} |
60 |
|
61 |
|
62 |
/**
|
63 |
* @param store
|
64 |
* @param band
|
65 |
*/
|
66 |
public RasterStoreBand(RasterStore store, int band) { |
67 |
this.store = store;
|
68 |
DisposeUtils.bind(this.store);
|
69 |
this.setBand(band);
|
70 |
} |
71 |
|
72 |
private void initializeNoData() { |
73 |
try {
|
74 |
NoData noData = this.store.getRasterSet().getBand(band).getNoData();
|
75 |
if(noData!=null){ |
76 |
noDataNumber = noData.getValue(); |
77 |
} |
78 |
} catch (DataException e) {
|
79 |
LOG.warn("Can't get raster set of the store '"+this.store+"'", e); |
80 |
} |
81 |
} |
82 |
|
83 |
/**
|
84 |
* @return the store
|
85 |
*/
|
86 |
public RasterStore getStore() {
|
87 |
return store;
|
88 |
} |
89 |
|
90 |
|
91 |
/**
|
92 |
* @return the band
|
93 |
*/
|
94 |
public int getBand() { |
95 |
return band;
|
96 |
} |
97 |
|
98 |
/**
|
99 |
* @param band the band to set
|
100 |
*/
|
101 |
public void setBand(int band) { |
102 |
if(band<0 || band>=store.getBands()){ |
103 |
throw new IllegalArgumentException("Out of bounds. Band ='"+band+"' but store has "+store.getBands()+" bands."); |
104 |
} |
105 |
this.band = band;
|
106 |
} |
107 |
|
108 |
/**
|
109 |
* @return
|
110 |
*/
|
111 |
public String getBandColorInterpretation() { |
112 |
return bandColorInterpretation;
|
113 |
} |
114 |
|
115 |
/**
|
116 |
* @param bandColorInterpretation
|
117 |
*/
|
118 |
public void setBandColorInterpretation(String bandColorInterpretation) { |
119 |
this.bandColorInterpretation = bandColorInterpretation;
|
120 |
} |
121 |
|
122 |
/**
|
123 |
* @return
|
124 |
*/
|
125 |
public Number getNoDataNumber() { |
126 |
return this.noDataNumber; |
127 |
|
128 |
} |
129 |
|
130 |
/**
|
131 |
* @param noDataNumber
|
132 |
*/
|
133 |
public void setNoDataNumber(Number noDataNumber) { |
134 |
this.noDataNumber = noDataNumber;
|
135 |
} |
136 |
|
137 |
|
138 |
/**
|
139 |
* @return the bandName
|
140 |
*/
|
141 |
public String getBandName() { |
142 |
return bandName;
|
143 |
} |
144 |
|
145 |
|
146 |
/**
|
147 |
* @param bandName the bandName to set
|
148 |
*/
|
149 |
public void setBandName(String bandName) { |
150 |
this.bandName = bandName;
|
151 |
} |
152 |
|
153 |
|
154 |
/**
|
155 |
* @return the dataType
|
156 |
*/
|
157 |
public int getDataType() { |
158 |
return dataType;
|
159 |
} |
160 |
|
161 |
|
162 |
/**
|
163 |
* @param dataType the dataType to set
|
164 |
*/
|
165 |
public void setDataType(int dataType) { |
166 |
this.dataType = dataType;
|
167 |
} |
168 |
|
169 |
|
170 |
@Override
|
171 |
protected void doDispose() throws BaseException { |
172 |
DisposeUtils.dispose(store); |
173 |
} |
174 |
|
175 |
} |