how to draw a line using gwt?

1,067 views
Skip to first unread message

剑涛 何

unread,
Apr 23, 2011, 9:54:23 AM4/23/11
to Google Web Toolkit
if there are two coordinates -p1:(x1,y1),p2:(x2,y2) in the
browser ,how to draw an arrow from p1 to p2?

Gal Dolber

unread,
Apr 23, 2011, 10:20:39 AM4/23/11
to google-we...@googlegroups.com
http://gwtcanvasdemo.appspot.com/

On Sat, Apr 23, 2011 at 10:54 AM, 剑涛 何 <hejia...@gmail.com> wrote:
if there are two coordinates -p1:(x1,y1),p2:(x2,y2) in the
browser ,how to draw an arrow from p1 to p2?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.




--
Guit: Elegant, beautiful, modular and *production ready* gwt applications.

http://code.google.com/p/guit/




剑涛 何

unread,
Apr 23, 2011, 11:20:12 PM4/23/11
to Google Web Toolkit
can you tell me something detail?

On 4月23日, 下午10时20分, Gal Dolber <gal.dol...@gmail.com> wrote:
> http://gwtcanvasdemo.appspot.com/
>

Gilles B

unread,
Apr 24, 2011, 11:10:33 AM4/24/11
to Google Web Toolkit
Drawing a Line inside a browser a well know problem, just look for
"java script line drawing" in your search engine. The basic idea is to
use a set of "div" tags to draw various points, ie 1px*1px rectangles
with background-color but with performance problems. An idea is to
agregate adjacent rectangles in a same column or in the same row to
optimize this drawing. Various js libraries exists depending on the
drawing and graphics complexity you are looking for.

This Canvas library is a good thing but rely on new HTML 5 standard
and is not supported by a lot of browser (current IE and all the old
versions), may be it's a problem in your application. The Canvas class
is includes in GWT 2.2 but as: "Experimental API: This API is still
under development and is subject to change." If this is not a problem
for you this is the best GWT complient solution. The previous post
give you the url of the google demo and examples
http://code.google.com/p/gwtcanvasdemo/

There is (was) another Canvas library in the incubator project and it
works fine in Web mode across the major browser working as JavaScript
wrapper but is not a good idea (now this library is obsolete)
http://code.google.com/p/google-web-toolkit-incubator/wiki/GWTCanvas

Another way is to build a graphic at run time in your server using a
graphics context from java and common drawing API to building an image
and then display it on your server. It's convenient with complex
images or to build a captcha as example. It is also possible to rely
on SVG tags, like LINE. These are simple XML tags but sometimes
requires a browser plugin. In fact there is multiple solutions
depending on your project environment and your targets.
> >http://code.google.com/p/guit/- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -
Reply all
Reply to author
Forward
0 new messages