views:

532

answers:

5

Is there any library out there to create graphics without using AWT?
What I need is simple drawing functions (like to draw a line) and text drawing functions to create graphics in memory for a Google app engine application. App engine does not support AWT.

Thanks!

A: 

Google Web Toolkit contains a nice graphics library designed for interfacing with the Google app engine.

edit to clarify: Google App Engine is designed for hosting applications on the web. You need to design graphics that can run in the browser. To do this, you need to write code in a web language, Javascript, for example. Google Web Toolkit contains a Java graphics library which compiles down to Javascript, saving you the effort of writing the Javascript yourself.

Pace
What? Google Web Toolkit is not a graphics library...
Damian
But I need to create images on the server.
Damian
A: 

There's a blog here about deploying Javafx applications to Google App Engine:

http://110j.wordpress.com/2008/12/31/javafx-on-google-app-engine/

you can use that to create graphics, but you need to do some research first into 2D graphics and such:

http://www.dieajax.com/2007/10/15/10-minute-tutorial-javafx-basic-2d-graphics-and-animation/

Jon
JavaFX would be running on the client side, not the server side.
Jay Askren
Yes, I need to create images on the server.
Damian
On second thought, it's not an elegant solution, but would it work for you to generate the image on the client side (JavaFX or Java Applet) and upload the image to the server?
Jay Askren
No way... what if I need to create a captcha? Besides that, I can't think of it as a solution to create images on the server.
Damian
A: 

You might try using SenseLan. In the requirements section, it says they don't use awt or ImageIO. Of course, there is the Images api but it seems fairly limited in what it offers.

Edit:

It looks like there are a couple of Python possibilities that could offer you some limited drawing capabilities. You could probably write appropriate image functionality as python web services, and keep the rest of the app in Java:

  1. http://stackoverflow.com/questions/1131992/replacing-functionality-of-pil-imagedraw-in-google-app-engine-gae
  2. http://denislaprise.com/2008/08/21/drawing-images-on-google-app-engine/
Jay Askren
Well, senselan is great but it only converts images from format to format. What I need is simple graphic functions (like to draw lines) and to draw text.
Damian
As the title says, it must be a Java library. My app is already developed in java.
Damian
@Damian: Jhython -- run Python code in Java, and would let you bridge the gap.
BobMcGee
A: 

'The Java 2D API is a set of classes for advanced 2D graphics and imaging, encompassing line art, text, and images' http://java.sun.com/products/java-media/2D/index.jsp

Here's another possibility: org.eclipse.draw2d It probably relies on eclipse SWT.

rleir
Look at the javadoc: http://java.sun.com/j2se/1.4.2/docs/guide/2d/spec.htmlI can't use AWT.
Damian
+2  A: 

Not unless you want to implement your own image class (say, a bitmap) and rendering algorithms for lines, shapes, images.

If you have experience with computer graphics and rasterization, this may not be very hard, but otherwise it will be more than you want to bite off.

BobMcGee
That's what I've done and it works great, but the problem is rendering text. That's something I think I cant solve writing my own code. At least not as easily as drawing lines or circles.
Damian
@Damian: Text rendering is complex, and I'm not sure you'll find an easy solution. You *might* try using the non-native parts of AWT as a standard package -- I recall seeing a fully software (no GPU) implementation of a lot of the drawing functionality somewhere. They were using it for benchmarking and demonstrating a parallel approach.
BobMcGee
Well I found this: http://fonteditor.org/ ... I will try it out as soon as I can.
Damian