Statistics
| Revision:

gvsig-raster / org.gvsig.raster / branches / org.gvisg.raster_proyeccion_al_vuelo / org.gvsig.raster.lib / org.gvsig.raster.lib.impl / src / main / java / org / gvsig / raster / impl / store / AbstractRasterDataParameters.java @ 5461

History | View | Annotate | Download (5.78 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
        /**
54
         * @param definition
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
                setType(org.cresques.DataTypes.CRS).
95
                setMandatory(false);
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
                setSRS(par.getSRS());
106
        }
107

    
108
        /**
109
         *
110
         */
111
        public AbstractRasterDataParameters() {
112
                super();
113
        }
114

    
115
        public void setReprojectionOption(int option) {
116
                this.setDynValue(FIELD_REPROJ_OPTION, option);
117
        }
118

    
119
        public int getReprojectionOption() {
120
                Integer b = (Integer)getDynValue(FIELD_REPROJ_OPTION);
121
                if(b != null)
122
                        return ((Integer)b).intValue();
123
                return 0;
124
        }
125

    
126
        public boolean isValid() {
127
                return (this.getURI() != null);
128
        }
129

    
130
        public URI getURI() {
131
                return (URI) this.getDynValue(FIELD_URI);
132
        }
133

    
134
        public void setURI(URI uri) {
135
                this.setDynValue(FIELD_URI, uri);
136
        }
137

    
138
    public void setRMFFolder(File rmfFolder) {
139
        this.setDynValue(FIELD_RMF_FOLDER, rmfFolder);
140
    }
141

    
142
        public File getRMFFolder() {
143
                return (File)this.getDynValue(FIELD_RMF_FOLDER);
144
        }
145

    
146
        public String getSRSID() {
147
            return getSRS() != null ? getSRS().getAbrev() : null;
148
        }
149

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

    
158
        public void setSRS(IProjection srs) {
159
            this.setDynValue(FIELD_CRS, srs);
160
        }
161

    
162
        public IProjection getSRS() {
163
                return (IProjection) this.getDynValue(FIELD_CRS);
164
        }
165

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

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

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

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

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

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

    
215
        public boolean isSourceTiled() {
216
                return false;
217
        }
218
}