1 |
mojays |
2 |
package appl.parallel.data.xulugridfile; |
2 |
|
|
|
3 |
|
|
import schmitzm.data.WritableGrid; |
4 |
|
|
import appl.data.DataLoader; |
5 |
|
|
import appl.data.LoadingException; |
6 |
|
|
|
7 |
|
|
/** |
8 |
|
|
* This {@link DataLoader} is responsible to load data from a |
9 |
|
|
* {@link XuluGridFile}. When {@link #load()} is called it tries to load the |
10 |
|
|
* whole(!) grid into the memory. Notice that using this loader will destroy all |
11 |
|
|
* memory advantages of the {@link XuluGridFile}. It is intended as standard loader in |
12 |
|
|
* the xulu application. The user can therefore force the loading of the grid |
13 |
|
|
* into the local memory e.g. for visualization. |
14 |
|
|
* |
15 |
|
|
* @author Dominik Appl |
16 |
|
|
*/ |
17 |
|
|
public class GridFileDataLoader implements DataLoader { |
18 |
|
|
|
19 |
|
|
private final XuluGridFile gridFile; |
20 |
|
|
|
21 |
|
|
public GridFileDataLoader(XuluGridFile gridFile) { |
22 |
|
|
this.gridFile = gridFile; |
23 |
|
|
} |
24 |
|
|
|
25 |
|
|
/* (non-Javadoc) |
26 |
|
|
* @see appl.data.DataLoader#getLoadInfo() |
27 |
|
|
*/ |
28 |
|
|
public String getLoadInfo() { |
29 |
|
|
// TODO Auto-generated method stub |
30 |
|
|
return "Loading gridfile " + gridFile.getOutputFile().getPath() + ". "; |
31 |
|
|
} |
32 |
|
|
|
33 |
|
|
/** loads the whole grid into memory and returns it |
34 |
|
|
* @see appl.data.DataLoader#load() |
35 |
|
|
*/ |
36 |
|
|
public WritableGrid load() throws LoadingException { |
37 |
|
|
try { |
38 |
|
|
return gridFile.getWholeGrid(); |
39 |
|
|
} catch (XuluGridFileException e) { |
40 |
|
|
// TODO Auto-generated catch block |
41 |
|
|
e.printStackTrace(); |
42 |
|
|
} |
43 |
|
|
return null; |
44 |
|
|
} |
45 |
|
|
|
46 |
|
|
} |