summaryrefslogtreecommitdiff
path: root/java/ImageProcessing
diff options
context:
space:
mode:
authorpjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-04-25 19:55:36 +0000
committerpjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-04-25 19:55:36 +0000
commit6933852ff0038829575a6ddc3428569024e64353 (patch)
tree4a8fe38c18c2be5c6aa23f75d5e06b83780a9958 /java/ImageProcessing
parent5a3f2480a40b58208b2e5bd79462dca753af312f (diff)
downloadATCD-6933852ff0038829575a6ddc3428569024e64353.tar.gz
Small changes
Diffstat (limited to 'java/ImageProcessing')
-rw-r--r--java/ImageProcessing/framework/ImageApp.java2
-rw-r--r--java/ImageProcessing/framework/ImageByteCounter.java28
-rw-r--r--java/ImageProcessing/framework/ImageSender.java9
-rw-r--r--java/ImageProcessing/framework/StatusIndicator.java47
-rw-r--r--java/ImageProcessing/framework/Tester.java159
5 files changed, 226 insertions, 19 deletions
diff --git a/java/ImageProcessing/framework/ImageApp.java b/java/ImageProcessing/framework/ImageApp.java
index 767ee6508f2..97272693742 100644
--- a/java/ImageProcessing/framework/ImageApp.java
+++ b/java/ImageProcessing/framework/ImageApp.java
@@ -145,7 +145,7 @@ public class ImageApp extends Applet
public void saveFile (String url)
{
- ImageSender imageSender = new ImageSender ();
+ ImageSender imageSender = new ImageSender (this);
imageSender.open (this.imageCanvas_.getImage (), url);
int bytesSent = imageSender.send ();
if (bytesSent == -1)
diff --git a/java/ImageProcessing/framework/ImageByteCounter.java b/java/ImageProcessing/framework/ImageByteCounter.java
index 9b238c02b22..c907c9f1c92 100644
--- a/java/ImageProcessing/framework/ImageByteCounter.java
+++ b/java/ImageProcessing/framework/ImageByteCounter.java
@@ -2,23 +2,39 @@ package imaging.framework;
import java.io.*;
import java.awt.*;
+import java.applet.*;
+import java.net.*;
import JACE.OS.*;
public class ImageByteCounter
{
- public ImageByteCounter (String title, Image image)
+ public ImageByteCounter (String title, Image image, Applet parent)
{
this.image_ = image;
+ this.parent_ = parent;
+
+ Image im = null;
+ try
+ {
+ im = this.parent_.getImage (new URL (this.parent_.getCodeBase () +
+ "../ImageProcessing/framework/" +
+ "10.gif"));
+ }
+ catch (MalformedURLException e)
+ {
+ ACE.ERROR (e);
+ }
+
+ indicator_ = new StatusIndicator ("", im);
}
public int count ()
{
- indicator_ = new StatusIndicator ("");
int length = 0;
try
{
- // GIFOutputStream ostream = new GIFOutputStream (statusIndicator_);
- GIFOutputStream ostream = new GIFOutputStream (null);
+ GIFOutputStream ostream = new GIFOutputStream (indicator_);
+ // GIFOutputStream ostream = new GIFOutputStream (null);
GifEncoder encoder = new GifEncoder (this.image_, ostream);
encoder.encode ();
@@ -29,12 +45,14 @@ public class ImageByteCounter
{
ACE.ERROR ("Exception generating gif");
}
- // indicator_.dispose ();
+ indicator_.dispose ();
return length;
}
Image image_ = null;
StatusIndicator indicator_ = null;
+ boolean done_ = false;
+ Applet parent_;
}
class GIFOutputStream extends OutputStream
diff --git a/java/ImageProcessing/framework/ImageSender.java b/java/ImageProcessing/framework/ImageSender.java
index d4d1915e162..708e39f9fae 100644
--- a/java/ImageProcessing/framework/ImageSender.java
+++ b/java/ImageProcessing/framework/ImageSender.java
@@ -3,11 +3,17 @@ package imaging.framework;
import java.awt.*;
import java.net.*;
import java.io.*;
+import java.applet.*;
import JACE.OS.*;
import JACE.Connection.*;
public class ImageSender
{
+ public ImageSender (Applet parent)
+ {
+ this.parent_ = parent;
+ }
+
public void open (Image image, String url)
{
this.image_ = image;
@@ -42,8 +48,8 @@ public class ImageSender
public int send ()
{
+ ImageByteCounter byteCounter = new ImageByteCounter ("", this.image_, this.parent_);
// StatusIndicator indicator = new StatusIndicator ("");
- ImageByteCounter byteCounter = new ImageByteCounter ("", this.image_);
// ImageByteCounter byteCounter = new ImageByteCounter ("", this.image_, indicator);
int length = byteCounter.count ();
// indicator.dispose ();
@@ -99,5 +105,6 @@ public class ImageSender
String hostname_;
int port_;
Connector connector_ = new Connector ();
+ Applet parent_;
}
diff --git a/java/ImageProcessing/framework/StatusIndicator.java b/java/ImageProcessing/framework/StatusIndicator.java
index 3526bc550d5..0f13a71c016 100644
--- a/java/ImageProcessing/framework/StatusIndicator.java
+++ b/java/ImageProcessing/framework/StatusIndicator.java
@@ -5,43 +5,66 @@ import java.awt.*;
public class StatusIndicator extends Frame
{
- public StatusIndicator (String title)
+ public StatusIndicator (String title, Image image)
{
super (title);
-
+ this.image_ = image;
+ // statusCanvas_ = new CounterCanvas (image);
this.setLayout (new BorderLayout ());
- this.add ("Center", textCanvas_);
+ this.text_ = new TextField ();
+ this.label_ = new TextField ("Generating");
+
+ this.add ("North", this.label_);
+ this.add ("Center", text_);
+ // this.add ("Center", statusCanvas_);
// this.add ("Center", new Button ("Hello"));
- this.add ("South", new Button ("Hello"));
+ // this.add ("South", new Button ("Hello"));
this.resize (300,200);
this.show ();
}
public void update (int count)
{
- textCanvas_.setCount (count);
+ // this.label_.setText ("Generating...");
+ this.text_.setText ((new Integer (count++)).toString ());
+ // statusCanvas_.update ();
+ // textCanvas_.setCount (count);
}
- CounterCanvas textCanvas_ = new CounterCanvas ();
+ TextField text_;
+ TextField label_;
+ Image image_;
+ // CounterCanvas statusCanvas_ = null;
}
class CounterCanvas extends Canvas
{
+ public CounterCanvas (Image image)
+ {
+ this.image_ = image;
+ }
+
public void paint (Graphics g)
{
g.clearRect (0, 0, this.size ().width, this.size ().height);
- g.setFont (new Font ("TimesRoman", Font.PLAIN, 18));
this.setBackground (Color.white);
- g.drawString ("Generating GIF format: ", 20, 20);
- g.drawString ((new Integer (count_)).toString (), 200, 20);
+
+ if (this.image_ != null)
+ g.drawImage(this.image_,
+ 40, 40,
+ this.image_.getWidth (this),
+ this.image_.getHeight (this),
+ this);
+
+ g.setFont (new Font ("TimesRoman", Font.PLAIN, 18));
+ g.drawString ("Generating GIF format: ", 120, 120);
}
- public void setCount (int count)
+ public void update ()
{
- count_ = count;
repaint ();
}
- int count_ = 0;
+ Image image_ = null;
}
diff --git a/java/ImageProcessing/framework/Tester.java b/java/ImageProcessing/framework/Tester.java
new file mode 100644
index 00000000000..953bbe71e76
--- /dev/null
+++ b/java/ImageProcessing/framework/Tester.java
@@ -0,0 +1,159 @@
+package imaging.framework;
+
+import java.io.*;
+import java.net.*;
+import java.awt.*;
+import java.awt.image.*;
+import java.util.*;
+import JACE.Timers.*;
+
+public class Tester implements Runnable
+{
+ public Tester (String testInFile, String testOutFile, ImageApp parent)
+ {
+ this.testInFile_ = testInFile;
+ this.testOutFile_ = testOutFile;
+ this.parent_ = parent;
+ this.filterTable_ = this.parent_.filterTable();
+
+ // Run in your own thread of control
+ (new Thread (this)).start ();
+ }
+
+ public void run ()
+ {
+ URL inputURL;
+ URL outputURL;
+ String imageList= null;
+ try
+ {
+ System.out.println ("Test Input File: " + this.testInFile_);
+ System.out.println ("Test Output File: " + this.testOutFile_);
+
+ // Create URLs
+ 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
+ String tempString = iStream.readLine ();
+ while (tempString != null)
+ {
+ tempBuf.append (tempString);
+ tempBuf.append (" ");
+ tempString = iStream.readLine ();
+ }
+ imageList = tempBuf.toString ();
+ }
+ catch (MalformedURLException e)
+ {
+ System.err.println (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);
+ }
+ }
+ }
+
+ 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)
+ {
+ if (oStream_ == null)
+ System.out.print ("\tLoading...");
+ else
+ oStream_.print ("\tLoading...");
+
+ // Start the timer
+ timer_.start ();
+
+ // Load the image
+ parent_.openURL (image);
+
+ // 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...");
+
+ for (Enumeration e = filterTable_.keys (); e.hasMoreElements (); )
+ {
+ 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 ();
+ }
+ }
+
+ 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;
+}