From b768fe3f95b1c0bb089fc38a99c32ed483c996b0 Mon Sep 17 00:00:00 2001 From: Vedran Kasalica Date: Wed, 22 Nov 2023 19:15:45 +0100 Subject: [PATCH] Improve figure styling --- pom.xml | 2 +- .../solutionStructure/SolutionWorkflow.java | 12 +++++---- .../solver/solutionStructure/TypeNode.java | 27 +++++++++++++++---- .../graphviz/SolutionGraph.java | 2 +- .../graphviz/SolutionGraphFactory.java | 12 ++++----- 5 files changed, 37 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index 82caf2d..e354414 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 io.github.sanctuuary APE - 2.2.4 + 2.2.6 jar io.github.sanctuuary:APE APE is a command line tool and an API for the automated exploration of possible computational pipelines (workflows) from large collections of computational tools. diff --git a/src/main/java/nl/uu/cs/ape/solver/solutionStructure/SolutionWorkflow.java b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/SolutionWorkflow.java index cd5a636..b60209a 100644 --- a/src/main/java/nl/uu/cs/ape/solver/solutionStructure/SolutionWorkflow.java +++ b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/SolutionWorkflow.java @@ -35,7 +35,7 @@ public class SolutionWorkflow { @Getter - private static final String fileNamePrefix = "workflowSolution_"; + private static final String fileNamePrefix = "candidate_solution_"; /** * List of module nodes ordered according to their position in the workflow. @@ -308,13 +308,14 @@ public SolutionGraph getTavernaStyleGraph(String title) { * @return The file name of the solution file (without the file extension). */ public String getFileName() { - return String.format("%s%o", getFileNamePrefix(), getIndex()); + return String.format("%s%o", getFileNamePrefix(), getIndex() + 1); } public String getDescriptiveName() { StringBuilder descrName = new StringBuilder(); - this.moduleNodes.forEach(moduleNode -> descrName.append(moduleNode.toString()).append("->")); - descrName.delete(descrName.length() - 2, descrName.length()); + this.moduleNodes + .forEach(moduleNode -> descrName.append(moduleNode.getUsedModule().getPredicateLabel()).append("->")); + descrName.delete(descrName.length() - 1, descrName.length()); return descrName.toString(); } @@ -322,7 +323,8 @@ public String getDescription() { StringBuilder descrName = new StringBuilder(); int stepNo = 1; for (ModuleNode moduleNode : this.moduleNodes) { - descrName.append("Step ").append(stepNo++).append(": ").append(moduleNode.getUsedModule().getPredicateID()) + descrName.append("Step ").append(stepNo++).append(": ") + .append(moduleNode.getUsedModule().getPredicateLabel()) .append("\n"); } descrName.delete(descrName.length() - 2, descrName.length()); diff --git a/src/main/java/nl/uu/cs/ape/solver/solutionStructure/TypeNode.java b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/TypeNode.java index cb00d9b..944c34c 100644 --- a/src/main/java/nl/uu/cs/ape/solver/solutionStructure/TypeNode.java +++ b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/TypeNode.java @@ -219,7 +219,7 @@ public Graph addTypeToGraph(Graph workflowGraph) { public Graph addTavernaStyleTypeToGraph(Graph workflowGraph) { return workflowGraph .with(node(getNodeID()).with(Style.FILLED, Color.rgb("6CF1FF").fill(), - Label.lines(Justification.MIDDLE, getNodeGraphLabels()), Shape.RECTANGLE)); + Label.html(getNodeGraphLabels()), Shape.RECTANGLE)); } /** @@ -245,8 +245,8 @@ public String getNodeLabel() { /** * Get label of the current workflow node as an HTML element. */ - public String[] getNodeGraphLabels() { - String[] labels = new String[this.usedTypes.size()]; + public String getNodeGraphLabels() { + StringBuilder labelBuilder = new StringBuilder(); int i = 0; for (Type type : this.usedTypes) { String typeLabel = type.getPredicateLabel(); @@ -254,9 +254,26 @@ public String[] getNodeGraphLabels() { // remove "_plain" suffix typeLabel = APEUtils.removeNLastChar(typeLabel, 2); } - labels[i++] = typeLabel; + String formatting = "%s"; + + switch (i++ % 4) { + case 1: + formatting = "%s"; + break; + case 2: + formatting = "%s"; + break; + case 3: + formatting = "%s"; + break; + default: + formatting = "%s"; + + } + labelBuilder.append(String.format(formatting, typeLabel)).append("
"); } - return labels; + labelBuilder.delete(labelBuilder.length() - 5, labelBuilder.length()); + return labelBuilder.toString(); } /** diff --git a/src/main/java/nl/uu/cs/ape/solver/solutionStructure/graphviz/SolutionGraph.java b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/graphviz/SolutionGraph.java index 40c20b1..6d22661 100644 --- a/src/main/java/nl/uu/cs/ape/solver/solutionStructure/graphviz/SolutionGraph.java +++ b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/graphviz/SolutionGraph.java @@ -40,7 +40,7 @@ public SolutionGraph(Graph graph) { * @return The {@link Renderer} object. */ public Renderer getRenderer(Format format) { - return Graphviz.fromGraph(graph).render(format); + return Graphviz.fromGraph(graph).scale(2).render(format); } /** diff --git a/src/main/java/nl/uu/cs/ape/solver/solutionStructure/graphviz/SolutionGraphFactory.java b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/graphviz/SolutionGraphFactory.java index 9dc07fe..4dbc478 100644 --- a/src/main/java/nl/uu/cs/ape/solver/solutionStructure/graphviz/SolutionGraphFactory.java +++ b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/graphviz/SolutionGraphFactory.java @@ -135,9 +135,9 @@ public static SolutionGraph generateTavernaDesignGraph(SolutionWorkflow workflow Attributes helveticaFont = Font.name("Arial"); Graph workflowGraph = graph(title).directed().graphAttr() .with(Rank.dir(RankDir.TOP_TO_BOTTOM)) - .graphAttr().with(helveticaFont) - .nodeAttr().with(helveticaFont) - .linkAttr().with(helveticaFont); + .graphAttr().with(helveticaFont, Font.size(14)) + .nodeAttr().with(helveticaFont, Font.size(16)) + .linkAttr().with(helveticaFont, Font.size(14)); List workflowInputs = workflow.getWorkflowInputTypeStates(); List workflowOutputs = workflow.getWorkflowOutputTypeStates(); List moduleNodes = workflow.getModuleNodes(); @@ -170,13 +170,13 @@ public static SolutionGraph generateTavernaDesignGraph(SolutionWorkflow workflow if (toolInput.getCreatedByModule() == null) { workflowGraph = workflowGraph .with(node(toolInput.getNodeID()).link(to(node(currTool.getNodeID())) - .with(Label.lines(toolInput.getNodeGraphLabels()), Color.BLACK, + .with(Label.html(toolInput.getNodeGraphLabels()), Color.BLACK, LinkAttr.weight(index++)))); } else { workflowGraph = workflowGraph .with(node(toolInput.getCreatedByModule().getNodeID()) .link(to(node(currTool.getNodeID())) - .with(Label.lines(toolInput.getNodeGraphLabels()), Color.BLACK, + .with(Label.html(toolInput.getNodeGraphLabels()), Color.BLACK, LinkAttr.weight(index++)))); } } @@ -196,7 +196,7 @@ public static SolutionGraph generateTavernaDesignGraph(SolutionWorkflow workflow workflowGraph = workflowOutput.addTavernaStyleTypeToGraph(workflowGraph); workflowGraph = workflowGraph.with(node(workflowOutput.getCreatedByModule().getNodeID()) .link(to(node(workflowOutput.getNodeID())) - .with(Label.lines(workflowOutput.getNodeGraphLabels()), Color.BLACK, + .with(Label.html(workflowOutput.getNodeGraphLabels()), Color.BLACK, LinkAttr.weight(index++)))); } workflowGraph = workflowGraph.with(graph("outputs_frame").cluster()