Statistics
| Revision:

gvsig-raster / org.gvsig.raster / branches / org.gvsig.raster.2.4 / org.gvsig.raster / org.gvsig.fmap.mapcontext.raster.swing / org.gvsig.fmap.mapcontext.raster.swing.impl / src / main / java / org / gvsig / fmap / mapcontext / raster / swing / impl / bands / RasterStoreBand.java @ 6703

History | View | Annotate | Download (3.78 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.api.RasterStore;
30
import org.gvsig.raster.lib.buffer.api.NoData;
31

    
32

    
33
/**
34
 * @author fdiaz
35
 *
36
 */
37
public class RasterStoreBand {
38

    
39
    private static final Logger LOG = LoggerFactory.getLogger(RasterStoreBand.class);
40

    
41
    private RasterStore store;
42
    private int band;
43
    private String bandName;
44
    private Number noDataNumber;
45
    private String bandColorInterpretation;
46
    private int dataType;
47

    
48
    /**
49
     * @param store
50
     */
51
    public RasterStoreBand(RasterStore store) {
52
        this.store = store;
53
        this.setBand(0);
54
        initializeNoData();
55
    }
56

    
57

    
58
    /**
59
     * @param store
60
     * @param band
61
     */
62
    public RasterStoreBand(RasterStore store, int band) {
63
        this.store = store;
64
        this.setBand(band);
65
    }
66

    
67
    private void initializeNoData() {
68
        try {
69
            NoData noData = this.store.getRasterSet().getBand(band).getNoData();
70
            if(noData!=null){
71
                noDataNumber = noData.getValue();
72
            }
73
        } catch (DataException e) {
74
            LOG.warn("Can't get raster set of the store '"+this.store+"'", e);
75
        }
76
    }
77

    
78
    /**
79
     * @return the store
80
     */
81
    public RasterStore getStore() {
82
        return store;
83
    }
84

    
85

    
86
    /**
87
     * @return the band
88
     */
89
    public int getBand() {
90
        return band;
91
    }
92

    
93
    /**
94
     * @param band the band to set
95
     */
96
    public void setBand(int band) {
97
        if(band<0 || band>=store.getBands()){
98
            throw new IllegalArgumentException("Out of bounds. Band ='"+band+"' but store has "+store.getBands()+" bands.");
99
        }
100
        this.band = band;
101
    }
102

    
103
    /**
104
     * @return
105
     */
106
    public String getBandColorInterpretation() {
107
        return bandColorInterpretation;
108
    }
109

    
110
    /**
111
     * @param bandColorInterpretation
112
     */
113
    public void setBandColorInterpretation(String bandColorInterpretation) {
114
        this.bandColorInterpretation = bandColorInterpretation;
115
    }
116

    
117
    /**
118
     * @return
119
     */
120
    public Number getNoDataNumber() {
121
        return this.noDataNumber;
122

    
123
    }
124

    
125
    /**
126
     * @param noDataNumber
127
     */
128
    public void setNoDataNumber(Number noDataNumber) {
129
        this.noDataNumber = noDataNumber;
130
    }
131

    
132

    
133
    /**
134
     * @return the bandName
135
     */
136
    public String getBandName() {
137
        return bandName;
138
    }
139

    
140

    
141
    /**
142
     * @param bandName the bandName to set
143
     */
144
    public void setBandName(String bandName) {
145
        this.bandName = bandName;
146
    }
147

    
148

    
149
    /**
150
     * @return the dataType
151
     */
152
    public int getDataType() {
153
        return dataType;
154
    }
155

    
156

    
157
    /**
158
     * @param dataType the dataType to set
159
     */
160
    public void setDataType(int dataType) {
161
        this.dataType = dataType;
162
    }
163

    
164
}