gvsig-raster / org.gvsig.raster / branches / org.gvsig.raster_dataaccess_refactoring / org.gvsig.raster.lib / org.gvsig.raster.lib.impl / src / main / java / org / gvsig / raster / impl / store / AbstractRasterDataParameters.java @ 2370
History | View | Annotate | Download (5.79 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 |
|
27 |
import org.cresques.DataTypes; |
28 |
import org.cresques.cts.IProjection; |
29 |
import org.gvsig.fmap.crs.CRSFactory; |
30 |
import org.gvsig.fmap.dal.coverage.store.RasterDataServerExplorer; |
31 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
32 |
import org.gvsig.fmap.dal.spi.AbstractDataParameters; |
33 |
import org.gvsig.tools.dynobject.DynStruct; |
34 |
|
35 |
/**
|
36 |
* Base class for all kind of parameters in raster
|
37 |
* TODO: Now it only accepts files. Maybe in the future other kind of sources could be accepted like remote services (URL)
|
38 |
*
|
39 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
40 |
*/
|
41 |
public abstract class AbstractRasterDataParameters extends AbstractDataParameters implements |
42 |
RasterDataParameters { |
43 |
public static final String PERSISTENT_NAME = "AbstractRasterDataParameters_Persistent"; |
44 |
public static final String PERSISTENT_DESCRIPTION = "AbstractRasterDataParameters Persistent"; |
45 |
|
46 |
private static final String FIELD_CRS = "crs"; |
47 |
private static final String FIELD_FRAME = "frame"; |
48 |
private static final String FIELD_ALPHABAND = "alphaband"; |
49 |
private static final String FIELD_VISIBLE = "visible"; |
50 |
private static final String FIELD_REPROJ_OPTION = "selected_option"; |
51 |
|
52 |
protected IProjection crs = null; |
53 |
|
54 |
|
55 |
public static void registerDynClass(DynStruct definition) { |
56 |
definition.addDynFieldString(FIELD_URI) |
57 |
.setDescription("Uniform Resource Identifier (File name or URL)")
|
58 |
.setType(DataTypes.STRING) |
59 |
.setMandatory(false);
|
60 |
|
61 |
definition.addDynFieldInt(FIELD_FRAME) |
62 |
.setDescription("frame")
|
63 |
.setType(DataTypes.INT) |
64 |
.setMandatory(false)
|
65 |
.setHidden(true);
|
66 |
|
67 |
definition.addDynFieldInt(FIELD_ALPHABAND) |
68 |
.setDescription("alphaband")
|
69 |
.setType(DataTypes.INT) |
70 |
.setMandatory(false)
|
71 |
.setHidden(true);
|
72 |
|
73 |
definition.addDynFieldBoolean(FIELD_VISIBLE) |
74 |
.setDescription("If the boolean in i position is true, that means that the i provider is visible")
|
75 |
.setMandatory(false)
|
76 |
.setHidden(true);
|
77 |
|
78 |
definition.addDynFieldInt(FIELD_REPROJ_OPTION) |
79 |
.setDescription("Reprojection option")
|
80 |
.setType(DataTypes.INT) |
81 |
.setDefaultFieldValue(new Integer(0)) |
82 |
.setMandatory(false)
|
83 |
.setHidden(true);
|
84 |
|
85 |
definition.addDynFieldFile(FIELD_RMF_FOLDER) |
86 |
.setDescription("Folder to store the RMF file")
|
87 |
.setMandatory(false)
|
88 |
.setHidden(true);
|
89 |
|
90 |
/*definition.addDynFieldObject(FIELD_CRS)
|
91 |
.setDescription("CRS")
|
92 |
.setMandatory(false)
|
93 |
.setHidden(true);*/
|
94 |
} |
95 |
|
96 |
public void assignFields(RasterDataParameters par, RasterDataServerExplorer explorer) { |
97 |
setRMFFolder(par.getRMFFolder()); |
98 |
setReprojectionOption(par.getReprojectionOption()); |
99 |
setVisible(par.isVisible()); |
100 |
setAlphaBand(par.getAlphaBand()); |
101 |
setFrame(par.getFrame()); |
102 |
setURI(par.getURI()); |
103 |
} |
104 |
|
105 |
public AbstractRasterDataParameters() {
|
106 |
super();
|
107 |
} |
108 |
|
109 |
public void setReprojectionOption(int option) { |
110 |
this.setDynValue(FIELD_REPROJ_OPTION, option);
|
111 |
} |
112 |
|
113 |
public int getReprojectionOption() { |
114 |
Integer b = (Integer)getDynValue(FIELD_REPROJ_OPTION); |
115 |
if(b != null) |
116 |
return ((Integer)b).intValue(); |
117 |
return 0; |
118 |
} |
119 |
|
120 |
public boolean isValid() { |
121 |
return (this.getURI() != null); |
122 |
} |
123 |
|
124 |
public String getURI() { |
125 |
return (String) this.getDynValue(FIELD_URI); |
126 |
} |
127 |
|
128 |
public void setURI(String uri) { |
129 |
this.setDynValue(FIELD_URI, uri);
|
130 |
} |
131 |
|
132 |
public void setRMFFolder(File rmfFolder) { |
133 |
this.setDynValue(FIELD_RMF_FOLDER, rmfFolder);
|
134 |
} |
135 |
|
136 |
public File getRMFFolder() { |
137 |
return (File) this.getDynValue(FIELD_RMF_FOLDER); |
138 |
} |
139 |
|
140 |
public String getSRSID() { |
141 |
if (crs == null) { |
142 |
return null; |
143 |
} |
144 |
return crs.getAbrev();
|
145 |
} |
146 |
|
147 |
public void setSRSID(String srsid) { |
148 |
if (srsid == null) { |
149 |
crs = null;
|
150 |
} else {
|
151 |
crs = CRSFactory.getCRS(srsid); |
152 |
} |
153 |
} |
154 |
|
155 |
public void setSRS(IProjection srs) { |
156 |
this.crs = srs;
|
157 |
} |
158 |
|
159 |
public IProjection getSRS() {
|
160 |
if (this.getSRSID() == null) { |
161 |
return null; |
162 |
} |
163 |
return 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 |
} |