summaryrefslogtreecommitdiff
path: root/java/ImageProcessing/framework/Tester.java
diff options
context:
space:
mode:
authorpjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-04-25 22:08:33 +0000
committerpjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-04-25 22:08:33 +0000
commitddf5f9be236bdcc327e713b6c8c73d0bea61f808 (patch)
tree607e158178511f33dc485b47e8e3c9a2389e23b6 /java/ImageProcessing/framework/Tester.java
parent3e0461fc9fa0d722904a6f53b21635a982fcac52 (diff)
downloadATCD-ddf5f9be236bdcc327e713b6c8c73d0bea61f808.tar.gz
Added new classes to implement the server side (for testing)
Diffstat (limited to 'java/ImageProcessing/framework/Tester.java')
-rw-r--r--java/ImageProcessing/framework/Tester.java148
1 files changed, 49 insertions, 99 deletions
diff --git a/java/ImageProcessing/framework/Tester.java b/java/ImageProcessing/framework/Tester.java
index 953bbe71e76..bb2dd8e31bd 100644
--- a/java/ImageProcessing/framework/Tester.java
+++ b/java/ImageProcessing/framework/Tester.java
@@ -5,16 +5,17 @@ import java.net.*;
import java.awt.*;
import java.awt.image.*;
import java.util.*;
-import JACE.Timers.*;
+import JACE.Connection.*;
+import JACE.OS.*;
public class Tester implements Runnable
{
- public Tester (String testInFile, String testOutFile, ImageApp parent)
+ public Tester (String testInFile, String server, int port, ImageApp parent)
{
this.testInFile_ = testInFile;
- this.testOutFile_ = testOutFile;
+ this.server_ = server;
+ this.port_ = port;
this.parent_ = parent;
- this.filterTable_ = this.parent_.filterTable();
// Run in your own thread of control
(new Thread (this)).start ();
@@ -22,25 +23,24 @@ public class Tester implements Runnable
public void run ()
{
+ this.setupConnection (this.getImages ());
+ }
+
+ private String getImages ()
+ {
URL inputURL;
- URL outputURL;
- String imageList= null;
+ String imageList = null;
try
{
System.out.println ("Test Input File: " + this.testInFile_);
- System.out.println ("Test Output File: " + this.testOutFile_);
+ System.out.println ("Server: " + this.server_ + "\tPort: " + this.port_);
- // Create URLs
+ // Create input URL
inputURL = new URL (this.testInFile_);
- outputURL = new URL (this.testOutFile_);
- URLConnection connection = outputURL.openConnection ();
// Get the input stream and pipe it to a DataInputStream
DataInputStream iStream = new DataInputStream (inputURL.openStream ());
- // Get the output stream and pipe it to a PrintStream
- oStream_ = new PrintStream (connection.getOutputStream ());
-
// Create a buffer to hold all the data we get
StringBuffer tempBuf = new StringBuffer ();
// Keep reading the data until we are done
@@ -55,105 +55,55 @@ public class Tester implements Runnable
}
catch (MalformedURLException e)
{
- System.err.println (e);
+ ACE.ERROR (e);
}
catch (IOException e)
{
- System.err.println (e);
- }
-
- if (imageList != null)
- {
- StringTokenizer tokens = new StringTokenizer (imageList);
- String image = null;
-
- // Now parse the string, picking up image names.
- while (tokens.hasMoreTokens ())
- {
- // Get the next token
- image = tokens.nextToken ();
- this.doTesting (image);
- }
+ ACE.ERROR (e);
}
+ return imageList;
}
- private void doTesting (String image)
- {
- if (oStream_ == null)
- System.out.println ("Image: " + image);
- else
- oStream_.println ("Image: " + image);
-
- this.loadImage (image);
- this.processImage (image);
- this.uploadImage (image);
- }
-
- private void loadImage (String image)
+ private void setupConnection (String imageList)
{
- if (oStream_ == null)
- System.out.print ("\tLoading...");
- else
- oStream_.print ("\tLoading...");
-
- // Start the timer
- timer_.start ();
-
- // Load the image
- parent_.openURL (image);
+ // First try to connect to the server. If the server is not
+ // running then we will write to standard output.
- // Stop the timer
- timer_.stop ();
- long time = timer_.elapsedTime ();
- if (oStream_ == null)
- System.out.println ("done (" + ((double) time)/1000 + " seconds).");
- else
- oStream_.println ("done (" + ((double) time)/1000 + " seconds).");
- }
-
- private void processImage (String image)
- {
- if (oStream_ == null)
- System.out.println ("\tProcessing...");
- else
- oStream_.println ("\tProcessing...");
+ // Create a handler which will handle our connection.
+ TestHandler handler = new TestHandler (imageList, this.parent_);
- for (Enumeration e = filterTable_.keys (); e.hasMoreElements (); )
+ try
{
- String filterName = (String) e.nextElement ();
- if (oStream_ == null)
- System.out.print ("\t\t" + filterName + "...");
- else
- oStream_.print ("\t\t" + filterName + "...");
-
- ImageFilter filter = (ImageFilter) filterTable_.get (filterName);
-
- // Start the timer
- timer_.start ();
-
- this.parent_.apply (filter);
-
- // Stop the timer
- timer_.stop ();
- long time = timer_.elapsedTime ();
-
- if (oStream_ == null)
- System.out.println ("done (" + ((double) time)/1000 + " seconds).");
- else
- oStream_.println ("done (" + ((double) time)/1000 + " seconds).");
- this.parent_.resetImage ();
+ Connector connector = new Connector ();
+ connector.open (server_, port_);
+ connector.connect (handler);
+ }
+ catch (UnknownHostException e)
+ {
+ ACE.ERROR (e);
+ }
+ catch (SocketException e)
+ {
+ // The server is not running so write all the output to screen
+ handler.doTesting ();
+ }
+ catch (InstantiationException e)
+ {
+ ACE.ERROR (e);
+ }
+ catch (IllegalAccessException e)
+ {
+ ACE.ERROR (e);
+ }
+ catch (IOException e)
+ {
+ ACE.ERROR (e);
}
- }
-
- private void uploadImage (String image)
- {
-
}
private String testInFile_ = null;
- private String testOutFile_ = null;
private ImageApp parent_ = null;
- private ProfileTimer timer_ = new ProfileTimer ();
- private Hashtable filterTable_ = null;
- PrintStream oStream_ = null;
+ private String server_ = "siesta.cs.wustl.edu";
+ private int port_ = 7787;
}
+