org.faceless.graph2.tag
Class Embedder

java.lang.Object
  extended by org.faceless.graph2.tag.Embedder
Direct Known Subclasses:
FlashEmbedder, PNGEmbedder, SVGEmbedder

public abstract class Embedder
extends Object

An Embedder is responsible for converting a Graph object to HTML and binary output. Subclasses of this object handle conversion from a Graph object to various output formats (PNG, SVG, Flash etc). This class is used by the EmbeddedXMLGraph class. It's possible for customers to subclass this (or further subclass one of the existing subclasses) to create their own output formats.

Since:
2.4
See Also:
EmbeddedXMLGraph.doEmbed(), EmbedderFactory

Field Summary
static Collection ACTIONS
          A list of the "actions" that can be applied to each rollover area.
 
Constructor Summary
Embedder()
           
 
Method Summary
abstract  void convert()
          Convert the object returned by getGraph() to an appropriate binary form, write it to getImageOutputStream() and write the HTML required to embed it to getPageWriter(), referencing the image at getImagePath().
protected  String getAction(String key, String action)
          Return the specified action for the specified key.
protected  Collection getActionKeys()
          Return the list of keys that have actions associated with them.
 String getAttribute(String attribute)
          Get the specified non-standard attribute set on the or tag, or null if it doesn't exist
 Collection getAttributes()
          Get the list of non-standard attributes set on the or tag.
protected  Font getFont(String fontname)
          Get the Font object matching the specified name, or null if it does not exist.
protected  Set getFonts()
          Return the name of all the fonts specified as available for use with the Graph
 String getForeignXML()
          Get any XML that was included in the Graph XML from a different namespace
 Graph getGraph()
          Get the Graph this Embedder is operating on
 int getHeight()
          Get the requested height of the Graph
 String getId()
          Get the ID for the object being created by this Embedder.
protected  OutputStream getImageOutputStream()
          Get the OutputStream object that the binary image file should be written to
protected  String getImagePath()
          Get the path that should be specified in the HTML to reference the image.
abstract  String getMIMEType()
          Get the MIME type for the image that will be written by this Embedder to getImageOutputStream()
protected  Map getPageResources()
          Return the page resources - font names and URLs.
protected  Writer getPageWriter()
          Get the Writer object that the HTML should be written to
protected static Paint getPaint(String val)
          Given a String representing a color (eg #F0F0F0 or "red") , convert it to a Paint object
 int getWidth()
          Get the requested width of the Graph
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTIONS

public static final Collection ACTIONS
A list of the "actions" that can be applied to each rollover area. These include "title", "href", "target" and the "onNNN" attributes.

Constructor Detail

Embedder

public Embedder()
Method Detail

getAttributes

public Collection getAttributes()
Get the list of non-standard attributes set on the or tag.

See Also:
getAttribute(java.lang.String)

getAttribute

public String getAttribute(String attribute)
Get the specified non-standard attribute set on the or tag, or null if it doesn't exist

See Also:
getAttributes()

getPageWriter

protected Writer getPageWriter()
Get the Writer object that the HTML should be written to


getImageOutputStream

protected OutputStream getImageOutputStream()
Get the OutputStream object that the binary image file should be written to


getImagePath

protected String getImagePath()
Get the path that should be specified in the HTML to reference the image. For instance, if an Embedder is creating an <img> tag to reference the image written to getImageOutputStream(), it should use code like:
  getPageWriter().write("<img src='"+getImagePath()+"' />");
 


getActionKeys

protected Collection getActionKeys()
Return the list of keys that have actions associated with them. This will be a collection with items like "graph.series.MySeries", "graph.marker.MyMarker" and so on - created as a result of applying an "href", "title", "onmouseover" or similar attribute to an item in the graph XML.

See Also:
ACTIONS

getAction

protected String getAction(String key,
                           String action)
Return the specified action for the specified key.

Parameters:
key - a named item that might be added to the graph - eg "graph.series.MySeries"
action - the action, eg "href", "title" or "onmouseover". One of ACTIONS
Returns:
the matching value, or null

getGraph

public Graph getGraph()
Get the Graph this Embedder is operating on


getWidth

public int getWidth()
Get the requested width of the Graph


getHeight

public int getHeight()
Get the requested height of the Graph


getId

public String getId()
Get the ID for the object being created by this Embedder. The ID is unique on its page for this graph, and should be used if any other objects (like image maps or JavaScript) are to be created that relate to this Graph.


getPaint

protected static Paint getPaint(String val)
Given a String representing a color (eg #F0F0F0 or "red") , convert it to a Paint object


getPageResources

protected final Map getPageResources()
Return the page resources - font names and URLs.

Returns:
Map of page resources

getFont

protected Font getFont(String fontname)
Get the Font object matching the specified name, or null if it does not exist.

Parameters:
fontname - the name of the font.
Returns:
the Font or null

getFonts

protected Set getFonts()
Return the name of all the fonts specified as available for use with the Graph


getForeignXML

public String getForeignXML()
Get any XML that was included in the Graph XML from a different namespace


getMIMEType

public abstract String getMIMEType()
Get the MIME type for the image that will be written by this Embedder to getImageOutputStream()


convert

public abstract void convert()
                      throws IOException
Convert the object returned by getGraph() to an appropriate binary form, write it to getImageOutputStream() and write the HTML required to embed it to getPageWriter(), referencing the image at 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.

Throws:
IOException


Copyright © 2001-2011 Big Faceless Organization