GP-280 fixed issue preventing exporting a graph to DOT format.

This commit is contained in:
ghidravore
2020-11-30 16:30:53 -05:00
parent 1259632113
commit 7758c069b7
2 changed files with 12 additions and 5 deletions

View File

@@ -125,8 +125,15 @@ public abstract class AbstractGraphExporterFactory<V, E> {
return exporter;
}
String getQuotedId(V vertex) {
String id = vertexIdProvider.apply(vertex);
return "\"" + id + "\"";
}
private GraphExporter<V, E> createDotExporter() {
DOTExporter<V, E> exporter = new DOTExporter<>(vertexIdProvider);
// DOT format is picky about its identifiers, so pass in a vertex id supplier
// that wraps the vertex ids in quotes
DOTExporter<V, E> exporter = new DOTExporter<>(this::getQuotedId);
setupExporter(exporter);
return exporter;
}

View File

@@ -276,14 +276,14 @@ public class GraphExporterDialog extends DialogComponentProvider {
GraphExportFormat exporterFormat = getSelectedExporter();
File outputFile = getSelectedOutputFile();
try {
if (outputFile.exists() &&
if (outputFile.exists() &&
OptionDialog.showOptionDialog(getComponent(), "Overwrite Existing File?",
"The file " + outputFile + " already exists.\nDo you want to overwrite it?",
"Overwrite", OptionDialog.QUESTION_MESSAGE) != OptionDialog.OPTION_ONE) {
return false;
}
Writer writer = new FileWriter(outputFile);
}
try (Writer writer = new FileWriter(outputFile)) {
GraphExporter<AttributedVertex, AttributedEdge> exporter =
AttributedGraphExporterFactory.getExporter(exporterFormat);