private void waitForLayoutTransition(
			VisualizationModel<AttributedVertex, AttributedEdge> model) {

		Graph<AttributedVertex, AttributedEdge> graph = model.getGraph();
		if (graph.vertexSet().isEmpty()) {
			// note: the underlying graph API will not notify us of the layout state change if the
			//       graph is empty, so do not wait.
			return;
		}

		// some of the layouts are done on the calling thread and some aren't. If they are on
		// the calling thread, then by now, we already got the "done" callback and the "taskDone"
		// countdown latch has been triggered and won't wait.  If, however, the layout has been
		// diverted to another thread, we want to wait until the layout is completed
		// There are two ways the latch will be triggered, the layout is completed or the user
		// cancels the layout.
		try {
			taskDone.await();
		}
		catch (InterruptedException e) {
			model.getLayoutAlgorithm().cancel();
		}

	}
Task to change the layout of the graph
Ghidra/Features/GraphServices/src/main/java/ghidra/graph/visualization/SetLayoutTask.java