yext.export.io
Class SWFOutputHandler

java.lang.Object
  extended by y.io.IOHandler
      extended by yext.export.io.OutputHandler
          extended by yext.export.io.SWFOutputHandler

public class SWFOutputHandler
extends OutputHandler

Writes a Graph2D in SWF vector graphics format.

The size, viewport and zoom level of the output will be determined by the Graph2DView associated with the input graph.

A SWFOutputHandler is used the same way as any other IOHandler. E.g. the simplest way to export a given Graph2D instance to SWF is:

 try {
   new SWFOutputHandler().write(graph2D, "myGraphAsSWF.swf");
 } catch(IOException ex) {
   // error handling code
 }

If a non-null link map is passed to the constructor or set using setReferences(y.io.LinkMap), the output handler will create transparent buttons on top of all graph items (nodes, edges, labels) that contain a non-null mapping to a LinkInfo object in the link map.

See Also:
Graph2DView
 

Field Summary
static int SWF_VERSION_7
          Version constant representing SWF file version 7.
static int SWF_VERSION_8
          Version constant representing SWF file version 8.
 
Constructor Summary
SWFOutputHandler()
          Creates a new output handler using the default SWF version number.
SWFOutputHandler(int swfVersion)
          Creates a new output handler using the given swf version.
SWFOutputHandler(int swfVersion, LinkMap references)
          Creates a new output handler using the given swf version number and link map.
SWFOutputHandler(LinkMap references)
          Creates a new output handler using the given link map and the default SWF version number.
 
Method Summary
 double getEdgeHitSensitivity()
          Returns the width of an additional hit-test-sensitive border applied to each hyperlinked edge path.
 String getFileNameExtension()
          Returns "swf", the standard file name extension for Macromedia Flash.
 LinkMap getReferences()
          Gets the link map that maps graph items to references that will be included in the swf file.
 int getSwfVersion()
          Returns the SWF version of the SWF files this output handler produces.
 void setEdgeHitSensitivity(double sensitivity)
          Sets the width of an additional hit-test-sensitive border applied to each hyperlinked edge path.
 void setReferences(LinkMap references)
          Sets the link map that maps graph items to references that will be included in the swf file.
 void setSWFVersion(int swfVersion)
          Sets the SWF version to write to the SWF header.
protected  void writeLinkInfo(org.freehep.graphicsio.swf.YSWFGraphics2D gfx, LinkInfo linkInfo, EdgeRealizer realizer)
          Write a LinkInfo instance for the given edge realizer to the given swf graphics.
protected  void writeLinkInfo(org.freehep.graphicsio.swf.YSWFGraphics2D gfx, LinkInfo linkInfo, NodeRealizer realizer)
          Write a LinkInfo instance for the given node realizer to the given swf graphics.
protected  void writeLinkInfo(org.freehep.graphicsio.swf.YSWFGraphics2D gfx, LinkInfo linkInfo, YLabel label)
          Write a LinkInfo instance for the given label to the given swf graphics.
protected  void writeReferences(org.freehep.graphicsio.swf.YSWFGraphics2D gfx, Graph2DView view, LinkMap linkMap)
          Writes the link references that were stored in the given linkMap.
 
Methods inherited from class yext.export.io.OutputHandler
addRenderingHint, canRead, canWrite, createDefaultGraph2DView, createGraphicsContext, getCreator, getFileFormatString, read, removeRenderingHint, setCreator, write
 
Methods inherited from class y.io.IOHandler
canWriteSubset, createObjectInputStream, createObjectOutputStream, hide, read, read, shouldSerialize, shouldSerialize, write, writeSubset, writeSubset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SWF_VERSION_7

public static final int SWF_VERSION_7
Version constant representing SWF file version 7. Version 7 of the SWF file format allows embedded links to local and external resources.

See Also:
Constant Field Values

SWF_VERSION_8

public static final int SWF_VERSION_8
Version constant representing SWF file version 8. Version 8 of the SWF file format allows embedded links to either local or external/network resources, but not both.

See Also:
Constant Field Values
Constructor Detail

SWFOutputHandler

public SWFOutputHandler()
Creates a new output handler using the default SWF version number.

No hyperlinks will be created unless setReferences(y.io.LinkMap) is called with a non-null link map before OutputHandler.write(y.view.Graph2D, java.io.OutputStream) is called.


SWFOutputHandler

public SWFOutputHandler(LinkMap references)
Creates a new output handler using the given link map and the default SWF version number.

Note: For SWF_VERSION_8 currently only local links are supported, i.e. external (or network) links are blocked by Flash player implementations.

Parameters:
references - the link map that maps graph items to references that will be included in the SWF file.
See Also:
setReferences(y.io.LinkMap)

SWFOutputHandler

public SWFOutputHandler(int swfVersion)
Creates a new output handler using the given swf version.

No hyperlinks will be created unless setReferences(y.io.LinkMap) is called with a non-null link map before OutputHandler.write(y.view.Graph2D, java.io.OutputStream) is called.

Parameters:
swfVersion - the SWF version to write to the SWF header.
See Also:
setSWFVersion(int)

SWFOutputHandler

