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 @ 723
History | View | Annotate | Download (5.31 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 org.cresques.cts.IProjection; |
31 |
import org.gvsig.fmap.crs.CRSFactory; |
32 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
33 |
import org.gvsig.fmap.dal.spi.AbstractDataParameters; |
34 |
import org.gvsig.tools.ToolsLocator; |
35 |
import org.gvsig.tools.dynobject.DynClass; |
36 |
import org.gvsig.tools.dynobject.DynField; |
37 |
import org.gvsig.tools.dynobject.DynObjectManager; |
38 |
|
39 |
/**
|
40 |
* Base class for all kind of parameters in raster
|
41 |
* TODO: Now it only accepts files. Maybe in the future other kind of sources could be accepted like remote services (URL)
|
42 |
*
|
43 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
44 |
*/
|
45 |
public abstract class AbstractRasterDataParameters extends AbstractDataParameters implements |
46 |
RasterDataParameters { |
47 |
|
48 |
protected static final String FIELD_URI = "uri"; |
49 |
private static final String FIELD_SRS = "srs"; |
50 |
private static final String FIELD_FRAME = "frame"; |
51 |
private static final String FIELD_ALPHABAND = "alphaband"; |
52 |
private static final String FIELD_VISIBLE = "visible"; |
53 |
|
54 |
|
55 |
public static DynClass registerDynClass(String dynClassName) { |
56 |
DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
57 |
DynField field; |
58 |
|
59 |
if(dynman == null) |
60 |
return null; |
61 |
|
62 |
DynClass dynClass = dynman.add(dynClassName); |
63 |
|
64 |
field = dynClass.addDynFieldString(FIELD_URI); |
65 |
field.setDescription("Uniform Resource Identifier (File name or URL)");
|
66 |
field.setClassOfValue(String.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.addDynFieldInt(FIELD_FRAME); |
75 |
field.setDescription("frame");
|
76 |
field.setClassOfValue(Integer.class);
|
77 |
field.setMandatory(false);
|
78 |
|
79 |
field = dynClass.addDynFieldInt(FIELD_ALPHABAND); |
80 |
field.setDescription("alphaband");
|
81 |
field.setClassOfValue(Integer.class);
|
82 |
field.setMandatory(false);
|
83 |
|
84 |
field = dynClass.addDynFieldObject(FIELD_VISIBLE); |
85 |
field.setDescription("If the boolean in i position is true, that means that the i provider is visible");
|
86 |
field.setMandatory(false);
|
87 |
field.setClassOfValue(Object.class);
|
88 |
|
89 |
return dynClass;
|
90 |
} |
91 |
|
92 |
public AbstractRasterDataParameters() {
|
93 |
super();
|
94 |
} |
95 |
|
96 |
public boolean isValid() { |
97 |
return (this.getURI() != null); |
98 |
} |
99 |
|
100 |
/*
|
101 |
* (non-Javadoc)
|
102 |
* @see org.gvsig.fmap.dal.coverage.store.RasterStoreParameters#getURI()
|
103 |
*/
|
104 |
public String getURI() { |
105 |
return (String) this.getDynValue(FIELD_URI); |
106 |
} |
107 |
|
108 |
/*
|
109 |
* (non-Javadoc)
|
110 |
* @see org.gvsig.fmap.dal.coverage.store.RasterStoreParameters#setURI(java.lang.String)
|
111 |
*/
|
112 |
public void setURI(String uri) { |
113 |
this.setDynValue(FIELD_URI, uri);
|
114 |
} |
115 |
|
116 |
public String getSRSID() { |
117 |
IProjection srs = (IProjection) getDynValue(FIELD_SRS); |
118 |
if (srs == null) { |
119 |
return null; |
120 |
} |
121 |
return srs.getAbrev();
|
122 |
} |
123 |
|
124 |
public void setSRSID(String srsid) { |
125 |
if (srsid == null) { |
126 |
setDynValue(FIELD_SRS, null);
|
127 |
} else {
|
128 |
setDynValue(FIELD_SRS, CRSFactory.getCRS(srsid)); |
129 |
} |
130 |
} |
131 |
|
132 |
public void setSRS(IProjection srs) { |
133 |
setDynValue(FIELD_SRS, srs); |
134 |
} |
135 |
|
136 |
public IProjection getSRS() {
|
137 |
if (this.getSRSID() == null) { |
138 |
return null; |
139 |
} |
140 |
return (IProjection) getDynValue(FIELD_SRS);
|
141 |
} |
142 |
|
143 |
/**
|
144 |
* Sets the number of alpha band
|
145 |
* @param alphaBand
|
146 |
*/
|
147 |
public void setAlphaBand(int alphaBand) { |
148 |
this.setDynValue(FIELD_ALPHABAND, new Integer(alphaBand)); |
149 |
} |
150 |
|
151 |
/**
|
152 |
* Sets the frame width
|
153 |
* @param frame
|
154 |
*/
|
155 |
public void setFrame(int frame) { |
156 |
this.setDynValue(FIELD_FRAME, new Integer(frame)); |
157 |
} |
158 |
|
159 |
/**
|
160 |
* Gets the number of alpha band
|
161 |
* @param alphaBand
|
162 |
*/
|
163 |
public int getAlphaBand() { |
164 |
Integer b = (Integer)getDynValue(FIELD_ALPHABAND); |
165 |
if(b != null) |
166 |
return ((Integer)b).intValue(); |
167 |
return 0; |
168 |
} |
169 |
|
170 |
/**
|
171 |
* Gets the frame width
|
172 |
* @param frame
|
173 |
*/
|
174 |
public int getFrame() { |
175 |
Integer b = (Integer)getDynValue(FIELD_FRAME); |
176 |
if(b != null) |
177 |
return ((Integer)b).intValue(); |
178 |
return 0; |
179 |
} |
180 |
|
181 |
/*
|
182 |
* (non-Javadoc)
|
183 |
* @see org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters#isVisible()
|
184 |
*/
|
185 |
public boolean isVisible() { |
186 |
Boolean b = (Boolean)getDynValue(FIELD_VISIBLE); |
187 |
if(b != null) |
188 |
return ((Boolean)b).booleanValue(); |
189 |
return true; |
190 |
} |
191 |
|
192 |
/*
|
193 |
* (non-Javadoc)
|
194 |
* @see org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters#setVisible(boolean)
|
195 |
*/
|
196 |
public void setVisible(boolean visible) { |
197 |
this.setDynValue(FIELD_VISIBLE, new Boolean(visible)); |
198 |
} |
199 |
} |