If you check panning in the forum you will get some hits.
How to pan an image
Need Help: Zoomable interface for a procedural drawing program
The post of interest for your topic:
https://forum.processing.org/two/discussion/20813/zooming-and-panning-headache#latest Scale Translate AB comparission - Processing 2.x and 3.x Forum
Kf