public SWFOutputHandler(int swfVersion,
                        LinkMap references)
Creates a new output handler using the given swf version number and link map.

Parameters:
swfVersion - the SWF version to write to the SWF header.
references - the link map that maps graph items to references that will be included in the SWF file.
See Also:
setReferences(y.io.LinkMap), setSWFVersion(int)
Method Detail

getSwfVersion

public int getSwfVersion()
Returns the SWF version of the SWF files this output handler produces.

Returns:
the SWF version of the SWF files this output handler produces.

setSWFVersion

public void setSWFVersion(int swfVersion)
Sets the SWF version to write to the SWF header. The version has to be set before OutputHandler.write(y.view.Graph2D, java.io.OutputStream) is called.

The main impact of the SWF version is the security policy used by Flash player implementations for links embedded into the generated SWF files.

Note: For SWF_VERSION_8 currently only local links are supported, i.e. external (or network) links are blocked by Flash player implementations.

Defaults to SWF_VERSION_7.

Parameters:
swfVersion - The version number to write to the SWF file header. Currently only SWF_VERSION_7 and SWF_VERSION_8 are supported.
Throws:
IllegalArgumentException - if the specified version is neither SWF_VERSION_7 nor SWF_VERSION_8.

getFileNameExtension

public String getFileNameExtension()
Returns "swf", the standard file name extension for Macromedia Flash.

Specified by:
getFileNameExtension in class IOHandler

writeReferences

protected void writeReferences(org.freehep.graphicsio.swf.YSWFGraphics2D gfx,
                               Graph2DView view,
                               LinkMap linkMap)
Writes the link references that were stored in the given linkMap. This method is called by OutputHandler.write(y.view.Graph2D, java.io.OutputStream) after the graph's content has been painted, if a non-null reference map has been added using setReferences(y.io.LinkMap).

Parameters:
gfx - the swf graphics to write to.
view - the view to be exported.
linkMap - the link map that contains LinkInfo objects for graph items.

writeLinkInfo

protected void writeLinkInfo(org.freehep.graphicsio.swf.YSWFGraphics2D gfx,
                             LinkInfo linkInfo,
                             NodeRealizer realizer)
Write a LinkInfo instance for the given node realizer to the given swf graphics.

This implementation uses YSWFGraphics2D.writeLink(String,String, java.awt.Shape) to write the link to the swf. The sensible area of the link is determined by the bounding box of the given realizer.
The link url is queried using the swf_url attribute of the linkInfo instance. The link target is queried using the swf_target attribute of the linkInfo instance.

Parameters:
gfx - the swf graphics to write to.
linkInfo - the link info that was stored for the node realized by realizer.
realizer - the realizer of the node for which the link should be written.

writeLinkInfo

protected void writeLinkInfo(org.freehep.graphicsio.swf.YSWFGraphics2D gfx,
                             LinkInfo linkInfo,
                             EdgeRealizer realizer)
Write a LinkInfo instance for the given edge realizer to the given swf graphics.

This implementation uses YSWFGraphics2D.writeLink(String,String, java.awt.Shape) to write the link to the swf. The sensible area of the link is determined by the edge's path and by the getEdgeHitSensitivity() property.
The link url is queried using the swf_url attribute of the linkInfo instance. The link target is queried using the swf_target attribute of the linkInfo instance.

Parameters:
gfx - the swf graphics to write to.
linkInfo - the link info that was stored for the edge realized by realizer.
realizer - the realizer of the edge for which the link should be written.

writeLinkInfo

protected void writeLinkInfo(org.freehep.graphicsio.swf.YSWFGraphics2D gfx,
                             LinkInfo linkInfo,
                             YLabel label)
Write a LinkInfo instance for the given label to the given swf graphics.

This implementation uses YSWFGraphics2D.writeLink(String,String, java.awt.Shape) to write the link to the swf. The sensible area of the link is determined by the location and size of the given label.
The link url is queried using the swf_url attribute of the linkInfo instance. The link target is queried using the swf_target attribute of the linkInfo instance.

Parameters:
gfx - the swf graphics to write to.
linkInfo - the link info that was stored for label.
label - the label for which the link should be written.

setEdgeHitSensitivity

public void setEdgeHitSensitivity(double sensitivity)
Sets the width of an additional hit-test-sensitive border applied to each hyperlinked edge path. The given width is interpreted in world-coordinate space.

By default this value is set to 10.0.


getEdgeHitSensitivity

public double getEdgeHitSensitivity()
Returns the width of an additional hit-test-sensitive border applied to each hyperlinked edge path.


getReferences

public LinkMap getReferences()
Gets the link map that maps graph items to references that will be included in the swf file.

Returns:
the current LinkMap instance

setReferences

public void setReferences(LinkMap references)
Sets the link map that maps graph items to references that will be included in the swf file.

The default writeLinkInfo implementations will query the LinkInfo instances stored in the link map for the swf_url and swf_target attributes.

Note: For SWF_VERSION_8 currently only local links are supported, i.e. external (or network) links are blocked by Flash player implementations.

Parameters:
references - the new LinkMap instance


© Copyright 2007-2015,
yWorks GmbH.
All rights reserved.