/[xulu]/trunk/src/appl/data/WritableGridLLProxy.java
ViewVC logotype

Contents of /trunk/src/appl/data/WritableGridLLProxy.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations)
Wed Feb 25 11:54:01 2009 UTC (15 years, 9 months ago) by mojays
File size: 6162 byte(s)
First Commit, corresponds to Revision 1008 of Wikisquare-SVN 
1 package appl.data;
2
3 import java.awt.Rectangle;
4
5 import schmitzm.data.WritableGrid;
6 import schmitzm.data.WritableGridArray;
7 import appl.util.RasterMetaData;
8 import edu.bonn.xulu.appl.XuluRegistry;
9 import edu.bonn.xulu.io.ImportFactory;
10 import edu.bonn.xulu.plugin.io.grid.WritableGridFactory;
11 import org.opengis.referencing.crs.CoordinateReferenceSystem;
12
13 /**
14 * This is an a late loading implementation for {@link WritableGrid WritableGrids}.
15 *
16 * @author Dominik Appl
17 */
18 public class WritableGridLLProxy extends LateLoadingProxy implements
19 WritableGrid {
20
21 protected RasterMetaData metaData;
22
23 public WritableGridLLProxy(ImportFactory importFac,
24 RasterMetaData metaData, Object inputPara, XuluRegistry reg) {
25 super(new ImportFactoryLoader(importFac, inputPara, reg));
26 this.metaData = metaData;
27 }
28
29 public WritableGridLLProxy(WritableGridFactory targetFactory,
30 RasterMetaData metaData) {
31 super(new FactoryLoader(targetFactory, metaData));
32 this.metaData = metaData;
33 }
34
35 public WritableGridLLProxy(RasterMetaData metaData) {
36 super(new WritableGridArrayLoader(metaData));
37 baseObject = null;
38 loaded = false;
39 this.metaData = metaData;
40 }
41
42 protected WritableGridLLProxy(RasterMetaData metaData, DataLoader loader) {
43 super(loader);
44 loaded = false;
45 this.metaData = metaData;
46 }
47
48 public double convertRasterToReal(int cell, int dim) {
49 if (!loaded)
50 tryLoadingGrid();
51 ;
52 return ((WritableGrid) baseObject).convertRasterToReal(cell, dim);
53 }
54
55 public int convertRealToRaster(double coord, int dim) {
56 if (!loaded)
57 tryLoadingGrid();
58 return ((WritableGrid) baseObject).convertRealToRaster(coord, dim);
59 }
60
61 /** @see WritableGrid#dispose() */
62 public void dispose() {
63 if (baseObject != null)
64 ((WritableGrid) baseObject).dispose();
65 }
66
67 public Object getGridSample(double... coord) {
68 if (!loaded)
69 tryLoadingGrid();
70 return ((WritableGrid) baseObject).getGridSample();
71 }
72
73 public byte getGridSampleAsByte(double... coord) {
74 if (!loaded)
75 tryLoadingGrid();
76 return ((WritableGrid) baseObject).getGridSampleAsByte(coord);
77 }
78
79 public double getGridSampleAsDouble(double... coord) {
80 if (!loaded)
81 tryLoadingGrid();
82 return ((WritableGrid) baseObject).getGridSampleAsDouble(coord);
83 }
84
85 public float getGridSampleAsFloat(double... coord) {
86 if (!loaded)
87 tryLoadingGrid();
88 return ((WritableGrid) baseObject).getGridSampleAsFloat(coord);
89 }
90
91 public int getGridSampleAsInt(double... coord) {
92 if (!loaded)
93 tryLoadingGrid();
94 return ((WritableGrid) baseObject).getGridSampleAsInt(coord);
95 }
96
97 public long getGridSampleAsLong(double... coord) {
98 if (!loaded)
99 tryLoadingGrid();
100 return ((WritableGrid) baseObject).getGridSampleAsLong(coord);
101 }
102
103 public short getGridSampleAsShort(double... coord) {
104 if (!loaded)
105 tryLoadingGrid();
106 return ((WritableGrid) baseObject).getGridSampleAsShort(coord);
107 }
108
109 public CoordinateReferenceSystem getCoordinateReferenceSystem() {
110 return metaData.getCoordinateReferenceSystem();
111 }
112
113 public int getHeight() {
114 return metaData.getHeight();
115 }
116
117 public int getMinX() {
118 return metaData.getMinX();
119
120 }
121
122 public int getMinY() {
123 return metaData.getMinY();
124 }
125
126 public Object getRasterSample(int... cell) {
127 if (!loaded)
128 tryLoadingGrid();
129 return ((WritableGrid) baseObject).getRasterSample(cell);
130 }
131
132 public byte getRasterSampleAsByte(int... cell) {
133 if (!loaded)
134 tryLoadingGrid();
135 return ((WritableGrid) baseObject).getRasterSampleAsByte(cell);
136 }
137
138 public double getRasterSampleAsDouble(int... cell) {
139 if (!loaded)
140 tryLoadingGrid();
141 return ((WritableGrid) baseObject).getRasterSampleAsDouble(cell);
142 }
143
144 public float getRasterSampleAsFloat(int... cell) {
145 if (!loaded)
146 tryLoadingGrid();
147 return ((WritableGrid) baseObject).getRasterSampleAsFloat(cell);
148 }
149
150 public int getRasterSampleAsInt(int... cell) {
151 if (!loaded)
152 tryLoadingGrid();
153 return ((WritableGrid) baseObject).getRasterSampleAsInt(cell);
154 }
155
156 public long getRasterSampleAsLong(int... cell) {
157 if (!loaded)
158 tryLoadingGrid();
159 return ((WritableGrid) baseObject).getRasterSampleAsLong(cell);
160 }
161
162 public short getRasterSampleAsShort(int... cell) {
163 if (!loaded)
164 tryLoadingGrid();
165 return ((WritableGrid) baseObject).getRasterSampleAsShort(cell);
166 }
167
168 public double getRealHeight() {
169 return metaData.getRealHeight();
170 }
171
172 public double getRealWidth() {
173 return metaData.getRealWidth();
174 }
175
176 public int getSampleType() {
177 return metaData.getDataType();
178 }
179
180 /** Returns the Width of the Grid */
181 public int getWidth() {
182 return metaData.getWidth();
183 }
184
185 public double getX() {
186 return metaData.getX();
187 }
188
189 public double getY() {
190 return metaData.getY();
191 }
192
193 public void setGridSample(Object value, double... coord) {
194 if (!loaded)
195 tryLoadingGrid();
196 ((WritableGrid) baseObject).setGridSample(value, coord);
197 }
198
199 public void setRasterSample(Object value, int... cell) {
200 if (!loaded)
201 tryLoadingGrid();
202 ((WritableGrid) baseObject).setRasterSample(value, cell);
203
204 }
205
206 /**
207 * Trys to load the grid and gives out an error to the LOG, if the loading
208 * fails.
209 */
210 protected void tryLoadingGrid() {
211 try {
212 super.loadData();
213 } catch (LoadingException e) {
214 LOG.error("Error while Loading Grid " + this + " from Source "
215 + e.getLoadSource());
216 e.printStackTrace();
217 }
218
219 }
220
221 /*
222 * (non-Javadoc)
223 *
224 * @see schmitzm.data.WritableGrid#getCellHeight()
225 */
226 public double getCellHeight() {
227 // TODO Auto-generated method stub
228 return metaData.getCellHeight();
229 }
230
231 /*
232 * (non-Javadoc)
233 *
234 * @see schmitzm.data.WritableGrid#getCellWidth()
235 */
236 public double getCellWidth() {
237 // TODO Auto-generated method stub
238 return metaData.getCellWidth();
239 }
240
241 /**
242 * This class supports late loading
243 *
244 * @see appl.data.LateLoadable#unloadData()
245 * @return true;
246 * @see appl.data.LateLoadable#isLateLoadable()
247 */
248 public boolean isLateLoadable() {
249 return true;
250 }
251 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26