Wrapper enhance!

41 views
Skip to first unread message

Cristian Miranda

unread,
Oct 25, 2011, 10:47:06 AM10/25/11
to raphaelgwt
Hi!,

I would like to know if is it ok for me to enhance the wrapper with
some new methods supporting Raphael JS Library v2.0.0 compiled for
java 1.5 & java 1.6, and create a new google project with Apache
Common Licence 2.0 uploading it there. Or maybe you prefer to add me
as a collaborator rather than upload my enhancements to other source.

Great job btw ;)
Thanks.

Regards..

Cristian Miranda

Cristian Miranda

unread,
Oct 25, 2011, 10:50:25 AM10/25/11
to raphaelgwt
Some of this new methods include drag and drop functionality (WITHOUT
any other kind of external library, pure raphael)

Geoff Speicher

unread,
Oct 25, 2011, 11:12:47 AM10/25/11
to rapha...@googlegroups.com
Hi Christian,

Thanks for your enthusiasm and support.  We welcome contributions such as this to RaphaelGWT, especially if it can be done in a way that maintains backward compatibility with the existing API.  I have no idea if that's possible or not with RaphaelJS 2.0 but if you have a handle on this then I encourage you to go for it.  Naturally we are hesitant to grant commit privilege to anyone who asks until they earn it.  ;)

Can you work up your changes locally (you can always use git to manage large changesets) and submit patches to the issue tracker?  Try to post separate patches for separate enhancements to the degree that it is possible, so that each one can be judged on its own merit.  I encourage discussion of your plans and design decisions in this public forum and I will gladly participate as my time allows.

For something like drag-n-drop it would be ideal to support both native Raphael and native GWT without forcing the developer to use one or the other.

Why do you mention compiling for Java 1.5 and 1.6?  Is there a version-specific issue with the distributed jar?

Geoff

Cristian Miranda

unread,
Oct 25, 2011, 11:23:36 AM10/25/11
to rapha...@googlegroups.com
Hi Geoff,

Thanks for replying instantly. I will gladly participate uploading the enhancements on different patches on the issue tracker.
When mentioned compiling for Java 1.5 and 1.6, i meant that it would be great to provide the wrapper compiled on those two versions of java so that developers would not have to compile it by themselves.
But it was just an idea. Never mind.

I will be uploading the enhancements with its corresponding documentation during this week or the next one. :)

Thanks.

Geoff Speicher

unread,
Oct 25, 2011, 11:27:43 AM10/25/11
to rapha...@googlegroups.com
Great, looking forward to it!  Also, I just realized I spelled your name wrong in my last message.  Sorry.  :-/

Cristian Miranda

unread,
Oct 26, 2011, 2:58:28 PM10/26/11
to raphaelgwt
Hi Geoff!

I uploaded to sourceforge the code, patch and the compiled library of
the gwtRaphael wrapper supporting Drag and drop.

Link: https://sourceforge.net/projects/gwtraphaeldnd/files/

I will also upload the patch to the issue tracker of the project.

Regards,
Cristian Miranda
Blog: http://gwtexpress.blogspot.com

On Oct 25, 12:27 pm, Geoff Speicher <ge...@sea-incorporated.com>
wrote:
> Great, looking forward to it!  Also, I just realized I spelled your name
> wrong in my last message.  Sorry.  :-/
>

Geoff Speicher

unread,
Oct 26, 2011, 3:39:30 PM10/26/11
to rapha...@googlegroups.com
Hi Cristian,

Here are a few comments about your patch:

1. Please try to follow the GWT team guidelines for formatting: two spaces for indentation and no tabs anywhere.
2. This patch seems to allow end-users to drag/drop an element within the canvas, using default styling for opacity of the element while it's being moved.  This is nice, but it doesn't allow developers to do things that I would expect they will want to do, such as hooking up custom behavior to drag start/stop event, applying different visual styling than the default, constraining the element to different bounds, etc.
3. We've tried to avoid the use of native Javascript methods on the Raphael class itself, favoring their placement on the RaphaelJS overlay instead.

