I have a great deal of manual segmenting/outlining to do, and I've been
trying to find the best way to accomplish this. I've gotten a Wacom Intuos3 8x6 pen tablet which helps. However I'd like for ImageJ to have support for the pen and tablet features. Has anyone done any work on supporting tablets in ImageJ? I've found there's a Java tablet API called JPen that supports Windows and Linux. Chief among the features I'd like is the ability to map all buttons on the tablet and pen to macros, to support different tools for the "pen" and "eraser" part of the stylus, and to perhaps even offer pressure sensitivity when working with brush selections or any of the drawing tools. I'd love to work on this myself, but unfortunately I don't have the time now for this. Regards, -Josh |
I've downloaded the JPen library and have successfully created a plugin that
allows me to create a frame and then capture all pen information and display it in a log file, as well as associate different tools with each cursor, stylus, and eraser. However, this only works in the JFrame that I created, as it needs to implement a PenListener and override some event methods. Is it possible to continue this as a plugin? Somehow I'd need to have all ImageJ windows implement PenListener. Right now I have to move the cursor inside my JFrame to record the change in tools. I feel like I might have to modify the core ImageJ code to accomplish what I'm trying to do. Thanks for any input! -Josh On Fri, Nov 7, 2008 at 9:28 AM, Josh D <[hidden email]> wrote: > I have a great deal of manual segmenting/outlining to do, and I've been > trying to find the best way to accomplish this. > > I've gotten a Wacom Intuos3 8x6 pen tablet which helps. However I'd like > for ImageJ to have support for the pen and tablet features. > > Has anyone done any work on supporting tablets in ImageJ? I've found > there's a Java tablet API called JPen that supports Windows and Linux. > > Chief among the features I'd like is the ability to map all buttons on the > tablet and pen to macros, to support different tools for the "pen" and > "eraser" part of the stylus, and to perhaps even offer pressure sensitivity > when working with brush selections or any of the drawing tools. > > I'd love to work on this myself, but unfortunately I don't have the time > now for this. > Regards, > -Josh > |
Hi,
On Wed, 19 Nov 2008, Josh D wrote: > I've downloaded the JPen library and have successfully created a plugin > that allows me to create a frame and then capture all pen information > and display it in a log file, as well as associate different tools with > each cursor, stylus, and eraser. > > However, this only works in the JFrame that I created, as it needs to > implement a PenListener and override some event methods. > > Is it possible to continue this as a plugin? Somehow I'd need to have > all ImageJ windows implement PenListener. Right now I have to move the > cursor inside my JFrame to record the change in tools. > > I feel like I might have to modify the core ImageJ code to accomplish > what I'm trying to do. I do not think that you'd need any more than to extend ij.gui.ImageWindow or ij.gui.ImageCanvas, implementing that pen listener. You cannot do that in ImageJ itself, as that would introduce a dependency on JPen. The problem would not so much be the LGPL, but that JPen only supports Linux and WindowsXP. In any case, could I have your source code? :-) Ciao, Dscho |
Sure, I've attached the source code, it is quite basic, I just wanted to see
if it would work. To be really useful it would have to have a great deal added to it. One thing, can the selection brush and painting/pen brush size be changed on the fly, i.e. while the tool is being used? This would allow the pressure sensitivity to be used. I personally would find that useful using the selection brush. To run the code you must add the jpen-2.jar to your classpath, which I accomplished by opening the ImageJ.cfg and changing "-cp ij.jar" to "-cp jpen-2.jar;ij.jar". Also, you must have jpen-2.dll in the top ImageJ folder. You'll find both the JAR and the DLL at http://sf.net/projects/jpen/download I hope there's someway this could be implemented as a plugin. Any way for a plugin to capture all of the input? Perhaps Wayne could modify ImageJ so that a plugin could do this, so there doesn't have to be any kind of dependency on JPen, just a sort of hook for a JPen-based plugin to use. -Josh <SOURCE> import ij.*; import ij.process.*; import ij.gui.*; import java.awt.*; import ij.plugin.*; import javax.swing.JFrame; import javax.swing.JLabel; import jpen.event.PenListener; import jpen.PButtonEvent; import jpen.PenManager; import jpen.PenProvider; import jpen.PKindEvent; import jpen.PLevelEvent; import jpen.provider.Utils; import jpen.PScrollEvent; import jpen.PKind; public class Pen_Test implements PlugIn , PenListener { PenManager pm; int[] tools = new int[3]; int currentKind; public void run(String arg) { init(); } public void init() { tools[0]=0; tools[1]=0; tools[2]=0; JLabel l=new JLabel("Move the pen or mouse over me!"); pm=new PenManager(l); pm.pen.addListener(this); // Associate current IJ tool to the currently in use "kind" (CURSOR,STYLUS,ERASER) currentKind = pm.pen.getKind().typeNumber; if(currentKind>=0 && currentKind<=3) tools[currentKind]=Toolbar.getToolId(); JFrame f=new JFrame("JPen Example"); f.getContentPane().add(l); f.setSize(300, 300); f.setVisible(true); } @Override public void penButtonEvent(PButtonEvent ev) { IJ.log("PButtonEvent: "+ev.toString()); } @Override public void penKindEvent(PKindEvent ev) { IJ.log("PKindEvent: "+ev.kind); //Save IJ tool to previous kind if(currentKind>=0 && currentKind<=3) tools[currentKind]=Toolbar.getToolId(); currentKind = pm.pen.getKind().typeNumber; // Load IJ tool to current kind if(currentKind>=0 && currentKind<=3) Toolbar.getInstance().setTool(tools[currentKind]); } @Override public void penLevelEvent(PLevelEvent ev) { IJ.log("PLevelEvent: "+ev.toString()); } @Override public void penScrollEvent(PScrollEvent ev) { IJ.log("PScrollEvent: "+ev.toString()); } @Override public void penTock(long availableMillis) { IJ.log("TOCK - available period fraction: "+availableMillis); } } </SOURCE> On Thu, Nov 20, 2008 at 6:28 AM, Johannes Schindelin < [hidden email]> wrote: > Hi, > > On Wed, 19 Nov 2008, Josh D wrote: > > > I've downloaded the JPen library and have successfully created a plugin > > that allows me to create a frame and then capture all pen information > > and display it in a log file, as well as associate different tools with > > each cursor, stylus, and eraser. > > > > However, this only works in the JFrame that I created, as it needs to > > implement a PenListener and override some event methods. > > > > Is it possible to continue this as a plugin? Somehow I'd need to have > > all ImageJ windows implement PenListener. Right now I have to move the > > cursor inside my JFrame to record the change in tools. > > > > I feel like I might have to modify the core ImageJ code to accomplish > > what I'm trying to do. > > I do not think that you'd need any more than to extend ij.gui.ImageWindow > or ij.gui.ImageCanvas, implementing that pen listener. > > You cannot do that in ImageJ itself, as that would introduce a dependency > on JPen. The problem would not so much be the LGPL, but that JPen only > supports Linux and WindowsXP. > > In any case, could I have your source code? :-) > > Ciao, > Dscho > > |
In reply to this post by dscho
Hi,
[keeping the whole quoted text, because I think the ImageJ list does not accept attachments, and therefore ate your message] On Thu, 20 Nov 2008, Josh D wrote: > Sure, I've attached the source code, it is quite basic, I just wanted to > see if it would work. To be really useful it would have to have a great > deal added to it. > > One thing, can the selection brush and painting/pen brush size be > changed on the fly, i.e. while the tool is being used? This would allow > the pressure sensitivity to be used. I personally would find that useful > using the selection brush. To run the code you must add the jpen-2.jar > to your classpath, which I accomplished by opening the ImageJ.cfg and > changing "-cp ij.jar" to "-cp jpen-2.jar;ij.jar". Also, you must have > jpen-2.dll in the top ImageJ folder. You'll find both the JAR and the > DLL at http://sf.net/projects/jpen/download <shameless-plug> You could also download Fiji, drop the jpen-2.jar in jars/ and just use it; you could even use a scripting language to play around, without the need to compile, and without the need to be very precise with exceptions. </shameless-plug> > I hope there's someway this could be implemented as a plugin. Any way > for a plugin to capture all of the input? Perhaps Wayne could modify > ImageJ so that a plugin could do this, so there doesn't have to be any > kind of dependency on JPen, just a sort of hook for a JPen-based plugin > to use. As I said, I do not think it is necessary to change ImageJ at all, and I strongly believe it is not possible without breaking support for everything except Linux and WindowsXP. But there are ways to make this a plugin, _without_ touching the base of ImageJ. There are basically two ways to go about it: - you keep the existing tools, and just register a PenListener with the plugin, which just induces the necessary events into the currently active ImageWindow. See http://rsb.info.nih.gov/ij/plugins/mouse-listener.html for inspiration, or - you add another tool, which also registers a PenListener, but does its thing only when the appropriate tool is selected. For inspiration with that approach, I recommend studying the original ROIBrush tool: http://pacific.mpi-cbg.de/cgi-bin/gitweb.cgi?p=VIB.git;a=blob;f=ROIBrush_.java;h=4fabf0695c4da6e8dd5c49fa4c27520898678859;hb=95551a4c903453691e20d29c59820e955de10087 You would _not_ need the while-loop in the macro, though, since you get your events from somewhere else. You'd need to do the drawing yourself, though. Unfortunately, I do not have a tablet myself, but I think that having good tablet support is both doable and desirable. So I will try to help you as much as I can. Hth, Dscho |
Hello,
On Thu, Nov 20, 2008 at 9:04 AM, Johannes Schindelin < [hidden email]> wrote: > Hi, > > [keeping the whole quoted text, because I think the ImageJ list does not > accept attachments, and therefore ate your message] > > On Thu, 20 Nov 2008, Josh D wrote: > > > Sure, I've attached the source code, it is quite basic, I just wanted to > > see if it would work. To be really useful it would have to have a great > > deal added to it. > > > > One thing, can the selection brush and painting/pen brush size be > > changed on the fly, i.e. while the tool is being used? This would allow > > the pressure sensitivity to be used. I personally would find that useful > > using the selection brush. To run the code you must add the jpen-2.jar > > to your classpath, which I accomplished by opening the ImageJ.cfg and > > changing "-cp ij.jar" to "-cp jpen-2.jar;ij.jar". Also, you must have > > jpen-2.dll in the top ImageJ folder. You'll find both the JAR and the > > DLL at http://sf.net/projects/jpen/download > > <shameless-plug> > You could also download Fiji, drop the jpen-2.jar in jars/ and > just use it; you could even use a scripting language to play > around, without the need to compile, and without the need to be > very precise with exceptions. > </shameless-plug> I'm not familiar with Fiji, I'll take a look. > > > > I hope there's someway this could be implemented as a plugin. Any way > > for a plugin to capture all of the input? Perhaps Wayne could modify > > ImageJ so that a plugin could do this, so there doesn't have to be any > > kind of dependency on JPen, just a sort of hook for a JPen-based plugin > > to use. > > As I said, I do not think it is necessary to change ImageJ at all, and I > strongly believe it is not possible without breaking support for > everything except Linux and WindowsXP. > > But there are ways to make this a plugin, _without_ touching the base > of ImageJ. There are basically two ways to go about it: > > - you keep the existing tools, and just register a PenListener with the > plugin, which just induces the necessary events into the currently > active ImageWindow. See > > http://rsb.info.nih.gov/ij/plugins/mouse-listener.html > > for inspiration, or I looked at that, but if I'm understanding things correctly it won't work. That example uses the java.awt.Component.addMouseListener() method, but there is no addPenListener() or addGenericListener(). I don't see how it could work. Of course I'm no Java expert, so maybe I'm confusing things. > > > - you add another tool, which also registers a PenListener, but does its > thing only when the appropriate tool is selected. For inspiration with > that approach, I recommend studying the original ROIBrush tool: > > > > http://pacific.mpi-cbg.de/cgi-bin/gitweb.cgi?p=VIB.git;a=blob;f=ROIBrush_.java;h=4fabf0695c4da6e8dd5c49fa4c27520898678859;hb=95551a4c903453691e20d29c59820e955de10087 > > You would _not_ need the while-loop in the macro, though, since you get > your events from somewhere else. You'd need to do the drawing yourself, > though. > > Unfortunately, I do not have a tablet myself, but I think that having > good tablet support is both doable and desirable. So I will try to help > you as much as I can. > > Hth, > Dscho > -Josh |
Josh,
> I looked at that, but if I'm understanding things correctly it won't work. > That example uses the java.awt.Component.addMouseListener() method, but > there is no addPenListener() or addGenericListener(). I don't see how it > could work. Of course I'm no Java expert, so maybe I'm confusing things. Somewhat of a hack: 1 - define a new class ij.gui.ImageCanvas, which extends ImageCanvas and implements PenListener 2 - add that file in .jar in the classpath after ij.jar, so that when the class ImageCanvas is looked for, yours is found first. Now ImageJ will be aware of your pen tablet, without changing the source code. Very simple really. A cleaner alternative: Create a plugin that replaces the ij.gui.ImageCanvas class in ImageJ's classloader and its parent, and so on. This will require a bit of trickery, for example current, open images with an ImageCanvas may need to be closed and reopened. In this way the whole thing can be done from a plugin without touching the user's classpath. Albert -- Albert Cardona http://albert.rierol.net |
In reply to this post by Josh Doe-2
Hi Josh,
you could consider writing a plugin that converts your pen events into mouse events and call the appropriate routines of the MouseListener and MouseMotionListener interfaces of the ImageCanvas of the foreground image. e.g. for move events something like this: ImagePlus imp = getImage(); if (imp==null) return; ImageCanvas ic = imp.getCanvas(); if (ic==null) return; MouseEvent e = new MouseEvent(ic, ....); ic.mouseMoved(e); Concerning the line thickness: The ROI Brush reads it from the toolbar only once, when the left mouse button is pressed. So you can't change it while drawing a line. You would have to write your own tool for this. http://rsb.info.nih.gov/ij/source/ij/gui/RoiBrush.java The paint brush and eraser tools are macros anyhow, situated in the StartupMacros.txt, so you can easily modify them. Your plugin could have a static method that can be called from a macro. You can call this in the loop by the 'call' command of the macro language and set the width accordingly: while (true) { getCursorLoc(x, y, z, flags); penWidth = parseInt(call("myPenPlugin.getPenWidth")); setLineWidth(penWidth); just a few random thoughts... Michael ________________________________________________________________ On 20 Nov 2008, at 15:37, Josh D wrote: > Hello, > > On Thu, Nov 20, 2008 at 9:04 AM, Johannes Schindelin < > [hidden email]> wrote: > >> Hi, >> >> [keeping the whole quoted text, because I think the ImageJ list >> does not >> accept attachments, and therefore ate your message] >> >> On Thu, 20 Nov 2008, Josh D wrote: >> >>> Sure, I've attached the source code, it is quite basic, I just >>> wanted to >>> see if it would work. To be really useful it would have to have a >>> great >>> deal added to it. >>> >>> One thing, can the selection brush and painting/pen brush size be >>> changed on the fly, i.e. while the tool is being used? This would >>> allow >>> the pressure sensitivity to be used. I personally would find that >>> useful >>> using the selection brush. To run the code you must add the >>> jpen-2.jar >>> to your classpath, which I accomplished by opening the ImageJ.cfg >>> and >>> changing "-cp ij.jar" to "-cp jpen-2.jar;ij.jar". Also, you must >>> have >>> jpen-2.dll in the top ImageJ folder. You'll find both the JAR and >>> the >>> DLL at http://sf.net/projects/jpen/download >> >> <shameless-plug> >> You could also download Fiji, drop the jpen-2.jar in jars/ and >> just use it; you could even use a scripting language to play >> around, without the need to compile, and without the need >> to be >> very precise with exceptions. >> </shameless-plug> > > > I'm not familiar with Fiji, I'll take a look. > >> >> >>> I hope there's someway this could be implemented as a plugin. Any >>> way >>> for a plugin to capture all of the input? Perhaps Wayne could modify >>> ImageJ so that a plugin could do this, so there doesn't have to >>> be any >>> kind of dependency on JPen, just a sort of hook for a JPen-based >>> plugin >>> to use. >> >> As I said, I do not think it is necessary to change ImageJ at all, >> and I >> strongly believe it is not possible without breaking support for >> everything except Linux and WindowsXP. >> >> But there are ways to make this a plugin, _without_ touching the base >> of ImageJ. There are basically two ways to go about it: >> >> - you keep the existing tools, and just register a PenListener >> with the >> plugin, which just induces the necessary events into the currently >> active ImageWindow. See >> >> http://rsb.info.nih.gov/ij/plugins/mouse-listener.html >> >> for inspiration, or > > > I looked at that, but if I'm understanding things correctly it > won't work. > That example uses the java.awt.Component.addMouseListener() method, > but > there is no addPenListener() or addGenericListener(). I don't see > how it > could work. Of course I'm no Java expert, so maybe I'm confusing > things. > >> >> >> - you add another tool, which also registers a PenListener, but >> does its >> thing only when the appropriate tool is selected. For >> inspiration with >> that approach, I recommend studying the original ROIBrush tool: >> >> >> >> http://pacific.mpi-cbg.de/cgi-bin/gitweb.cgi? >> p=VIB.git;a=blob;f=ROIBrush_.java;h=4fabf0695c4da6e8dd5c49fa4c2752089 >> 8678859;hb=95551a4c903453691e20d29c59820e955de10087 >> >> You would _not_ need the while-loop in the macro, though, since >> you get >> your events from somewhere else. You'd need to do the drawing >> yourself, >> though. >> >> Unfortunately, I do not have a tablet myself, but I think that having >> good tablet support is both doable and desirable. So I will try >> to help >> you as much as I can. >> >> Hth, >> Dscho >> > Thanks, I appreciate your interest! > -Josh |
In reply to this post by Josh Doe-2
Hi,
On Thu, 20 Nov 2008, Josh D wrote: > On Thu, Nov 20, 2008 at 9:04 AM, Johannes Schindelin < > [hidden email]> wrote: > > > - you keep the existing tools, and just register a PenListener with > > the plugin, which just induces the necessary events into the > > currently active ImageWindow. See > > > > http://rsb.info.nih.gov/ij/plugins/mouse-listener.html > > > > for inspiration, or > > I looked at that, but if I'm understanding things correctly it won't > work. That example uses the java.awt.Component.addMouseListener() > method, but there is no addPenListener() or addGenericListener(). I > don't see how it could work. Of course I'm no Java expert, so maybe I'm > confusing things. AFAICT from your source code, you have to instantiate the PenManager by passing the constructor an instance of a Component. This does not need to be a JFrame, it should be possible to do that with an ij.gui.ImageWindow(), too (which you should get using ij.WindowManager.getCurrentWindow()). As mentioned, though, I cannot test my ideas. Ciao, Dscho |
On Thu, Nov 20, 2008 at 12:38 PM, Johannes Schindelin <
[hidden email]> wrote: > Hi, > > On Thu, 20 Nov 2008, Josh D wrote: > > > On Thu, Nov 20, 2008 at 9:04 AM, Johannes Schindelin < > > [hidden email]> wrote: > > > > > - you keep the existing tools, and just register a PenListener with > > > the plugin, which just induces the necessary events into the > > > currently active ImageWindow. See > > > > > > http://rsb.info.nih.gov/ij/plugins/mouse-listener.html > > > > > > for inspiration, or > > > > I looked at that, but if I'm understanding things correctly it won't > > work. That example uses the java.awt.Component.addMouseListener() > > method, but there is no addPenListener() or addGenericListener(). I > > don't see how it could work. Of course I'm no Java expert, so maybe I'm > > confusing things. > > AFAICT from your source code, you have to instantiate the PenManager by > passing the constructor an instance of a Component. This does not need > to be a JFrame, it should be possible to do that with an > ij.gui.ImageWindow(), too (which you should get using > ij.WindowManager.getCurrentWindow()). > You actually pass to the PenManager any instance of a class that implements PenListener, so I don't think I can pass the current ImageJ window since it definitely does not implement the listener. Thanks! -Josh > > As mentioned, though, I cannot test my ideas. > > Ciao, > Dscho > > |
In reply to this post by Albert Cardona
On Thu, Nov 20, 2008 at 9:45 AM, Albert Cardona
<[hidden email]>wrote: > Josh, > > I looked at that, but if I'm understanding things correctly it won't work. >> That example uses the java.awt.Component.addMouseListener() method, but >> there is no addPenListener() or addGenericListener(). I don't see how it >> could work. Of course I'm no Java expert, so maybe I'm confusing things. >> > > Somewhat of a hack: > > 1 - define a new class ij.gui.ImageCanvas, which extends ImageCanvas and > implements PenListener > 2 - add that file in .jar in the classpath after ij.jar, so that when the > class ImageCanvas is looked for, yours is found first. > > Now ImageJ will be aware of your pen tablet, without changing the source > code. Very simple really. > > A cleaner alternative: > > Create a plugin that replaces the ij.gui.ImageCanvas class in ImageJ's > classloader and its parent, and so on. This will require a bit of trickery, > for example current, open images with an ImageCanvas may need to be closed > and reopened. > In this way the whole thing can be done from a plugin without touching the > user's classpath. > I don't understand how I could replace the ImageCanvas class with one of my own. Perhaps this idea is outside of my Java skills. Also, I would want the pen events to be captured even if the toolbar (or for that matter any ImageJ window) is in focus, otherwise the behaviour would be confusing and frustrating IMHO, at least to implement all the features that I think would be expected. Any developers out there with a tablet that want to mess around with this? Thank you for your ideas! -Josh > > Albert > > -- > Albert Cardona > http://albert.rierol.net > |
In reply to this post by Josh Doe-2
Hi,
On Thu, 20 Nov 2008, Josh D wrote: > On Thu, Nov 20, 2008 at 12:38 PM, Johannes Schindelin < > [hidden email]> wrote: > > > On Thu, 20 Nov 2008, Josh D wrote: > > > > > On Thu, Nov 20, 2008 at 9:04 AM, Johannes Schindelin < > > > [hidden email]> wrote: > > > > > > > - you keep the existing tools, and just register a PenListener > > > > with the plugin, which just induces the necessary events into > > > > the currently active ImageWindow. See > > > > > > > > http://rsb.info.nih.gov/ij/plugins/mouse-listener.html > > > > > > > > for inspiration, or > > > > > > I looked at that, but if I'm understanding things correctly it won't > > > work. That example uses the java.awt.Component.addMouseListener() > > > method, but there is no addPenListener() or addGenericListener(). I > > > don't see how it could work. Of course I'm no Java expert, so maybe > > > I'm confusing things. > > > > AFAICT from your source code, you have to instantiate the PenManager > > by passing the constructor an instance of a Component. This does not > > need to be a JFrame, it should be possible to do that with an > > ij.gui.ImageWindow(), too (which you should get using > > ij.WindowManager.getCurrentWindow()). > > You actually pass to the PenManager any instance of a class that > implements PenListener, so I don't think I can pass the current ImageJ > window since it definitely does not implement the listener. From my copy of the source of PenManager, it seems that the component passed to the constructor does not need to implement a PenManagerListener, but is rather a component whose width and height are needed to determine the desired dimensions. Further, my copy of the source of PenManager does not allow a PenListener to be added via addListener(), but only a PenManagerListener. Instead, you have to instantiate the class jpen.Pen (without the need to pass a parameter to the constructor) and add a PenListener there. The PenListener still can be the PlugIn, as you did it, just that the events have to be handled appropriately (most likely, I think the PLevelEvent, which has to be translated into the coordinates and the pressure, and the appropriate action has to be performed on the current window). Ciao, Dscho |
In reply to this post by Josh Doe-2
Hi,
On Thu, 20 Nov 2008, Josh D wrote: > On Thu, Nov 20, 2008 at 9:45 AM, Albert Cardona > <[hidden email]>wrote: > > I don't understand how I could replace the ImageCanvas class with one of > my own. Perhaps this idea is outside of my Java skills. I do not think that you need to replace or extend the ImageCanvas. Your plugin should be able to do what it wants to do without extending any ImageJ core class, but merely by accessing the available functions. > Also, I would want the pen events to be captured even if the toolbar (or > for that matter any ImageJ window) is in focus, otherwise the behaviour > would be confusing and frustrating IMHO, at least to implement all the > features that I think would be expected. From my understanding of the source code, it appears that you would get the events from the pen device, completely independent of any window. Indeed, as far as I can tell, you can add pen listeners even if there is no graphical desktop at all. Ciao, Dscho |
In reply to this post by dscho
On Thu, Nov 20, 2008 at 1:55 PM, Johannes Schindelin <
[hidden email]> wrote: > Hi, > > On Thu, 20 Nov 2008, Josh D wrote: > > > On Thu, Nov 20, 2008 at 12:38 PM, Johannes Schindelin < > > [hidden email]> wrote: > > > > > On Thu, 20 Nov 2008, Josh D wrote: > > > > > > > On Thu, Nov 20, 2008 at 9:04 AM, Johannes Schindelin < > > > > [hidden email]> wrote: > > > > > > > > > - you keep the existing tools, and just register a PenListener > > > > > with the plugin, which just induces the necessary events into > > > > > the currently active ImageWindow. See > > > > > > > > > > http://rsb.info.nih.gov/ij/plugins/mouse-listener.html > > > > > > > > > > for inspiration, or > > > > > > > > I looked at that, but if I'm understanding things correctly it won't > > > > work. That example uses the java.awt.Component.addMouseListener() > > > > method, but there is no addPenListener() or addGenericListener(). I > > > > don't see how it could work. Of course I'm no Java expert, so maybe > > > > I'm confusing things. > > > > > > AFAICT from your source code, you have to instantiate the PenManager > > > by passing the constructor an instance of a Component. This does not > > > need to be a JFrame, it should be possible to do that with an > > > ij.gui.ImageWindow(), too (which you should get using > > > ij.WindowManager.getCurrentWindow()). > > > > You actually pass to the PenManager any instance of a class that > > implements PenListener, so I don't think I can pass the current ImageJ > > window since it definitely does not implement the listener. > > From my copy of the source of PenManager, it seems that the component > passed to the constructor does not need to implement a PenManagerListener, > but is rather a component whose width and height are needed to determine > the desired dimensions. > > Further, my copy of the source of PenManager does not allow a PenListener > to be added via addListener(), but only a PenManagerListener. > > Instead, you have to instantiate the class jpen.Pen (without the need to > pass a parameter to the constructor) and add a PenListener there. > > The PenListener still can be the PlugIn, as you did it, just that the > events have to be handled appropriately (most likely, I think the > PLevelEvent, which has to be translated into the coordinates and the > pressure, and the appropriate action has to be performed on the current > window). > > Ciao, > Dscho > Okay I understand now. Yes, you can pass any Component to the PenManager constructor. Whenever the cursor is above that component my plugin receives events. Following the mouse_listener code I was able to capture pen events whenever the cursor was on top of the image canvas. I could create new PenManagers for all image windows and the ImageJ frame, but it would be so much nicer if I could just capture all pen events regardless of where the cursor is, so long as an ImageJ window has the focus. Well, I think I see that there is quite a bit to go to make this at all usable. I hope someone else with a tablet picks up on this. I'd gladly be a tester. Thank you all for your help! -Josh |
Hi,
On Thu, 20 Nov 2008, Josh D wrote: > On Thu, Nov 20, 2008 at 1:55 PM, Johannes Schindelin < > [hidden email]> wrote: > > > On Thu, 20 Nov 2008, Josh D wrote: > > > > > On Thu, Nov 20, 2008 at 12:38 PM, Johannes Schindelin < > > > [hidden email]> wrote: > > > > > > > On Thu, 20 Nov 2008, Josh D wrote: > > > > > > > > > On Thu, Nov 20, 2008 at 9:04 AM, Johannes Schindelin < > > > > > [hidden email]> wrote: > > > > > > > > > > > - you keep the existing tools, and just register a PenListener > > > > > > with the plugin, which just induces the necessary events > > > > > > into the currently active ImageWindow. See > > > > > > > > > > > > http://rsb.info.nih.gov/ij/plugins/mouse-listener.html > > > > > > > > > > > > for inspiration, or > > > > > > > > > > I looked at that, but if I'm understanding things correctly it > > > > > won't work. That example uses the > > > > > java.awt.Component.addMouseListener() method, but there is no > > > > > addPenListener() or addGenericListener(). I don't see how it > > > > > could work. Of course I'm no Java expert, so maybe I'm confusing > > > > > things. > > > > > > > > AFAICT from your source code, you have to instantiate the > > > > PenManager by passing the constructor an instance of a Component. > > > > This does not need to be a JFrame, it should be possible to do > > > > that with an ij.gui.ImageWindow(), too (which you should get using > > > > ij.WindowManager.getCurrentWindow()). > > > > > > You actually pass to the PenManager any instance of a class that > > > implements PenListener, so I don't think I can pass the current > > > ImageJ window since it definitely does not implement the listener. > > > > From my copy of the source of PenManager, it seems that the component > > passed to the constructor does not need to implement a > > PenManagerListener, but is rather a component whose width and height > > are needed to determine the desired dimensions. > > > > Further, my copy of the source of PenManager does not allow a > > PenListener to be added via addListener(), but only a > > PenManagerListener. > > > > Instead, you have to instantiate the class jpen.Pen (without the need > > to pass a parameter to the constructor) and add a PenListener there. > > > > The PenListener still can be the PlugIn, as you did it, just that the > > events have to be handled appropriately (most likely, I think the > > PLevelEvent, which has to be translated into the coordinates and the > > pressure, and the appropriate action has to be performed on the > > current window). > > Okay I understand now. Yes, you can pass any Component to the PenManager > constructor. Whenever the cursor is above that component my plugin > receives events. Following the mouse_listener code I was able to capture > pen events whenever the cursor was on top of the image canvas. I could > create new PenManagers for all image windows and the ImageJ frame, but > it would be so much nicer if I could just capture all pen events > regardless of where the cursor is, so long as an ImageJ window has the > focus. You seem to forget the point I try to make pretty often, these last hours: you _cannot_ break compatibility with, say, MacOSX. And that would be the case if you changed the core of ImageJ. That's not going to happen. > Well, I think I see that there is quite a bit to go to make this at all > usable. I think it would be pretty easy: register PenManagers for all open windows (IJ.getInstance() and WindowManager.getImage(id) for every id in the list returned by WindowManager.getIDList()), and then register an ImageListener with ImagePlus.addImageListener(this). This listener gets notifications when ImagePlus instances are opened or closed. Hth, Dscho |
On Thu, Nov 20, 2008 at 6:29 PM, Johannes Schindelin <
[hidden email]> wrote: > Hi, > > On Thu, 20 Nov 2008, Josh D wrote: > > Okay I understand now. Yes, you can pass any Component to the PenManager > > constructor. Whenever the cursor is above that component my plugin > > receives events. Following the mouse_listener code I was able to capture > > pen events whenever the cursor was on top of the image canvas. I could > > create new PenManagers for all image windows and the ImageJ frame, but > > it would be so much nicer if I could just capture all pen events > > regardless of where the cursor is, so long as an ImageJ window has the > > focus. > > You seem to forget the point I try to make pretty often, these last > hours: you _cannot_ break compatibility with, say, MacOSX. And that would > be the case if you changed the core of ImageJ. > > That's not going to happen. I'm sorry but I don't think you read my last reply. I said nothing about changing the core of ImageJ, I understand about breaking compatibility. Besides, it only breaks compatibility if you do a poor job of adding the functionality. It would be quite easy to add JPen support to the core, WITHOUT breaking MacOSX or Solaris or whatever compatibility, BUT supporting the OS's which do have a pen provider, namely Windows and Linux (and MacOSX support is in beta). Programs support additional features on just certain OS's all the time. However I agree, I do not think the core has to be changed to add this support, so there is no need to do so. > > > > Well, I think I see that there is quite a bit to go to make this at all > > usable. > > I think it would be pretty easy: register PenManagers for all open windows > (IJ.getInstance() and WindowManager.getImage(id) for every id in the list > returned by WindowManager.getIDList()), and then register an > ImageListener with ImagePlus.addImageListener(this). This listener gets > notifications when ImagePlus instances are opened or closed. > > Hth, > Dscho > I agree, that part would not be hard. What I'm talking about is making it a truly functional and useful plugin. That means I would have to have an additonal toolset or separate toolbar to hold all the pen enabled tools. I would have to write or rewrite all the applicable tools to add pressure sensitivity (at least the tools brush selection, paint, spraypaint, eraser, and probably acouple of others). This is just more work then I am willing to put in at this time. I was hoping it would be a quick hack that I could use and others perhaps could refine. Hopefully someone will take up this work that has the time and a tablet. Thank you again for your help. -Josh |
Hi,
On Fri, 21 Nov 2008, Josh D wrote: > On Thu, Nov 20, 2008 at 6:29 PM, Johannes Schindelin < > [hidden email]> wrote: > > > On Thu, 20 Nov 2008, Josh D wrote: > > > Okay I understand now. Yes, you can pass any Component to the > > > PenManager constructor. Whenever the cursor is above that component > > > my plugin receives events. Following the mouse_listener code I was > > > able to capture pen events whenever the cursor was on top of the > > > image canvas. I could create new PenManagers for all image windows > > > and the ImageJ frame, but it would be so much nicer if I could just > > > capture all pen events regardless of where the cursor is, so long as > > > an ImageJ window has the focus. > > > > You seem to forget the point I try to make pretty often, these last > > hours: you _cannot_ break compatibility with, say, MacOSX. And that > > would be the case if you changed the core of ImageJ. > > > > That's not going to happen. > > I'm sorry but I don't think you read my last reply. I did. But obviously I misunderstood it. Sorry. > I said nothing about changing the core of ImageJ, I understand about > breaking compatibility. Good! We are on one level, then. BTW I just realized that JPen also handles a regular mouse, so I _will_ be able to test (at least with only one pressure level). So now I'm in the game. IMO your Pen_Test.java is a good start, and can be enhanced to paint into any ImageWindow. That's what you want, right? Ciao, Dscho |
On Fri, Nov 21, 2008 at 2:43 PM, Johannes Schindelin <
[hidden email]> wrote: > Hi, > > On Fri, 21 Nov 2008, Josh D wrote: > > > On Thu, Nov 20, 2008 at 6:29 PM, Johannes Schindelin < > > [hidden email]> wrote: > > > > > On Thu, 20 Nov 2008, Josh D wrote: > > > > Okay I understand now. Yes, you can pass any Component to the > > > > PenManager constructor. Whenever the cursor is above that component > > > > my plugin receives events. Following the mouse_listener code I was > > > > able to capture pen events whenever the cursor was on top of the > > > > image canvas. I could create new PenManagers for all image windows > > > > and the ImageJ frame, but it would be so much nicer if I could just > > > > capture all pen events regardless of where the cursor is, so long as > > > > an ImageJ window has the focus. > > > > > > You seem to forget the point I try to make pretty often, these last > > > hours: you _cannot_ break compatibility with, say, MacOSX. And that > > > would be the case if you changed the core of ImageJ. > > > > > > That's not going to happen. > > > > I'm sorry but I don't think you read my last reply. > > I did. But obviously I misunderstood it. Sorry. > > > I said nothing about changing the core of ImageJ, I understand about > > breaking compatibility. > > Good! We are on one level, then. > > BTW I just realized that JPen also handles a regular mouse, so I _will_ be > able to test (at least with only one pressure level). > > So now I'm in the game. Great to see you're interested in working on this. > > IMO your Pen_Test.java is a good start, and can be enhanced to paint into > any ImageWindow. That's what you want, right? > > Ciao, > Dscho > Yes, mostly what I'd like to see is all the features you'd expect from a pen and tablet combination to be supported. Right now ImageJ treats the tablet input like a mouse, just like every other program. I actually have been using the tablet right now for segmenting, it's just the tablet is absolute location whereas the mouse is relative. 1) Pressure and tilt sensitivity. Can be configured to affect the size of appropriate tools, namely the brush selection, paint, pencil, and eraser tools. Perhaps with spraypaint it could also affect the flow rate. Not exactly sure how the tilt could be implemented. 2) Tool association. My test code already has this working, in a basic way. What would be ideal (but difficult to accomplish in a full way) is to be able to associate any ImageJ tool AND its settings to each of the stylus, eraser, and mouse cursor. Saving the settings might be difficult. I.e. if you wanted to have the stylus be a selection brush of 15 pixel width and the eraser be a selection brush of 5 pixels, I'm not sure how this would work. 3) Button configurability. Tablets have different buttons, but the one I have (Wacom Intuos3) has 8 buttons and two touch sensitive sliders. In the Wacom settings menu you can configure buttons to send different keyboard signals, which is how I do it now. I then have macros in ImageJ which match to these keys. This might be sufficient. It would be interesting to do something with the sliders, though I don't know what. Glad you're interested in this, let me know and I'd be glad to test anything you work on. -Josh |
Can you guys make an announcement to the list when you've got this
working? I've got a ModBook tablet Mac, and having full pen functionality in ImageJ would be a wonderfull thing! Bill At 3:31 PM -0500 11/21/08, Josh D wrote: > On Fri, Nov 21, 2008 at 2:43 PM, Johannes Schindelin < >[hidden email]> wrote: > >> Hi, >> >> On Fri, 21 Nov 2008, Josh D wrote: >> >> > On Thu, Nov 20, 2008 at 6:29 PM, Johannes Schindelin < >> > [hidden email]> wrote: >> > >> > > On Thu, 20 Nov 2008, Josh D wrote: >> > > > Okay I understand now. Yes, you can pass any Component to the >> > > > PenManager constructor. Whenever the cursor is above that component >> > > > my plugin receives events. Following the mouse_listener code I was >> > > > able to capture pen events whenever the cursor was on top of the >> > > > image canvas. I could create new PenManagers for all image windows >> > > > and the ImageJ frame, but it would be so much nicer if I could just >> > > > capture all pen events regardless of where the cursor is, so long as >> > > > an ImageJ window has the focus. >> > > >> > > You seem to forget the point I try to make pretty often, these last >> > > hours: you _cannot_ break compatibility with, say, MacOSX. And that >> > > would be the case if you changed the core of ImageJ. >> > > >> > > That's not going to happen. >> > >> > I'm sorry but I don't think you read my last reply. >> >> I did. But obviously I misunderstood it. Sorry. >> >> > I said nothing about changing the core of ImageJ, I understand about >> > breaking compatibility. >> >> Good! We are on one level, then. >> >> BTW I just realized that JPen also handles a regular mouse, so I _will_ be >> able to test (at least with only one pressure level). >> >> So now I'm in the game. > > > Great to see you're interested in working on this. > > >> >> IMO your Pen_Test.java is a good start, and can be enhanced to paint into >> any ImageWindow. That's what you want, right? >> >> Ciao, >> Dscho >> >Yes, mostly what I'd like to see is all the features you'd expect from a pen >and tablet combination to be supported. Right now ImageJ treats the tablet >input like a mouse, just like every other program. I actually have been >using the tablet right now for segmenting, it's just the tablet is absolute >location whereas the mouse is relative. > >1) Pressure and tilt sensitivity. Can be configured to affect the size of >appropriate tools, namely the brush selection, paint, pencil, and eraser >tools. Perhaps with spraypaint it could also affect the flow rate. Not >exactly sure how the tilt could be implemented. >2) Tool association. My test code already has this working, in a basic way. >What would be ideal (but difficult to accomplish in a full way) is to be >able to associate any ImageJ tool AND its settings to each of the stylus, >eraser, and mouse cursor. Saving the settings might be difficult. I.e. if >you wanted to have the stylus be a selection brush of 15 pixel width and the >eraser be a selection brush of 5 pixels, I'm not sure how this would work. >3) Button configurability. Tablets have different buttons, but the one I >have (Wacom Intuos3) has 8 buttons and two touch sensitive sliders. In the >Wacom settings menu you can configure buttons to send different keyboard >signals, which is how I do it now. I then have macros in ImageJ which match >to these keys. This might be sufficient. It would be interesting to do >something with the sliders, though I don't know what. > >Glad you're interested in this, let me know and I'd be glad to test anything >you work on. >-Josh |
In reply to this post by Josh Doe-2
This is first an issue of when JPen (http://jpen.wiki.sourceforge.net/)
finalizes support of the Mac OSX pen provider. The second is of when a tablet plugin for ImageJ is completed. I'm certain Johannes or whoever might take up development of this plugin will announce any release they create. -Josh On Mon, Nov 24, 2008 at 2:59 PM, Bill Mohler <[hidden email]>wrote: > Can you guys make an announcement to the list when you've got this working? > I've got a ModBook tablet Mac, and having full pen functionality in ImageJ > would be a wonderfull thing! > > Bill > > > At 3:31 PM -0500 11/21/08, Josh D wrote: > >> On Fri, Nov 21, 2008 at 2:43 PM, Johannes Schindelin < >> [hidden email]> wrote: >> >> Hi, >>> >>> On Fri, 21 Nov 2008, Josh D wrote: >>> >>> > On Thu, Nov 20, 2008 at 6:29 PM, Johannes Schindelin < >>> > [hidden email]> wrote: >>> > >>> > > On Thu, 20 Nov 2008, Josh D wrote: >>> > > > Okay I understand now. Yes, you can pass any Component to the >>> > > > PenManager constructor. Whenever the cursor is above that >>> component >>> > > > my plugin receives events. Following the mouse_listener code I was >>> > > > able to capture pen events whenever the cursor was on top of the >>> > > > image canvas. I could create new PenManagers for all image windows >>> > > > and the ImageJ frame, but it would be so much nicer if I could >>> just >>> > > > capture all pen events regardless of where the cursor is, so long >>> as >>> > > > an ImageJ window has the focus. >>> > > >>> > > You seem to forget the point I try to make pretty often, these last >>> > > hours: you _cannot_ break compatibility with, say, MacOSX. And that >>> > > would be the case if you changed the core of ImageJ. >>> > > >>> > > That's not going to happen. >>> > >>> > I'm sorry but I don't think you read my last reply. >>> >>> I did. But obviously I misunderstood it. Sorry. >>> >>> > I said nothing about changing the core of ImageJ, I understand about >>> > breaking compatibility. >>> >>> Good! We are on one level, then. >>> >>> BTW I just realized that JPen also handles a regular mouse, so I _will_ >>> be >>> able to test (at least with only one pressure level). >>> >>> So now I'm in the game. >>> >> >> >> Great to see you're interested in working on this. >> >> >> >>> IMO your Pen_Test.java is a good start, and can be enhanced to paint >>> into >>> any ImageWindow. That's what you want, right? >>> >>> Ciao, >>> Dscho >>> >>> Yes, mostly what I'd like to see is all the features you'd expect from a >> pen >> and tablet combination to be supported. Right now ImageJ treats the tablet >> input like a mouse, just like every other program. I actually have been >> using the tablet right now for segmenting, it's just the tablet is >> absolute >> location whereas the mouse is relative. >> >> 1) Pressure and tilt sensitivity. Can be configured to affect the size of >> appropriate tools, namely the brush selection, paint, pencil, and eraser >> tools. Perhaps with spraypaint it could also affect the flow rate. Not >> exactly sure how the tilt could be implemented. >> 2) Tool association. My test code already has this working, in a basic >> way. >> What would be ideal (but difficult to accomplish in a full way) is to be >> able to associate any ImageJ tool AND its settings to each of the stylus, >> eraser, and mouse cursor. Saving the settings might be difficult. I.e. if >> you wanted to have the stylus be a selection brush of 15 pixel width and >> the >> eraser be a selection brush of 5 pixels, I'm not sure how this would work. >> 3) Button configurability. Tablets have different buttons, but the one I >> have (Wacom Intuos3) has 8 buttons and two touch sensitive sliders. In the >> Wacom settings menu you can configure buttons to send different keyboard >> signals, which is how I do it now. I then have macros in ImageJ which >> match >> to these keys. This might be sufficient. It would be interesting to do >> something with the sliders, though I don't know what. >> >> Glad you're interested in this, let me know and I'd be glad to test >> anything >> you work on. >> -Josh >> > |
Free forum by Nabble | Edit this page |