[ 6 posts ]

Sebastián Gurin

  • Offline
  • Profile

ImageCropper Java Example

Post Posted: Fri Aug 17, 2012 6:35 pm
+0-
Hello Juan Ignacio, your imagecropper works good. I would like to share with you how your's ImageCropper java code looks in my project http://code.google.com/p/yuigwt/. The example is this http://cancerbero.vacau.com/yuigwt/?test=imageCropper1, you can look at the java sources from there. Also take how it looks ImageCropper Java class API documentation (with UML)
http://cancerbero.vacau.com/yuigwt/javadoc/org/sgx/yuigwt/yuigallery/imagecropper/ImageCropper.html

I thought it can be interesting to you to see your creation ported to another language. A Java code fragment

Code:
String src1 = "http://cabopolonio.com/ovejasenelcabo.jpg";
ImageCropper ic1 = Y.newImageCropper(ImageCropperConfig.create().source(src1).
   width("743px").height("517px"));
ic1.render(parent);

ic1.on(ImageCropper.EVENT_CROPEND, new EventCallback<ImageCropperEvent>() {
   @Override
   public void call(ImageCropperEvent e) {
      console.log(e.left()+", "+e.top()+", "+e.width()+", "+e.height());
   }
});

Juan Ignacio Dopazo

YUI Contributor

  • Username: jdopazo
  • Joined: Fri Oct 02, 2009 5:39 am
  • Posts: 619
  • Location: Buenos Aires, Argentina
  • Twitter: juandopazo
  • GitHub: juandopazo
  • Gists: juandopazo
  • Offline
  • Profile

Re: ImageCropper Java Example

Post Posted: Sat Aug 18, 2012 5:47 am
+0-
That's fantastic! Great job!

Due to recent interest in this widget I'm starting to write a User Guide and examples. Here's an early draft: http://juandopazo.github.com/yui3/docs/ ... index.html

I'm also working on lowering the byte count a bit. I'm removing a dependency and, as you'll see in the user guide, I'm considering moving keyboard support to a Plugin. It'd be nice to get some feedback on that. Do you think it's worth it or do you prefer to have keyboard support by default?


I'm curious about why you're calling Y.newImageCropper instead of new Y.ImageCropper (I know next to nothing about Java).

Sebastián Gurin

  • Offline
  • Profile

Re: ImageCropper Java Example

Post Posted: Sat Aug 18, 2012 7:33 am
+0-
Quote:
Due to recent interest in this widget I'm starting to write a User Guide and examples. Here's an early draft: http://juandopazo.github.com/yui3/docs/ ... index.html


Nice! I hope ImageCropper enters in the set of YUI official modules. Do you know if as a YUI user I can vote to promote your and others gallery modules ?

Quote:
I'm also working on lowering the byte count a bit. I'm removing a dependency and, as you'll see in the user guide, I'm considering moving keyboard support to a Plugin. It'd be nice to get some feedback on that. Do you think it's worth it or do you prefer to have keyboard support by default?


IMHO: lowering load weight making keyboard support optional is good. But I'm not sure about making a plugin for that. Would be this plugin Y.Plugin.ImageCropperKeys usable on other modules / scenarios other than the image cropper ? Perhaps it would be better to make a plugin Y.Plugin.ResizeKeys, a plugin that can be plugged to a Resize so Resize could support keys. This way ImageCropper only have to delegate the plugin to its Resize and others can use it with their own resizes... Just my thougts.

Quote:
I'm curious about why you're calling Y.newImageCropper instead of new Y.ImageCropper (I know next to nothing about Java).


That is a long story ;) I choose to design yuigwt to be the most efficient as possible, based on GWT Overlay types. This way your java code is translated to JavaScript code that is equivalent to native YUI JavaScript code. No object wrapping, no delegate methods, zero-overhead java to javascript translation .

This of course have some consequences, and the biggest is that all the yuigwt objects are currently native JavaScript YUI objects, created by native Javascript YUI and not created in java. I cannot write in java "new Y.ImageCropper" because the image cropper instance must be created by the native JavaScript YUI not by the java code. Well I'm documenting some notes about this kind of things in http://code.google.com/p/yuigwt/wiki/YUIJavaApi

Regards

Juan Ignacio Dopazo

YUI Contributor

  • Username: jdopazo
  • Joined: Fri Oct 02, 2009 5:39 am
  • Posts: 619
  • Location: Buenos Aires, Argentina
  • Twitter: juandopazo
  • GitHub: juandopazo
  • Gists: juandopazo
  • Offline
  • Profile

Re: ImageCropper Java Example

Post Posted: Sat Aug 18, 2012 7:46 am
+0-
Cancerbero wrote:
Nice! I hope ImageCropper enters in the set of YUI official modules. Do you know if as a YUI user I can vote to promote your and others gallery modules ?

I think it's all very informal at the moment. If the module gets enough usage I'll send a pull request to the core library and see what the YUI developers think.
Cancerbero wrote:
Would be this plugin Y.Plugin.ImageCropperKeys usable on other modules / scenarios other than the image cropper ? Perhaps it would be better to make a plugin Y.Plugin.ResizeKeys, a plugin that can be plugged to a Resize so Resize could support keys. This way ImageCropper only have to delegate the plugin to its Resize and others can use it with their own resizes... Just my thougts.

Actually, another reason I'm considering moving it to a Plugin is that keys only work for dragging. Resizing with the keyboard wasn't supported by the YUI2 ImageCropper so I didn't write it. Y.Plugin.DragKeys makes sense. I'll play around with that idea and see how it works with Y.Plugin.DDConstrain.

Cancerbero wrote:
That is a long story ;)

Very interesting!

Sebastián Gurin

  • Offline
  • Profile

Re: ImageCropper Java Example

Post Posted: Sat Aug 18, 2012 8:07 am
+0-
Quote:
Actually, another reason I'm considering moving it to a Plugin is that keys only work for dragging. Resizing with the keyboard wasn't supported by the YUI2 ImageCropper so I didn't write it. Y.Plugin.DragKeys makes sense. I'll play around with that idea and see how it works with Y.Plugin.DDConstrain.


Yes, I get confused, I meant Y.PluginDragKeys. That would be nice, and you can make it in a separate module so others can use it in other scenarios. Regards

Sebastián Gurin

  • Offline
  • Profile

Re: ImageCropper Java Example

Post Posted: Sat Aug 18, 2012 8:14 am
+0-
About the hipotetical Y.Plugin.DragKeys, It would be nice to be able to perform this:

aDrag.plug(Y.Plugin.DragKeys, {
modifier: ["alt"],
throttle: 200
})

modifier : for indicating to react to key presses only when a certain modifier key like alt or ctrl is pressed.

throttle: for using Y.throttle when the user left an arrow key pressed . http://yuilibrary.com/yui/docs/api/clas ... d_throttle
  [ 6 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum