Login  Register

Re: dragging an big image

Posted by Michael Strupp on Jul 04, 2009; 12:40pm
URL: http://imagej.273.s1.nabble.com/dragging-an-big-image-tp3691912p3691914.html

Hello ImageJ Community

First of all thanks for your help.
I implemented the thread and now the image moves, while the user drags it.
However there are some disadvantages which I could not correct, so far.

The first thing is that, the old image gets re-drawn, while the user drags the image. When there is for example
an empty image with an object on the left side of the image and the user drags this object to the right side,
there will be a stripe over the image, where the user dragged the object.
So the question is to disable ImageJ to re-draw, while dragging.

The second point is, that the image gets not displayed correctly, after the image data of the next image section
is loaded. Not until I start to drag(just for the size of 1 pixel) the image again, the correct image section gets shown.
It looks like the correct image data is loaded, but the image is not shown.

Especially the second problem is difficult to explain, but I hope someone knows what I mean and can help me.
Maybe the second problem is answerd, when the first problem is solved.

Kind regards,
Michael


-------- Original-Nachricht --------
> Datum: Mon, 22 Jun 2009 18:18:30 +0200
> Von: Michael Schmid <[hidden email]>
> An: [hidden email]
> Betreff: Re: dragging an big image

> Hi Michael,
>
> you need a listener to 'mouse dragged' events and a second background  
> thread that moves the image and loads the missing parts (interface  
> Runnable).
> Here is a rough concept:
>
> public class LargeImageViewer implements MouseListener,  
> MouseMotionListener, Runnable {
>    //Class vars
>    x0, y0;         //position of mouse down
>    deltaX, deltaY; //how much the image has been dragged
>    Thread backgroundThread;
>
>    in constructor (or setup if plugin):
>      get foreground image, get canvas thereof
>      canvas.addMouseListener(this);
>      canvas.addMouseMotionListener(this);
>
>    destructor, mouseReleased, close or whereever:
>      canvas.removeMouseListener(this);
>      canvas.removeMouseMotionListener(this);
>
>    public void MouseDragged(MouseEvent e) {
>      deltaX = e.getX()-x0;
>      deltaY = e.getY()-y0;
>      synchronized(this) {notify();}
>    }
>
>    public void mousePressed ...
>      record x0, y0
>      backgroundThread = new Thread(this, "ImageDragger");
>      backgroundThread.start();
>
>
>    public void mouseReleased ...
>      backgroundThread.interrupt();
>
>    public void run() {
>      while (true) {  //i.e., while mouse down
>        update display(deltaX, deltaY);
>        synchronized(this) {
>          try {wait();}
>          catch(InterruptedException) {return;}
>        }
>      }
>    }
>
> Michael
> ________________________________________________________________
>
> On 22 Jun 2009, at 16:49, Michael Strupp wrote:
>
> > Hello ImageJ community
> >
> > I'm writing a plugin for imagej, to view some images that are much  
> > larger than the windowsize and the RAM. The plugin only loads the  
> > parts of the image which are currently displayed in the viewer. I  
> > overwrote the drag tool from imagej  to navigate, so I can see all  
> > parts of the image, which get loaded after the user navigated.
> > This all works fine so far, but now I want to improve the usability  
> > of the plugin. The problem is, that the image does not move while  
> > the user drags the image, instead it waits some seconds and then  
> > the new image part gets shown.
> >
> > I hope some people here have experience  with such a problem.
> >
> > Kind regards,
> > Michael

--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01