Re: JESS: Graphics

2005-11-29 Thread Dusan Sormaz


There is getGraphics method in both javax.swing.JPanel and
java.awt.Canvas. Th e proper Jess code
would be (within some function, or from Jess prompt)
(bind ?jp (new JPanel))
(bind ?g (?jp getGraphics))
(?g drawLine .
To display you would need frame, ...  for example:
(import javax.swing.*)
(bind ?f (new JFrame))
(?f setSize 400 400)
(?f setVisible TRUE)
(bind ?jp (?f getContentPane))
(bind ?g (?jp getGraphics))
(?g drawLine 100 200 300 400)

Dusan Sormaz


At 08:58 AM 11/29/2005, you wrote:
Hi
I'm traying to make a GUI on wich I can plot some objekts.  I have
made
the basic GUI I want by using java-commands through jess. I have made
a
panel on wich I wish to be able to draw on, when a function is
called.
My problem is that I can figure out how to make a variable of the
type
Graphics in jess. If I write:
(defglobal ?*graph* = (new Graphics))
in the same way I have made the JPanels, I get an error massege saying
the
constuctor is not found. And I have importes java.awt .
I have tryid to make a canves:
(defglobal ?*canvas* = (new jess.awt.Canvas painter (engine)))
and then use getGraphics on it, but I just can't make it work.
Does anyone have any ideas on how to make a function I can call, that
will
be able to use the drawRect(...) and functions like that, in the
java.awt.graphics library?
Basicly I just want to be able to draw a square of a given size and
position, on my panel when I want to.
I want to be able to call this function (because when that works I
can
change it to whatever shape I want). It is the ?graph variable that is
the
problem to create):
(deffunction draw ()
    ;;(new Graphics ?graph getGraphics)) ;; doesn't
work
    ;;(?graph = (getGraphics ?*canvas*)) ;; doesn't
work
    (?graph setColor (get-member java.awt.Color red))
    (?graph drawLine 0 0 600 600)
    (?graph drawLine 600 0 0 600)
    (?*f* repaint))


To unsubscribe, send the words 'unsubscribe jess-users
[EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify
[EMAIL PROTECTED]




*
* Dušan Šormaz, PhD, Associate
Professor 

* Ohio University
* Industrial and Manufacturing Systems Engineering Department
* 277 Stocker Center, Athens, OH 45701-2979
* phone: (740) 593-1545 
* fax:   (740) 593-0778  
* e-mail: [EMAIL PROTECTED] 
* url:

http://www.ent.ohiou.edu/~sormaz 
*
 



JESS: Graphics

2005-11-29 Thread jess
Hi

I'm traying to make a GUI on wich I can plot some objekts.  I have made
the basic GUI I want by using java-commands through jess. I have made a
panel on wich I wish to be able to draw on, when a function is called.

My problem is that I can figure out how to make a variable of the type
Graphics in jess. If I write:

(defglobal ?*graph* = (new Graphics))

in the same way I have made the JPanels, I get an error massege saying the
constuctor is not found. And I have importes java.awt .

I have tryid to make a canves:
(defglobal ?*canvas* = (new jess.awt.Canvas painter (engine)))

and then use getGraphics on it, but I just can't make it work.

Does anyone have any ideas on how to make a function I can call, that will
be able to use the drawRect(...) and functions like that, in the
java.awt.graphics library?

Basicly I just want to be able to draw a square of a given size and
position, on my panel when I want to.

I want to be able to call this function (because when that works I can
change it to whatever shape I want). It is the ?graph variable that is the
problem to create):

(deffunction draw ()
;;(new Graphics ?graph getGraphics)) ;; doesn't work
;;(?graph = (getGraphics ?*canvas*)) ;; doesn't work

(?graph setColor (get-member java.awt.Color red))
(?graph drawLine 0 0 600 600)
(?graph drawLine 600 0 0 600)
(?*f* repaint))



To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]