Permalink
Browse files

Made createGraphViz take a GraphStyle as a parameter. Minor refactoring.

  • Loading branch information...
nawroth authored and peterneubauer committed Mar 9, 2012
1 parent 71b18be commit 2fe87dbe7d8894f90e51810666b932ba3977de4a
Showing with 19 additions and 21 deletions.
  1. +19 −21 graphviz/src/main/java/org/neo4j/visualization/asciidoc/AsciidocHelper.java
@@ -39,46 +39,44 @@
public static String createGraphViz( String title,
GraphDatabaseService graph, String identifier )
{
return createGraphOutput( title, graph, identifier, false, false );
return createGraphViz( title, graph, identifier,
AsciiDocSimpleStyle.withAutomaticRelationshipTypeColors() );
}
public static String createGraphVizWithNodeId( String title,
GraphDatabaseService graph, String identifier )
{
return createGraphOutput( title, graph, identifier, false, true );
return createGraphViz( title, graph, identifier,
AsciiDocStyle.withAutomaticRelationshipTypeColors() );
}
public static String createGraphVizDeletingReferenceNode( String title,
GraphDatabaseService graph, String identifier )
{
return createGraphOutput( title, graph, identifier, true, false );
removeReferenceNode( graph );
return createGraphViz( title, graph, identifier,
AsciiDocSimpleStyle.withAutomaticRelationshipTypeColors() );
}
public static String createGraphVizWithNodeIdDeletingReferenceNode(
String title, GraphDatabaseService graph, String identifier )
{
return createGraphOutput( title, graph, identifier, true, true );
removeReferenceNode( graph );
return createGraphViz( title, graph, identifier,
AsciiDocStyle.withAutomaticRelationshipTypeColors() );
}
private static String createGraphOutput( String title,
GraphDatabaseService graph, String identifier,
boolean removeReferenceNode, boolean showNodeTitle )
/**
* Create graphviz output using a {@link GraphStyle) which is implemented by
* {@link AsciiDocSimpleStyle} and {@link AsciiDocStyle}.
* {@link AsciiDocSimpleStyle} provides different customization options for
* coloring.
*/
public static String createGraphViz( String title,
GraphDatabaseService graph, String identifier, GraphStyle graphStyle )
{
if ( removeReferenceNode )
{
removeReferenceNode( graph );
}
OutputStream out = new ByteArrayOutputStream();
GraphStyle graphStyle;
if ( showNodeTitle )
{
graphStyle = AsciiDocStyle.withAutomaticRelationshipTypeColors();
}
else
{
graphStyle = AsciiDocSimpleStyle.withAutomaticRelationshipTypeColors();
}
GraphvizWriter writer = new GraphvizWriter( graphStyle );
OutputStream out = new ByteArrayOutputStream();
try
{
writer.emit( out, Walker.fullGraph( graph ) );

0 comments on commit 2fe87db

Please sign in to comment.