Skip to content

Commit

Permalink
Add dot file generation from graph
Browse files Browse the repository at this point in the history
dot file generated from graphs.

Issue-ID: SMO-156
Change-Id: Icfb36d1102aaf99140c4630accbd263a5a56fd75
Signed-off-by: aravind.est <[email protected]>
  • Loading branch information
aravindtga committed Aug 21, 2024
1 parent b59b816 commit aa98f28
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ private void generateGraph(String name, List<Entity> entities) throws IOExceptio
MutableGraph g = prepareGraph(entities, name);
File outputFile = new File(graphOutput, name);
Graphviz.fromGraph(g).render(Format.SVG).toFile(outputFile);
Graphviz.fromGraph(g).render(Format.DOT).toFile(outputFile);
log.info("Graph rendered to: {}", outputFile.getAbsolutePath());
}

private MutableGraph prepareGraph(List<Entity> moduleEntities, String moduleName) {
MutableGraph g = Factory.mutGraph(moduleName).setDirected(true).graphAttrs().add(Rank.dir(RankDir.LEFT_TO_RIGHT))
.nodeAttrs().add(Shape.RECT, Style.BOLD, Color.BLACK, Style.FILLED, Color.LIGHTGRAY.fill());
.nodeAttrs().add(Shape.RECT, Style.BOLD, Color.BLACK, Style.FILLED, Color.LIGHTGRAY.fill(), Font.name(
"Arial"));
MutableNode moduleNameNode = Factory.mutNode(moduleName).attrs().add(Color.LIGHTBLUE.fill());
g.add(moduleNameNode);
for (Entity moduleEntity : moduleEntities) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
package org.oran.smo.teiv.pgsqlgenerator.grapghgenerator;

import guru.nidi.graphviz.attribute.Arrow;
import guru.nidi.graphviz.attribute.Attributes;
import guru.nidi.graphviz.attribute.Color;
import guru.nidi.graphviz.attribute.EndLabel;
import guru.nidi.graphviz.attribute.Font;
import guru.nidi.graphviz.attribute.ForAll;
import guru.nidi.graphviz.attribute.Shape;
import guru.nidi.graphviz.model.Factory;
import guru.nidi.graphviz.model.MutableGraph;
Expand Down Expand Up @@ -70,12 +73,14 @@ private void generateGraph(String name, List<Relationship> relationships, List<E
MutableGraph g = prepareGraph(relationships, entities);
File outputFile = new File(graphOutput, name + "-rel");
Graphviz.fromGraph(g).render(Format.SVG).toFile(outputFile);
Graphviz.fromGraph(g).render(Format.DOT).toFile(outputFile);
log.info("Graph rendered to: {}", outputFile.getAbsolutePath());
}

private MutableGraph prepareGraph(List<Relationship> moduleRelationships, List<Entity> moduleEntities) {
MutableGraph g = Factory.mutGraph("moduleName").setDirected(true).linkAttrs().add(Color.DARKSLATEGRAY4).nodeAttrs()
.add(Shape.BOX);
Attributes<ForAll> arialFont = Font.name("Arial");
MutableGraph g = Factory.mutGraph("moduleName").setDirected(true).linkAttrs().add(Color.DARKSLATEGRAY4, arialFont)
.nodeAttrs().add(Shape.BOX, arialFont);
for (Entity moduleEntity : moduleEntities) {
MutableNode node = Factory.mutNode(moduleEntity.getEntityName());
g.add(node);
Expand Down

0 comments on commit aa98f28

Please sign in to comment.