package imagej.gui;

import imagej.data.Types;
import imagej.dataset.Dataset;
import imagej.dataset.PlanarDatasetFactory;
import imagej.plugin.ij2.IPlugin;
import imagej.plugin.ij2.Parameter;
import imagej.plugin.ij2.Plugin;

@Plugin(
  menuPath="Process>Gradient"
)
public class GradientImage implements IPlugin {

	@Parameter private int width = 512;
	@Parameter	private int height = 512;

	@Parameter(output=true)
	private Dataset dataset;

	@Override
	public void run() {
		
		byte[] data = new byte[ this.width * this.height ];
		
		for(int x = 0; x < width; x++)
			for(int y = 0; y < height; y++)
			{
				int index = y*width+x;
				data[index] = (byte) (x+y);
			}
		
		PlanarDatasetFactory planarDatasetFactory = new PlanarDatasetFactory();
		dataset = planarDatasetFactory.createDataset( Types.findType( "8=bit unsigned"), new int[] { this.width, this.height } );
		dataset.setData( data );
  }
}

@@ -33,21 +33,32 @@
 ej.data.
+UnsignedByte
 Type
-s
 ;%0Aimport
@@ -82,16 +82,54 @@
 ataset;%0A
+import imagej.dataset.DatasetFactory;%0A
 import i
@@ -369,17 +369,18 @@
 arameter
- 
+%0A%09
 private 
@@ -396,16 +396,17 @@
  = 512;%0A
+%0A
 %09@Parame
@@ -408,16 +408,17 @@
 arameter
+%0A
 %09private
@@ -521,19 +521,16 @@
 run() %7B%0A
-%09%09%0A
 %09%09byte%5B%5D
@@ -550,22 +550,16 @@
 yte%5B
- this.
 width * 
 this
@@ -558,31 +558,23 @@
 h * 
-this.
 height
- 
 %5D;%0A
-%09%09%0A
 %09%09for
+ 
 (int
@@ -600,15 +600,18 @@
 x++)
+ %7B
 %0A%09%09%09for
+ 
 (int
@@ -634,20 +634,17 @@
 ht; y++)
-%0A%09%09%09
+ 
 %7B%0A%09%09%09%09in
@@ -658,15 +658,19 @@
  = y
-*
+ * 
 width
-+
+ + 
 x;%0A%09
@@ -695,17 +695,19 @@
 byte) (x
-+
+ + 
 y);%0A%09%09%09%7D
@@ -713,17 +713,19 @@
 %7D%0A%09%09
+%7D%0A
 %0A%09%09
-Planar
+final 
 Data
@@ -735,23 +735,17 @@
 Factory 
-planarD
+d
 atasetFa
@@ -780,16 +780,54 @@
 tory();%0A
+%09%09final int%5B%5D dims = %7Bwidth, height%7D;%0A
 %09%09datase
@@ -834,15 +834,9 @@
 t = 
-planarD
+d
 atas
@@ -863,82 +863,36 @@
 set(
- Types.findType( %228=bit unsigned%22), new int%5B%5D %7B this.width, this.height %7D 
+new UnsignedByteType(), dims
 );%0A%09
@@ -912,19 +912,18 @@
 ata(
- 
 data
- 
 );%0A  %7D%0A
+%0A
 %7D%0A

Clean up gradient image plugin code.