Re: [xwt-users]2D drawing capability

"Charles Goodwin" <[email protected]>
Newsgroups gmane.comp.java.xwt.users
Message-ID <[email protected]>
> Hi,
> 1. I just started using xwt for an application and wanted to know if it
> has any 2D line drawing feature on surfaces. I need to connect two images
> with a line and would appreciate it if someone lets me know the best way
> to do it using xwt.

Nitrogen (currently the 'unstable' XWT) has basic SVG support that
provides this kind of functionality.

Using the current stable series, you could draw a line using thin boxen
put together orthogonally as a line (enter crude diagram):
_____
     |______


> 2. When the application is loaded in the engine, is there a way to call
> the server without waiting for an event to happen (similar to the onLoad
> using javascript)?

Yes, just put it directly into the code.  The way a .xwt instantation
works is that it simply forms anything XML and then executes any
ECMAscript in that XML.  Trap assignments (_trap) are just that,
assignments being made by executed code.  Hence you can assign traps
anywhere in your ECMAscript.

<template>

    xwt.println( "5! = " + ( 1 * 2 * 3 * 4 * 5 ) );

    _trap = function( t ) {
        if ( t )
            xwt.println( "This is a trap!" );
        else {
            _trap = function() { xwt.println( "I've been replaced!" ); }
        }
    }

    trap = true;
    trap = false;
    trap = true;

</template>

Log output for the above:

5! = 120
This is a trap!
I've been replaced!

So to execute something straight away in the template, you put it in the
<templace /> scope (or another <box /> scope) rather than the scope of a
trap or function.

- Charlie

The future of webapps - www.xwt.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.