From: Rmagere
Subject: Question about Jlinker and MemoryImageSource (more generally about graphics in lisp)
Date: 
Message-ID: <b3irk6$2hj$1@news.ox.ac.uk>
Hi,

I am trying to use jlinker in order to generate graphics with lisp (I am
currently using the trial edition of ACL 6.2)

For the moment all I need is to be able to show some colored squares on a
black (or white) background. The idea is that those squares are changing
position according to some lisp code and each time step is displayed by a
java image which replaces the previous one in order to give the feeling of
watching a movie.

I do not want this to be run in batch mode (i.e. all the positions for all
frames are calculated beforehand) as I can do that by creating a data file
getting it read by matlab and generating a movie in matlab. What I would
like it is for it to be realtime so that in theory with a non ending loop I
can get a non ending movie.

I thought I could do this by using the MemoryImageSource class from java
(see
http://java.sun.com/j2se/1.4.1/docs/api/java/awt/image/MemoryImageSource.htm
l#MemoryImageSource(int,%20int,%20int[],%20int,%20int) ).
Which is specified as follows:
public MemoryImageSource(int w,
                         int h,
                         int[] pix,
                         int off,
                         int scan)Constructs an ImageProducer object which
uses an array of integers in the default RGB ColorModel to produce data for
an Image object.

  Parameters:
  w - the width of the rectangle of pixels
  h - the height of the rectangle of pixels
  pix - an array of pixels
  off - the offset into the array of where to store the first pixel
  scan - the distance from one row of pixels to the next in the array

However when I try to use:
(defun make-imagesource (w h pix off scan)
                (jnew (jconstructor "java.awt.image.MemoryImageSource" "int"
"int" "int[]" "int" "int")))

I get the following error: :JAVA-ERROR - java.lang.ClassNotFoundException:
int[]
I tried to replace "int[]" with "int" "java.lang.Integer" to no avail.

By the way "pix" was generated using
(defmacro make-black-array (size)
  (make-array '(,size) :element-type '(signed-byte 32) :initial-element 0))

As according to
http://www.franz.com/support/documentation/6.2/doc/jlinker.htm#data=types-co
nversions-3    int[] is an array of signed-byte 32

I would be really grateful for any help.
Also if anyone knows of another way (better or not) to generate some
graphics in lisp please do let me know as all this is really just a by the
side problem as I am interested in the modeling of the squares' behaviour
but I could really do with a intuititive, kind of real-time visualisation to
fully understand their interactions.

Thanks.

From: Kenny Tilton
Subject: Re: Question about Jlinker and MemoryImageSource (more generally about graphics in lisp)
Date: 
Message-ID: <3E5CFC18.8040501@nyc.rr.com>
Rmagere wrote:
> Hi,
> 
> I am trying to use jlinker in order to generate graphics with lisp (I am
> currently using the trial edition of ACL 6.2)

1. Why not just use ACL Common Graphics functions which wrap the win32 
GDI graphics lib? very friendly, that. (I /think/ I understood from a 
later comment of yours that Java was not a requirement for you--sorry if 
I misunderstood.)

2. Curiously, comp.lang.lisp.franz is not about ACL (produced by Franz).

3. sorry, don't know much about Java or jlinker.



-- 

  kenny tilton
  clinisys, inc
  http://www.tilton-technology.com/
  ---------------------------------------------------------------
"Cells let us walk, talk, think, make love and realize
  the bath water is cold." -- Lorraine Lee Cudmore
From: Donald Fisk
Subject: Re: Question about Jlinker and MemoryImageSource (more generallyabout  graphics in lisp)
Date: 
Message-ID: <3E5D0DB6.9B264274@enterprise.net>
Kenny Tilton wrote:

> 2. Curiously, comp.lang.lisp.franz is not about ACL (produced by Franz).

It's about Franz Lisp, I presume, a dialect similar to Maclisp
for Berkeley Unix.   Same people (Foderaro, etc.) involved who
started up Franz Inc., I think.

Is Franz Lisp still actively used?   I haven't seen it since
1985.

>   kenny tilton

Le Hibou
-- 
In any large organization, mediocrity is almost by definition
an overwhelming phenomenon; the systematic disqualification
of competence, however, is the managers' own invention, for
the sad consequences of which they should bear the full blame.
			-- Edsger W. Dijkstra, 1986.
From: Daniel Barlow
Subject: Re: Question about Jlinker and MemoryImageSource (more generallyabout  graphics in lisp)
Date: 
Message-ID: <878yw12ygi.fsf@noetbook.telent.net>
Donald Fisk <················@enterprise.net> writes:

> Is Franz Lisp still actively used?   I haven't seen it since
> 1985.

Dunno about actively used, but it's still available - 

http://www.aiai.ed.ac.uk/~jeff/franz-for-386.html


-dan

-- 

   http://www.cliki.net/ - Link farm for free CL-on-Unix resources 
From: Rmagere
Subject: Re: Question about Jlinker and MemoryImageSource (more generally about graphics in lisp)
Date: 
Message-ID: <b3kt6r$4ih$1@news.ox.ac.uk>
"Kenny Tilton" <·······@nyc.rr.com> wrote in message
·····················@nyc.rr.com...
> 1. Why not just use ACL Common Graphics functions which wrap the win32
> GDI graphics lib? very friendly, that. (I /think/ I understood from a
> later comment of yours that Java was not a requirement for you--sorry if
> I misunderstood.)
>

Thanks for the input as I am more than happy to use anything easy and
friendly especially if within Lisp itself.

Do you know of any good tutorial to get started in ACL Common Graphics?

As I tried the doodler tutorial but it didn't feel v. useful and at the
moment I have just started programming in Lisp
and I have not found any book dealing with graphics in Lisp nor any real
good tutorial on the web (though I will look better
now that  I know what to look for).

My knowledge is really limited to "Lisp 3rd Ed" by Winston and Horn, "ANSI
Common Lisp" by -can not remember this
guy name but I did like his book very much- and I have just started reading
"Paradigms of Artificial Intelligence" by Norvig.


> 2. Curiously, comp.lang.lisp.franz is not about ACL (produced by Franz).
That explains why the newsgroup had so few messages (none that I could see).

Thanks again for your help and for any futher comments hints anyone can
provide me.
From: Kenny Tilton
Subject: Re: Question about Jlinker and MemoryImageSource (more generally about graphics in lisp)
Date: 
Message-ID: <3E5E4D1D.3090805@nyc.rr.com>
Rmagere wrote:
> "Kenny Tilton" <·······@nyc.rr.com> wrote in message
> ·····················@nyc.rr.com...
> 
>>1. Why not just use ACL Common Graphics functions which wrap the win32
>>GDI graphics lib? very friendly, that. (I /think/ I understood from a
>>later comment of yours that Java was not a requirement for you--sorry if
>>I misunderstood.)
>>
> 
> 
> Thanks for the input as I am more than happy to use anything easy and
> friendly especially if within Lisp itself.
> 
> Do you know of any good tutorial to get started in ACL Common Graphics?

Costs a few grand. Comes with the purchased copy.


> and I have not found any book dealing with graphics in Lisp nor any real
> good tutorial on the web (though I will look better
> now that  I know what to look for).

Well, it is not so much "graphics in Lisp" or even graphics that is your 
problem since you just want to draw boxes. That is real easy in CG. Then 
you can concentrate on your algorithm.

Go to the Help menu in ACl and the fifth itme will be "Allegro CL Doc". 
That takes you to a navigable doc suite. It's a little tricky. Hit item 
2.1 tot ake you to an alleged "contents" page, then in the first 
paragraph click the "contents" url/word to get to the real contents 
page. scroll down a few to get to CG doc.

1. Learn how to make an empty window

2. Learn how to make and paint a box.

3. Learn how to put the box where you want it (the coordinate system)

Basically you subclass FrameWindow and specialize the WM_PAINT method to 
do all drawing. Other WM_ methods are named after win32 methods: mouse 
motion, button downs, key events.

That's low-level. If you want fancier stuff look at CG widgets and the 
handlers (callbacks) they support.

I would suggest my Cello project if it had any doc. Follow my url below 
to see if a constraints-based dataflow approach sounds right for your 
algotrithm, if so I could use a guinea pig to develop the doc for.

But right now I am looking at OpenRM (OpenGL Scene Graphics manager) as 
an alternative to FreeGlut (raw OpenGL) so not ready to release yet. RSN. :)



