|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.googlecode.sarasvati.visual.GraphImageMapCreator
public class GraphImageMapCreator
Class which generates HTML image maps for graphs. This uses SarasvatiGraphScene
internally, which can be used directly if more control is required.
Note: If using SarasvatiGraphScene, be sure to call
GraphSceneImpl.setupForExportOnHeadless() before calling
GraphSceneImpl.export(StringBuilder, Function, Function).
Example usage in a JSP:
<%
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>
| Constructor Summary | |
|---|---|
GraphImageMapCreator(Graph graph,
GraphToImageMap graphToImageMap)
Creates a new GraphImageMapCreate using the given graph and graph to image map helper. |
|
| Method Summary | |
|---|---|
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 |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
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.| Method Detail |
|---|
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 to
IOException - If an error occurs writing the image to disc
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||