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 / AbstractNewRasterStoreParameters.java @ 2438
History | View | Annotate | Download (6.9 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.awt.geom.AffineTransform; |
26 |
import java.io.File; |
27 |
|
28 |
import org.cresques.cts.IProjection; |
29 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
30 |
import org.gvsig.fmap.dal.coverage.datastruct.Params; |
31 |
import org.gvsig.fmap.dal.coverage.store.DataServerWriter; |
32 |
import org.gvsig.fmap.dal.coverage.store.parameter.NewRasterStoreParameters; |
33 |
import org.gvsig.tools.ToolsLocator; |
34 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
35 |
import org.gvsig.tools.dynobject.DynClass; |
36 |
import org.gvsig.tools.dynobject.DynField; |
37 |
import org.gvsig.tools.dynobject.DynObjectManager; |
38 |
|
39 |
/**
|
40 |
* This class represents parameters that we need to create a new
|
41 |
* raster source.
|
42 |
*
|
43 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
44 |
*/
|
45 |
public abstract class AbstractNewRasterStoreParameters extends AbstractRasterFileDataParameters |
46 |
implements NewRasterStoreParameters {
|
47 |
public static final String DYNCLASS_NAME = "NewRasterStoreParameters"; |
48 |
protected DelegatedDynObject delegatedDynObject = null; |
49 |
private static DynClass DYNCLASS = null; |
50 |
private Buffer buffer = null; |
51 |
|
52 |
public AbstractNewRasterStoreParameters() {
|
53 |
super();
|
54 |
initialize(); |
55 |
} |
56 |
|
57 |
public static void registerDynClass() { |
58 |
DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
59 |
DynClass dynClass = dynman.get(DYNCLASS_NAME); |
60 |
DynField field; |
61 |
if (dynClass == null) { |
62 |
dynClass = dynman.add(DYNCLASS_NAME); |
63 |
|
64 |
field = dynClass.addDynFieldObject(FIELD_DATA_SERVER); |
65 |
field.setDescription("Data server");
|
66 |
field.setClassOfValue(Object.class);
|
67 |
field.setMandatory(false);
|
68 |
|
69 |
field = dynClass.addDynField(FIELD_SRS); |
70 |
field.setDescription("SRS");
|
71 |
field.setClassOfValue(Object.class);
|
72 |
field.setMandatory(false);
|
73 |
|
74 |
field = dynClass.addDynFieldObject(FIELD_PARAMS); |
75 |
field.setDescription("Driver parameters");
|
76 |
field.setClassOfValue(Object.class);
|
77 |
field.setMandatory(false);
|
78 |
|
79 |
field = dynClass.addDynFieldInt(FIELD_BAND); |
80 |
field.setDescription("band");
|
81 |
field.setClassOfValue(Integer.class);
|
82 |
field.setMandatory(false);
|
83 |
|
84 |
field = dynClass.addDynFieldString(FIELD_WKT); |
85 |
field.setDescription("");
|
86 |
field.setMandatory(false);
|
87 |
field.setClassOfValue(String.class);
|
88 |
|
89 |
field = dynClass.addDynFieldArray(FIELD_COLORINTERPRETATION); |
90 |
field.setDescription("Color interpretation by band");
|
91 |
field.setMandatory(false);
|
92 |
field.setClassOfValue(String.class);
|
93 |
|
94 |
field = dynClass.addDynFieldString(FIELD_AFFINETRANSFORM); |
95 |
field.setDescription("Affine transform");
|
96 |
field.setClassOfValue(String.class);
|
97 |
field.setMandatory(false);
|
98 |
|
99 |
field = dynClass.addDynFieldString(FIELD_URI); |
100 |
field.setDescription("Uniform Resource Identifier (File name or URL)");
|
101 |
field.setClassOfValue(String.class);
|
102 |
field.setMandatory(false);
|
103 |
|
104 |
DYNCLASS = dynClass; |
105 |
} |
106 |
|
107 |
} |
108 |
|
109 |
protected void initialize() { |
110 |
this.delegatedDynObject = (DelegatedDynObject) ToolsLocator
|
111 |
.getDynObjectManager().createDynObject( |
112 |
DYNCLASS); |
113 |
} |
114 |
|
115 |
protected DelegatedDynObject getDelegatedDynObject() {
|
116 |
return this.delegatedDynObject; |
117 |
} |
118 |
|
119 |
public Buffer getBuffer() { |
120 |
return buffer;
|
121 |
} |
122 |
|
123 |
public String[] getColorInterpretation() { |
124 |
return (String[])getDynValue(FIELD_COLORINTERPRETATION); |
125 |
} |
126 |
|
127 |
public String getFileName() { |
128 |
String s = getFile().toString();
|
129 |
int n = s.lastIndexOf(File.separator); |
130 |
if(n >= 0) |
131 |
return s.substring(n + 1, s.length()); |
132 |
return s;
|
133 |
} |
134 |
|
135 |
public String getPath() { |
136 |
String s = getFile().toString();
|
137 |
int n = s.lastIndexOf(File.separator); |
138 |
if(n >= 0) |
139 |
return s.substring(0, n); |
140 |
return s;
|
141 |
} |
142 |
|
143 |
public IProjection getProjection() {
|
144 |
return (IProjection) getDynValue(FIELD_SRS);
|
145 |
} |
146 |
|
147 |
public Params getDriverParams() {
|
148 |
return (Params)getDynValue(FIELD_PARAMS);
|
149 |
} |
150 |
|
151 |
public void setDriverParams(Params params) { |
152 |
this.setDynValue(FIELD_PARAMS, params);
|
153 |
} |
154 |
|
155 |
public void setBuffer(Buffer buffer) { |
156 |
this.buffer = buffer;
|
157 |
} |
158 |
|
159 |
public int getBand() { |
160 |
if(getDynValue(FIELD_BAND) == null) |
161 |
return -1; |
162 |
return (Integer)getDynValue(FIELD_BAND); |
163 |
} |
164 |
|
165 |
public void setBand(int n) { |
166 |
this.setDynValue(FIELD_BAND, n);
|
167 |
} |
168 |
|
169 |
public void setAffineTransform(AffineTransform at) { |
170 |
StringBuilder str = new StringBuilder(); |
171 |
str.append(at.getScaleX()); |
172 |
str.append(",");
|
173 |
str.append(at.getShearX()); |
174 |
str.append(",");
|
175 |
str.append(at.getShearY()); |
176 |
str.append(",");
|
177 |
str.append(at.getScaleY()); |
178 |
str.append(",");
|
179 |
str.append(at.getTranslateX()); |
180 |
str.append(",");
|
181 |
str.append(at.getTranslateY()); |
182 |
this.setDynValue(FIELD_AFFINETRANSFORM, str);
|
183 |
} |
184 |
|
185 |
public AffineTransform getAffineTransform() { |
186 |
if(getDynValue(FIELD_AFFINETRANSFORM) != null) { |
187 |
String str = (String)getDynValue(FIELD_AFFINETRANSFORM); |
188 |
String[] values = str.split(","); |
189 |
return new AffineTransform( |
190 |
new Double(values[0]), |
191 |
new Double(values[1]), |
192 |
new Double(values[2]), |
193 |
new Double(values[3]), |
194 |
new Double(values[4]), |
195 |
new Double(values[5])); |
196 |
} |
197 |
return null; |
198 |
} |
199 |
|
200 |
public void setWktProjection(String wkt) { |
201 |
this.setDynValue(FIELD_WKT, wkt);
|
202 |
} |
203 |
|
204 |
public String getWktProjection() { |
205 |
return (String)getDynValue(FIELD_WKT); |
206 |
} |
207 |
|
208 |
public void setColorInterpretation(String[] colorInterpretation) { |
209 |
this.setDynValue(FIELD_COLORINTERPRETATION, colorInterpretation);
|
210 |
} |
211 |
|
212 |
public void setDestination(String path, String fileName) { |
213 |
this.setFile(new File(path, fileName)); |
214 |
} |
215 |
|
216 |
public void setDestination(String fileName) { |
217 |
this.setFile(new File(fileName)); |
218 |
} |
219 |
|
220 |
public void setProjection(IProjection projection) { |
221 |
this.setDynValue(FIELD_SRS, projection);
|
222 |
} |
223 |
|
224 |
public boolean isValid() { |
225 |
if(getFileName() == null) |
226 |
return false; |
227 |
return true; |
228 |
} |
229 |
|
230 |
public DataServerWriter getDataServer() {
|
231 |
return (DataServerWriter)getDynValue(FIELD_DATA_SERVER);
|
232 |
} |
233 |
|
234 |
public void setDataServer(DataServerWriter dataServer) { |
235 |
this.setDynValue(FIELD_DATA_SERVER, dataServer);
|
236 |
} |
237 |
} |