Producing an Image from a Java-Client Graph

In an HTML-client application, the thin graph produces a GIF that is rendered into an HTML page. In a Java-client application or applet, you can produce an image file from a graph. You can create a GIF, a JPEG, or a PNG file from a Java-client graph.

To set the resolution for the image, call the setImageSize method of the graph before you call the method to create the image. You can also specify whether to have font sizes scaled for the image size, by calling setScaleFontSizeForGIF.

Example: Producing a GIF file

The following short example shows how to create a GIF file from the default graph. This example creates a GIF file called myThinGraph.gif in the current folder.


Graph myThickGraph = new Graph(); FileOutputStream filestream = null; try{ filestream = new FileOutputStream("myThinGraph.gif"); } catch(FileNotFoundException e){ // handle the exception here } if(filestream != null){ myThickGraph.exportToGif(filestream); }