scrollable zoom

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

scrollable zoom

Leon Espinosa
Hello I have modified the plugin scrollable-stackwindow (by Johannes  
Schindlin) to have a mouse wheel control of the current image/stack...

//---------------------------------------------

import ij.IJ;
import ij.ImagePlus;
import ij.gui.ImageCanvas;
import ij.gui.StackWindow;
import ij.plugin.PlugIn;
import ij.plugin.*;

import java.awt.event.MouseWheelListener;
import java.awt.event.MouseWheelEvent;

public class Scrollable_Zoom implements PlugIn {
        public void run(String arg) {
                ImagePlus image = IJ.getImage();
                image.setWindow(new Window(image, image.getCanvas()));
        }

        static class Window extends StackWindow implements MouseWheelListener {
                public Window(ImagePlus image, ImageCanvas canvas) {
                        super(image, canvas);
                        addMouseWheelListener(this);
                }

                public void mouseWheelMoved(MouseWheelEvent event) {
                        synchronized(this) {
                                int zoom = event.getWheelRotation();
                                if (zoom<0) IJ.run("In");
                                else IJ.run("Out");
                        }
                }
        }
}

//---------------------------------------------------------


Save it as Scrollable_Zoom.java and use "compile and run..." command.

Leon



Leon Espinosa
[hidden email]

Laboratoire des Rickettsies du Pr. RAOULT
UMR CNRS 6020
Fac. de Medecine de la Timone
27 Bd Jean Moulin
13005 Marseille

tel  04 91 38 55 17
fax 04 91 38 77 72

portable  06 79 25 97 40