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 / AbstractRasterStoreParameters.java @ 162
History | View | Annotate | Download (4.07 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 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2009 IVER T.I {{Task}}
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.raster.impl.store; |
29 |
|
30 |
import java.io.File; |
31 |
|
32 |
import org.cresques.cts.IProjection; |
33 |
import org.gvsig.fmap.crs.CRSFactory; |
34 |
import org.gvsig.fmap.dal.DataTypes; |
35 |
import org.gvsig.fmap.dal.coverage.store.RasterStoreParameters; |
36 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
37 |
import org.gvsig.fmap.dal.spi.AbstractDataParameters; |
38 |
import org.gvsig.tools.ToolsLocator; |
39 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
40 |
import org.gvsig.tools.dynobject.DynClass; |
41 |
import org.gvsig.tools.dynobject.DynField; |
42 |
import org.gvsig.tools.dynobject.DynObjectManager; |
43 |
|
44 |
/**
|
45 |
* Base class for all kind of parameters in raster
|
46 |
* TODO: Now it only accepts files. Maybe in the future other kind of sources could be accepted like remote services (URL)
|
47 |
*
|
48 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
49 |
*/
|
50 |
public abstract class AbstractRasterStoreParameters extends AbstractDataParameters implements |
51 |
RasterStoreParameters, FilesystemStoreParameters { |
52 |
|
53 |
protected static final String FIELD_FILENAME = "filename"; |
54 |
private static final String FIELD_SRS = "srs"; |
55 |
protected static DynClass DYNCLASS = null; |
56 |
|
57 |
private DelegatedDynObject delegatedDynObject;
|
58 |
|
59 |
@SuppressWarnings("deprecation") |
60 |
public static void registerDynClass() { |
61 |
DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
62 |
DynClass dynClass; |
63 |
DynField field; |
64 |
|
65 |
if(dynman == null) |
66 |
return;
|
67 |
|
68 |
if (DYNCLASS == null) { |
69 |
dynClass = dynman.add(DYNCLASS_NAME); |
70 |
|
71 |
field = dynClass.addDynField(FIELD_FILENAME); |
72 |
field.setTheTypeOfAvailableValues(DynField.ANY); |
73 |
field.setDescription("File name");
|
74 |
field.setType(DataTypes.STRING); |
75 |
field.setMandatory(true);
|
76 |
|
77 |
|
78 |
field = dynClass.addDynField(FIELD_SRS); |
79 |
field.setTheTypeOfAvailableValues(DynField.ANY); |
80 |
field.setDescription("SRS");
|
81 |
field.setType(DataTypes.CRS); |
82 |
field.setMandatory(true);
|
83 |
|
84 |
DYNCLASS = dynClass; |
85 |
} |
86 |
|
87 |
} |
88 |
|
89 |
public AbstractRasterStoreParameters() {
|
90 |
super();
|
91 |
initialize(); |
92 |
} |
93 |
|
94 |
protected void initialize() { |
95 |
this.delegatedDynObject = (DelegatedDynObject) ToolsLocator
|
96 |
.getDynObjectManager().createDynObject( |
97 |
DYNCLASS); |
98 |
} |
99 |
|
100 |
protected DelegatedDynObject getDelegatedDynObject() {
|
101 |
return delegatedDynObject;
|
102 |
} |
103 |
|
104 |
public boolean isValid() { |
105 |
return (this.getFileName() != null); |
106 |
} |
107 |
|
108 |
|
109 |
public String getFileName() { |
110 |
return (String) this.getDynValue(FIELD_FILENAME); |
111 |
} |
112 |
|
113 |
public File getFile() { |
114 |
return new File((String) this.getDynValue(FIELD_FILENAME)); |
115 |
} |
116 |
|
117 |
public void setFile(File aFile) { |
118 |
this.setDynValue(FIELD_FILENAME, aFile.getPath());
|
119 |
} |
120 |
|
121 |
public void setFileName(String aFileName) { |
122 |
this.setDynValue(FIELD_FILENAME, aFileName);
|
123 |
} |
124 |
|
125 |
public String getSRSID() { |
126 |
IProjection srs = (IProjection) getDynValue(FIELD_SRS); |
127 |
if (srs == null) { |
128 |
return null; |
129 |
} |
130 |
return srs.getAbrev();
|
131 |
} |
132 |
|
133 |
public void setSRSID(String srsid) { |
134 |
if (srsid == null) { |
135 |
setDynValue(FIELD_SRS, null);
|
136 |
} else {
|
137 |
setDynValue(FIELD_SRS, CRSFactory.getCRS(srsid)); |
138 |
} |
139 |
} |
140 |
|
141 |
public void setSRS(IProjection srs) { |
142 |
setDynValue(FIELD_SRS, srs); |
143 |
} |
144 |
|
145 |
public IProjection getSRS() {
|
146 |
if (this.getSRSID() == null) { |
147 |
return null; |
148 |
} |
149 |
return (IProjection) getDynValue(FIELD_SRS);
|
150 |
} |
151 |
|
152 |
} |