@@ -547,15 +547,25 @@ public static void zoomTo(final ImagePlus imp, final double zoomMagnification, f
547547 public static void zoomTo (final ImagePlus imp , final double zoomMagnification ,
548548 final PointInImage location , final Path path ) {
549549 if (imp == null || location == null ) return ;
550- final Calibration cal = imp .getCalibration ();
551- final PointInCanvas offset = (path != null )
552- ? path .getCanvasOffset ()
553- : new PointInCanvas (0 , 0 , 0 );
554- final int px = (int ) (cal .getRawX (location .x ) + offset .x );
555- final int py = (int ) (cal .getRawY (location .y ) + offset .y );
556- final int pz = (int ) (cal .getRawZ (location .z ) + offset .z );
557- imp .setPosition (imp .getC (), pz + 1 , imp .getT ());
558- zoomTo (imp , zoomMagnification , px , py );
550+ if (location .onPath != null ) {
551+ zoomToPointInCanvas (imp , zoomMagnification , location .getUnscaledPoint ());
552+ } else if (path != null ) {
553+ final PointInImage loc = location .clone ();
554+ loc .onPath = path ;
555+ zoomToPointInCanvas (imp , zoomMagnification , loc .getUnscaledPoint ());
556+ } else {
557+ final Calibration cal = imp .getCalibration ();
558+ final int px = (int ) (cal .getRawX (location .x ));
559+ final int py = (int ) (cal .getRawY (location .y ));
560+ final int pz = (int ) (cal .getRawZ (location .z ));
561+ imp .setPosition (imp .getC (), pz + 1 , imp .getT ());
562+ zoomTo (imp , zoomMagnification , px , py );
563+ }
564+ }
565+
566+ private static void zoomToPointInCanvas (final ImagePlus imp , final double zoomMagnification , final PointInCanvas pic ) {
567+ imp .setPosition (imp .getC (), (int ) pic .z + 1 , imp .getT ());
568+ zoomTo (imp , zoomMagnification , (int ) pic .x , (int ) pic .y );
559569 }
560570
561571 /**
0 commit comments