Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Java, Ruby, JRuby, JRubify some Java?

Reply
Thread Tools

Java, Ruby, JRuby, JRubify some Java?

 
 
Audrey A Lee
Guest
Posts: n/a
 
      09-23-2009
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/ap...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().getScreenSiz e
()) );

// 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

 
Reply With Quote
 
 
 
 
Axel Etzold
Guest
Posts: n/a
 
      09-23-2009

-------- Original-Nachricht --------
> Datum: Wed, 23 Sep 2009 15:25:11 +0900
> Von: Audrey A Lee <(E-Mail Removed)>
> An: http://www.velocityreviews.com/forums/(E-Mail Removed)
> Betreff: Java, Ruby, JRuby, JRubify some Java?


> 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/ap...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().getScreenSiz e
> ()) );
>
> // 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
>


Dear Audrey,

you can use Java classes in Jruby straight away:

http://blogs.sun.com/coolstuff/entry...asses_in_jruby

For Linux automation, you might want to look at (the non-Java)
xdotool and its Ruby gem binding xdo:

http://osdir.com/ml/ruby-talk/2009-08/msg01393.html


You might combine that with one of the many ways to take screenshots
in Linux:

http://tips.webdesign10.com/how-to-t...n-ubuntu-linux

Best regards,

Axel



--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

 
Reply With Quote
 
 
 
 
Ilan Berci
Guest
Posts: n/a
 
      09-23-2009
Axel Etzold wrote:

>



Your responses were amazingly concise and to the point, I was hoping you
could provide me with some marriage counseling when you have the time

ilan


--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SetAuthCookie works some times and fails some times? =?Utf-8?B?bWF2cmlja18xMDE=?= ASP .Net 0 03-23-2006 09:24 PM
How can I restrict that the some ID can only login once in the some time ad ASP .Net 2 08-12-2005 09:14 PM
Need some help for some perl homework.... Perl 0 02-25-2004 01:45 AM
Forms Authentication question: How to have some pages open and some requiring forms authentication Eric ASP .Net 2 02-13-2004 02:14 PM
Some questions regarding 070-305 and hopefully some right answers. Needs correction... wink, wink ;-) Daniel Walzenbach MCSD 1 11-10-2003 12:25 AM



Advertisments