JRobin: Not able to save graph as a PNG file

  • Post author:
  • Post last modified:August 17, 2024
  • Reading time:1 mins read

Error:

Not able to save graph as a PNG file.  
Compilation error: cannot find symbol  
[javac] symbol  : method saveAsPNG(java.lang.String,int,int)  

Solution:

saveAsPNG does not seem to be there in JRobin anymore. Use the RrdGraph.render (java.awt.Graphics g) method. For example,


// Create a buffered image in which the graph would be drawn    
BufferedImage bImage = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);   
// Create a graphics context on the buffered image    
Graphics2D g = bImage.createGraphics();   
// Define the graph ...    
RrdGraphDef rrdGraphDef = new RrdGraphDef ();   
// Complete the graph definition   
....   
// Make the graph    
RrdGraph rrdGraph = new RrdGraph (rrdGraphDef);   
// render the graph    
rrdGraph.render (g);   
// Graphics context no longer needed so it can be disposed    
g.dispose();    

Karunesh Johri

Software developer, working with C and Linux.