summaryrefslogtreecommitdiff
path: root/java/ImageProcessing
diff options
context:
space:
mode:
authorpjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-04-25 18:17:02 +0000
committerpjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-04-25 18:17:02 +0000
commitecb69a6cb04bb925efe017529e52ce0064227f7a (patch)
treea2a80f240b59b00a370536eb06d7a8d96394cea3 /java/ImageProcessing
parent2e64cf5aa0c0686b211f6566d8e189b37a74eff9 (diff)
downloadATCD-ecb69a6cb04bb925efe017529e52ce0064227f7a.tar.gz
New files used to show status of image being uploaded
Diffstat (limited to 'java/ImageProcessing')
-rw-r--r--java/ImageProcessing/framework/ImageByteCounter.java76
-rw-r--r--java/ImageProcessing/framework/StatusIndicator.java47
2 files changed, 123 insertions, 0 deletions
diff --git a/java/ImageProcessing/framework/ImageByteCounter.java b/java/ImageProcessing/framework/ImageByteCounter.java
new file mode 100644
index 00000000000..9b238c02b22
--- /dev/null
+++ b/java/ImageProcessing/framework/ImageByteCounter.java
@@ -0,0 +1,76 @@
+package imaging.framework;
+
+import java.io.*;
+import java.awt.*;
+import JACE.OS.*;
+
+public class ImageByteCounter
+{
+ public ImageByteCounter (String title, Image image)
+ {
+ this.image_ = image;
+ }
+
+ public int count ()
+ {
+ indicator_ = new StatusIndicator ("");
+ int length = 0;
+ try
+ {
+ // GIFOutputStream ostream = new GIFOutputStream (statusIndicator_);
+ GIFOutputStream ostream = new GIFOutputStream (null);
+ GifEncoder encoder = new GifEncoder (this.image_, ostream);
+ encoder.encode ();
+
+ length = ostream.count ();
+ System.out.println ("send: " + length);
+ }
+ catch (IOException e)
+ {
+ ACE.ERROR ("Exception generating gif");
+ }
+ // indicator_.dispose ();
+ return length;
+ }
+
+ Image image_ = null;
+ StatusIndicator indicator_ = null;
+}
+
+class GIFOutputStream extends OutputStream
+{
+ public GIFOutputStream (StatusIndicator indicator)
+ {
+ super ();
+ this.indicator_ = indicator;
+ }
+
+ public synchronized void write (int b) throws IOException
+ {
+ bytesWritten_++;
+ if (this.indicator_ != null)
+ this.indicator_.update (bytesWritten_);
+ }
+
+ public synchronized void write (byte buf[]) throws IOException
+ {
+ bytesWritten_ += buf.length;
+ if (this.indicator_ != null)
+ this.indicator_.update (bytesWritten_);
+ }
+
+ public synchronized void write (byte buf[], int offset, int length) throws IOException
+ {
+ bytesWritten_ += length;
+ if (this.indicator_ != null)
+ this.indicator_.update (bytesWritten_);
+ }
+
+ public int count ()
+ {
+ return this.bytesWritten_;
+ }
+
+ private int bytesWritten_ = 0;
+ private StatusIndicator indicator_ = null;
+}
diff --git a/java/ImageProcessing/framework/StatusIndicator.java b/java/ImageProcessing/framework/StatusIndicator.java
new file mode 100644
index 00000000000..3526bc550d5
--- /dev/null
+++ b/java/ImageProcessing/framework/StatusIndicator.java
@@ -0,0 +1,47 @@
+package imaging.framework;
+
+import java.io.*;
+import java.awt.*;
+
+public class StatusIndicator extends Frame
+{
+ public StatusIndicator (String title)
+ {
+ super (title);
+
+ this.setLayout (new BorderLayout ());
+ this.add ("Center", textCanvas_);
+ // this.add ("Center", new Button ("Hello"));
+ this.add ("South", new Button ("Hello"));
+ this.resize (300,200);
+ this.show ();
+ }
+
+ public void update (int count)
+ {
+ textCanvas_.setCount (count);
+ }
+
+ CounterCanvas textCanvas_ = new CounterCanvas ();
+}
+
+class CounterCanvas extends Canvas
+{
+ 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);
+ }
+
+ public void setCount (int count)
+ {
+ count_ = count;
+ repaint ();
+ }
+
+ int count_ = 0;
+}
+