private boolean scaleToFitViewer(VisualizationViewer<V, E> visualizationViewer,
			Rectangle2D graphBounds) {

		Dimension windowSize = visualizationViewer.getSize();
		Rectangle bounds = graphBounds.getBounds();

		Shape viewShape = translateShapeFromLayoutSpaceToViewSpace(bounds, visualizationViewer);
		Rectangle viewBounds = viewShape.getBounds();
		boolean fitsInView =
			viewBounds.width < windowSize.width && viewBounds.height < windowSize.height;
		if (onlyResizeWhenTooBig && fitsInView) {
			return false;
		}

		Double scaleRatio = getScaleRatioToFitInDimension(bounds.getSize(), windowSize);
		if (scaleRatio == null) {
			return true;
		}
		if (scaleRatio > 1.0) {
			scaleRatio = 1.0;
		}

		// add some padding and make it relative to the new scale
		int unscaledPaddingSize = 10;
		addPaddingToRectangle((int) (unscaledPaddingSize / scaleRatio), bounds);
		scaleRatio = getScaleRatioToFitInDimension(bounds.getSize(), windowSize);
		if (scaleRatio == null) {
			return true;
		}

		RenderContext<V, E> renderContext = visualizationViewer.getRenderContext();
		MultiLayerTransformer multiLayerTransformer = renderContext.getMultiLayerTransformer();
		MutableTransformer viewTransformer = multiLayerTransformer.getTransformer(Layer.VIEW);

		viewTransformer.setScale(scaleRatio, scaleRatio, new Point(0, 0));
		return true;
	}
A job to scale one or more viewers such that the contained graph will fit entirely inside the
viewing area.

@param <V> the vertex type
@param <E> the edge type
Ghidra/Framework/Graph/src/main/java/ghidra/graph/job/FitGraphToViewJob.java