addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1light-bulblinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Re: [la-ruby] Java, Ruby, JRuby, JRubify some Java?

From: jay
Sent on: Wednesday, September 23, 2009 11:07 AM
It's essentially a line for line mapping. You just have to learn the jruby syntax for importing java classes which you can find here.
http://kenai.com/projects/jruby/pages/CallingJavaFromJRuby

let me know if you run into any specific problems and I'll help out.

Jay

On Wed, Sep 23, 2009 at 8:24 AM, Audrey A Lee <[address removed]> wrote:
Hello JRuby People,

I'm not quite ready to JRubyify yet but,
I'm working on a mini-project which requires that I screen-capture a
portion of my x-display on a linux box.

It looks like I can use a class in Java named "Robot" to do this:
?- http://java.sun.com/javase/6/docs/api/java/awt/Robot.html

I figure any class (even if it is a Java class) named "Robot" deserves
my attention.

So I ran this query:
?- http://www.google.com/search?q=java+robot+screencapture

And this page looks good:
?- http://www.rgagnon.com/javadetails/java-0489.html

I see this example:

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.imageio.ImageIO;

class ScreenCapture {
?public static void main(String args[]) throws
? ? ? ? ? AWTException, IOException {
? ? // capture the whole screen
? ? BufferedImage screencapture = new Robot().createScreenCapture(
? ? ? ? ? new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()) );

? ? // Save as JPEG
? ? File file = new File("screencapture.jpg");
? ? ImageIO.write(screencapture, "jpg", file);

? ? // Save as PNG
? ? // File file = new File("screencapture.png");
? ? // ImageIO.write(screencapture, "png", file);
?}
}

My question:
Is it possible to transform the above Java-syntax into Ruby-syntax
which could be interpreted by JRuby?

Or I could ask it this way:
How do I transform the above Java-syntax into JRuby-syntax?

--Audrey




--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
http://www.meetup.com/laruby/
This message was sent by Audrey A Lee ([address removed]) from The Los Angeles Ruby/Rails Meetup Group.
To learn more about Audrey A Lee, visit his/her member profile: http://www.meetup.com/laruby/members/10196215/
To unsubscribe or to update your mailing list settings, click here: http://www.meetup.com/account/comm/
Meetup Support: [address removed]
632 Broadway, New York, NY 10012 USA


People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy