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 |
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 |
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 |
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 |
In reply to this post by Michael Schmid
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 |
On Saturday 04 July 2009, Michael Strupp wrote:
> First of all thanks for your help. > 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. Maybe a starting point would be to post the code so far and provide a sample image to try it. Cheers G. |
Free forum by Nabble | Edit this page |