drawing lines...

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

drawing lines...

Andreas Zieritz
This should be an easy thing for the most of you...

What I want is an application, that opens a window/frame and draws a line.
(I'm stuck in this - probably rather simple thing - quite a few days now).

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>

Reply | Threaded
Open this post in threaded view
|

Re: drawing lines...

dIon Gillard/Multitask Consulting/AU
Check out the Scribble samples from the FAC page.

They show you how to draw lines using the mouse events, but the code is
still fairly simple.

Andreas Zieritz wrote:

>
> This should be an easy thing for the most of you...
>
> What I want is an application, that opens a window/frame and draws a line.
> (I'm stuck in this - probably rather simple thing - quite a few days now).
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
> [hidden email]
> with the following message in the body of the note
> unsubscribe ibm-netrexx <e-mail address>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>

Reply | Threaded
Open this post in threaded view
|

Re: drawing lines...

Andreas Zieritz
At 09:43 24.03.98 +1000, you wrote:
>Check out the Scribble samples from the FAC page.

The 'Scribble'-example is an written as an applet, but it certainly can be
used as an application, too. I looked into the 'Spectrum' example, which is
similar. What I'm a little bit confused about is the handling of the
paint(g=Graphics) and update(g=Graphics) methods. In 'Spectrum' all drawing
is done in the update-method, which is called at the beginning (when
starting the application).

What I want is not to run the class stand alone but from an other
class/program. It should open a window and (probably later) begin to draw
something.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>

Reply | Threaded
Open this post in threaded view
|

RE: drawing lines...

Patrick McPhee-3
In reply to this post by Andreas Zieritz
Andreas Zieritz ([hidden email]) wrote:

> used as an application, too. I looked into the 'Spectrum' example,
> which is
> similar. What I'm a little bit confused about is the handling of the
> paint(g=Graphics) and update(g=Graphics) methods. In 'Spectrum' all
> drawing
> is done in the update-method, which is called at the beginning (when
> starting the application).
>
You can force a call to update() by calling repaint(). Depending on what
you're doing, it may be best to do very little in update() itself -- the
Tablet applet is a good demonstration of this approach.

--
Patrick TJ McPhee
DataMirror Corporation
[hidden email]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>

Reply | Threaded
Open this post in threaded view
|

RE: drawing lines...

Andreas Zieritz
In reply to this post by Andreas Zieritz
>You can force a call to update() by calling repaint(). Depending on what
>you're doing, it may be best to do very little in update() itself -- the
>Tablet applet is a good demonstration of this approach.

Well, as you wrote it is an applet, what I need is an application...

After all I seemed to get something that appears to work...

I'll post it here to get some comments about it.

First, the file that calls the class.
/* test1.nrx */

trace results
a=Test("a Test")
a.draw(10,10,100,100)
a.draw(10,10,0,100)
a.draw(30,150,200,100)

...then the class itself
/* test.nrx */
class test extends Frame

  properties private
        shadow = Image

  method Test(s=String)
        super(s)
        setBounds(0,0,300,300)
        show()

  method draw(x1=int,y1=int,x2=int,y2=int)
        if shadow=null then
                createshadow()
        g = shadow.getGraphics
        g.setColor(Color.black)
        g.drawLine(x1,y1,x2,y2)
        paint(g)

  method paint(g=Graphics)
        if shadow=null then
                createshadow()
        g.drawImage(shadow,0,0,this)


  method createshadow
        shadow = createImage(getSize.width,getSize.height)


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>