use of au.gov.asd.tac.constellation.utilities.gui.TextIoProgress in project constellation by constellation-app.
the class InfoMapMainNGTest method testMain.
/**
* Test of InfoMapMain.
*
* @throws java.lang.Exception
*/
@Test
public void testMain() throws Exception {
final String fnam = "ninetriangles" + GraphDataObject.FILE_EXTENSION;
// A test graph.
Graph graph;
try (InputStream inStream = InfoMapMainNGTest.class.getResourceAsStream(fnam)) {
graph = new GraphJsonReader().readGraphZip(fnam, inStream, new TextIoProgress(true));
}
final Config conf = new Config();
conf.setNoFileOutput(false);
conf.setVerbosity(1);
conf.setNetworkFile(fnam);
conf.setOutDirectory(System.getProperty("java.io.tmpdir"));
conf.setPrintClu(true);
conf.setPrintNodeRanks(true);
conf.setPrintFlowNetwork(true);
conf.setVerbosity(1);
conf.setNumTrials(5);
System.out.printf("fastHierarchicalSolution %d\n", conf.getFastHierarchicalSolution());
System.out.printf("Parsing %s network from file '%s'... ", conf.isUndirected() ? "undirected" : "directed", conf.getNetworkFile());
conf.setConnectionType(Config.ConnectionType.TRANSACTIONS);
final ReadableGraph rg = graph.getReadableGraph();
try {
System.out.printf("vertices=%d, Transactions=%d edges=%d links=%d\n", rg.getVertexCount(), rg.getTransactionCount(), rg.getEdgeCount(), rg.getLinkCount());
runInfoMap(conf, rg);
} finally {
rg.release();
}
}
use of au.gov.asd.tac.constellation.utilities.gui.TextIoProgress in project constellation by constellation-app.
the class GraphSavingNGTest method writeReadGraphTest.
@Test
public void writeReadGraphTest() throws Exception {
final String name = "tmp1";
File graphFile = File.createTempFile(name, ".star");
ReadableGraph rg = graph.getReadableGraph();
try {
assertEquals("num nodes", 7, rg.getVertexCount());
assertEquals("num transactions", 5, rg.getTransactionCount());
assertTrue("nd 'name1' found", nodeFound(rg, "name1"));
assertTrue("nd 'name2' found", nodeFound(rg, "name2"));
assertTrue("nd 'name3' found", nodeFound(rg, "name3"));
assertTrue("nd 'name4' found", nodeFound(rg, "name4"));
assertTrue("nd 'name5' found", nodeFound(rg, "name5"));
assertTrue("nd 'name6' found", nodeFound(rg, "name6"));
assertTrue("nd 'name7' found", nodeFound(rg, "name7"));
assertTrue("tx 'name101' found", transactionFound(rg, "name101"));
assertTrue("tx 'name102' found", transactionFound(rg, "name102"));
assertTrue("tx 'name103' found", transactionFound(rg, "name103"));
assertTrue("tx 'name104' found", transactionFound(rg, "name104"));
assertTrue("tx 'name105' found", transactionFound(rg, "name105"));
} finally {
rg.release();
}
rg = graph.getReadableGraph();
try {
GraphJsonWriter writer = new GraphJsonWriter();
writer.writeGraphToZip(rg, graphFile.getPath(), new TextIoProgress(false));
} finally {
rg.release();
}
assertTrue("file created", graphFile.exists());
String path = graphFile.getPath();
path = path.substring(0, path.length() - 5);
final Graph newGraph = new GraphJsonReader().readGraphZip(graphFile, new TextIoProgress(false));
graphFile.delete();
rg = newGraph.getReadableGraph();
try {
assertEquals("num nodes", 7, rg.getVertexCount());
assertEquals("num transactions", 5, rg.getTransactionCount());
assertTrue("nd 'name1' found", nodeFound(rg, "name1"));
assertTrue("nd 'name2' found", nodeFound(rg, "name2"));
assertTrue("nd 'name3' found", nodeFound(rg, "name3"));
assertTrue("nd 'name4' found", nodeFound(rg, "name4"));
assertTrue("nd 'name5' found", nodeFound(rg, "name5"));
assertTrue("nd 'name6' found", nodeFound(rg, "name6"));
assertTrue("nd 'name7' found", nodeFound(rg, "name7"));
assertTrue("tx 'name101' found", transactionFound(rg, "name101"));
assertTrue("tx 'name102' found", transactionFound(rg, "name102"));
assertTrue("tx 'name103' found", transactionFound(rg, "name103"));
assertTrue("tx 'name104' found", transactionFound(rg, "name104"));
assertTrue("tx 'name105' found", transactionFound(rg, "name105"));
} finally {
rg.release();
}
}
use of au.gov.asd.tac.constellation.utilities.gui.TextIoProgress in project constellation by constellation-app.
the class SaveGraphUtilities method saveGraphToTemporaryDirectory.
/**
* Save the graph to the temporary directory for debugging.
* <p>
* The main use case of this method is debugging unit tests and so this
* method does extra checks to make sure one can interact with the graph
* build from a crude unit test.
*
* @param graph The graph
* @param filename The filename excluding the file extension
* @param makeInteractable If true, will modify the graph and add attributes
* to make sure the graph can be opened
* @throws IOException
* @throws InterruptedException
*/
public static void saveGraphToTemporaryDirectory(final Graph graph, final String filename, boolean makeInteractable) throws IOException, InterruptedException {
final File saveCreatedGraph = File.createTempFile(filename, FileExtensionConstants.STAR);
final WritableGraph wg = graph.getWritableGraph("make graph interactable", true);
try {
if (makeInteractable) {
makeGraphInteractable(wg);
}
} finally {
wg.commit();
}
final ReadableGraph rg = graph.getReadableGraph();
try {
final GraphJsonWriter writer = new GraphJsonWriter();
writer.writeGraphToZip(rg, saveCreatedGraph.getPath(), new TextIoProgress(false));
} finally {
rg.release();
}
}
use of au.gov.asd.tac.constellation.utilities.gui.TextIoProgress in project constellation by constellation-app.
the class SaveGraphUtilities method saveGraphToTemporaryDirectory.
/**
* Save the graph to the temporary directory for debugging.
* <p>
* The main use case of this method is debugging unit tests and so this
* method does extra checks to make sure one can interact with the graph
* build from a crude unit test.
*
* @param graph The graph
* @param file The graph file
* @param makeInteractable If true, will modify the graph and add attributes
* to make sure the graph can be opened
* @throws IOException
* @throws InterruptedException
*/
public static void saveGraphToTemporaryDirectory(final Graph graph, final File file, boolean makeInteractable) throws IOException, InterruptedException {
final WritableGraph wg = graph.getWritableGraph("make graph interactable", true);
try {
if (makeInteractable) {
makeGraphInteractable(wg);
}
} finally {
wg.commit();
}
final ReadableGraph rg = graph.getReadableGraph();
try {
final GraphJsonWriter writer = new GraphJsonWriter();
writer.writeGraphToZip(rg, file.getPath(), new TextIoProgress(false));
} finally {
rg.release();
}
}
Aggregations