Add saveVisualization to ClusteringResult, ClusteringResultList Used in MiddlewareTagGenI

parent 1af7f61e
Pipeline #104168 failed with stages
in 20 minutes and 6 seconds
...@@ -3,7 +3,9 @@ package de.monticore.lang.monticar.generator.middleware.clustering; ...@@ -3,7 +3,9 @@ package de.monticore.lang.monticar.generator.middleware.clustering;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.FileContent; import de.monticore.lang.monticar.generator.FileContent;
import de.monticore.lang.monticar.generator.middleware.cli.algorithms.AlgorithmCliParameters; import de.monticore.lang.monticar.generator.middleware.cli.algorithms.AlgorithmCliParameters;
import de.monticore.lang.monticar.generator.middleware.clustering.visualization.ModelVisualizer;
import de.monticore.lang.monticar.generator.middleware.impls.MiddlewareTagGenImpl; import de.monticore.lang.monticar.generator.middleware.impls.MiddlewareTagGenImpl;
import org.graphstream.graph.Graph;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
...@@ -64,4 +66,12 @@ public class ClusteringResult { ...@@ -64,4 +66,12 @@ public class ClusteringResult {
res.setFileContent(prefix + content); res.setFileContent(prefix + content);
return res; return res;
} }
//TODO: refactor to File?
public void saveVisualization(String path, String fileName){
Graph g = ModelVisualizer.buildGraph(component, parameters.toString());
ModelVisualizer.visualizeClustering(g, clustering, component);
ModelVisualizer.saveGraphAsImage(g, path, fileName);
}
} }
\ No newline at end of file
...@@ -42,4 +42,13 @@ public class ClusteringResultList extends ArrayList<ClusteringResult> { ...@@ -42,4 +42,13 @@ public class ClusteringResultList extends ArrayList<ClusteringResult> {
} }
return res; return res;
} }
//TODO: refactor to List<File>?
public void saveAllVisualizations(String path, String baseName){
int i = 1;
for (ClusteringResult r : this){
r.saveVisualization(path, baseName + "_" + i + "_" + r.getParameters().getName());
i++;
}
}
} }
...@@ -40,6 +40,7 @@ public class MiddlewareTagGenImpl implements GeneratorImpl { ...@@ -40,6 +40,7 @@ public class MiddlewareTagGenImpl implements GeneratorImpl {
res.add(FileHelper.generateFile(generationTargetPath , fc)); res.add(FileHelper.generateFile(generationTargetPath , fc));
} }
clusteringResults.saveAllVisualizations(generationTargetPath, "img_");
return res; return res;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment