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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26