gvsig-raster / org.gvsig.raster.cache / trunk / org.gvsig.raster.cache / org.gvsig.raster.cache.io / src / main / java / org / gvsig / raster / cache / io / TileDataParametersImpl.java @ 483
History | View | Annotate | Download (6.22 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.cache.io; |
24 |
|
25 |
import org.gvsig.fmap.dal.DataParameters; |
26 |
import org.gvsig.fmap.dal.DataTypes; |
27 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
28 |
import org.gvsig.fmap.dal.coverage.store.parameter.RemoteStoreParameters; |
29 |
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters; |
30 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
31 |
import org.gvsig.raster.cache.tile.provider.TileServer; |
32 |
import org.gvsig.raster.impl.store.AbstractRasterDataParameters; |
33 |
import org.gvsig.raster.impl.store.AbstractRasterFileDataParameters; |
34 |
import org.gvsig.tools.ToolsLocator; |
35 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
36 |
import org.gvsig.tools.dynobject.DynClass; |
37 |
import org.gvsig.tools.dynobject.DynField; |
38 |
import org.gvsig.tools.dynobject.DynObjectManager; |
39 |
|
40 |
/**
|
41 |
* Parameters for the WMTS provider
|
42 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
43 |
*/
|
44 |
public class TileDataParametersImpl extends AbstractRasterFileDataParameters implements TileDataParameters { |
45 |
public static final String FIELD_PARAMETERS = "parameters"; |
46 |
public static final String FIELD_TILESERVER = "tileserver"; |
47 |
public static final String FIELD_SECONDLEVEL = "secondlevel"; |
48 |
public static final String FIELD_NAME = "name"; |
49 |
|
50 |
private DelegatedDynObject delegatedDynObject = null; |
51 |
protected static DynClass DYNCLASS = null; |
52 |
|
53 |
public TileDataParametersImpl() {
|
54 |
super();
|
55 |
initialize(); |
56 |
} |
57 |
|
58 |
protected void initialize() { |
59 |
this.delegatedDynObject = (DelegatedDynObject) ToolsLocator
|
60 |
.getDynObjectManager().createDynObject( |
61 |
DYNCLASS); |
62 |
} |
63 |
|
64 |
@SuppressWarnings("deprecation") |
65 |
public static void registerDynClass() { |
66 |
DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
67 |
DynClass dynClass; |
68 |
DynField field; |
69 |
|
70 |
if(dynman == null) |
71 |
return;
|
72 |
|
73 |
if (DYNCLASS == null) { |
74 |
dynClass = AbstractRasterDataParameters.registerDynClass(TileDataParameters.DYNCLASS_NAME); |
75 |
|
76 |
field = dynClass.addDynField(FIELD_PARAMETERS); |
77 |
field.setTheTypeOfAvailableValues(DynField.ANY); |
78 |
field.setDescription("Provider");
|
79 |
field.setType(DataTypes.OBJECT); |
80 |
field.setMandatory(false);
|
81 |
|
82 |
field = dynClass.addDynField(FIELD_TILESERVER); |
83 |
field.setTheTypeOfAvailableValues(DynField.ANY); |
84 |
field.setDescription("TileServer");
|
85 |
field.setType(DataTypes.OBJECT); |
86 |
field.setMandatory(false);
|
87 |
|
88 |
field = dynClass.addDynField(FIELD_SECONDLEVEL); |
89 |
field.setTheTypeOfAvailableValues(DynField.ANY); |
90 |
field.setDescription("SecondLevelProvider");
|
91 |
field.setType(DataTypes.BOOLEAN); |
92 |
field.setMandatory(false);
|
93 |
|
94 |
field = dynClass.addDynField(FIELD_NAME); |
95 |
field.setTheTypeOfAvailableValues(DynField.ANY); |
96 |
field.setDescription("Name");
|
97 |
field.setType(DataTypes.STRING); |
98 |
field.setMandatory(false);
|
99 |
|
100 |
DYNCLASS = dynClass; |
101 |
} |
102 |
} |
103 |
|
104 |
/*
|
105 |
* (non-Javadoc)
|
106 |
* @see org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters#setDataParameters(org.gvsig.fmap.dal.DataParameters)
|
107 |
*/
|
108 |
public void setDataParameters(DataParameters params) { |
109 |
this.setDynValue(FIELD_PARAMETERS, params);
|
110 |
} |
111 |
|
112 |
/*
|
113 |
* (non-Javadoc)
|
114 |
* @see org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters#getDataParameters()
|
115 |
*/
|
116 |
public DataParameters getDataParameters() {
|
117 |
return (DataParameters) this.getDynValue(FIELD_PARAMETERS); |
118 |
} |
119 |
|
120 |
/*
|
121 |
* (non-Javadoc)
|
122 |
* @see org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters#setTileServer(org.gvsig.raster.cache.tile.provider.TileServer)
|
123 |
*/
|
124 |
public void setTileServer(TileServer tileServer) { |
125 |
this.setDynValue(FIELD_TILESERVER, tileServer);
|
126 |
} |
127 |
|
128 |
/*
|
129 |
* (non-Javadoc)
|
130 |
* @see org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters#getTileServer()
|
131 |
*/
|
132 |
public TileServer getTileServer() {
|
133 |
return (TileServer) this.getDynValue(FIELD_TILESERVER); |
134 |
} |
135 |
|
136 |
/*
|
137 |
* (non-Javadoc)
|
138 |
* @see org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters#isSecondLevelCache()
|
139 |
*/
|
140 |
public boolean isSecondLevelCache() { |
141 |
Object obj = this.getDynValue(FIELD_SECONDLEVEL); |
142 |
if(obj != null && obj instanceof Boolean) |
143 |
return ((Boolean)obj).booleanValue(); |
144 |
return false; |
145 |
} |
146 |
|
147 |
/*
|
148 |
* (non-Javadoc)
|
149 |
* @see org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters#setSecondLevelCache(boolean)
|
150 |
*/
|
151 |
public void setSecondLevelCache(boolean secondLevel) { |
152 |
this.setDynValue(FIELD_SECONDLEVEL, new Boolean(secondLevel)); |
153 |
} |
154 |
|
155 |
/*
|
156 |
* (non-Javadoc)
|
157 |
* @see org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters#getName()
|
158 |
*/
|
159 |
public String getName() { |
160 |
DataParameters p = getDataParameters(); |
161 |
if(p != null) { |
162 |
if(p instanceof RemoteStoreParameters) |
163 |
return ((RasterDataParameters)p).getURI();
|
164 |
if(p instanceof FilesystemStoreParameters) |
165 |
return ((FilesystemStoreParameters)p).getFile().getAbsolutePath();
|
166 |
} |
167 |
return null; |
168 |
} |
169 |
|
170 |
|
171 |
//**********************************************
|
172 |
|
173 |
/*
|
174 |
* (non-Javadoc)
|
175 |
* @see org.gvsig.fmap.dal.DataStoreParameters#getDataStoreName()
|
176 |
*/
|
177 |
public String getDataStoreName() { |
178 |
return TileProvider.NAME;
|
179 |
} |
180 |
|
181 |
/*
|
182 |
* (non-Javadoc)
|
183 |
* @see org.gvsig.fmap.dal.DataStoreParameters#getDescription()
|
184 |
*/
|
185 |
public String getDescription() { |
186 |
return TileProvider.DESCRIPTION;
|
187 |
} |
188 |
|
189 |
public String getExplorerName() { |
190 |
return TileServerExplorer.NAME;
|
191 |
} |
192 |
|
193 |
public boolean isValid() { |
194 |
return (this.getDataParameters() != null); |
195 |
} |
196 |
|
197 |
protected DelegatedDynObject getDelegatedDynObject() {
|
198 |
return delegatedDynObject;
|
199 |
} |
200 |
} |