Reputation: 956
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!
Upvotes: 2
Views: 1886
Reputation: 29569
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.
Upvotes: 2
Reputation: 2232
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
Upvotes: 1
Reputation: 35306
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 ?
Upvotes: 2
Reputation: 64835
you could use jfreechart
here is some nice tutorial http://www.oracle.com/technology/pub/articles/marx-jchart.html
Upvotes: 3