Statistics
| Revision:

gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.impl / src / main / java / org / gvsig / raster / impl / store / AbstractRasterDataParameters.java @ 4181

History | View | Annotate | Download (5.75 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
package org.gvsig.raster.impl.store;
24

    
25
import java.io.File;
26
import java.net.URI;
27

    
28
import org.cresques.DataTypes;
29
import org.cresques.cts.IProjection;
30

    
31
import org.gvsig.fmap.crs.CRSFactory;
32
import org.gvsig.fmap.dal.coverage.store.RasterDataServerExplorer;
33
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
34
import org.gvsig.fmap.dal.spi.AbstractDataParameters;
35
import org.gvsig.tools.dynobject.DynStruct;
36

    
37
/**
38
 * Base class for all kind of parameters in raster
39
 * TODO: Now it only accepts files. Maybe in the future other kind of sources could be accepted like remote services (URL)
40
 *
41
 * @author Nacho Brodin (nachobrodin@gmail.com)
42
 */
43
public abstract class AbstractRasterDataParameters extends AbstractDataParameters implements
44
                RasterDataParameters {
45
        public static final String     PERSISTENT_NAME        = "AbstractRasterDataParameters_Persistent";
46
    public static final String     PERSISTENT_DESCRIPTION = "AbstractRasterDataParameters Persistent";
47

    
48
        private static final String    FIELD_FRAME            = "frame";
49
        private static final String    FIELD_ALPHABAND        = "alphaband";
50
        private static final String    FIELD_VISIBLE          = "visible";
51
        private static final String    FIELD_REPROJ_OPTION    = "selected_option";
52

    
53
        protected IProjection          crs                    = null;
54

    
55

    
56
        public static void registerDynClass(DynStruct definition) {
57
                definition.addDynFieldString(FIELD_URI)
58
                .setDescription("Uniform Resource Identifier (File name or URL)")
59
                .setType(DataTypes.URI)
60
                .setMandatory(false);
61

    
62
                definition.addDynFieldInt(FIELD_FRAME)
63
                .setDescription("frame")
64
                .setType(DataTypes.INT)
65
                .setMandatory(false)
66
                .setHidden(true);
67

    
68
                definition.addDynFieldInt(FIELD_ALPHABAND)
69
                .setDescription("alphaband")
70
                .setType(DataTypes.INT)
71
                .setMandatory(false)
72
                .setHidden(true);
73

    
74
                definition.addDynFieldBoolean(FIELD_VISIBLE)
75
        .setDescription("If the boolean in i position is true, that means that the i provider is visible")
76
        .setMandatory(false)
77
        .setHidden(true);
78

    
79
        definition.addDynFieldInt(FIELD_REPROJ_OPTION)
80
                .setDescription("Reprojection option")
81
                .setType(DataTypes.INT)
82
                .setDefaultFieldValue(new Integer(0))
83
                .setMandatory(false)
84
                .setHidden(true);
85

    
86
                definition.addDynFieldString(FIELD_RMF_FOLDER)
87
                .setDescription("Folder to store the RMF file")
88
        .setType(DataTypes.FILE)
89
                .setMandatory(false)
90
                .setHidden(true);
91

    
92
                /*definition.addDynFieldObject(FIELD_CRS)
93
                .setDescription("CRS")
94
                .setMandatory(false)
95
                .setHidden(true);*/
96
        }
97

    
98
        public void assignFields(RasterDataParameters par, RasterDataServerExplorer explorer) {
99
                setRMFFolder(par.getRMFFolder());
100
                setReprojectionOption(par.getReprojectionOption());
101
                setVisible(par.isVisible());
102
                setAlphaBand(par.getAlphaBand());
103
                setFrame(par.getFrame());
104
                setURI(par.getURI());
105
        }
106

    
107
        public AbstractRasterDataParameters() {
108
                super();
109
        }
110

    
111
        public void setReprojectionOption(int option) {
112
                this.setDynValue(FIELD_REPROJ_OPTION, option);
113
        }
114

    
115
        public int getReprojectionOption() {
116
                Integer b = (Integer)getDynValue(FIELD_REPROJ_OPTION);
117
                if(b != null)
118
                        return ((Integer)b).intValue();
119
                return 0;
120
        }
121

    
122
        public boolean isValid() {
123
                return (this.getURI() != null);
124
        }
125

    
126
        public URI getURI() {
127
                return (URI) this.getDynValue(FIELD_URI);
128
        }
129

    
130
        public void setURI(URI uri) {
131
                this.setDynValue(FIELD_URI, uri);
132
        }
133

    
134
    public void setRMFFolder(File rmfFolder) {
135
        this.setDynValue(FIELD_RMF_FOLDER, rmfFolder);
136
    }
137

    
138
        public File getRMFFolder() {
139
                return (File)this.getDynValue(FIELD_RMF_FOLDER);
140
        }
141

    
142
        public String getSRSID() {
143
                if (crs == null) {
144
                        return null;
145
                }
146
                return crs.getAbrev();
147
        }
148

    
149
        public void setSRSID(String srsid) {
150
                if (srsid == null) {
151
                        crs = null;
152
                } else {
153
                        crs = CRSFactory.getCRS(srsid);
154
                }
155
        }
156

    
157
        public void setSRS(IProjection srs) {
158
                this.crs = srs;
159
        }
160

    
161
        public IProjection getSRS() {
162
                if (this.getSRSID() == null) {
163
                        return null;
164
                }
165
                return crs;
166
        }
167

    
168
        /**
169
         * Sets the number of alpha band
170
         * @param alphaBand
171
         */
172
        public void setAlphaBand(int alphaBand) {
173
                this.setDynValue(FIELD_ALPHABAND, new Integer(alphaBand));
174
        }
175

    
176
        /**
177
         * Sets the frame width
178
         * @param frame
179
         */
180
        public void setFrame(int frame) {
181
                this.setDynValue(FIELD_FRAME, new Integer(frame));
182
        }
183

    
184
        /**
185
         * Gets the number of alpha band
186
         * @param alphaBand
187
         */
188
        public int getAlphaBand() {
189
                Integer b = (Integer)getDynValue(FIELD_ALPHABAND);
190
                if(b != null)
191
                        return ((Integer)b).intValue();
192
                return 0;
193
        }
194

    
195
        /**
196
         * Gets the frame width
197
         * @param frame
198
         */
199
        public int getFrame() {
200
                Integer b = (Integer)getDynValue(FIELD_FRAME);
201
                if(b != null)
202
                        return ((Integer)b).intValue();
203
                return 0;
204
        }
205

    
206
        public boolean isVisible() {
207
                Boolean b = (Boolean)getDynValue(FIELD_VISIBLE);
208
                if(b != null)
209
                        return ((Boolean)b).booleanValue();
210
                return true;
211
        }
212

    
213
        public void setVisible(boolean visible) {
214
                this.setDynValue(FIELD_VISIBLE, new Boolean(visible));
215
        }
216

    
217
        public boolean isSourceTiled() {
218
                return false;
219
        }
220
}