/[xulu]/branches/1.8-gt2-2.6/src/appl/parallel/data/WritableGridArrayPartition.java
ViewVC logotype

Annotation of /branches/1.8-gt2-2.6/src/appl/parallel/data/WritableGridArrayPartition.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 60 - (hide annotations)
Sun Oct 4 16:54:52 2009 UTC (15 years, 2 months ago) by alfonx
File size: 7430 byte(s)
* organized imports
1 mojays 2 package appl.parallel.data;
2    
3     import java.awt.Rectangle;
4    
5 alfonx 60 import schmitzm.data.WritableGrid;
6     import schmitzm.data.WritableGridArray;
7 mojays 2 import appl.data.DataProxy;
8     import appl.parallel.spmd.split.DataPartition;
9     import appl.parallel.spmd.split.WritableGridPartition;
10     import appl.parallel.util.PartitionUtil;
11     import appl.util.RasterMetaData;
12    
13     /**
14     * A WritableGridArrayPartition extends the {@link WritableGridArray} so that
15     * it can be used in parallel computation. Every partition represents a
16     * rectangle-shaped part of a father-grid. It has information about its bounds
17     * and about its father-grid. The partition may be used for data transfer
18     * between computing resources. It is very fast, because it is not proxyied
19     * by a {@link DataProxy}, but uses the {@link WritableGridArray} directly.
20     *
21     * @see WritableGridArrayPartition
22     *
23     * @author Dominik Appl
24     */
25     public abstract class WritableGridArrayPartition {
26    
27     /**
28     * For Float data types
29     *
30     * @see WritableGridArray.Float
31     * @author Dominik Appl
32     */
33     public static class Float extends WritableGridArray.Float implements
34     WritableGridPartition {
35    
36     private final int rootID;
37    
38     private final Rectangle thisPartition;
39    
40     private final RasterMetaData metaData;
41    
42     public Float(RasterMetaData metaData, int rootID,
43     Rectangle thisPartition) {
44     super(metaData.getMinX(), metaData.getMinY(), metaData.getWidth(),
45     metaData.getHeight(), metaData.getX(), metaData.getY(),
46     metaData.getRealWidth(), metaData.getRealHeight(), metaData
47     .getCoordinateReferenceSystem(), null);
48     this.metaData = metaData;
49     this.rootID = rootID;
50     this.thisPartition = thisPartition;
51     }
52    
53     /*
54     * (non-Javadoc)
55     *
56     * @see appl.parallel.spmd.split.DataPartition#getBounds(java.awt.Rectangle)
57     */
58     public Rectangle getPartitionBounds() {
59     return thisPartition;
60    
61     }
62    
63     /*
64     * (non-Javadoc)
65     *
66     * @see appl.parallel.spmd.split.DataPartition#getPartition(java.awt.Rectangle)
67     */
68     public DataPartition getPartition(Rectangle partitionBounds) {
69     return PartitionUtil.getPartitialGrid2D(this, partitionBounds,
70     rootID);
71     }
72    
73     /*
74     * (non-Javadoc)
75     *
76     * @see appl.parallel.spmd.split.DataPartition#getRootID()
77     */
78     public int getRootID() {
79     return rootID;
80     }
81    
82     /*
83     * (non-Javadoc)
84     *
85     * @see appl.parallel.spmd.split.DataPartition#setPartition(appl.parallel.spmd.split.DataPartition,
86     * java.awt.Rectangle)
87     */
88     public void setPartition(DataPartition partition,
89     Rectangle partitionBounds) {
90     if (!(partition instanceof WritableGrid))
91     throw new UnsupportedOperationException(
92     "The partition must be an instance of WritableGrid!");
93     PartitionUtil.setPartition(this, (WritableGrid) partition,
94     partitionBounds);
95    
96     }
97    
98     /*
99     * (non-Javadoc)
100     *
101     * @see appl.parallel.spmd.split.DataPartition#getEmpty(int id)
102     */
103     public DataPartition getEmpty(int id) {
104     return new WritableGridArrayPartition.Float(this.metaData, id,
105     thisPartition);
106     }
107     }
108    
109     /**
110     * For Double data types
111     *
112     * @see WritableGridArray.Double
113     * @author Dominik Appl
114     */
115     public static class Double extends WritableGridArray.Float implements
116     WritableGridPartition {
117    
118     private final int rootID;
119    
120     private final Rectangle thisPartition;
121    
122     private final RasterMetaData metaData;
123    
124    
125     public Double(RasterMetaData metaData, int rootID,
126     Rectangle thisPartition) {
127     super(metaData.getMinX(), metaData.getMinY(), metaData.getWidth(),
128     metaData.getHeight(), metaData.getX(), metaData.getY(),
129     metaData.getRealWidth(), metaData.getRealHeight(), metaData
130     .getCoordinateReferenceSystem(), null);
131     this.metaData = metaData;
132     this.rootID = rootID;
133     this.thisPartition = thisPartition;
134     }
135    
136     /*
137     * (non-Javadoc)
138     *
139     * @see appl.parallel.spmd.split.DataPartition#getBounds(java.awt.Rectangle)
140     */
141     public Rectangle getPartitionBounds() {
142     return thisPartition;
143    
144     }
145    
146     /*
147     * (non-Javadoc)
148     *
149     * @see appl.parallel.spmd.split.DataPartition#getPartition(java.awt.Rectangle)
150     */
151     public DataPartition getPartition(Rectangle partitionBounds) {
152     return PartitionUtil.getPartitialGrid2D(this, partitionBounds,
153     rootID);
154     }
155    
156     /*
157     * (non-Javadoc)
158     *
159     * @see appl.parallel.spmd.split.DataPartition#getRootID()
160     */
161     public int getRootID() {
162     return rootID;
163     }
164    
165     /*
166     * (non-Javadoc)
167     *
168     * @see appl.parallel.spmd.split.DataPartition#setPartition(appl.parallel.spmd.split.DataPartition,
169     * java.awt.Rectangle)
170     */
171     public void setPartition(DataPartition partition,
172     Rectangle partitionBounds) {
173     if (!(partition instanceof WritableGrid))
174     throw new UnsupportedOperationException(
175     "The partition must be an instance of WritableGrid!");
176     PartitionUtil.setPartition(this, (WritableGrid) partition,
177     partitionBounds);
178    
179     }
180    
181     /*
182     * (non-Javadoc)
183     *
184     * @see appl.parallel.spmd.split.DataPartition#getEmpty(int id)
185     */
186     public DataPartition getEmpty(int id) {
187     return new WritableGridArrayPartition.Double(this.metaData, id,
188     thisPartition);
189     }
190     }
191    
192     /**
193     * For Integer data types
194     *
195     * @see WritableGridArray.Integer
196     * @author Dominik Appl
197     */
198     public static class Integer extends WritableGridArray.Integer implements
199     WritableGridPartition {
200    
201     private final int rootID;
202    
203     private final Rectangle thisPartition;
204    
205     private final RasterMetaData metaData;
206    
207     public Integer(RasterMetaData metaData, int rootID,
208     Rectangle thisPartition) {
209     super(metaData.getMinX(), metaData.getMinY(), metaData.getWidth(),
210     metaData.getHeight(), metaData.getX(), metaData.getY(),
211     metaData.getRealWidth(), metaData.getRealHeight(), metaData
212     .getCoordinateReferenceSystem(), null);
213     this.metaData = metaData;
214     this.rootID = rootID;
215     this.thisPartition = thisPartition;
216     }
217    
218     /*
219     * (non-Javadoc)
220     *
221     * @see appl.parallel.spmd.split.DataPartition#getBounds(java.awt.Rectangle)
222     */
223     public Rectangle getPartitionBounds() {
224     return thisPartition;
225    
226     }
227    
228     /*
229     * (non-Javadoc)
230     *
231     * @see appl.parallel.spmd.split.DataPartition#getPartition(java.awt.Rectangle)
232     */
233     public DataPartition getPartition(Rectangle partitionBounds) {
234     return PartitionUtil.getPartitialGrid2D(this, partitionBounds,
235     rootID);
236     }
237    
238     /*
239     * (non-Javadoc)
240     *
241     * @see appl.parallel.spmd.split.DataPartition#getRootID()
242     */
243     public int getRootID() {
244     return rootID;
245     }
246    
247     /*
248     * (non-Javadoc)
249     *
250     * @see appl.parallel.spmd.split.DataPartition#setPartition(appl.parallel.spmd.split.DataPartition,
251     * java.awt.Rectangle)
252     */
253     public void setPartition(DataPartition partition,
254     Rectangle partitionBounds) {
255     if (!(partition instanceof WritableGrid))
256     throw new UnsupportedOperationException(
257     "The partition must be an instance of WritableGrid!");
258     PartitionUtil.setPartition(this, (WritableGrid) partition,
259     partitionBounds);
260    
261     }
262    
263     /*
264     * (non-Javadoc)
265     *
266     * @see appl.parallel.spmd.split.DataPartition#getEmpty(int id)
267     */
268     public DataPartition getEmpty(int id) {
269     return new WritableGridArrayPartition.Integer(this.metaData, id,
270     thisPartition);
271     }
272     }
273    
274     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26