-- 

  kenny tilton
  clinisys, inc
  http://www.tilton-technology.com/
  ---------------------------------------------------------------
"Cells let us walk, talk, think, make love and realize
  the bath water is cold." -- Lorraine Lee Cudmore
From: Kenny Tilton
Subject: Re: Question about Jlinker and MemoryImageSource (more generally about graphics in lisp)
Date: 
Message-ID: <3E5E841B.9020406@nyc.rr.com>
Kenny Tilton wrote:
> 
> Basically you subclass FrameWindow and specialize the WM_PAINT method to 
> do all drawing. 

Sorry, WM_PAINT is overkill. The CG default WM_PAINT gets round to 
calling redisplay-window, and you can (should) just specialize that 
method for your window class.

As for a quick intro into painting, use the ACL IDE apropos dialog. 
Limit the search to exported symbols, then search on "box" (without the 
quotes). when you see a likely name (fill-box?) click once and hit F1 to 
jump to the CG doc on that function.



-- 

  kenny tilton
  clinisys, inc
  http://www.tilton-technology.com/
  ---------------------------------------------------------------
"Cells let us walk, talk, think, make love and realize
  the bath water is cold." -- Lorraine Lee Cudmore
From: Rmagere
Subject: Re: Question about Jlinker and MemoryImageSource (more generally about graphics in lisp)
Date: 
Message-ID: <b3ps7d$jv7$1@news.ox.ac.uk>
>"Kenny Tilton" <·······@nyc.rr.com> wrote in message
·····················@nyc.rr.com...

Thanks for your reply and tips as for the first time round I have been able
to create a window
and drawing something in it (admittedly only a line for the moment but it's
a huge step forward)

> Sorry, WM_PAINT is overkill. The CG default WM_PAINT gets round to
> calling redisplay-window, and you can (should) just specialize that
> method for your window class.

I did not understand very well the bit about WM_PAINT (however I haven't
looked into it too much
either like I haven't yet looked at:  >CG widgets and the handlers
(callbacks) they support.

At the moment I just used this snippet of code and I am planning to build
some more understanding
from this starting point:

(defclass my-window (frame-window) nil (:default-initargs :title "Rmagere's
Window"))
(defmethod redisplay-window ((window my-window) &optional box)
  (declare (ignore box)) (call-next-method) (draw-line window (make-position
0 0) (make-position 1000 1000)))
(make-window :one :class 'my-window)

Finally I haven't yet fully looked into your Cello project though I will as
soon as I have a better feeling for the
Common Graphics basic functionalities and I wouldn't mind to act as guinea
pig if you need one.

Thanks again.
From: Kenny Tilton
Subject: Re: Question about Jlinker and MemoryImageSource (more generally about graphics in lisp)
Date: 
Message-ID: <3E60ED3F.6020806@nyc.rr.com>
Rmagere wrote:
>>"Kenny Tilton" <·······@nyc.rr.com> wrote in message
> 
> ·····················@nyc.rr.com...
> 
> Thanks for your reply and tips as for the first time round I have been able
> to create a window
> and drawing something in it (admittedly only a line for the moment but it's
> a huge step forward)

Right, as K&R pointed out, there's nothing trivial about getting to 
"Hello, world."


> (defclass my-window (frame-window) nil (:default-initargs :title "Rmagere's
> Window"))
> (defmethod redisplay-window ((window my-window) &optional box)
>   (declare (ignore box)) (call-next-method) (draw-line window (make-position
> 0 0) (make-position 1000 1000)))
> (make-window :one :class 'my-window)


OK, now the spec was:

> For the moment all I need is to be able to show some colored squares on a
> black (or white) background. The idea is that those squares are changing
> position according to some lisp code and each time step is displayed by a
> java image which replaces the previous one in order to give the feeling of
> watching a movie.
> 
> I do not want this to be run in batch mode (i.e. all the positions for all
> frames are calculated beforehand) as I can do that by creating a data file
> getting it read by matlab and generating a movie in matlab. What I would
> like it is for it to be realtime so that in theory with a non ending loop I
> can get a non ending movie.

(apropos 'timer) and follow that to the doc to learn how to create a 
timer instance which will kick off some code of yours to execute each 
generation. expect excitement when you close a window and the timer is 
still running calling your function to work on the window (at least to 
trigger a redraw--see below) which is no more. :)

I believe you can specialize device-close to kill the timer instance 
when the window closes. or just have your timer callback look for the 
window in a special *my-window* and do not draw to it if (IIRC) 
closed-stream-p on that is t. then you can just make the timer once and 
forget about it.

Your callback might read:

(unless (closed-stream-p *my-window*) ;; check me onthis
    (change-world *my-window*) ;; data structure changes
    (invalidate *my-window*)) ;; leads eventually to redisplay-window 
being called

> 
> Finally I haven't yet fully looked into your Cello project though I will as
> soon as I have a better feeling for the
> Common Graphics basic functionalities and I wouldn't mind to act as guinea
> pig if you need one.
> 

OK, as soon as I settle on a substrate (OpenRM or FreeGlut) I'll post 
here looking for people who don't mind being on the bleeding edge of a 
project.



-- 

  kenny tilton
  clinisys, inc
  http://www.tilton-technology.com/
  ---------------------------------------------------------------
"Cells let us walk, talk, think, make love and realize
  the bath water is cold." -- Lorraine Lee Cudmore
From: rmagere
Subject: Re: Question about Jlinker and MemoryImageSource (more generally about graphics in lisp)
Date: 
Message-ID: <b44ib4$ihr$1@news.ox.ac.uk>
"Kenny Tilton" <·······@nyc.rr.com> wrote in message
·····················@nyc.rr.com...
>
> (apropos 'timer) and follow that to the doc to learn how to ....

Kenny, once again thanks for your inputs as I have now been able to generate
a couple of boxes that keep moving

Regarding closing the timer once the windows closes I have used the
following code:

(defmethod close :before ((window boxes-window) &key abort)
  (declare (ignore abort))
  (let* ((timer (bouncing-boxes-timer)))
    (setf (timer-info timer)
      (delete (frame-child window)(timer-info timer)))
    (unless (timer-info timer)
      (stop-timer timer))))

Now I only need to figure out two things:
a) can boxes be drawn at angles or do they have their sides parallel to the
window (I think the latter so I need to work out how to get them tilted)
b) I have got a licenced professional edition acl lisp v.5.0.1 is the
graphic implemented in it v. much different from v6.2? as the main reason I
moved to the trial of 6.2 was the addition of jlinker which is now clearly
not anymore needed.  As if 6.2 offeres other advantages then I might ask the
lab to buy a copy otherwise they might as well save the money.

Thanks again,
 Rmagere
From: Kenny Tilton
Subject: Re: Question about Jlinker and MemoryImageSource (more generally about graphics in lisp)
Date: 
Message-ID: <3E661E13.4010606@nyc.rr.com>
rmagere wrote:

> Now I only need to figure out two things:
> a) can boxes be drawn at angles or do they have their sides parallel to the
> window (I think the latter so I need to work out how to get them tilted)

(apropos 'poly)

You probably want fill-polygon. The CG "box" functions do not support 
rotation, so you have to do the trig yourself to compute the vertices of 
the rotated box. I am developing Cello, a GUI sitting atop OpenGL where 
rotation is straightforward (glRotateF). Keep your eye out for a Cello 
CFGP (call for guinea pigs) RSN.

> b) I have got a licenced professional edition acl lisp v.5.0.1 is the
> graphic implemented in it v. much different from v6.2? 

You can do all this stuff in ACL5. But I am scratching my head--there 
/was/ something we had to do once re timers because of some change in 
ACL, but I forget what. IIRC, we got forced into the timer scheme 
because some other mechanism went away. Pretty sure we used to handle 
win32 WM_TIMER events, then had to use timers instead. Something like 
that.  Anyway, there might be some issues, but nothing too bad.

Is 6.2 worth it? I guess you have it right: only if some particular new 
feature strikes your fancy.


-- 

  kenny tilton
  clinisys, inc
  http://www.tilton-technology.com/
  ---------------------------------------------------------------
"Cells let us walk, talk, think, make love and realize
  the bath water is cold." -- Lorraine Lee Cudmore
From: Jason Sewall
Subject: Re: Question about Jlinker and MemoryImageSource (more generally about graphics in lisp)
Date: 
Message-ID: <vr8p1kcrfd7o32@corp.supernews.com>
Rmagere wrote:

> "Kenny Tilton" <·······@nyc.rr.com> wrote in message
> ·····················@nyc.rr.com...
> 
>>1. Why not just use ACL Common Graphics functions which wrap the win32
>>GDI graphics lib? very friendly, that. (I /think/ I understood from a
>>later comment of yours that Java was not a requirement for you--sorry if
>>I misunderstood.)
>>
> 
> 
> Thanks for the input as I am more than happy to use anything easy and
> friendly especially if within Lisp itself.
> 
> Do you know of any good tutorial to get started in ACL Common Graphics?
> 
> As I tried the doodler tutorial but it didn't feel v. useful and at the
> moment I have just started programming in Lisp
> and I have not found any book dealing with graphics in Lisp nor any real
> good tutorial on the web (though I will look better
> now that  I know what to look for).
> 
> My knowledge is really limited to "Lisp 3rd Ed" by Winston and Horn, "ANSI
> Common Lisp" by -can not remember this
> guy name but I did like his book very much- and I have just started reading
> "Paradigms of Artificial Intelligence" by Norvig.
> 
> 
Paul Graham, prophet of Lisp, is responsible for On Lisp and ANSI Common 
Lisp.

> 
>>2. Curiously, comp.lang.lisp.franz is not about ACL (produced by Franz).
> 
> That explains why the newsgroup had so few messages (none that I could see).
> 
> Thanks again for your help and for any futher comments hints anyone can
> provide me.
> 
>