views:

302

answers:

4

How would you generate an JPG image file containing data fields that are stored and updated within a database table? The image would then be regenerated every hour or so reflecting the latest values within the database table.

You would start with a basic background image, and then the generated image should contain data fields (e.g. average temperature, cpu load, time since last reboot etc.) overlayed on top of the background image. The data would be visualized with nice charts, icons and fonts.

Thanks!

EDIT: Good stuff. There are many good suggestions covering charting especially like JFreechart. I'm still a bit unsure on how best to work with overlaying images (i.e. icons) over a background image. Would the basic Java API be best for this case?

TIA!

+2  A: 

Check out the Java Tutorial on 2D Graphics. You could load your background image as a BufferedImage using ImageIO.read(), and then draw text on it using Graphics.drawString(). You could then save the image using ImageIO.write().


The OP has added more sophisticated requirements (nice charts, icons and fonts). In this case, one of the many charting or reporting packages (e.g. JFreeChart, JasperForge) would be more suitable.

Zach Scrivena
+3  A: 

you could use jfreechart

here is some nice tutorial http://www.oracle.com/technology/pub/articles/marx-jchart.html

01
+2  A: 

Create your BufferedImage

create a Graphics2D from this image

draw your picture on the Graphics2D

save your Image using the ImageIO class

See an example here: http://www.java2s.com/Code/Java/2D-Graphics-GUI/DrawanImageandsavetopng.htm

In your case, I would rather use a SVG image, or why not a simple HTML table ?

Pierre
Thanks for the tip. Well I want to make the data visualization as attractive as possible. So I'm looking at using icons, charts and nice fonts.
Walter
+1  A: 

RRDtool (Round Robin Database) is a db specialized in manipulating such kind of data.

There are a lot of java implementations of RDDtool. IMHO, you should try Jrobin first.

LLP, Andrea

andcoz