Search in sources :

Example 1 with Graph

use of de.strullerbaumann.visualee.ui.graph.entity.Graph in project visualee by Thomas-S-B.

the class GraphCreator method generateGraph.

public static Graph generateGraph(String fileName, String title, DependencyFilter filter, File outputdirectory) {
    id = 0;
    Graph graph = new Graph();
    graph.setName(fileName);
    File jsonFile = new File(outputdirectory.toString() + File.separatorChar + fileName + ".json");
    graph.setJsonFile(jsonFile);
    File htmlFile = new File(outputdirectory.toString() + File.separatorChar + fileName + ".html");
    graph.setHtmlFile(htmlFile);
    graph.setTitle(title);
    GraphConfigurator.configGraph(graph);
    JsonObjectBuilder builder = Json.createObjectBuilder();
    // Nodes
    JsonArrayBuilder nodesArray = buildJSONNodes(filter);
    builder.add("nodes", nodesArray);
    // Links
    JsonArrayBuilder linksArray = buildJSONLinks(filter);
    builder.add("links", linksArray);
    JsonObject json = builder.build();
    try (PrintStream ps = new PrintStream(graph.getJsonFile())) {
        ps.println(json.toString());
    } catch (FileNotFoundException ex) {
        LogProvider.getInstance().error("Didn't found file " + graph.getJsonFile().getName(), ex);
    }
    return graph;
}
Also used : PrintStream(java.io.PrintStream) Graph(de.strullerbaumann.visualee.ui.graph.entity.Graph) FileNotFoundException(java.io.FileNotFoundException) JsonObject(javax.json.JsonObject) JsonArrayBuilder(javax.json.JsonArrayBuilder) JsonObjectBuilder(javax.json.JsonObjectBuilder) File(java.io.File)

Example 2 with Graph

use of de.strullerbaumann.visualee.ui.graph.entity.Graph in project visualee by Thomas-S-B.

the class GraphCreator method generateGraphs.

public static void generateGraphs(File rootFolder, File outputdirectory, String graphTemplatePath) {
    if (!outputdirectory.exists()) {
        outputdirectory.mkdir();
    }
    // Load graph-Template, if not already done (Maven modules)
    if (graphTemplate == null) {
        graphTemplate = HTMLManager.loadHTMLTemplate(graphTemplatePath);
    }
    for (String graphName : GRAPHS.keySet()) {
        Graph graph = GraphCreator.generateGraph(graphName, (String) GRAPHS.get(graphName).get(0) + rootFolder.getPath(), (DependencyFilter) GRAPHS.get(graphName).get(1), outputdirectory);
        HTMLManager.generateHTML(graph, graphTemplate);
    }
}
Also used : Graph(de.strullerbaumann.visualee.ui.graph.entity.Graph)

Aggregations

Graph (de.strullerbaumann.visualee.ui.graph.entity.Graph)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 PrintStream (java.io.PrintStream)1 JsonArrayBuilder (javax.json.JsonArrayBuilder)1 JsonObject (javax.json.JsonObject)1 JsonObjectBuilder (javax.json.JsonObjectBuilder)1