Package org.faceless.graph2.tag
Class PDFEmbedder
- java.lang.Object
-
- org.faceless.graph2.tag.Embedder
-
- org.faceless.graph2.tag.PDFEmbedder
-
public class PDFEmbedder extends Embedder
A class which may be used as a starting point for rendering "interactive" graphs (i.e those containing actions like hyperlinks) to PDF.
-
-
Constructor Summary
Constructors Constructor Description PDFEmbedder()
Create a new PDFEmbedder
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
convert()
Convert the object returned byEmbedder.getGraph()
to an appropriate binary form, write it toEmbedder.getImageOutputStream()
and write the HTML required to embed it toEmbedder.getPageWriter()
, referencing the image atEmbedder.getImagePath()
.PDFCanvas
getCanvas()
Return the PDFCanvas that was generated by the XML.String
getMIMEType()
Get the MIME type for the image that will be written by this Embedder toEmbedder.getImageOutputStream()
PDF
getPDF()
Return a single page PDF that contains the Graph, as returned bygetCanvas()
.PDFFont
getPDFFont(String fontname)
Return the PDF font that is mapped to the specified font name.XMLGraphResourceProvider
getResourceProvider()
Return theXMLGraphResourceProvider
to use with this formatPDFAction
parseHREF(String url)
Return a PDFAction for the specified URL.void
setPDFFont(String fontname, PDFFont font)
Map the specified fontname, which may appear in the XML, to the specified PDF font-
Methods inherited from class org.faceless.graph2.tag.Embedder
getAttribute, getAttributes, getForeignXML, getGraph, getHeight, getId, getWidth
-
-
-
-
Method Detail
-
getResourceProvider
public XMLGraphResourceProvider getResourceProvider()
Description copied from class:Embedder
Return theXMLGraphResourceProvider
to use with this format- Overrides:
getResourceProvider
in classEmbedder
-
getMIMEType
public String getMIMEType()
Description copied from class:Embedder
Get the MIME type for the image that will be written by this Embedder toEmbedder.getImageOutputStream()
- Specified by:
getMIMEType
in classEmbedder
-
setPDFFont
public void setPDFFont(String fontname, PDFFont font)
Map the specified fontname, which may appear in the XML, to the specified PDF font
-
getPDFFont
public PDFFont getPDFFont(String fontname)
Return the PDF font that is mapped to the specified font name.
-
convert
public void convert() throws IOException
Description copied from class:Embedder
Convert the object returned byEmbedder.getGraph()
to an appropriate binary form, write it toEmbedder.getImageOutputStream()
and write the HTML required to embed it toEmbedder.getPageWriter()
, referencing the image atEmbedder.getImagePath()
. At it's very minimum it could look something like this:ImageOutput output = new ImageOutput(); getGraph().draw(output); output.writePNG(getImageOutputStream(), 0); getPageWriter().write("<img src='"+getImagePath()+"' />");
which is suitable for embedding an image with no mouse interaction.- Specified by:
convert
in classEmbedder
- Throws:
IOException
-
getCanvas
public PDFCanvas getCanvas()
Return the PDFCanvas that was generated by the XML. This object has no interactivity (it's not possible for PDFCanvas)
-
getPDF
public PDF getPDF()
Return a single page PDF that contains the Graph, as returned bygetCanvas()
. The page may also have annotations which will reflect any interactivity specified in the XML, for example it will haveAnnotationLink
objects for any "href" attributes.
-
parseHREF
public PDFAction parseHREF(String url)
Return a PDFAction for the specified URL. By default this method returnsPDFAction.goToURL(url)
, but this can be overridden to convert special URLs into a particular PDFAction
-
-