Login  Register

Re: dragging an big image

Posted by Michael Schmid on Jun 23, 2009; 5:19pm
URL: http://imagej.273.s1.nabble.com/dragging-an-big-image-tp3691912p3691917.html

Hi Michael,

dragging is handled in ImageCanvas.mouseDragged.
If you don't override ImageCanvas, you can use the
   public void setSourceRect(Rectangle r)
method of ImageCanvas.

Michael
________________________________________________________________

On 23 Jun 2009, at 19:01, Michael Strupp wrote:

> Hello mailing list readers.
>
> Thank you for your help respectively interest. I implemented the  
> thread, which watches if the user is dragging the image, but I  
> cannot find the right command in imagej to move the image.
>
> I added the functionality explained in my first mail and now I need  
> the basic functionality, that the scrolling tool(hand) normally has  
> in imagej. Is there a way to call this functionality explicitly?
>
> @Prodanov Dimiter: I have to ask my employer, if I can give you the  
> source files. I will write you soon...
>
> 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