001: /*
002: * @(#) $Header: /cvs/jai-operators/src/tests/ca/forklabs/media/jai/opimage/DFT3DOpImageTest.java,v 1.3 2007/09/07 18:13:05 forklabs Exp $
003: *
004: * Copyright (C) 2006 DIRO Daniel Léonard
005: */
006:
007: package ca.forklabs.media.jai.opimage;
008:
009: import java.awt.image.DataBuffer;
010: import java.awt.image.Raster;
011: import java.awt.image.RenderedImage;
012: import java.util.Locale;
013: import javax.media.jai.CollectionImage;
014: import javax.media.jai.operator.DFTDataNature;
015: import javax.media.jai.operator.DFTScalingType;
016: import junit.framework.TestCase;
017: import ca.forklabs.media.jai.RasterAdapter;
018: import ca.forklabs.media.jai.SimpleCollectionImage;
019: import ca.forklabs.media.jai.operator.DFT3DDescriptor;
020:
021: /**
022: * Class {@code DFT3DOpImageTest} tests class {@link DFT3DOpImage}.
023: *
024: * @author <a href="mailto:forklabs at dev.java.net?subject=ca.forklabs.media.jai.opimage.DFT3DOpImageTest">Daniel Léonard</a>
025: * @version $Revision: 1.3 $
026: */
027: @SuppressWarnings("nls")
028: public class DFT3DOpImageTest extends TestCase {
029:
030: //---------------------------
031: // Constructors
032: //---------------------------
033:
034: /**
035: * Constructor.
036: * @param name the name of this test.
037: */
038: public DFT3DOpImageTest(String name) {
039: super (name);
040: }
041:
042: //---------------------------
043: // Test methods
044: //---------------------------
045:
046: private void compareArrays(String message, float[] expected,
047: float[] got) {
048: assertEquals(message, expected.length, got.length);
049: for (int i = 0; i < expected.length; i++) {
050: assertEquals(message, expected[i], got[i], 10e-6f);
051: }
052: }
053:
054: private void compareArrays(String message, double[] expected,
055: double[] got) {
056: assertEquals(message, expected.length, got.length);
057: for (int i = 0; i < expected.length; i++) {
058: assertEquals(message, expected[i], got[i], 10e-6);
059: }
060: }
061:
062: /**
063: * Tests that it works for real to complex in floats
064: */
065: public void testRealToComplexInFloat() {
066: RenderedImage[] sources = new RenderedImage[] {
067: RasterAdapter.buildFloatImage(new float[][] { { 1.0f,
068: 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f,
069: 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f,
070: 16.0f, }, }, 4, 4),
071: RasterAdapter.buildFloatImage(new float[][] { { 17.0f,
072: 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f,
073: 24.0f, 25.0f, 26.0f, 27.0f, 28.0f, 29.0f,
074: 30.0f, 31.0f, 32.0f, }, }, 4, 4),
075: RasterAdapter.buildFloatImage(new float[][] { { 33.0f,
076: 34.0f, 35.0f, 36.0f, 37.0f, 38.0f, 39.0f,
077: 40.0f, 41.0f, 42.0f, 43.0f, 44.0f, 45.0f,
078: 46.0f, 47.0f, 48.0f, }, }, 4, 4),
079: RasterAdapter.buildFloatImage(new float[][] { { 49.0f,
080: 50.0f, 51.0f, 52.0f, 53.0f, 54.0f, 55.0f,
081: 56.0f, 57.0f, 58.0f, 59.0f, 60.0f, 61.0f,
082: 62.0f, 63.0f, 64.0f, }, }, 4, 4), };
083:
084: DFT3DOpImage.Transform transform = DFT3DOpImage.FORWARD_TRANSFORM;
085: DFTScalingType scaling = DFT3DDescriptor.SCALING_NONE;
086: DFTDataNature nature = DFT3DDescriptor.REAL_TO_COMPLEX;
087:
088: CollectionImage sinks = new DFT3DOpImage(
089: new SimpleCollectionImage(sources[0], sources[1],
090: sources[2], sources[3]), transform, scaling,
091: nature);
092:
093: assertEquals(4, sinks.size());
094:
095: Raster[] solutions = new Raster[] {
096: RasterAdapter.buildFloatImage(
097: new float[][] {
098: { 2080.0f, -32.0f, -32.0f, -32.0f,
099: -128.0f, 0.0f, 0.0f, 0.0f,
100: -128.0f, 0.0f, 0.0f, 0.0f,
101: -128.0f, 0.0f, 0.0f, 0.0f, },
102: { 0.0f, 32.0f, 0.0f, -32.0f, 128.0f,
103: 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
104: 0.0f, 0.0f, -128.0f, 0.0f,
105: 0.0f, 0.0f, }, }, 4, 4)
106: .getData(),
107: RasterAdapter
108: .buildFloatImage(
109: new float[][] {
110: { -512.0f, 0.0f, 0.0f, 0.0f,
111: 0.0f, 0.0f, 0.0f, 0.0f,
112: 0.0f, 0.0f, 0.0f, 0.0f,
113: 0.0f, 0.0f, 0.0f, 0.0f, },
114: { 512.0f, 0.0f, 0.0f, 0.0f,
115: 0.0f, 0.0f, 0.0f, 0.0f,
116: 0.0f, 0.0f, 0.0f, 0.0f,
117: 0.0f, 0.0f, 0.0f, 0.0f, }, },
118: 4, 4).getData(),
119: RasterAdapter
120: .buildFloatImage(
121: new float[][] {
122: { -512.0f, 0.0f, 0.0f, 0.0f,
123: 0.0f, 0.0f, 0.0f, 0.0f,
124: 0.0f, 0.0f, 0.0f, 0.0f,
125: 0.0f, 0.0f, 0.0f, 0.0f, },
126: { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
127: 0.0f, 0.0f, 0.0f, 0.0f,
128: 0.0f, 0.0f, 0.0f, 0.0f,
129: 0.0f, 0.0f, 0.0f, }, },
130: 4, 4).getData(),
131: RasterAdapter.buildFloatImage(
132: new float[][] {
133: { -512.0f, 0.0f, 0.0f, 0.0f, 0.0f,
134: 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
135: 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
136: 0.0f, },
137: { -512.0f, 0.0f, 0.0f, 0.0f, 0.0f,
138: 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
139: 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
140: 0.0f, }, }, 4, 4).getData(), };
141:
142: for (int i = 0; i < sinks.size(); i++) {
143: RenderedImage sink = (RenderedImage) sinks.get(i);
144: Raster raster = sink.getData();
145:
146: assertEquals(0, raster.getMinX());
147: assertEquals(0, raster.getMinY());
148: assertEquals(4, raster.getWidth());
149: assertEquals(4, raster.getHeight());
150: assertEquals(2, raster.getNumBands());
151: assertEquals(DataBuffer.TYPE_FLOAT, raster.getSampleModel()
152: .getDataType());
153:
154: Raster solution = solutions[i];
155:
156: float[] got = null;
157: float[] expected = null;
158: for (int y = 0; y < 4; y++) {
159: for (int x = 0; x < 4; x++) {
160: got = raster.getPixel(x, y, got);
161: expected = solution.getPixel(x, y, expected);
162: this .compareArrays("(" + x + "," + y + "," + i
163: + ")", expected, got);
164: }
165: }
166: }
167: }
168:
169: /**
170: * Tests that it works for real to complex in floats
171: */
172: public void testRealToComplexInDouble() {
173: RenderedImage[] sources = new RenderedImage[] {
174: RasterAdapter.buildDoubleImage(new double[][] { { 1.0,
175: 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0,
176: 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, }, }, 4, 4),
177: RasterAdapter.buildDoubleImage(new double[][] { { 17.0,
178: 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0,
179: 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0, }, },
180: 4, 4),
181: RasterAdapter.buildDoubleImage(new double[][] { { 33.0,
182: 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, 40.0, 41.0,
183: 42.0, 43.0, 44.0, 45.0, 46.0, 47.0, 48.0, }, },
184: 4, 4),
185: RasterAdapter.buildDoubleImage(new double[][] { { 49.0,
186: 50.0, 51.0, 52.0, 53.0, 54.0, 55.0, 56.0, 57.0,
187: 58.0, 59.0, 60.0, 61.0, 62.0, 63.0, 64.0, }, },
188: 4, 4), };
189:
190: DFT3DOpImage.Transform transform = DFT3DOpImage.FORWARD_TRANSFORM;
191: DFTScalingType scaling = DFT3DDescriptor.SCALING_NONE;
192: DFTDataNature nature = DFT3DDescriptor.REAL_TO_COMPLEX;
193:
194: CollectionImage sinks = new DFT3DOpImage(
195: new SimpleCollectionImage(sources[0], sources[1],
196: sources[2], sources[3]), transform, scaling,
197: nature);
198:
199: assertEquals(4, sinks.size());
200:
201: Raster[] solutions = new Raster[] {
202: RasterAdapter.buildDoubleImage(
203: new double[][] {
204: { 2080.0, -32.0, -32.0, -32.0, -128.0,
205: 0.0, 0.0, 0.0, -128.0, 0.0,
206: 0.0, 0.0, -128.0, 0.0, 0.0,
207: 0.0, },
208: { 0.0, 32.0, 0.0, -32.0, 128.0, 0.0,
209: 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
210: -128.0, 0.0, 0.0, 0.0, }, }, 4,
211: 4).getData(),
212: RasterAdapter.buildDoubleImage(
213: new double[][] {
214: { -512.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
215: 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
216: 0.0, 0.0, 0.0, },
217: { 512.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
218: 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
219: 0.0, 0.0, 0.0, }, }, 4, 4)
220: .getData(),
221: RasterAdapter.buildDoubleImage(
222: new double[][] {
223: { -512.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
224: 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
225: 0.0, 0.0, 0.0, },
226: { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
227: 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
228: 0.0, 0.0, 0.0, }, }, 4, 4)
229: .getData(),
230: RasterAdapter.buildDoubleImage(
231: new double[][] {
232: { -512.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
233: 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
234: 0.0, 0.0, 0.0, },
235: { -512.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
236: 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
237: 0.0, 0.0, 0.0, }, }, 4, 4)
238: .getData(), };
239:
240: for (int i = 0; i < sinks.size(); i++) {
241: RenderedImage sink = (RenderedImage) sinks.get(i);
242: Raster raster = sink.getData();
243:
244: assertEquals(0, raster.getMinX());
245: assertEquals(0, raster.getMinY());
246: assertEquals(4, raster.getWidth());
247: assertEquals(4, raster.getHeight());
248: assertEquals(2, raster.getNumBands());
249:
250: Raster solution = solutions[i];
251:
252: double[] got = null;
253: double[] expected = null;
254: for (int y = 0; y < 4; y++) {
255: for (int x = 0; x < 4; x++) {
256: got = raster.getPixel(x, y, got);
257: expected = solution.getPixel(x, y, expected);
258: this .compareArrays("(" + x + "," + y + "," + i
259: + ")", expected, got);
260: }
261: }
262: }
263: }
264:
265: /**
266: * Tests that it works for complex to real in floats
267: */
268: public void testComplexToRealInFloat() {
269: Raster[] solutions = new Raster[] {
270: RasterAdapter
271: .buildFloatImage(
272: new float[][] { { 1.0f, 2.0f, 3.0f,
273: 4.0f, 5.0f, 6.0f, 7.0f, 8.0f,
274: 9.0f, 10.0f, 11.0f, 12.0f,
275: 13.0f, 14.0f, 15.0f, 16.0f, }, },
276: 4, 4).getData(),
277: RasterAdapter.buildFloatImage(
278: new float[][] { { 17.0f, 18.0f, 19.0f, 20.0f,
279: 21.0f, 22.0f, 23.0f, 24.0f, 25.0f,
280: 26.0f, 27.0f, 28.0f, 29.0f, 30.0f,
281: 31.0f, 32.0f, }, }, 4, 4).getData(),
282: RasterAdapter.buildFloatImage(
283: new float[][] { { 33.0f, 34.0f, 35.0f, 36.0f,
284: 37.0f, 38.0f, 39.0f, 40.0f, 41.0f,
285: 42.0f, 43.0f, 44.0f, 45.0f, 46.0f,
286: 47.0f, 48.0f, }, }, 4, 4).getData(),
287: RasterAdapter.buildFloatImage(
288: new float[][] { { 49.0f, 50.0f, 51.0f, 52.0f,
289: 53.0f, 54.0f, 55.0f, 56.0f, 57.0f,
290: 58.0f, 59.0f, 60.0f, 61.0f, 62.0f,
291: 63.0f, 64.0f, }, }, 4, 4).getData(), };
292:
293: RenderedImage[] sources = new RenderedImage[] {
294: RasterAdapter.buildFloatImage(new float[][] {
295: { 2080.0f, -32.0f, -32.0f, -32.0f, -128.0f,
296: 0.0f, 0.0f, 0.0f, -128.0f, 0.0f, 0.0f,
297: 0.0f, -128.0f, 0.0f, 0.0f, 0.0f, },
298: { 0.0f, 32.0f, 0.0f, -32.0f, 128.0f, 0.0f,
299: 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
300: -128.0f, 0.0f, 0.0f, 0.0f, }, }, 4, 4),
301: RasterAdapter.buildFloatImage(new float[][] {
302: { -512.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
303: 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
304: 0.0f, 0.0f, 0.0f, },
305: { 512.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
306: 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
307: 0.0f, 0.0f, 0.0f, }, }, 4, 4),
308: RasterAdapter.buildFloatImage(new float[][] {
309: { -512.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
310: 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
311: 0.0f, 0.0f, 0.0f, },
312: { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
313: 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
314: 0.0f, 0.0f, 0.0f, }, }, 4, 4),
315: RasterAdapter.buildFloatImage(new float[][] {
316: { -512.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
317: 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
318: 0.0f, 0.0f, 0.0f, },
319: { -512.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
320: 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
321: 0.0f, 0.0f, 0.0f, }, }, 4, 4), };
322:
323: DFT3DOpImage.Transform transform = DFT3DOpImage.INVERSE_TRANSFORM;
324: DFTScalingType scaling = DFT3DDescriptor.SCALING_DIMENSIONS;
325: DFTDataNature nature = DFT3DDescriptor.COMPLEX_TO_REAL;
326:
327: CollectionImage sinks = new DFT3DOpImage(
328: new SimpleCollectionImage(sources[0], sources[1],
329: sources[2], sources[3]), transform, scaling,
330: nature);
331:
332: assertEquals(4, sinks.size());
333:
334: for (int i = 0; i < sinks.size(); i++) {
335: RenderedImage sink = (RenderedImage) sinks.get(i);
336: Raster raster = sink.getData();
337:
338: assertEquals(0, raster.getMinX());
339: assertEquals(0, raster.getMinY());
340: assertEquals(4, raster.getWidth());
341: assertEquals(4, raster.getHeight());
342: assertEquals(1, raster.getNumBands());
343:
344: Raster solution = solutions[i];
345:
346: float[] got = null;
347: float[] expected = null;
348: for (int y = 0; y < 4; y++) {
349: for (int x = 0; x < 4; x++) {
350: got = raster.getPixel(x, y, got);
351: expected = solution.getPixel(x, y, expected);
352: this .compareArrays("(" + x + "," + y + "," + i
353: + ")", expected, got);
354: }
355: }
356: }
357: }
358:
359: /**
360: * Tests that it works for complex to real in doubles
361: */
362: public void testComplexToRealInDouble() {
363: Raster[] solutions = new Raster[] {
364: RasterAdapter.buildDoubleImage(
365: new double[][] { { 1.0, 2.0, 3.0, 4.0, 5.0,
366: 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0,
367: 13.0, 14.0, 15.0, 16.0, }, }, 4, 4)
368: .getData(),
369: RasterAdapter
370: .buildDoubleImage(
371: new double[][] { { 17.0, 18.0, 19.0,
372: 20.0, 21.0, 22.0, 23.0, 24.0,
373: 25.0, 26.0, 27.0, 28.0, 29.0,
374: 30.0, 31.0, 32.0, }, }, 4, 4)
375: .getData(),
376: RasterAdapter
377: .buildDoubleImage(
378: new double[][] { { 33.0, 34.0, 35.0,
379: 36.0, 37.0, 38.0, 39.0, 40.0,
380: 41.0, 42.0, 43.0, 44.0, 45.0,
381: 46.0, 47.0, 48.0, }, }, 4, 4)
382: .getData(),
383: RasterAdapter
384: .buildDoubleImage(
385: new double[][] { { 49.0, 50.0, 51.0,
386: 52.0, 53.0, 54.0, 55.0, 56.0,
387: 57.0, 58.0, 59.0, 60.0, 61.0,
388: 62.0, 63.0, 64.0, }, }, 4, 4)
389: .getData(), };
390:
391: RenderedImage[] sources = new RenderedImage[] {
392: RasterAdapter.buildDoubleImage(new double[][] {
393: { 2080.0, -32.0, -32.0, -32.0, -128.0, 0.0,
394: 0.0, 0.0, -128.0, 0.0, 0.0, 0.0,
395: -128.0, 0.0, 0.0, 0.0, },
396: { 0.0, 32.0, 0.0, -32.0, 128.0, 0.0, 0.0, 0.0,
397: 0.0, 0.0, 0.0, 0.0, -128.0, 0.0, 0.0,
398: 0.0, }, }, 4, 4),
399: RasterAdapter.buildDoubleImage(
400: new double[][] {
401: { -512.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
402: 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
403: 0.0, 0.0, 0.0, },
404: { 512.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
405: 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
406: 0.0, 0.0, 0.0, }, }, 4, 4),
407: RasterAdapter.buildDoubleImage(
408: new double[][] {
409: { -512.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
410: 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
411: 0.0, 0.0, 0.0, },
412: { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
413: 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
414: 0.0, 0.0, 0.0, }, }, 4, 4),
415: RasterAdapter.buildDoubleImage(
416: new double[][] {
417: { -512.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
418: 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
419: 0.0, 0.0, 0.0, },
420: { -512.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
421: 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
422: 0.0, 0.0, 0.0, }, }, 4, 4), };
423:
424: DFT3DOpImage.Transform transform = DFT3DOpImage.INVERSE_TRANSFORM;
425: DFTScalingType scaling = DFT3DDescriptor.SCALING_DIMENSIONS;
426: DFTDataNature nature = DFT3DDescriptor.COMPLEX_TO_REAL;
427:
428: CollectionImage sinks = new DFT3DOpImage(
429: new SimpleCollectionImage(sources[0], sources[1],
430: sources[2], sources[3]), transform, scaling,
431: nature);
432:
433: assertEquals(4, sinks.size());
434:
435: for (int i = 0; i < sinks.size(); i++) {
436: RenderedImage sink = (RenderedImage) sinks.get(i);
437: Raster raster = sink.getData();
438:
439: assertEquals(0, raster.getMinX());
440: assertEquals(0, raster.getMinY());
441: assertEquals(4, raster.getWidth());
442: assertEquals(4, raster.getHeight());
443: assertEquals(1, raster.getNumBands());
444:
445: Raster solution = solutions[i];
446:
447: double[] got = null;
448: double[] expected = null;
449: for (int y = 0; y < 4; y++) {
450: for (int x = 0; x < 4; x++) {
451: got = raster.getPixel(x, y, got);
452: expected = solution.getPixel(x, y, expected);
453: this .compareArrays("(" + x + "," + y + "," + i
454: + ")", expected, got);
455: }
456: }
457: }
458: }
459:
460: // BUG : test complex-to-complex in float
461: // BUG : test complex-to-complex in double
462: // BUG : test with a cubic image of width 1
463: // BUG : test with a cubic image of length 1
464: // BUG : test with a cubic image of depth 1 (should be same as the normal dft and idft)
465:
466: /**
467: * Tests the English messages.
468: */
469: public void testEnglishMessages() {
470: Locale locale = Locale.getDefault();
471: Locale.setDefault(Locale.ENGLISH);
472:
473: try {
474: String[] expected = new String[] {
475: "Expected either DataBuffer.TYPE_FLOAT or DataBuffer.TYPE_DOUBLE but got (10)",
476: "The data nature (null) is unknown", };
477:
478: DFT3DOpImage image = new DFT3DOpImage(null, null, null,
479: null) {
480: @Override
481: protected void transform(CollectionImage sources,
482: Transform transform, DFTScalingType scaling,
483: DFTDataNature nature) { /* nothing */
484: }
485: };
486: DFT3DOpImage.PixelSpecialization<int[]> specialization = new DFT3DOpImage.PixelSpecialization<int[]>() {
487: @Override
488: public void drain(int[] real, int[] imag,
489: DataBuffer buffer, int band, int offset,
490: DFTDataNature nature) { /* nothing */
491: }
492:
493: @Override
494: public void fill(int[] real, int[] imag,
495: DataBuffer buffer, int band, int offset,
496: DFTDataNature nature) { /* nothing */
497: }
498:
499: @Override
500: public DataBuffer newSinkBuffer(int size, int bands,
501: DFTDataNature nature) {
502: return null;
503: }
504:
505: @Override
506: public int[] newWorkingArray(int len) {
507: return null;
508: }
509: };
510: String[] got = new String[] { image.getBadDataType(10),
511: specialization.getUnknownDataNature(null), };
512:
513: assertEquals(expected.length, got.length);
514:
515: for (int i = 0; i < expected.length; i++) {
516: assertEquals("[" + i + "]", expected[i], got[i]);
517: }
518: } finally {
519: Locale.setDefault(locale);
520: }
521: }
522:
523: /**
524: * Tests the French messages.
525: */
526: public void testFrenchMessages() {
527: Locale locale = Locale.getDefault();
528: Locale.setDefault(Locale.FRENCH);
529:
530: try {
531: String[] expected = new String[] {
532: "Attendais soit DataBuffer.TYPE_FLOAT ou DataBuffer.TYPE_DOUBLE mais ai recu (10)",
533: "La nature des données (null) est inconnue", };
534:
535: DFT3DOpImage image = new DFT3DOpImage(null, null, null,
536: null) {
537: @Override
538: protected void transform(CollectionImage sources,
539: Transform transform, DFTScalingType scaling,
540: DFTDataNature nature) { /* nothing */
541: }
542: };
543: DFT3DOpImage.PixelSpecialization<int[]> specialization = new DFT3DOpImage.PixelSpecialization<int[]>() {
544: @Override
545: public void drain(int[] real, int[] imag,
546: DataBuffer buffer, int band, int offset,
547: DFTDataNature nature) { /* nothing */
548: }
549:
550: @Override
551: public void fill(int[] real, int[] imag,
552: DataBuffer buffer, int band, int offset,
553: DFTDataNature nature) { /* nothing */
554: }
555:
556: @Override
557: public DataBuffer newSinkBuffer(int size, int bands,
558: DFTDataNature nature) {
559: return null;
560: }
561:
562: @Override
563: public int[] newWorkingArray(int len) {
564: return null;
565: }
566: };
567: String[] got = new String[] { image.getBadDataType(10),
568: specialization.getUnknownDataNature(null), };
569:
570: assertEquals(expected.length, got.length);
571:
572: for (int i = 0; i < expected.length; i++) {
573: assertEquals("[" + i + "]", expected[i], got[i]);
574: }
575: } finally {
576: Locale.setDefault(locale);
577: }
578: }
579:
580: //---------------------------
581: // Class methods
582: //---------------------------
583:
584: /**
585: * Runs only this test.
586: * @param args ignored.
587: */
588: public static void main(String... args) {
589: junit.swingui.TestRunner.run(DFT3DOpImageTest.class);
590: }
591:
592: }
593:
594: /*
595: * $Log: DFT3DOpImageTest.java,v $
596: * Revision 1.3 2007/09/07 18:13:05 forklabs
597: * Added test markers.
598: *
599: * Revision 1.2 2007/07/05 18:29:50 forklabs
600: * Now uses CollectionImage instead of lists.
601: *
602: * Revision 1.1 2007/06/05 02:27:50 forklabs
603: * Operators dft3d and idft3d
604: *
605: */
|