public class GraphImageMapCreator extends Object
SarasvatiGraphScene
internally, which can be used directly if more control is required.
SarasvatiGraphScene, be sure to call
GraphSceneImpl.setupForExportOnHeadless() before calling
GraphSceneImpl.export(StringBuilder, Function, Function).
<%
GraphToImageMapAdapter helper = new GraphToImageMapAdapter ()
{
public String hrefForNode (Node node)
{
return "javascript:alert( 'You have selected " + node.getName() + "' );";
}
public String hoverForNode (Node node)
{
return "Name: " + node.getName() + ", Type: " + node.getType() +
", Guard: " + node.getGuard() + ", Is start: " + node.isStart() +
", Is join: " + node.isJoin();
}
};
String basePath = config.getServletContext().getRealPath( "/" );
GraphImageMapCreator imageMapCreator = new GraphImageMapCreator( graph, helper );
imageMapCreator.writeImageToFile( "gif", basepath + "/test-graph.gif" );
%>
<map name="graphMap">
<%=imageMapCreator.getMapContents()%>
</map>
<div style="margin-left:10px; padding-top:10px">
<image style="border:2px black solid" src="<%=request.getContextPath() + "/test-graph.gif"%>" usemap="#graphMap"/>
</div>
| Modifier and Type | Field and Description |
|---|---|
protected BufferedImage |
image |
protected String |
mapContents |
| Constructor and Description |
|---|
GraphImageMapCreator(Graph graph,
GraphToImageMap graphToImageMap)
Creates a new GraphImageMapCreate using the given graph and graph to image map
helper.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
generateMapAndImage(Graph graph,
GraphToImageMap graphToImageMap) |
BufferedImage |
getImage()
Returns the generated graph image.
|
String |
getMapContents()
Returns what should placed in a map tag.
|
void |
writeImageToFile(String imageFormat,
String imageFileName)
Writes the generate graph image to a file in the given format
|
protected String mapContents
protected BufferedImage image
public GraphImageMapCreator(Graph graph, GraphToImageMap graphToImageMap)
graph - The graph to create an image map and image from.graphToImageMap - Controls how the image and image map are constructed.protected void generateMapAndImage(Graph graph, GraphToImageMap graphToImageMap)
public String getMapContents()
public BufferedImage getImage()
writeImageToFile(String, String).public void writeImageToFile(String imageFormat, String imageFileName) throws IOException
imageFormat - The informal name of the format to write the file in,
as understood by ImageIO.imageFileName - The name of the file to write the image toIOException - If an error occurs writing the image to discCopyright © 2012. All Rights Reserved.