Skip to content

Commit

Permalink
Make background color in diagrams configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
atextor committed Aug 6, 2021
1 parent f2263d2 commit 04e313e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cli/src/main/java/de/atextor/owlcli/OWLCLIDiagramCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public class OWLCLIDiagramCommand extends AbstractCommand implements Runnable {
@CommandLine.Option( names = { "--dotbinary" }, description = "Path to dot binary (Default: ${DEFAULT-VALUE})" )
private String dotBinary = config.dotBinary;

@CommandLine.Option( names = { "--bgcolor" }, description = "Background color (Default: ${DEFAULT-VALUE})" )
private String bgColor = config.bgColor;

@CommandLine.Parameters( paramLabel = "INPUT", description = "File name or - for stdin", arity = "1",
index = "0" )
private String input;
Expand All @@ -96,6 +99,7 @@ public void run() {
.format( format )
.layoutDirection( layoutDirection )
.dotBinary( dotBinary )
.bgColor( bgColor )
.build();

final MappingConfiguration mappingConfig = DefaultMappingConfiguration.builder().build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public class Configuration {
@Builder.Default
public String nodeStyle = "rounded";

@Builder.Default
public String bgColor = "white";

@Builder.Default
public Format format = Format.SVG;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class GraphvizDocument implements Function<Configuration, String> {
digraph G {
rankdir = ${rankdir}
bgcolor = "${bgcolor}"
fontname = "${fontname}"
fontsize = ${fontsize}
Expand All @@ -54,6 +56,7 @@ public class GraphvizDocument implements Function<Configuration, String> {
style = "${nodeStyle}"
height = 0.3
width = 0.2
bgcolor = "${bgcolor}"
]
${statements}
Expand Down Expand Up @@ -104,6 +107,7 @@ public String apply( final Configuration configuration ) {
"nodeShape", configuration.nodeShape,
"nodeMargin", configuration.nodeMargin,
"nodeStyle", configuration.nodeStyle,
"bgColor", configuration.bgColor,
"statements", Stream.concat( nodeStatements.stream(), edgeStatements.stream() )
.map( Statement::toFragment )
.collect( Collectors.joining( " \n" ) ) ) );
Expand Down
5 changes: 5 additions & 0 deletions docs/modules/ROOT/pages/usage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ extension changed, e.g. myontology.ttl -> myontology.svg. If `input` is `-` and
|See the https://www.graphviz.org/doc/info/attrs.html#k:style[Graphviz
documentation] for more information

|`--bgcolor`
|Background color for the generated diagram
|white
|See the https://www.graphviz.org/docs/attrs/bgcolor/[Graphviz documentation] for more information

|===

[#diagram-example-usage]
Expand Down

0 comments on commit 04e313e

Please sign in to comment.