I would like to modify the cursor, under Java plugin control.
I have a particular plugin which allows the user to select particles. We would like to modify the cursor so that it is a circle with a known size (in real world coordinates). The plugin puts ImageJ into multi-point mode and allows the user to pick particles. What we really want to do is to provide a quick and dirty size gauge so that the user can judge if this particle is BIG, or SMALL. Is this possible? If that can be done, the next level of ambition is to be able to modify the size of the circle under user control (perhaps some key presses). In all cases, we would like the size of the circle-cursor to be in world coordinates, not pixels. We currently drop markers on an overlay, keeping track of the size as the window’s magnification factor changes. I’d like to do the same thing for the cursor. All I can find is the ability to choose between an arrow and a crosshair-cursor.gif. -- Kenneth Sloan [hidden email] <mailto:[hidden email]> Vision is the art of seeing what is invisible to others. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
On 2016-05-13 07:13, Kenneth Sloan wrote:
> I would like to modify the cursor, under Java plugin control ... Hi Kenneth, yes, you can have a custom cursor with Java AWT: BufferedImage image = ... from wherever you take it (PNG, GIF, array) Point hotSpot = new Point(x_coordinate, y_coordinate); Cursor cursor = toolkit.createCustomCursor(image, hotSpot, "name of cursor"); Michael -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Kenneth Sloan-2
Dear Kenneth,
here is my suggestion as a macro using overlays and hiding the cursor. The space key exits the painting of a ellipse which you can resize with the Shift (+) and Alt key (-). Of course this is a rough draft but maybee fits your needs. A custom cursor could also be set: isDown=false; width=50; height=50; eval("script","ImageCanvas.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB), new Point(0, 0), \"blank cursor\"),1)"); while(isDown==false) { isDown=isKeyDown("space"); if(isKeyDown("shift")){ width++; height++; } if(isKeyDown("alt")){ if(width>1&&height>1){ width--; height--; } } getCursorLoc(x, y, z, flags); Overlay.drawEllipse(x-(width/2), y-(height/2), width, height); Overlay.show; wait(30); Overlay.remove; } eval("script","ImageCanvas.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR),1)"); For scaled coordinates, see: http://rsb.info.nih.gov/ij/developer/macro/functions.html#toScaled Best, Marcel |
Thank you. I’ll probably do something like this with the overlay (in full Java - it will be embedded in an existing application). It looks like I don’t really want to modify the cursor - what I want to do instead is to produce the “sizing tool” on command. Perhaps a keypress to display a fixed-size (in scaled dimensions) circle. I think the user really only needs one “reference” size. I’m guessing (without implementing it, yet, that it would be overkill to re-draw the circle every time the cursor moves - but a singe keypress that displays the sizing gauge might just do it. I’ll test. If re-drawing on cursor move is acceptable, I might do that - but that might raise other issues.
Strange…almost 40 years ago I had this working on an AppleIIc with graphics overlaid on a video feed (they said it was impossible, but we managed it). It seemed easier, then… Ah…I remember - there was a “make it bigger” button and a “make it smaller” button (one pill makes you big, the other makes you small - it was the 70s). Perhaps a slider. Which leads to…I’m using 1 slider to control an integer. Is there an easy method of using a slider to control a real number? One “frill” I’ve been asked for is a slider to set gamma. I couldn’t come up with anything easier that using the standard ImageJ menus. But, now, I might want a slider to control diameter. I suppose I could make the units nanometers. That works. But, as long as I’ve already asked: is there a “double” slider as easy to use as the “int” slider? -- Kenneth Sloan [hidden email] Vision is the art of seeing what is invisible to others. > On May 13, 2016, at 04:51 , Bio7 <[hidden email]> wrote: > > Dear Kenneth, > > here is my suggestion as a macro using overlays and hiding the cursor. The > space key exits the painting of a ellipse which you can resize with the > Shift (+) and Alt key (-). Of course this is a rough draft but maybee fits > your needs. A custom cursor could also be set: > > isDown=false; > width=50; > height=50; > eval("script","ImageCanvas.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(new > BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB), new Point(0, 0), \"blank > cursor\"),1)"); > while(isDown==false) { > isDown=isKeyDown("space"); > if(isKeyDown("shift")){ > width++; > height++; > } > if(isKeyDown("alt")){ > if(width>1&&height>1){ > width--; > height--; > } > } > getCursorLoc(x, y, z, flags); > Overlay.drawEllipse(x-(width/2), y-(height/2), width, height); > Overlay.show; > wait(30); > Overlay.remove; > } > eval("script","ImageCanvas.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR),1)"); > > For scaled coordinates, see: > > http://rsb.info.nih.gov/ij/developer/macro/functions.html#toScaled > > Best, > > Marcel > > > > > > > -- > View this message in context: http://imagej.1557.x6.nabble.com/custom-cursor-tp5016417p5016421.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |