summaryrefslogtreecommitdiff
path: root/java/ImageProcessing
diff options
context:
space:
mode:
authorpjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-05-02 21:47:59 +0000
committerpjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-05-02 21:47:59 +0000
commit5256f4c70ae13242cccd72d26b199d247ba23ebe (patch)
tree319df02e9cfa1b84ab4e13707c01f1dfbe4662a3 /java/ImageProcessing
parent3b6a3f722fc0e145291a858a481013dfbd3b638f (diff)
downloadATCD-5256f4c70ae13242cccd72d26b199d247ba23ebe.tar.gz
Cleaned up code a lot and added image uploading to testing.
Diffstat (limited to 'java/ImageProcessing')
-rw-r--r--java/ImageProcessing/framework/ImageApp.java8
-rw-r--r--java/ImageProcessing/framework/TestHandler.java125
-rw-r--r--java/ImageProcessing/framework/Tester.java55
-rw-r--r--java/ImageProcessing/framework/test.html6
4 files changed, 115 insertions, 79 deletions
diff --git a/java/ImageProcessing/framework/ImageApp.java b/java/ImageProcessing/framework/ImageApp.java
index 1c994ef4276..1ee44397792 100644
--- a/java/ImageProcessing/framework/ImageApp.java
+++ b/java/ImageProcessing/framework/ImageApp.java
@@ -24,12 +24,8 @@ public class ImageApp extends Applet
String testFile = getParameter ("testFile");
if (testFile != null)
{
- String server = getParameter ("server");
- String portString = getParameter ("port");
- int port = (new Integer (portString)).intValue ();
-
- this.tester_ = new Tester (testFile, server, port, this);
- System.out.println ("Initializing tester...");
+ this.tester_ = new Tester (testFile, this);
+ this.tester_.initialize ();
}
}
diff --git a/java/ImageProcessing/framework/TestHandler.java b/java/ImageProcessing/framework/TestHandler.java
index 84af7809ae8..f1aa96072e4 100644
--- a/java/ImageProcessing/framework/TestHandler.java
+++ b/java/ImageProcessing/framework/TestHandler.java
@@ -11,9 +11,13 @@ import JACE.Timers.*;
public class TestHandler extends SvcHandler
{
- public TestHandler (String imageList, ImageApp parent)
+ public TestHandler (String imageList,
+ String JAWSServer, int JAWSPort,
+ ImageApp parent)
{
this.imageList_ = imageList;
+ this.JAWSServer_ = JAWSServer;
+ this.JAWSPort_ = JAWSPort;
this.parent_ = parent;
this.filterTable_ = this.parent_.filterTable();
}
@@ -45,19 +49,26 @@ public class TestHandler extends SvcHandler
}
}
- private void process (String image)
+ private void write (String data)
{
try
{
+ // If we are connected to the server then send the data to the
+ // server, otherwise write it to standard out.
if (stdOut)
- System.out.println ("Image: " + image);
+ System.out.print (data);
else
- this.peer ().send ("Image: " + image + "\n");
+ this.peer ().send (data);
}
catch (IOException e)
{
ACE.ERROR (e);
}
+ }
+
+ private void process (String image)
+ {
+ this.write ("Image: " + image + "\n");
this.loadImage (image);
this.processImage (image);
@@ -66,78 +77,65 @@ public class TestHandler extends SvcHandler
private void loadImage (String image)
{
- try
+ this.write ("\tLoading...");
+
+ // Start the timer
+ timer_.start ();
+
+ // Load the image
+ parent_.openURL (image);
+
+ // Stop the timer
+ timer_.stop ();
+ long time = timer_.elapsedTime ();
+
+ this.write ("done (" + ((double) time)/1000 + " seconds).\n");
+ }
+
+ private void processImage (String image)
+ {
+ this.write ("\tProcessing...\n");
+
+ for (Enumeration e = filterTable_.keys (); e.hasMoreElements (); )
{
- if (stdOut)
- System.out.print ("\tLoading...");
- else
- this.peer ().send ("\tLoading...");
+ String filterName = (String) e.nextElement ();
+ this.write ("\t\t" + filterName + "...");
+
+ ImageFilter filter = (ImageFilter) filterTable_.get (filterName);
+
// Start the timer
timer_.start ();
-
- // Load the image
- parent_.openURL (image);
-
+
+ this.parent_.apply (filter);
+
// Stop the timer
timer_.stop ();
long time = timer_.elapsedTime ();
- if (stdOut)
- System.out.println ("done (" + ((double) time)/1000 + " seconds).");
- else
- this.peer ().send ("done (" + ((double) time)/1000 + " seconds).\n");
- }
- catch (IOException e)
- {
- ACE.ERROR (e);
+
+ this.write ("done (" + ((double) time)/1000 + " seconds).\n");
+
+ this.parent_.resetImage ();
}
-
}
-
- private void processImage (String image)
+
+ private void uploadImage (String image)
{
- try
- {
- if (stdOut)
- System.out.println ("\tProcessing...");
- else
- this.peer ().send ("\tProcessing...\n");
-
- for (Enumeration e = filterTable_.keys (); e.hasMoreElements (); )
- {
- String filterName = (String) e.nextElement ();
- if (stdOut)
- System.out.print ("\t\t" + filterName + "...");
- else
- this.peer ().send ("\t\t" + filterName + "...");
-
- ImageFilter filter = (ImageFilter) filterTable_.get (filterName);
+ int index = image.lastIndexOf ("/");
+ String imageName = image.substring (index+1);
+ String url = "http://" + this.JAWSServer_ + ":" + this.JAWSPort_ + "/" + imageName;
+ this.write ("\tUploading " + url + "...");
- // Start the timer
- timer_.start ();
+ // Start the timer
+ timer_.start ();
- this.parent_.apply (filter);
+ this.parent_.saveFile (url);
- // Stop the timer
- timer_.stop ();
- long time = timer_.elapsedTime ();
-
- if (stdOut)
- System.out.println ("done (" + ((double) time)/1000 + " seconds).");
- else
- this.peer ().send ("done (" + ((double) time)/1000 + " seconds).\n");
- this.parent_.resetImage ();
- }
- }
- catch (IOException e)
- {
- ACE.ERROR (e);
- }
- }
-
- private void uploadImage (String image)
- {
+ // Stop the timer
+ timer_.stop ();
+ long time = timer_.elapsedTime ();
+ this.write ("done (" + ((double) time)/1000 + " seconds).\n");
}
private ImageApp parent_ = null;
@@ -145,5 +143,6 @@ public class TestHandler extends SvcHandler
private String imageList_ = null;
private boolean stdOut = true;
private Hashtable filterTable_ = null;
-
+ private String JAWSServer_ = null;
+ private int JAWSPort_ = 5432;
}
diff --git a/java/ImageProcessing/framework/Tester.java b/java/ImageProcessing/framework/Tester.java
index bb2dd8e31bd..79204bb4c5a 100644
--- a/java/ImageProcessing/framework/Tester.java
+++ b/java/ImageProcessing/framework/Tester.java
@@ -10,12 +10,49 @@ import JACE.OS.*;
public class Tester implements Runnable
{
- public Tester (String testInFile, String server, int port, ImageApp parent)
+ public static final String DEFAULT_TEST_SERVER = "siesta.cs.wustl.edu";
+ public static final int DEFAULT_TEST_SERVER_PORT = 7787;
+ public static final String DEFAULT_JAWS_SERVER = "siesta.cs.wustl.edu";
+ public static final int DEFAULT_JAWS_SERVER_PORT = 5432;
+
+ public Tester (String testInFile,
+ ImageApp parent)
{
this.testInFile_ = testInFile;
- this.server_ = server;
- this.port_ = port;
this.parent_ = parent;
+ }
+
+ public void initialize ()
+ {
+ System.out.println ("Initializing tester...");
+
+ // Get the hostname of the test server
+ this.server_ = this.parent_.getParameter ("testServer");
+ if (this.server_ == null)
+ this.server_ = DEFAULT_TEST_SERVER;
+
+ // Get the port number of the test server
+ String testPortString = this.parent_.getParameter ("testPort");
+ if (testPortString == null)
+ this.port_ = DEFAULT_TEST_SERVER_PORT;
+ else
+ this.port_ = (new Integer (testPortString)).intValue ();
+
+ // Get the hostname of the JAWS server
+ this.JAWSServer_ = this.parent_.getParameter ("JAWSServer");
+ if (this.JAWSServer_ == null)
+ this.JAWSServer_ = DEFAULT_JAWS_SERVER;
+
+ // Get the port number of the JAWS server
+ String JAWSPortString = this.parent_.getParameter ("JAWSPort");
+ if (JAWSPortString == null)
+ this.JAWSServerPort_ = DEFAULT_JAWS_SERVER_PORT;
+ else
+ this.JAWSServerPort_ = (new Integer (JAWSPortString)).intValue ();
+
+ System.out.println ("Test Input File: " + this.testInFile_);
+ System.out.println ("Test Server: " + this.server_ + "\tPort: " + this.port_);
+ System.out.println ("JAWS Server: " + this.JAWSServer_ + "\tPort: " + this.JAWSServerPort_);
// Run in your own thread of control
(new Thread (this)).start ();
@@ -32,9 +69,6 @@ public class Tester implements Runnable
String imageList = null;
try
{
- System.out.println ("Test Input File: " + this.testInFile_);
- System.out.println ("Server: " + this.server_ + "\tPort: " + this.port_);
-
// Create input URL
inputURL = new URL (this.testInFile_);
@@ -70,8 +104,9 @@ public class Tester implements Runnable
// running then we will write to standard output.
// Create a handler which will handle our connection.
- TestHandler handler = new TestHandler (imageList, this.parent_);
-
+ TestHandler handler = new TestHandler (imageList,
+ this.JAWSServer_, this.JAWSServerPort_,
+ this.parent_);
try
{
Connector connector = new Connector ();
@@ -84,6 +119,7 @@ public class Tester implements Runnable
}
catch (SocketException e)
{
+ System.out.println ("Test Server not running! Writing to standard out...");
// The server is not running so write all the output to screen
handler.doTesting ();
}
@@ -105,5 +141,8 @@ public class Tester implements Runnable
private ImageApp parent_ = null;
private String server_ = "siesta.cs.wustl.edu";
private int port_ = 7787;
+
+ private String JAWSServer_ = "siesta.cs.wustl.edu";
+ private int JAWSServerPort_ = 5432;
}
diff --git a/java/ImageProcessing/framework/test.html b/java/ImageProcessing/framework/test.html
index 5ceec898152..caa20935816 100644
--- a/java/ImageProcessing/framework/test.html
+++ b/java/ImageProcessing/framework/test.html
@@ -10,8 +10,10 @@ bgcolor="#888888">
<!param name=filename value="cow.gif">
<param name=filename value="myphoto.gif">
<param name=testFile value="http://www.cs.wustl.edu/~pjain/java/ACE_wrappers/java/ImageProcessing/framework/testImages.conf">
-<param name=server value="siesta.cs.wustl.edu">
-<param name=port value="7787">
+<param name=testServer value="siesta.cs.wustl.edu">
+<param name=testPort value="7789">
+<param name=JAWSServer value="siesta.cs.wustl.edu">
+<param name=JAWSPort value="5432">
</APPLET>
<HR>