guru.nidi.graphviz.engine.Graphviz类的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(217)

本文整理了Java中guru.nidi.graphviz.engine.Graphviz类的一些代码示例,展示了Graphviz类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graphviz类的具体详情如下:
包路径:guru.nidi.graphviz.engine.Graphviz
类名称:Graphviz

Graphviz介绍

暂无

代码示例

代码示例来源:origin: org.apache.oozie/oozie-fluent-job-api

public static void workflowToPng(final Workflow workflow, final String fileName) throws IOException {
    final MutableGraph mg = Parser.read(workflowToDot(workflow));
    mg.setName(fileName);

    Graphviz.fromGraph(mg)
        .width(PNG_WIDTH)
        .render(Format.PNG)
        .toFile(new File(PARENT_FOLDER_NAME, FilenameUtils.getName(fileName)));
  }
}

代码示例来源:origin: apache/oozie

private Graphviz newGraphviz() {
    // Defaults to Rasterizer#BATIK
    return Graphviz.fromGraph(graphvizGraph)
        .engine(Engine.DOT)
        .height(calculateHeight(arcCount));
  }
}

代码示例来源:origin: schemacrawler/SchemaCrawler

Graphviz.useEngine(engines);
Graphviz.fromString(dotSource).render(format).toFile(outputFile.toFile());

代码示例来源:origin: nidi3/graphviz-java

private static String render(String raw) {
  final int pos = raw.indexOf("@@@");
  final Options options;
  final String src;
  if (pos < 0) {
    options = Options.create().format(SVG_STANDALONE);
    src = raw;
  } else {
    options = Options.fromJson(raw.substring(0, pos));
    src = raw.substring(pos + 3);
  }
  return Graphviz.fromString(src)
      .engine(options.engine)
      .totalMemory(options.totalMemory)
      .yInvert(options.yInvert)
      .render(options.format).toString();
}

代码示例来源:origin: com.simiacryptus/mindseye

log.p("This is a network apply the following layout:");
 log.eval(() -> {
  return Graphviz.fromGraph(TestUtil.toGraph((DAGNetwork) smallLayer))
    .height(400).width(600).render(Format.PNG).toImage();
 });
} catch (Throwable e) {
  @Nonnull DAGNetwork network = (DAGNetwork) explode;
  log.eval(() -> {
   @Nonnull Graphviz graphviz = Graphviz.fromGraph(TestUtil.toGraph(network)).height(400).width(600);
   @Nonnull File file = new File(log.getResourceDir(), log.getName() + "_network.svg");
   graphviz.render(Format.SVG_STANDALONE).toFile(file);
   log.link(file, "Saved to File");
   return graphviz.render(Format.SVG).toString();
  });

代码示例来源:origin: apache/oozie

@Override
  public String call() throws Exception {
    final Graphviz graphviz = newGraphviz();
    return graphviz.render(Format.SVG).toString();
  }
}

代码示例来源:origin: nidi3/graphviz-java

public static void createFontTest(String name, double adjust, File output) throws IOException {
  final Node width = node("If text is too narrow, increase fontAdjust. If it's too wide, decrease it.");
  final Node center = node(Label.html("A very long node label that should be centered inside the border<br/>"
      + "If text is too much left, increase fontAdjust.<br/>"
      + "If it's too much right, decrease it."));
  Graphviz.fromGraph(graph()
      .nodeAttr().with(Font.name(name), Shape.RECTANGLE)
      .with(width.link(center)))
      .fontAdjust(adjust)
      .render(PNG)
      .toFile(output);
}

代码示例来源:origin: gradle.plugin.com.simonharrer/gradle-graphviz-plugin

