[2083] in java-interest
Returned mail: User unknown
daemon@ATHENA.MIT.EDU (Mail Delivery Subsystem)
Sat Sep 23 04:03:48 1995
Date: Fri, 22 Sep 95 23:46:48 EDT
From: Mailer-Daemon@IConNet.COM (Mail Delivery Subsystem)
To: <java-interest@java.sun.com>
----- Transcript of session follows -----
Connected to nextec.iconnet.com:
>>> RCPT To:<sharmolin@nextec>
<<< 550 <sharmolin@nextec>... User unknown
550 sharmolin@nextec... User unknown
----- Unsent message follows -----
Return-Path: <java-interest@java.sun.com>
Received: by overlord.IConNet.COM (4.1/SMI-4.1)
id AA02251; Fri, 22 Sep 95 23:46:48 EDT
Received: from nextec.iconnet.com(199.173.161.199) by overlord.IConNet.COM via smap (V1.3)
id sma002249; Fri Sep 22 23:46:20 1995
Received: from overlord.IConNet.COM by nextec. (5.x/SMI-SVR4)
id AA00987; Fri, 22 Sep 1995 23:49:25 -0400
Received: by overlord.IConNet.COM (4.1/SMI-4.1)
id AA02246; Fri, 22 Sep 95 23:46:18 EDT
Received: from mail.iconnet.com(199.173.161.113) by overlord.IConNet.COM via smap (V1.3)
id sma002244; Fri Sep 22 23:46:03 1995
Received: from cc:Mail by mail.IConNet.COM
id AA811839733; Sat, 23 Sep 95 00:02:06 EST
Date: Sat, 23 Sep 95 00:02:06 EST
From: java-interest@java.sun.com
Encoding: 1119 Text
Message-Id: <9508238118.AA811839733@mail.IConNet.COM>
To: java-interest-digest@java.sun.com
Subject: java-interest-digest V1 #183
Received: by ccmail from java.sun.com
From owner-java-interest-digest@java.sun.com
X-Envelope-From: owner-java-interest-digest@java.sun.com
Received: (from majordom@localhost) by java.sun.com (8.6.12/8.6.12) id KAA16349 for java-interest-digest-outgoing; Fri, 22 Sep 1995 10:42:10 -0700
Date: Fri, 22 Sep 1995 10:42:10 -0700
Message-Id: <199509221742.KAA16349@java.sun.com>
From: owner-java-interest-digest@java.sun.com
To: java-interest-digest@java.sun.com
Subject: java-interest-digest V1 #183
Reply-To: java-interest@java.sun.com
Errors-To: owner-java-interest-digest@java.sun.com
Precedence: bulk
X-Info: To unsubscribe, send 'unsubscribe' to java-interest-digest-request@java.sun.com
java-interest-digest Friday, 22 September 1995 Volume 01 : Number 183
In this issue:
Re: loading error
Re: loading error
Wouldn't it be nice if...
// javac not counting well
Java interpreters for AIX or Linux?
Re: thread.sleep and java.lang.InterruptedException
[none]
Using search tool with pre-beta api doco
Re: thread.sleep and java.lang.InterruptedException
Need java programming guide or user's guide.
Re: throws declataration in Java/beta
RE>java-interest-digest V1 #178
JPEG Support
Re: Setting Boundaries (was Re: JDK Question)
Re: throws declataration in Java/beta
Re: method/fn ptrs?
Getting nowhere with JDK
Returned mail: User unknown
----------------------------------------------------------------------
From: Mentor <mentor@io.org>
Date: Fri, 22 Sep 1995 09:57:14 -0400 (EDT)
Subject: Re: loading error
On Thu, 21 Sep 1995, Jeffrey Tseng wrote:
>
> I have written a few classes, but kept them all in the same file. One of
> the classes extends Applet, but the others don't. When I try to use HotJava
> to load the class file, it gives me an Access Exception error, and says that
> an "applet has attempted to read ...filename.class"
It was driving me bananas on a SPARC, but then I read the docs... ;-)
I moved everything to ~/public_html/classes, and the problem went away. It
turns out that $HOME/public_html/ is one of the possible directories which are
okay to access as determined by the HOTJAVA_READ_PATH environment variable.
So, you have two choices: move your stuff to the directory, or change the
variable.
(this should be in the FAQ)
Cheers,
David Forster
Mentor Software Solutions
<a href="http://www.io.org/~mentor">Mentor Software Solutions</a>
------------------------------
From: Jeffrey Tseng <jtseng@graphics.cornell.edu>
Date: Fri, 22 Sep 95 10:29:04 EDT
Subject: Re: loading error
>
> On Thu, 21 Sep 1995, Jeffrey Tseng wrote:
> >
> > I have written a few classes, but kept them all in the same file. One of
> > the classes extends Applet, but the others don't. When I try to use HotJava
> > to load the class file, it gives me an Access Exception error, and says that
> > an "applet has attempted to read ...filename.class"
>
> It was driving me bananas on a SPARC, but then I read the docs... ;-)
>
> I moved everything to ~/public_html/classes, and the problem went away. It
> turns out that $HOME/public_html/ is one of the possible directories which are
> okay to access as determined by the HOTJAVA_READ_PATH environment variable.
> So, you have two choices: move your stuff to the directory, or change the
> variable.
>
> (this should be in the FAQ)
>
> Cheers,
> David Forster
> Mentor Software Solutions
> <a href="http://www.io.org/~mentor">Mentor Software Solutions</a>
>
>
It's still driving me bananas, since I'm working on NT and I can't for the
life of me figure out which directories are ok to access. The environment
variable HOTJAVA_READ_PATH doesn't seem to work here, either.
I've tried searching the docs, also, and can't find anything...
Thanks in advance (again)
- - Jeff
------------------------------
From: rethingt@lehman.com (Russell Ethington)
Date: Fri, 22 Sep 95 10:36:11 EDT
Subject: Wouldn't it be nice if...
I just learned that putting an Applet thread to sleep in the wrong
place can block other Applets of the same kind. For example:
// ...
Thread life;
// ...
public void paint() {
for (int i = 0; i < 100; i++) {
// ...
life.sleep(50);
}
}
So, I guess we're getting one event queue per Browser and not one
per Applet? Wouldn't it be nice if each Applet had it's own event
queue? Is this just a Windows NT/95 thing??
Or, is paint() synchronized and one Applet instance doing a paint()
locks out other Applet instances from entering paint()??? Hope not.
When the real doc's come out, I hope we'll be able to read in great
depth about how user events turn into method calls; which methods
are event "handlers" and which aren't; which are synchronized, etc.
Having fun,
- -r
------------------------------
From: rethingt@lehman.com (Russell Ethington)
Date: Fri, 22 Sep 95 11:21:24 EDT
Subject: // javac not counting well
Are you (and your editor) being misled by the line numbers coming
out of javac? It looks like lines with // comments are not being
counted.
Still having fun,
- -r
------------------------------
From: Igor_Chudov@wiltel.com (Igor Chudov)
Date: Fri, 22 Sep 1995 10:45:37 -0500 (CDT)
Subject: Java interpreters for AIX or Linux?
Hello,
Are there any working [and hopefully free] Java interpreters/compilers
for either AIX (RS6000) or Linux? Your reply and/or post to mailing
list will be most appreciated.
Thanks,
- Igor x2309.
------------------------------
From: Larry Reu <larryr@CyberGate.COM>
Date: Fri, 22 Sep 1995 08:55:33 -0700 (PDT)
Subject: Re: thread.sleep and java.lang.InterruptedException
On Thu, 21 Sep 1995, Janet Coursey wrote:
> In the JDK prebeta1 , I get this compiler error:
>
> javac Foo.java
> Foo.java:11: Warning: Exception java.lang.InterruptedException must be caught, or it must be
> declared in throws clause of this method.
> thread.sleep(150);
you can try something like:
public void run()
{
try
{
thread.sleep(150);
}
catch (java.lang.Exception e)
{
System.out.println("got exception");
//do other stuff
}
}
this of course catchs all exceptions you can just catch
the one you may expect, etc, etc.
.....................larry
------------------------------
From: pfu.fujitsu.co.jp!satoo@fujitsuI.fujitsu.com
Date: Sat, 23 Sep 1995 00:47:41 +0900
Subject: [none]
unsbscribe
------------------------------
From: James L Weaver/DELCO <JLWEAVER@mail.delcoelect.com>
Date: Fri, 22 Sep 1995 10:50:52 -0500 (EST)
Subject: Using search tool with pre-beta api doco
If you want to search the beta API documentation using HotJava, here's what
you need to do:
1) Download the beta api html files from the JDK page
(http://java.sun.com/JDK-prebeta1/ftp_docs.html)
2) Unpack these documents -- the tar file will put them in a directory
named api
3) Rename that api directory to something like betaDocs and move the
betaDocs to $JAVAHOME/doc where JAVAHOME is the installation directory
of the *alpha* version of java/hotjava
4) In $JAVAHOME/doc there's a file called ListOfBooks; edit that file
and include the following two lines
JAVA Beta API
betaDocs
5) In $JAVAHOME/doc run the following command
$JAVAHOME/bin/java -classpath
$JAVAHOME/classes/browser/tools/JavaSearch:$JAVAHOME/classes
browser.tools.JavaSearch.javaindex -stoplist
$JAVAHOME/doc/real-short-stoplist.txt -db betaDocs/ betaDocs/*
Note that JAVAHOME still refers to the *alpha* distribution of java
Then you can start the alpha HotJava and in the Search window, select the
JAVA Beta API as the Books to search and you'll be set.
- - -sdo
----------------------------------------------------------------------
Step #5 above didn't work for me. Are there any typos?
Thanks,
Jim Weaver
------------------------------
From: jpayne@starwave.com (Jonathan Payne)
Date: Fri, 22 Sep 1995 09:00:51 -0700
Subject: Re: thread.sleep and java.lang.InterruptedException
You have to put a bogus try/catch around your code which uses
Thread.sleep in order to make the compiler happy.
------------------------------
From: doug@equator.Central.Sun.COM (Doug McMullen - Des Moines SE)
Date: Fri, 22 Sep 1995 11:27:20 +0600
Subject: Need java programming guide or user's guide.
Does such a document exist yet, and if so, where can I find it?
Thanks,
Doug McMullen
------------------------------
From: Christopher Lindblad <cjl@Eng.Sun.COM>
Date: Fri, 22 Sep 1995 09:21:51 -0700
Subject: Re: throws declataration in Java/beta
Date: Thu, 21 Sep 1995 18:46:16 -0400
From: arnold@cocolat.East.Sun.COM (Ken Arnold - Sun Labs)
As the words on the front of the HHGTTG say:
DON'T PANIC
A method cannot throw an exception type not declared in its throws
clause. This is good. You now know which exceptions can be thrown by
a method.
Then shouldn't any method that uses the "new" operator be required to either
catch java.lang.OutOfMemoryError or declare it in its throws clause? The
"new" operator certainly throws this exception.
Also, shouldn't any method that uses arrays or accesses an instance variable
or method on another object either catch java.lang.NullPointerException or
declare it in its throws clause? The method could potentially cause that
exception to be thrown.
Perhaps these should be considered "universal" exceptions, in that one should
assume that all methods throw them. In that case, shouldn't
InterruptedException be counted as a "universal" exception too?
------------------------------
From: Keith Ray <Keith.Ray@khis.Kodak.COM>
Date: Fri, 22 Sep 1995 11:27:25 +0000
Subject: RE>java-interest-digest V1 #178
Date 9/22/95
Subject RE>java-interest-digest V1
From Keith Ray
To java-interest
Reply to: RE>java-interest-digest V1 #178
unsubscribe
what kind of digest is this that keeps sending me ~6 mail messages in one day?
------------------------------
From: Karl Asha <karl@blackdown.org>
Date: Fri, 22 Sep 1995 12:27:11 -0400
Subject: JPEG Support
Has anything been done to support the jpeg image format?
Karl Asha
karl@blackdown.org
http://www.blackdown.org
------------------------------
From: cmcmanis@scndprsn.Eng.Sun.COM (Chuck McManis)
Date: Fri, 22 Sep 1995 09:29:55 -0700
Subject: Re: Setting Boundaries (was Re: JDK Question)
Actually, adding more java files doesn't impact portability since they
just work. There are currently 28 classes in the java.* hierarchy that
have native methods (and thus require porting). Pure java code works the
same where ever it runs.
- --Chuck
------------------------------
From: Larry Reu <larryr@CyberGate.COM>
Date: Fri, 22 Sep 1995 09:31:45 -0700 (PDT)
Subject: Re: throws declataration in Java/beta
The way Java handles exceptions (no pun intended) isn't
much different from C++. Java just does better compile
time checking.
If you read "The Design and Evolution of C++" Stroustrup
explains why the "throws clause" was added to fct sigs.
He also continues to express his desire to have the
compiler perform compile-time checks on the use of
exceptions but felt it would be cause for many recompiles
since whenever a fct changed its exceptions dependents
would have to recompile (much like changing param types, etc).
I feel the Java folks did it right! Modifying a method to
throw a new exception is just as important as adding or
removing arguments from the fct -- i.e. all clients should
be notified, etc.
......$0.02 for the pot................larry
------------------------------
From: fgreco@lehman.com (Frank Greco)
Date: Fri, 22 Sep 95 12:27:34 EDT
Subject: Re: method/fn ptrs?
> There is no direct equivalent in Java. What you can do is create a
> class, for example Action, that has an execute method. You then
> have an array of Action objects which you can call execute on.
Yeah... that I know. Then once in an array (of refs) the penalty is
only an indirect-indirect call (object handle de-ref, then the method
de-ref), right?
Thanks Sami.
Frank
- Was Dimension-X's JavaDay demo way cool or what... kudos to those boys.
------------------------------
From: ser@jersey.uoregon.edu
Date: Fri, 22 Sep 1995 10:29:11 -0700
Subject: Getting nowhere with JDK
D.C.Baldaro@reading.ac.uk (D. C. Baldaro) asked:
> This may seem like a silly question, but WHAT am I doing wrong?
> I am not normally one for following instructions etc. but this time I did
> and <bang> nothing!
>
> Downloaded JDK onto SPARC 10, loadsa disk and memory - a o k.
> Read the README .... always a un-nerving experience!
> Added ~/java/bin to my path.
> Tries appletviewer demo/TicTacToe/example1.html (Or whatever the path)
>
> and ...
>
> <BANG>
>
> skynet% appletviewer example1.html
> SIGSEGV 11* segmentation violation
> si_signo [11]: SIGSERV 11* segmentation violation
> si_errno [0]: Error 0
> si_code [1]: SEBV_ACCERR [addr:0xc]
>
> ... now not being an expert. I would say that was BAD.
> What did I say? Did I not ask it nicely?
>
> The machine is running Solaris 2.4, so thats not a prob. The
> only thing that I can think of is that I am trying to redirect
> the display! but thats just silly - isn't it?
Was HotJava already installed? Make sure you aren't overriding the beta
Java's library path with your LD_LIBRARY_PATH; it might be trying to run
with HotJava's librarys.
- --- SER
------------------------------
From: Mailer-Daemon@IConNet.COM (Mail Delivery Subsystem)
Date: Fri, 22 Sep 95 13:37:27 EDT
Subject: Returned mail: User unknown
----- Transcript of session follows -----
Connected to nextec.iconnet.com:
>>> RCPT To:<sharmolin@nextec>
<<< 550 <sharmolin@nextec>... User unknown
550 sharmolin@nextec... User unknown
----- Unsent message follows -----
Return-Path: <java-interest@java.sun.com>
Received: by overlord.IConNet.COM (4.1/SMI-4.1)
id AA00937; Fri, 22 Sep 95 13:37:27 EDT
Received: from nextec.iconnet.com(199.173.161.199) by overlord.IConNet.COM via smap (V1.3)
id sma000935; Fri Sep 22 13:36:59 1995
Received: from overlord.IConNet.COM by nextec. (5.x/SMI-SVR4)
id AA00772; Fri, 22 Sep 1995 13:40:04 -0400
Received: by overlord.IConNet.COM (4.1/SMI-4.1)
id AA00932; Fri, 22 Sep 95 13:36:57 EDT
Received: from mail.iconnet.com(199.173.161.113) by overlord.IConNet.COM via smap (V1.3)
id sma000930; Fri Sep 22 13:36:35 1995
Received: from cc:Mail by mail.IConNet.COM
id AA811803166; Fri, 22 Sep 95 13:52:40 EST
Date: Fri, 22 Sep 95 13:52:40 EST
From: java-interest@java.sun.com
Encoding: 647 Text
Message-Id: <9508228118.AA811803166@mail.IConNet.COM>
To: java-interest-digest@java.sun.com
Subject: java-interest-digest V1 #181
Received: by ccmail from java.sun.com
From owner-java-interest-digest@java.sun.com
X-Envelope-From: owner-java-interest-digest@java.sun.com
Received: (from majordom@localhost) by java.sun.com (8.6.12/8.6.12) id XAA28638
for java-interest-digest-outgoing; Thu, 21 Sep 1995 23:30:06 -0700
Date: Thu, 21 Sep 1995 23:30:06 -0700
Message-Id: <199509220630.XAA28638@java.sun.com>
From: owner-java-interest-digest@java.sun.com
To: java-interest-digest@java.sun.com
Subject: java-interest-digest V1 #181
Reply-To: java-interest@java.sun.com
Errors-To: owner-java-interest-digest@java.sun.com
Precedence: bulk
X-Info: To unsubscribe, send 'unsubscribe' to
java-interest-digest-request@java.sun.com
java-interest-digest Friday, 22 September 1995 Volume 01 : Number 181
In this issue:
Re: Fn ptrs & ... callbacks!?
Re: Displaying a Gif...
Setting Boundaries (was Re: JDK Question)
Re: Displaying a Gif...
thread.sleep and java.lang.InterruptedException
Re: new Image classes
Re: [Q] protocol of an object
Re: Displaying a Gif...
Re: throws declataration in Java/beta
- ----------------------------------------------------------------------
From: sw@tiac.net (Steve Witham)
Date: Thu, 21 Sep 1995 22:38:21 -0400
Subject: Re: Fn ptrs & ... callbacks!?
>From: jpayne@starwave.com (Jonathan Payne)
>Subject: Re: method/fn ptrs?
>
>Could you imagine implementing emacs-style keymaps in Java? You'd
>have to implement a KeyAction subclass for each command you want to
>bind to a key. And each one of those subclasses would probably make a
>call to another object that implements all that commands, since they
>would probably rather be all together.
So? What's your point? :-)
>It's also a problem for handling callbacks from GUI controls.
I thought Java got rid of callbacks by having threads...didn't it?
Callbacks are just a dumb, inside-out way to implement threads.
Why try to immitate them in a language that has real threads?
--Steve
Windows '95--Why 1995 will be like 1984.
- ------------------------------
From: Mentor <mentor@io.org>
Date: Fri, 22 Sep 1995 00:06:41 -0400 (EDT)
Subject: Re: Displaying a Gif...
On Thu, 21 Sep 1995, Karl Asha wrote:
> Would anyone care to show some sample code to simply display a gif
> in a -standalone- java program. Not an applet.
It's simpler than you'd think: First, you set up a window (there's code in the
archives from rizzoti.sven@ch.swissbank.com which tells how). Then, you haul
in the image with one of the following:
String nice_image = "http://www.io.org/~mentor/images/moose.gif";
// one way:
Object o = (new URL(nice_image)).getContent();
// second way:
GifImage i = new GifImage(nice_image);
// third way (more complex, but more general):
URL url = new URL(nice_image);
InputStream in = url.openStreamInteractively();
Object o = url.getContent(in, null);
Cheers,
David Forster
Mentor Software Solutions
<a href="http://www.io.org/~mentor">Mentor Software Solutions</a>
- ------------------------------
From: James C Deikun <jcdst10+@pitt.edu>
Date: Thu, 21 Sep 1995 20:35:05 -0400 (EDT)
Subject: Setting Boundaries (was Re: JDK Question)
On Mon, 18 Sep 1995, Arthur van Hoff wrote:
> The mandatory networking classes are in java.net. We've got some
> additional classess that we've put in sun.net.* to avoid name
> clashes with other software vendors.
>
> We are in control of what is part of the java.* classes that
> are available in every Java environment. As time goes on we
> will add more functionality in a controlled and upward compatible
> manner.
Speaking of that, I've wondered this since the JDK came out:
Should all this stuff really be required for every Java implementation,
or just every HotJava implementation?
Yeah, some of this stuff is awfully nice, but it sure puts a lot of
weight on the head of the implementor. (Not that this is any surprise
considering the involvement of large corporations here.) I really can't
see why for some purposes a simple implementation containing only files
and text i/o wouldn't suffice. For example, if one were producing a
super-optimized Java runtime for use on dedicated compute servers, I don't
see what the use of being burdened with writing awt classes would be.
Indeed, in contexts like that it would be good for user classes to
*expect* a more restricted environment. After all, on a machine in
Maine, opening up X windows wouldn't be particularly useful to me here in
Pittsburgh, even if they were redirected properly to my X server. (Hey, can
you say "slow"?)
- - --
James "e unix pluribus" Deikun
- ------------------------------
From: flar@bendenweyr.Eng.Sun.COM (Jim Graham)
Date: Thu, 21 Sep 1995 17:08:51 -0700
Subject: Re: Displaying a Gif...
> Would anyone care to show some sample code to simply display a gif
> in a -standalone- java program. Not an applet.
Unfortunately the standard Java packages do not contain the helper classes
that you need to do this, nor do they contain factory-style APIs to
instantiate the sun-specific classes you need. Only the Applet class
with its AppletContext and AppletStub contain the necessary environment
to get these classes instantiated for you in a portable way.
This is an oversight...
For now, you will have to instantiate one of:
new sun.awt.image.FileImageSource(String filename);
new sun.awt.image.URLImageSource(String href);
new sun.awt.image.URLImageSource(URL u);
which will give you an object that implements "ImageProducer". From that
you can use:
Toolkit.getDefaultToolkit().createImage(ImageProducer ip);
Since this requires you to refer to a class in a sun-specific package
directly, this won't be portable.
...jim
- ------------------------------
From: Janet.Coursey@Central.Sun.COM (Janet Coursey)
Date: Thu, 21 Sep 95 18:03:40 -0600
Subject: thread.sleep and java.lang.InterruptedException
In the JDK prebeta1 , I get this compiler error:
javac Foo.java
Foo.java:11: Warning: Exception java.lang.InterruptedException must be caught,
or it must be
declared in throws clause of this method.
thread.sleep(150);
^
for this source file called Foo.java ----
import java.lang.Thread;
import java.lang.InterruptedException;
public class Foo extends Object implements Runnable {
private Thread thread;
public void run()
// throws java.lang.InterruptedException
{
thread.sleep(150);
}
} // class Foo
But when I do what it suggests I get this compiler error:
javac Foo.java
Foo.java:8: Invalid exception class java.lang.InterruptedException in throws
clause. The
exception must be a subclass of an exception thrown by void run() from
interface
java.lang.Runnable.
public void run()
^
for this source---
import java.lang.Thread;
import java.lang.InterruptedException;
public class Foo extends Object implements Runnable {
private Thread thread;
public void run()
throws java.lang.InterruptedException
{
thread.sleep(150);
}
} // class Foo
Now in the JDKprebeta1, java/lang/Runnable.java,
the run() method does NOT declare any throws. So how can I possibly achieve the
compiler's
recommendation to "The exception must be a subclass of an exception thrown by
void run() from
interface java.lang.Runnable"?
[The run() body will actually do some work if i get past this problem; this was
the smallest code to
recreate the situation.]
Thanks in advance,
Janet
- ------------------------------
From: flar@bendenweyr.Eng.Sun.COM (Jim Graham)
Date: Thu, 21 Sep 1995 17:02:37 -0700
Subject: Re: new Image classes
- - ----------
X-Sun-Data-Type: text
X-Sun-Data-Description: text
X-Sun-Data-Name: text
X-Sun-Charset: us-ascii
X-Sun-Content-Lines: 68
> I'm tyring to convert my applets from alpha3 to beta, but I'm stuck on how
> to replace my use of DIBitmaps. I just want to get at the raw data of an
> image - I don't want to filter it or produce a new image, I just want to know
> the pixel value at a given coordinate. Can anyone show me a simple way of
> doing this?
There is no direct API for doing this since we don't necessarily have the
pixels for the image loaded into memory at any given time for two reasons:
1) We wanted to have the image data loaded asynchronously so
that Applets wouldn't get stuck waiting for image data to
come over the network while we were busy trying to layout
or paint the document (busy running their init() method when
we had other things to get done). This philosophy was carried
out to the extreme to the point that we don't provide any
synchronous methods to get information about an Image...
2) We may not have enough unfragmented memory laying around to
store all of the pixels for the image. Many of you may remember
that the Alpha 3 browser often failed to load large images
after running for a while since the heap could get fragmented
and there wouldn't be enough contiguous space to put the
array of pixels - thus pixel data is now only ever delivered
piecemeal and should be digested, put to use, and then dropped
on the floor (the image loaders save the data in special pixel
buffers that use "Ref" objects which allow asynchronous
reclamation of the space that they use and will avoid having
to refetch the image if their pixel buffer hasn't been freed,
so Applet programmers should not hold onto the image data
themselves if at all possible).
The idea behind the ImageFilter objects was that if you filter an
image, then you should filter it as the data is delivered rather than
to grab a buffer of pixels for the image, modify the pixels, and then
turn around and make a new image from that buffer. This doesn't work
when you need to filter lots of large images. The beta version of the
Sun home page now loads much more frequently in a lot less memory since
the ImageMap applet now uses dynamic filters rather than getDIBitmap
and createImage to make its button highlight areas...
For those cases when you need to query the contents of an image for
other purposes, then all you need to do is to create an object which
implements the ImageConsumer interface and attach it to the image's
ImageProducer. The ImageConsumer object will then have the image's
data fed to it asynchronously - when it gets what it wants, it can then
remove itself and return the information.
I wrote an example of this kind of class, which is attached below. To
use it you would write:
int[] pix = new int[w * h];
PixelGrabber pg = new PixelGrabber(img.getSource(),
x, y, w, h,
pix, 0, w);
pg.grabPixels();
When that method returns, the pix array will contain the data for the
specified subrectangle of the image in the default RGB format (see
ColorModel.getRGBdefault()). Note that since the grabPixels method
can take an arbitrarily large amount of time to complete, you should
not call it during any of an applet's methods that may be called by
a system thread (such as init(), paint(), or update()). Instead, call
it from a helper thread you create to do asynchronous setup.
Hope this helps!
...jim
- - ----------
X-Sun-Data-Type: default
X-Sun-Data-Description: default
X-Sun-Data-Name: PixelGrabber.java
X-Sun-Charset: us-ascii
X-Sun-Content-Lines: 144
import java.util.Hashtable;
import java.awt.image.ImageProducer;
import java.awt.image.ImageConsumer;
import java.awt.image.ColorModel;
public class PixelGrabber implements ImageConsumer {
ImageProducer producer;
int dstX;
int dstY;
int dstW;
int dstH;
int[] pixelbuf;
int dstOff;
int dstScan;
public PixelGrabber(ImageProducer ip, int x, int y, int w, int h,
int[] pix, int off, int scansize) {
producer = ip;
dstX = x;
dstY = y;
dstW = w;
dstH = h;
dstOff = off;
dstScan = scansize;
pixelbuf = pix;
}
public synchronized void grabPixels() throws InterruptedException {
producer.startProduction(this);
wait();
}
public void setDimensions(int width, int height) {
return;
}
public void setHints(int hints) {
return;
}
public void setProperties(Hashtable props) {
return;
}
public void setColorModel(ColorModel model) {
return;
}
public void setPixels(int srcX, int srcY, int srcW, int srcH,
ColorModel model,
byte pixels[], int srcOff, int srcScan) {
if (srcY < dstY) {
int diff = dstY - srcY;
if (diff >= srcH) {
return;
}
srcOff += srcScan * diff;
srcY += diff;
srcH -= diff;
}
if (srcY + srcH > dstY + dstH) {
srcH = (dstY + dstH) - srcY;
if (srcH <= 0) {
return;
}
}
if (srcX < dstX) {
int diff = dstX - srcX;
if (diff >= srcW) {
return;
}
srcOff += diff;
srcX += diff;
srcW -= diff;
}
if (srcX + srcW > dstX + dstW) {
srcW = (dstX + dstW) - srcX;
if (srcW <= 0) {
return;
}
}
int dstOff = this.dstOff + (srcY - dstY) * dstW + (srcX - dstX);
int dstRem = dstScan - srcW;
int srcRem = srcScan - srcW;
for (int h = srcH; h > 0; h--) {
for (int w = srcW; w > 0; w--) {
pixelbuf[dstOff++] = model.getRGB(pixels[srcOff++] & 0xff);
}
srcOff += srcRem;
dstOff += dstRem;
}
}
public void setPixels(int srcX, int srcY, int srcW, int srcH,
ColorModel model,
int pixels[], int srcOff, int srcScan) {
if (srcY < dstY) {
int diff = dstY - srcY;
if (diff >= srcH) {
return;
}
srcOff += srcScan * diff;
srcY += diff;
srcH -= diff;
}
if (srcY + srcH > dstY + dstH) {
srcH = (dstY + dstH) - srcY;
if (srcH <= 0) {
return;
}
}
if (srcX < dstX) {
int diff = dstX - srcX;
if (diff >= srcW) {
return;
}
srcOff += diff;
srcX += diff;
srcW -= diff;
}
if (srcX + srcW > dstX + dstW) {
srcW = (dstX + dstW) - srcX;
if (srcW <= 0) {
return;
}
}
int dstOff = (srcY - dstY) * dstW + (srcX - dstX);
int dstRem = dstScan - dstW;
int srcRem = srcScan - srcW;
for (int h = srcH; h > 0; h--) {
for (int w = srcW; w > 0; w--) {
pixelbuf[dstOff++] = model.getRGB(pixels[srcOff++]);
}
srcOff += srcRem;
dstOff += dstRem;
}
}
public synchronized void imageComplete(int flags) {
notifyAll();
}
}
- ------------------------------
From: Thomas.Ball@Eng.Sun.COM (Thomas Ball)
Date: Thu, 21 Sep 1995 13:44:32 -0700
Subject: Re: [Q] protocol of an object
There is no way to do this with the current Java API, unless you are either
willing to use the debugger API or write your own native method. The
problem with using the debugger API is that your app will be difficult to
distribute, since non-developers will be rarely running it. We also
purposely made it easy to delete the debugger entirely (get rid of the
agent shared library and the classes in sun/tools/debug and
sun/tools/ttydebug), for those customers who don't want to distribute it.
You therefore can't count on it being installed, unless you stay on your
own machine.
If you want to write a native method, check out oobj.h -- with a class
object, it's a simple matter to browse its methodtable.
Tom
> From daemon@java Thu Sep 21 00:01:35 1995
> To: java-interest@java.Eng.Sun.COM
> Subject: [Q] protocol of an object
> Cc: neudeca@ch.swissbank.com
> X-Info: To unsubscribe, send 'unsubscribe' to
java-interest-request@java.sun.com
>
> Hi ....
>
> I'm writing on a thesis about travelling objects [8-O], and I was
> thinking about using Java for implementing a prototype...
>
> Now I need a method that delivers dynamically (and at runtime)
> all public methods of an object.
>
> I already did try ObjectScope, but it didn't work.
>
> Any ideas ???
>
> Thanks, Arthy
> -
> Note to Sun employees: this is an EXTERNAL mailing list!
> Info: send 'help' to java-interest-request@java.sun.com
>
- ------------------------------
From: Karen.Sielski@Eng.Sun.COM (Karen L. Sielski)
Date: Thu, 21 Sep 1995 13:17:34 -0700
Subject: Re: Displaying a Gif...
Try this:
import java.io.*;
import java.awt.*;
import java.applet.*;
import java.awt.image.*;
import sun.awt.image.URLImageSource;
public class Test extends Frame {
public Test() {
super("ImageTest");
//http bug so use file protocol instead
// String gifURL = "http://sunprowww.eng/~karens/images/Duke.gif";
String gifURL = "file:///home/karens/public_html/images/Duke.gif";
add("center", new ImageCanvas(gifURL));
reshape(0, 0, 300, 200);
show();
}
public static void main(String args[]) {
new Test();
}
}
class ImageCanvas extends Canvas {
Image image;
public ImageCanvas(String imageFile) {
image = (Image)Toolkit.getDefaultToolkit().createImage(
new URLImageSource(imageFile));
reshape(0, 0, 50, 50);
}
public void paint(Graphics g) {
g.drawImage(image, 0, 0, 50, 50, this);
}
}
Karen L. Sielski e-mail: karen.sielski@Eng.Sun.COM
SunSoft voice: (415) 786-9005
2550 Garcia Avenue UMPK16-305 FAX: (415)
Mountain View, CA 94043-1100
. From daemon@java Thu Sep 21 12:57 PDT 1995
. From: Karl Asha <karl@one.net>
. To: "'java-interest@java.sun.com'" <java-interest@java>
. Subject: Displaying a Gif...
. Date: Thu, 21 Sep 1995 15:34:21 -0700
. Mime-Version: 1.0
. Content-Transfer-Encoding: 7bit
. X-Info: To unsubscribe, send 'unsubscribe' to
java-interest-request@java.sun.com
.
. Would anyone care to show some sample code to simply display a gif
. in a -standalone- java program. Not an applet.
.
. Cheers.
. Karl
. karl@one.net
.
. -
. Note to Sun employees: this is an EXTERNAL mailing list!
. Info: send 'help' to java-interest-request@java.sun.com
- ------------------------------
From: arnold@cocolat.East.Sun.COM (Ken Arnold - Sun Labs)
Date: Thu, 21 Sep 1995 18:46:16 -0400
Subject: Re: throws declataration in Java/beta
>But if I can't sleep in the Run method (as the mail below suggests),
>which is something you very commonly want to do, then I think
>something is horribly broken.
As the words on the front of the HHGTTG say:
DON'T PANIC
A method cannot throw an exception type not declared in its throws
clause. This is good. You now know which exceptions can be thrown by
a method.
Obviously this means that an overridden method cannot throw something
not in its the original method, since that would give you a method that
threw something not expected by the invoker who only knew the object as
its supertype. This is good. You still know which exceptions can be
thrown by a method, whether it gets overridden in an extended class or
not.
If a method invokes another method that throws an exception, there are
two cases:
(1) That method is compatible with the calling method's throws clause.
Everying is cool; the calling method can catch or not catch the
exception.
(2) That method is not compatible with the calling method's throws
clause. Everything isn't cool, because if that exception isn't
caught, the calling method could pass through an exception it isn't
supposed to throw. So the calling method must catch that
exception.
Now, let us look at Thread.run(), which throws nothing. Of *course*
you can invoke Thread.sleep(), even though Thread.sleep() throws
InterruptedException. The rule is that you have to *catch* it so it
doesn't leak through to the invoker of run().
Now, you can argue that run() should have a "throws
InterruptedException", but then you have to ask what it means to
"interrupt" run(). What interrupting sleep() means is well known.
Ken Arnold
- ------------------------------
End of java-interest-digest V1 #181
***********************************
------------------------------
End of java-interest-digest V1 #183
***********************************
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com