public class EmbeddedXMLGraph extends XMLGraph
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".
Constructor and Description |
---|
EmbeddedXMLGraph() |
Modifier and Type | Method and Description |
---|---|
void |
characters(char[] buf,
int off,
int len) |
void |
doEmbed(Embedder embedder,
String id,
String servlet,
Map pageresources,
Map contextresources,
Writer pageout,
OutputStream imageout)
Create the graph and the HTML required to embed it using the specified
Embedder . |
void |
endElement(String nspace,
String tag,
String qname) |
String |
getRequestedFormat()
Return the "format" attribute from the XML.
|
void |
startDocument() |
void |
startElement(String nspace,
String tag,
String qname,
Attributes atts) |
endDocument, getDefaultResourceProvider, getFonts, getGraph, getHeight, getWidth, parse, parse, setDocumentLocator, setResourceProvider, warning
endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDecl
public void startDocument() throws SAXException
startDocument
in interface ContentHandler
startDocument
in class DefaultHandler
SAXException
public void startElement(String nspace, String tag, String qname, Attributes atts) throws SAXException
startElement
in interface ContentHandler
startElement
in class XMLGraph
SAXException
public void endElement(String nspace, String tag, String qname) throws SAXException
endElement
in interface ContentHandler
endElement
in class XMLGraph
SAXException
public void characters(char[] buf, int off, int len) throws SAXException
characters
in interface ContentHandler
characters
in class XMLGraph
SAXException
public String getRequestedFormat()
public void doEmbed(Embedder embedder, String id, String servlet, Map pageresources, Map contextresources, Writer pageout, OutputStream imageout) throws IOException
Embedder
.
The Embedder is initialized and its Embedder.convert()
method called.
A new Embedder must be supplied to each call of this method - typically this
is obtained by a call to EmbedderFactory.newEmbedder(java.lang.String)
method.embedder
- the Embedder used to convert the Graph to HTML and binary outputid
- the ID to use for the graph, if one hasn't been specified with the "id" attributeservlet
- The full path to the graph servlet, eg "/app/servlet/GraphServlet/3/". The
format of this String will depend on the Servlet that is serving the Graph.pageresources
- A mapping of String->URL of any resources that are specified on this
for this page. Typically the keys are font names, the values URLscontextresources
- A map of URL->Object of any resources that apply beyond the life of
the page containing this Graph. Typically the keys are URLs and the values Fonts. The map
may be altered by this routine.pageout
- the Writer to write the HTML code toimageout
- the OutputStream to write the graph binary data toIOException
Copyright © 2001-2016 Big Faceless Organization