From 295705dd3d7a8e8271c5230a30b77370373a6de7 Mon Sep 17 00:00:00 2001
From: Jeffrey Phillips Freeman <jeffrey.freeman@syncleus.com>
Date: Mon, 17 Oct 2016 14:32:20 -0400
Subject: [PATCH] Added the median demo.

---
 doc/PrivateMemorySpace.md                     |  2 +-
 .../aparapi/sample/median/MedianSettings.java | 15 -----------
 .../com/syncleus/aparapi/examples/All.java    |  6 ++++-
 .../aparapi/examples}/median/MedianDemo.java  | 14 +++++++++--
 .../examples}/median/MedianKernel7x7.java     | 12 ++++++++-
 .../examples/median/MedianSettings.java       | 25 +++++++++++++++++++
 6 files changed, 54 insertions(+), 20 deletions(-)
 delete mode 100644 samples/median/src/com/amd/aparapi/sample/median/MedianSettings.java
 rename {samples/median/src/com/amd/aparapi/sample => src/main/java/com/syncleus/aparapi/examples}/median/MedianDemo.java (86%)
 rename {samples/median/src/com/amd/aparapi/sample => src/main/java/com/syncleus/aparapi/examples}/median/MedianKernel7x7.java (90%)
 create mode 100644 src/main/java/com/syncleus/aparapi/examples/median/MedianSettings.java

diff --git a/doc/PrivateMemorySpace.md b/doc/PrivateMemorySpace.md
index 2db75572..4b51d2f8 100644
--- a/doc/PrivateMemorySpace.md
+++ b/doc/PrivateMemorySpace.md
@@ -29,6 +29,6 @@ Without modification, an Aparapi kernel which uses private buffers may fail to w
 
 The Kernel.NoCL annotation exists to allow specialised code to be executed when running in Java (or JTP) which is not invoked when running on the GPU. A NoCL method can be inserted at the begining of a Kernel's run() method which sets the private array to a value obtained from a static ThreadLocal<foo[]> where foo is the primitive type of the array in question. This will have no effect upon OpenCL execution, but will allow threadsafe execution when running in java.
 
-In the project samples, there is a package com.syncleus.aparapi.sample.median which gives an example of a median image filter which uses a private array of pixel data to apply a distructive median algorithm to a "window" of local pixels. This sample also demonstrates how to use the ThreadLocal trick to allow correct behaviour when running in JTP execution mode.
+In the project samples, there is a package com.syncleus.com.syncleus.aparapi.examples.median which gives an example of a median image filter which uses a private array of pixel data to apply a distructive median algorithm to a "window" of local pixels. This sample also demonstrates how to use the ThreadLocal trick to allow correct behaviour when running in JTP execution mode.
 
 [http://code.google.com/p/aparapi/source/browse/trunk/samples/median/src/com/amd/aparapi/sample/median/MedianDemo.java](http://code.google.com/p/aparapi/source/browse/trunk/samples/median/src/com/amd/aparapi/sample/median/MedianDemo.java)
\ No newline at end of file
diff --git a/samples/median/src/com/amd/aparapi/sample/median/MedianSettings.java b/samples/median/src/com/amd/aparapi/sample/median/MedianSettings.java
deleted file mode 100644
index dbbbede5..00000000
--- a/samples/median/src/com/amd/aparapi/sample/median/MedianSettings.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.syncleus.aparapi.sample.median;
-
-public class MedianSettings {
-   public final int windowWidth;
-   public final int windowHeight;
-
-   public MedianSettings(int windowSize) {
-      this(windowSize, windowSize);
-   }
-
-   public MedianSettings(int windowWidth, int windowHeight) {
-      this.windowWidth = windowWidth;
-      this.windowHeight = windowHeight;
-   }
-}
diff --git a/src/main/java/com/syncleus/aparapi/examples/All.java b/src/main/java/com/syncleus/aparapi/examples/All.java
index b8120b87..448a8c5a 100644
--- a/src/main/java/com/syncleus/aparapi/examples/All.java
+++ b/src/main/java/com/syncleus/aparapi/examples/All.java
@@ -25,7 +25,8 @@ public class All {
         System.out.println("  8) Squares");
         System.out.println("  9) Multipass swing worker");
         System.out.println("  10) Progress and cancel demo");
-        System.out.println("  11) info");
+        System.out.println("  11) Info");
+        System.out.println("  12) Medians");
         System.out.println();
 
         Scanner in = new Scanner(System.in);
@@ -89,6 +90,9 @@ public class All {
             case "11":
                 com.syncleus.aparapi.examples.info.Main.main(args);
                 break;
+            case "12":
+                com.syncleus.aparapi.examples.median.MedianDemo.main(args);
+                break;
             default:
                 System.out.println("Invalid selection.");
         }
diff --git a/samples/median/src/com/amd/aparapi/sample/median/MedianDemo.java b/src/main/java/com/syncleus/aparapi/examples/median/MedianDemo.java
similarity index 86%
rename from samples/median/src/com/amd/aparapi/sample/median/MedianDemo.java
rename to src/main/java/com/syncleus/aparapi/examples/median/MedianDemo.java
index cec33d9c..bbff9bbd 100644
--- a/samples/median/src/com/amd/aparapi/sample/median/MedianDemo.java
+++ b/src/main/java/com/syncleus/aparapi/examples/median/MedianDemo.java
@@ -1,4 +1,14 @@
-package com.syncleus.aparapi.sample.median;
+/**
+ * This product currently only contains code developed by authors
+ * of specific components, as identified by the source code files.
+ *
+ * Since product implements StAX API, it has dependencies to StAX API
+ * classes.
+ *
+ * For additional credits (generally to people who reported problems)
+ * see CREDITS file.
+ */
+package com.syncleus.aparapi.examples.median;
 
 import com.syncleus.aparapi.internal.kernel.*;
 
@@ -16,7 +26,7 @@ public class MedianDemo {
 
    static {
       try {
-         File imageFile = new File("./samples/convolution/testcard.jpg").getCanonicalFile();
+         File imageFile = new File("./src/main/resources/testcard.jpg").getCanonicalFile();
          if (imageFile.exists()) {
             testImage = ImageIO.read(imageFile);
          }
diff --git a/samples/median/src/com/amd/aparapi/sample/median/MedianKernel7x7.java b/src/main/java/com/syncleus/aparapi/examples/median/MedianKernel7x7.java
similarity index 90%
rename from samples/median/src/com/amd/aparapi/sample/median/MedianKernel7x7.java
rename to src/main/java/com/syncleus/aparapi/examples/median/MedianKernel7x7.java
index 46653f17..349c2eec 100644
--- a/samples/median/src/com/amd/aparapi/sample/median/MedianKernel7x7.java
+++ b/src/main/java/com/syncleus/aparapi/examples/median/MedianKernel7x7.java
@@ -1,4 +1,14 @@
-package com.syncleus.aparapi.sample.median;
+/**
+ * This product currently only contains code developed by authors
+ * of specific components, as identified by the source code files.
+ *
+ * Since product implements StAX API, it has dependencies to StAX API
+ * classes.
+ *
+ * For additional credits (generally to people who reported problems)
+ * see CREDITS file.
+ */
+package com.syncleus.aparapi.examples.median;
 
 import com.syncleus.aparapi.*;
 
diff --git a/src/main/java/com/syncleus/aparapi/examples/median/MedianSettings.java b/src/main/java/com/syncleus/aparapi/examples/median/MedianSettings.java
new file mode 100644
index 00000000..76068c4a
--- /dev/null
+++ b/src/main/java/com/syncleus/aparapi/examples/median/MedianSettings.java
@@ -0,0 +1,25 @@
+/**
+ * This product currently only contains code developed by authors
+ * of specific components, as identified by the source code files.
+ *
+ * Since product implements StAX API, it has dependencies to StAX API
+ * classes.
+ *
+ * For additional credits (generally to people who reported problems)
+ * see CREDITS file.
+ */
+package com.syncleus.aparapi.examples.median;
+
+public class MedianSettings {
+   public final int windowWidth;
+   public final int windowHeight;
+
+   public MedianSettings(int windowSize) {
+      this(windowSize, windowSize);
+   }
+
+   public MedianSettings(int windowWidth, int windowHeight) {
+      this.windowWidth = windowWidth;
+      this.windowHeight = windowHeight;
+   }
+}
-- 
GitLab