projectPath.relativize(targetPngPath).toString());
  System.out.println(message);
  Graphviz.fromFile(path.toFile()).render(Format.PNG).toFile(targetPngPath.toFile());
} catch (IOException e) {
  throw new RuntimeException(e);

代码示例来源:origin: org.tinywind/scheme-reporter

public static String totalRelationSvg(List<TableDefinition> tables) {
  final Map<String, Node> nodeMap = tables.stream().collect(Collectors.toMap(Definition::getName, table -> createReferNode(table.getName())));
  final Graph g = graph("totalRelationSvg").directed()
      .general().attr(RankDir.LEFT_TO_RIGHT);
  final List<Pair<String, String>> linkedList = new ArrayList<>();
  tables.forEach(table -> table.getColumns().forEach(column -> column.getForeignKeys().forEach(fkey -> {
    if (linkedList.contains(new Pair<>(table.getName(), fkey.getReferencedTable().getName()))) return;
    final Node linked = nodeMap.get(fkey.getReferencedTable().getName());
    nodeMap.put(table.getName(), nodeMap.get(table.getName()).link(linked));
    linkedList.add(new Pair<>(table.getName(), fkey.getReferencedTable().getName()));
  })));
  nodeMap.forEach((name, node) -> g.node(node));
  return Graphviz.fromGraph(g).createSvg();
}

代码示例来源:origin: nidi3/graphviz-java

public static Graphviz fromGraph(Graph graph) {
  return fromGraph((MutableGraph) graph);
}

代码示例来源:origin: nidi3/graphviz-java

public static void useEngine(GraphvizEngine first, GraphvizEngine... rest) {
  final List<GraphvizEngine> engines = new ArrayList<>();
  engines.add(first);
  engines.addAll(Arrays.asList(rest));
  useEngine(engines);
}

代码示例来源:origin: nidi3/graphviz-java

public static Graphviz fromFile(File src) throws IOException {
  try (final InputStream in = new FileInputStream(src)) {
    return fromString(IoUtils.readStream(in));
  }
}

代码示例来源:origin: com.simiacryptus/mindseye-labs

log.p("This is a network apply the following layout:");
 log.eval(() -> {
  return Graphviz.fromGraph(TestUtil.toGraph((DAGNetwork) smallLayer))
    .height(400).width(600).render(Format.PNG).toImage();
 });
} catch (Throwable e) {
  @Nonnull DAGNetwork network = (DAGNetwork) explode;
  log.eval(() -> {
   @Nonnull Graphviz graphviz = Graphviz.fromGraph(TestUtil.toGraph(network)).height(400).width(600);
   @Nonnull File file = new File(log.getResourceDir(), log.getName() + "_network.svg");
   graphviz.render(Format.SVG_STANDALONE).toFile(file);
   log.link(file, "Saved to File");
   return graphviz.render(Format.SVG).toString();
  });

代码示例来源:origin: apache/oozie

@Override
  public BufferedImage call() throws Exception {
    final Graphviz graphviz = newGraphviz();
    return graphviz.render(Format.PNG).toImage();
  }
}

代码示例来源:origin: org.tinywind/scheme-reporter

public static Map<String, String> relationSvg(List<TableDefinition> tables) {
  final Map<String, String> relationSvg = new HashMap<>();
  for (TableDefinition table : tables) {
    final String cTable = table.getName();
    final Node[] cNode = {createNode(cTable).attr("weight", 8).attr("fillcolor", "grey75")};
    final Map<String, Node> refer = new HashMap<>();
    final Map<String, Node> referred = new HashMap<>();
    table.getColumns().forEach(column -> {
      column.getForeignKeys().forEach(fkey -> {
        final String rTable = fkey.getReferencedTable().getName();
        refer.putIfAbsent(rTable, createReferNode(rTable));
      });
      column.getUniqueKeys().forEach(ukey -> ukey.getForeignKeys().forEach(fkey -> {
        final String rTable = fkey.getKeyTable().getName();
        if (referred.get(rTable) == null && !cTable.equals(rTable))
          referred.put(rTable, createReferNode(rTable).link(cNode[0]));
      }));
    });
    refer.values().stream().distinct().forEach(rNode -> cNode[0] = cNode[0].link(rNode));
    final Graph g = graph(cTable).directed().node(cNode[0]);
    referred.values().stream().distinct().forEach(g::node);
    relationSvg.put(cTable, Graphviz.fromGraph(g).createSvg());
  }
  return relationSvg;
}

代码示例来源:origin: nidi3/graphviz-java

public static void main(String... args) throws IOException {
  LOG.info("starting graphviz server...");
  if (args.length > 0) {
    Graphviz.useEngine(Arrays.stream(args).map(GraphvizServer::engineFromString).collect(toList()));

代码示例来源:origin: nidi3/graphviz-java

public static Graphviz fromGraph(MutableGraph graph) {
  return fromString(new Serializer(graph).serialize());
}

代码示例来源:origin: com.simiacryptus/mindseye-test

log.p("This is a network apply the following layout:");
 log.eval(() -> {
  return Graphviz.fromGraph(TestUtil.toGraph((DAGNetwork) smallLayer))
    .height(400).width(600).render(Format.PNG).toImage();
 });
} catch (Throwable e) {
  @Nonnull DAGNetwork network = (DAGNetwork) explode;
  log.eval(() -> {
   @Nonnull Graphviz graphviz = Graphviz.fromGraph(TestUtil.toGraph(network)).height(400).width(600);
   @Nonnull File file = new File(log.getResourceDir(), log.getName() + "_network.svg");
   graphviz.render(Format.SVG_STANDALONE).toFile(file);
   log.link(file, "Saved to File");
   return graphviz.render(Format.SVG).toString();
  });

代码示例来源:origin: org.apache.oozie/oozie-fluent-job-api

public static void graphToPng(final Graph graph, final String fileName) throws IOException {
  final MutableGraph mg = Parser.read(graphToDot(graph));
  mg.setName(fileName);
  Graphviz.fromGraph(mg)
      .width(PNG_WIDTH)
      .render(Format.PNG)
      .toFile(new File(PARENT_FOLDER_NAME, FilenameUtils.getName(fileName)));
}

代码示例来源:origin: us.fatehi/schemacrawler

Graphviz.useEngine(engines);
Graphviz.fromString(dotSource).render(format).toFile(outputFile.toFile());

相关文章