Class EmbeddedXMLGraph

  • All Implemented Interfaces:
    ContentHandler, DTDHandler, EntityResolver, ErrorHandler

    public class EmbeddedXMLGraph
    extends XMLGraph
    An extension of XMLGraph which handles rollovers, and creates HTML which can be embedded in a webpage to display the generated Graph. This class is designed for use with the tag library and accompanying GraphServlet to serve the images, and it's rare that a user would need to be concerned with this class directly.

    In the event there is a need to call this class directly, here's an example showing broadly how to generate a bitmap graph, and the HTML to display it in a webpage. We say broadly because without the matching GraphServlet, JavaScript and (usually) tag library this example is non-functioning

     EmbeddedXMLGraph xml = new EmbeddedXMLGraph();
     xml.parse(inputsource);
    
     String id = "graph1";      // if no ID attribute is specified in the XML
     String servlet = "/path/to/servlet/";   // URL that will serve the image we create
    
     StringWriter writer = new StringWriter();
     ByteArrayOutputStream imageout = new ByteArrayOutputStream();
     Embedder embedder = new PNGEmbedder();
     xml.doEmbed(embedder, id, servlet, null, null, writer, imageout);
     writer.close();
     imageout.close();
    
     // The graph image was written to "imageout", the HTML to display it
     // was sent to "writer".
     
    Since:
    2.4