41
41
String allGraphs = CpogParsingTool.getExpressionFromGraph(visualCpog);
42
42
ArrayList<String> tempGraphs = new ArrayList<>();
43
43
ArrayList<String> graphs = new ArrayList<>();
44
String prefix = "input", suffix = ".tr";
45
44
inputFile = File.createTempFile("input", ".tr");
47
PrintStream expressions = new PrintStream(inputFile);
49
48
int i = allGraphs.indexOf(" + ");
51
50
allGraphs = allGraphs.substring(0, i) + "\n" + allGraphs.substring(i + 2);
52
51
i = allGraphs.indexOf(" + ");
53
allGraphs = allGraphs + "\n";
54
54
allGraphs = allGraphs.replaceAll(" -> ", " ");
56
while (allGraphs.contains("\n")) {
57
int index = allGraphs.indexOf("\n");
58
String graph = (allGraphs.substring(0, index));
59
allGraphs = allGraphs.substring(index + 1);
60
tempGraphs.add(graph);
56
String[] graphList = allGraphs.split("\n");
63
//tempGraphs.add(allGraphs);
58
for (String g : graphList) tempGraphs.add(g);
65
60
for (String graph : tempGraphs) {
66
61
int index = graph.indexOf("= ");
68
63
graph = graph.substring(index + 2);
70
while (graph.startsWith(" ")) {
71
graph = graph.substring(1);
73
while (graph.endsWith(" ")) {
74
graph = graph.substring(0, graph.length() - 1);
65
JOptionPane.showMessageDialog(null,
66
"Error: A graph which is not a scenario has been selected.\n"
67
+ "Please remove this from the selection, or group this as a page to continue",
69
JOptionPane.ERROR_MESSAGE);
76
PrintStream expressions = new PrintStream(inputFile);
79
78
for (String graph : graphs) {
80
79
expressions.println(graph);
83
82
expressions.close();
86
84
} catch (IOException exception) {
87
85
exception.printStackTrace();
88
86
} catch (ArrayIndexOutOfBoundsException e2) {
89
87
JOptionPane.showMessageDialog(null,
90
"Error: No graphs have been selected",
88
"Error: No scenarios have been selected",
92
90
JOptionPane.ERROR_MESSAGE);