mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-06-02 00:41:42 +00:00
92 lines
2.1 KiB
Java
92 lines
2.1 KiB
Java
package dk.camelot64.kickc.passes.reports;
|
|
|
|
import dk.camelot64.kickc.model.Program;
|
|
|
|
/**
|
|
* Create the flow components for mermaid report generation.
|
|
* Flows are interconnecting mermaid nodes or sub graphs.
|
|
*/
|
|
public class MermaidFlow extends Mermaid{
|
|
|
|
public enum Type {
|
|
FULL, DOTTED, LINED
|
|
}
|
|
|
|
public enum Direction {
|
|
UNI, BI
|
|
}
|
|
|
|
private MermaidNode from, to;
|
|
|
|
private Type type;
|
|
|
|
private Direction direction;
|
|
|
|
MermaidFlow(MermaidNode from, MermaidNode to, String title, Type type, Direction direction) {
|
|
super(from + "_" + to, title);
|
|
this.from = from;
|
|
this.to = to;
|
|
this.type = type;
|
|
this.direction = direction;
|
|
}
|
|
|
|
public String getText(Program program) {
|
|
StringBuilder text = new StringBuilder();
|
|
|
|
text.append(from.getId());
|
|
if(direction == Direction.BI) {
|
|
text.append("<");
|
|
}
|
|
switch(type) {
|
|
case FULL -> {
|
|
String title = getTitle();
|
|
if(title != null)
|
|
text.append("--").append(getTitle()).append("-->");
|
|
else
|
|
text.append("-->");
|
|
}
|
|
case DOTTED -> {
|
|
String title = getTitle();
|
|
if(title != null)
|
|
text.append("-.").append(getTitle()).append(".->");
|
|
else
|
|
text.append("-.->");
|
|
}
|
|
}
|
|
text.append(to.getId()).append("\n");
|
|
return text.toString();
|
|
}
|
|
|
|
public MermaidNode getFrom() {
|
|
return from;
|
|
}
|
|
|
|
public void setFrom(MermaidNode from) {
|
|
this.from = from;
|
|
}
|
|
|
|
public MermaidNode getTo() {
|
|
return to;
|
|
}
|
|
|
|
public void setTo(MermaidNode to) {
|
|
this.to = to;
|
|
}
|
|
|
|
public Type getType() {
|
|
return type;
|
|
}
|
|
|
|
public void setType(Type type) {
|
|
this.type = type;
|
|
}
|
|
|
|
public Direction getDirection() {
|
|
return direction;
|
|
}
|
|
|
|
public void setDirection(Direction direction) {
|
|
this.direction = direction;
|
|
}
|
|
}
|