Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve figure styling #100

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.sanctuuary</groupId>
<artifactId>APE</artifactId>
<version>2.2.4</version>
<version>2.2.6</version>
<packaging>jar</packaging>
<name>io.github.sanctuuary:APE</name>
<description>APE is a command line tool and an API for the automated exploration of possible computational pipelines (workflows) from large collections of computational tools.</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -308,21 +308,23 @@ 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();
}

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());
Expand Down
27 changes: 22 additions & 5 deletions src/main/java/nl/uu/cs/ape/solver/solutionStructure/TypeNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand All @@ -245,18 +245,35 @@ 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();
if (typeLabel.endsWith("_p")) {
// remove "_plain" suffix
typeLabel = APEUtils.removeNLastChar(typeLabel, 2);
}
labels[i++] = typeLabel;
String formatting = "%s";

switch (i++ % 4) {
case 1:
formatting = "<b><i>%s</i></b>";
break;
case 2:
formatting = "<i>%s</i>";
break;
case 3:
formatting = "<b>%s</b>";
break;
default:
formatting = "%s";

}
labelBuilder.append(String.format(formatting, typeLabel)).append("<br/>");
}
return labels;
labelBuilder.delete(labelBuilder.length() - 5, labelBuilder.length());
return labelBuilder.toString();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ public static SolutionGraph generateTavernaDesignGraph(SolutionWorkflow workflow
Attributes<ForAll> 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<TypeNode> workflowInputs = workflow.getWorkflowInputTypeStates();
List<TypeNode> workflowOutputs = workflow.getWorkflowOutputTypeStates();
List<ModuleNode> moduleNodes = workflow.getModuleNodes();
Expand Down Expand Up @@ -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++))));
}
}
Expand All @@ -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()
Expand Down
Loading