A patch more attuned to the spirit of this wrapper would expose the underlying Element.drag() method from the native Raphael library within the RaphaelJS API, along with all of the parameters that would allow a developer to hook up their own behavior as if they were calling it from native Javascript code.  Note that the native Raphael drag method expects native Javascript functions as parameters, but a GWT developer should not have to deal with that, so this wrapper should act as an adapter by providing an interface that deals exclusively in terms of pure Java.  For example, you can define an interface with three methods for onMove(), onStart(), and onEnd(), which you would then pass to RaphaelJS.drag() and use the JSNI notation for invoking methods on GWT objects from within native Javascript methods, to pass the three separate parameters to the underlying Element.drag() method in Raphael.  Then a consumer of this class can implement that interface and respond to events however they want.

Something like that would be great and would definitely warrant inclusion.  Is this something you can work on?

Geoff

Cristian Miranda

unread,
Oct 26, 2011, 4:50:53 PM10/26/11
to raphaelgwt
Hi Geoff,

Thanks for the feedback.
Of course I will work on that. I'll do my best. :)
If any question pops up on my mind regarding this i will ask you.

Regards,
Cristian Miranda

Cristian Miranda

unread,
Oct 28, 2011, 4:28:09 PM10/28/11
to raphaelgwt
Hi Geoff,

I didn't have much time but, finally, I could release the second
version of the patch that provides the support for the DND feature.
I've been reading about GWT Code style and I'm sticking to the rules
on this patch. Tell me if you see something wrong. :)

Download Link: https://sourceforge.net/projects/gwtraphaeldnd/files/

Thanks,

Cristian Miranda

unread,
Oct 28, 2011, 4:50:03 PM10/28/11
to raphaelgwt
Here is the way to use it..

//Draggable circle
final Circle c = this.new Circle(260, 100, 50);
c.attr("cursor","pointer");
c.attr("stroke-width","3").attr("stroke-dasharray","--");
c.attr("fill", "#00BFFF");
c.drag(new DndActions(){
@Override
public void onStart() {
c.animate((JSONObject) JSONParser.parseLenient("{rotation:
60}"), 400, "bounce");
}
@Override
public void onMove() {
c.attr("fill", "#415899");
}
@Override
public void onEnd() {
c.attr("fill", "#00BFFF");
c.animate((JSONObject)
JSONParser.parseLenient("{rotation:-60}"), 400, "bounce");
}
});

I've uploaded a sample application here:
http://sourceforge.net/projects/gwtraphaeldnd/files/DNDV2SampleApp.rar/download

Regards,

Cristian Miranda.
Blog: http://gwtexpress.blogspot.com

Geoff Speicher

unread,
Oct 29, 2011, 11:46:51 AM10/29/11
to raphaelgwt
I updated the issue tracker with a new patch:
http://code.google.com/p/raphaelgwt/issues/detail?id=18#c2

On Oct 28, 4:50 pm, Cristian Miranda <cris...@gmail.com> wrote:
> Here is the way to use it..
>
> //Draggable circle
> final Circle c = this.new Circle(260, 100, 50);
> c.attr("cursor","pointer");
> c.attr("stroke-width","3").attr("stroke-dasharray","--");
> c.attr("fill", "#00BFFF");
> c.drag(new DndActions(){
>       @Override
>       public void onStart() {
>         c.animate((JSONObject) JSONParser.parseLenient("{rotation:
> 60}"), 400, "bounce");
>       }
>       @Override
>       public void onMove() {
>         c.attr("fill", "#415899");
>       }
>       @Override
>       public void onEnd() {
>         c.attr("fill", "#00BFFF");
>         c.animate((JSONObject)
> JSONParser.parseLenient("{rotation:-60}"), 400, "bounce");
>       }
>
> });
>
> I've uploaded a sample application here:http://sourceforge.net/projects/gwtraphaeldnd/files/DNDV2SampleApp.ra...
Reply all
Reply to author
Forward
0 new messages