If i wanted to put a pause in my java plugin program so that the user could select and cut part of the image and then press an "ok" type button to carry on with the program, is this possible and if so how?
Thanks, Mark |
I'm trying to create a heatmap like this:
http://www.heatmapapi.com/Example_1.aspx Can ij.jar be used outside of the tool to compose a base image with an overlay, at a specific XY, using the MULTIPLY option? //create base image 500x500 pixels //colorize png spot //overlay png spot at 20,20; 50,50; etc. using ComposeMultiply //write out composed image Would anyone be able to provide short snippet? The code below is the same for doing it in Ruby using the Image Magick library. Thank you in advance! Anthony file.geturls.each do |url| puts "Parsing clicks for #{url}\n" pagedata = file.coordsurl(url) # Create click-dot, colorized intensity = (100-(100/pagedata.reps))/100.to_f * click_image = Magick::Image.read(conf.data['dotimage']).first.colorize(intensity,intensity,intensity,'white') * # Create overlay image halfwidth=conf.data['dotwidth']/2 image = Magick::Image.new(pagedata.x+halfwidth, pagedata.y+halfwidth) { self.background_color = 'gray100' } # Add click dots i = 0 pagedata.list.each do |coords| i = i+1 * image.composite!(click_image,coords.x-halfwidth,coords.y-halfwidth, Magick::MultiplyCompositeOp)* end puts "clicks composed" image.negate.write("#{url}map.png") # Haven't figured out how to do the following with RMagick yet: system("convert #{url}map.png -type TruecolorMatte #{conf.data['colorimage']} -fx \"v.p{0,u*v.h}\" #{url}map.png") system("convert #{url}map.png -channel A -fx \"A*#{conf.data['opacity']}\" #{url}map.png") puts "Done with #{url}map.png\n" end |
In reply to this post by meastwood98
meastwood98 wrote:
> If i wanted to put a pause in my java plugin program so that the user could > select and cut part of the image and then press an "ok" type button to carry > on with the program, is this possible and if so how? > Try this: http://imagejdocu.tudor.lu/imagej-documentation-wiki/plugins/wait_for_user A while ago Michael Schmid pointed me at this, and it solved my problem, so I am just passing the favor on. --aryeh -- Aryeh Weiss School of Engineering Bar Ilan University Ramat Gan 52900 Israel Ph: 972-3-5317638 FAX: 972-3-7384050 |
ok i've got the macro waitForUser(string); fine but cannot get this to work in the java plugin, can anyone give me the code to do this?
Thankyou Mark
|
> ok i've got the macro waitForUser(string); fine but cannot get this to work
> in the java plugin, can anyone give me the code to do this? > > Thankyou > Mark > There is no magical pill, neither a one-liner to do what you want. A system that could work: - add a keylistener to the canvas - IJ.showMessage("Now do this and that, then push key X") - your listener gets the key event, and executes the second part of the program. Albert -- Albert Cardona http://www.mcdb.ucla.edu/Research/Hartenstein/acardona |
In reply to this post by meastwood98
> If i wanted to put a pause in my java plugin program so that
> the user could select and cut part of the image and then press > an "ok" type button to carry on with the program, is this > possible and if so how? You can use the WaitForUserDialog class that was added in ImageJ 1.39r. For example new WaitForUserDialog("Do something, then click OK.").show(); or new WaitForUserDialog("Title", "Do something, then click OK.").show(); if you want to use a dialog title other than the default "Action Required". In a macro, use waitForUser("Do something, then click OK"); or waitForUser("Title", "Do something, then click OK"); Add new lines characters ("\n") to display multiple lines in the dialog, for example waitForUser("Do something\nthen something else,\nthen click OK."); -wayne |
In reply to this post by meastwood98
What I meant was not a macro. It is a plugin called Wait_For_User.java which I
compiled and is installed in my plugins directory. Then, inside a macro, I call it as follows: run("Wait For User", "your prompt for the user"); I am then able to do whatever I want at that point, and then click ok to continue the macro. --aryeh meastwood98 wrote: > ok i've got the macro waitForUser(string); fine but cannot get this to work > in the java plugin, can anyone give me the code to do this? > > Thankyou > Mark > > > > Aryeh Weiss wrote: >> meastwood98 wrote: >>> If i wanted to put a pause in my java plugin program so that the user >>> could >>> select and cut part of the image and then press an "ok" type button to >>> carry >>> on with the program, is this possible and if so how? >>> >> Try this: >> >> http://imagejdocu.tudor.lu/imagej-documentation-wiki/plugins/wait_for_user >> >> A while ago Michael Schmid pointed me at this, and it solved my problem, >> so I am >> just passing the favor on. >> >> --aryeh >> -- >> Aryeh Weiss >> School of Engineering >> Bar Ilan University >> Ramat Gan 52900 Israel >> >> Ph: 972-3-5317638 >> FAX: 972-3-7384050 >> >> > |
In reply to this post by Wayne Rasband
Hi list,
as I understand, GenericDialog is basically a modal dialog that you can fill in with initial values, ask the user to change them and process any changes only afte she/he has pressed "OK". However, I also learned you can circumvent this (partially) by using a DialogListener, to implement previews etc., i.e. immediately react to changes. I would now "envision" a plugin that has a button for.ex. "centered", when you press this the meaning of certain coordinates in other fields of the dialog changes, as in Specify ROI, however I would find it useful, that after any change to that button, the entries in those fields are changed accordingly, so that they reflect the **same** selection in the new coordinate system, i.e. one would need to update Dialog fields from within the Dialog Listener. Is this possible, any example code that already does something similar? Sincerely Joachim ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ |
Hi Joachim
if you want to add a button to a generic dialog, you have to put it into a panel and use the public void addPanel(Panel panel) method of GenericDialog. Then you have to add your plugin as an ActionListener to the dialog and handle th button events in the public void actionPerformed(ActionEvent e) method of your plugin. To change values after the button has been clicked, use the public Vector getNumericFields() method of GenericDialog to get the references to the fields (the fields are java.awt.TextField) and then use the setText(String text) of the textfield. For an example, see ij.plugin.filter.ScaleDialog.java Note that there is a bug in Mac OSX 10.4: It does not correctly update of the display if one changes more than one item (textfield, label, state of a checkbox...) at the same time. The only workaround I found so far is changing all items but one at once, then wait for 100 or 200 ms and then change the last item (or do some dummy change, e.g. add or remove a trailing space of a label). It looks like a problem of java.awt.Component.coalesceEvents, but I was not successful with overriding coalesceEvents by a method that returns null (to disable coalesceEvents). So I guess that there is a similar mechanism like coalesceEvents working on a deeper level (in the Mac OS) and the bug is there. Michael ________________________________________________________________ On 22 Feb 2008, at 09:37, Joachim Wesner wrote: > Hi list, > > as I understand, GenericDialog is basically a modal dialog that you > can > fill in with initial values, ask the user to change them and > process any > changes only > afte she/he has pressed "OK". However, I also learned you can > circumvent > this (partially) by using a DialogListener, to implement previews > etc., > i.e. immediately react to changes. > > I would now "envision" a plugin that has a button for.ex. > "centered", when > you press this the meaning of certain coordinates in other fields > of the > dialog changes, as in Specify ROI, > however I would find it useful, that after any change to that > button, the > entries in those fields are changed accordingly, so that they > reflect the > **same** selection in the new > coordinate system, i.e. one would need to update Dialog fields from > within > the Dialog Listener. > > Is this possible, any example code that already does something > similar? > > Sincerely > > Joachim > |
Hi Michael,
thanx a lot, this is exactly the info that I was looking for, I had taken a look at the description of the genericDialog class, but did not realize that getNumericFields really returns a *reference* and not numeric values that one could use to also update those! Joachim Michael Schmid <[hidden email] N.AC.AT> An Gesendet von: [hidden email] ImageJ Interest Kopie Group <[hidden email]. Thema GOV> Re: Dynamically updating GenericDialog fields 22.02.2008 12:00 Bitte antworten an ImageJ Interest Group <[hidden email]. GOV> Hi Joachim if you want to add a button to a generic dialog, you have to put it into a panel and use the public void addPanel(Panel panel) method of GenericDialog. Then you have to add your plugin as an ActionListener to the dialog and handle th button events in the public void actionPerformed(ActionEvent e) method of your plugin. To change values after the button has been clicked, use the public Vector getNumericFields() method of GenericDialog to get the references to the fields (the fields are java.awt.TextField) and then use the setText(String text) of the textfield. For an example, see ij.plugin.filter.ScaleDialog.java Note that there is a bug in Mac OSX 10.4: It does not correctly update of the display if one changes more than one item (textfield, label, state of a checkbox...) at the same time. The only workaround I found so far is changing all items but one at once, then wait for 100 or 200 ms and then change the last item (or do some dummy change, e.g. add or remove a trailing space of a label). It looks like a problem of java.awt.Component.coalesceEvents, but I was not successful with overriding coalesceEvents by a method that returns null (to disable coalesceEvents). So I guess that there is a similar mechanism like coalesceEvents working on a deeper level (in the Mac OS) and the bug is there. Michael ________________________________________________________________ On 22 Feb 2008, at 09:37, Joachim Wesner wrote: > Hi list, > > as I understand, GenericDialog is basically a modal dialog that you > can > fill in with initial values, ask the user to change them and > process any > changes only > afte she/he has pressed "OK". However, I also learned you can > circumvent > this (partially) by using a DialogListener, to implement previews > etc., > i.e. immediately react to changes. > > I would now "envision" a plugin that has a button for.ex. > "centered", when > you press this the meaning of certain coordinates in other fields > of the > dialog changes, as in Specify ROI, > however I would find it useful, that after any change to that > button, the > entries in those fields are changed accordingly, so that they > reflect the > **same** selection in the new > coordinate system, i.e. one would need to update Dialog fields from > within > the Dialog Listener. > > Is this possible, any example code that already does something > similar? > > Sincerely > > Joachim > ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ |
In reply to this post by Michael Schmid
Hi Joachim,
>> Is this possible, any example code that already does something similar? Yes it is posible. All you need is to add a listener to the dialog. See an example of using checkboxes to control the enabled/disabled input status of any other components of GenericDialog: http://repo.or.cz/w/trakem2.git?a=blob;f=ini/trakem2/utils/Utils.java;h=cb7545f6e14ebe83a7be72a230ba49b4a6ae98a8;hb=0edb0e6a735a8db64f0e1b80b566728e863b10e0 All you need to pass it is any component that comes from a GenericDialog, for example any of the items in the Vector returned by methods such as getNumericFields() etc. 724 /** A helper for GenericDialog checkboxes to control the enabled state of other GUI elements in the same dialog. */ 725 static public final void addEnablerListener(final Checkbox master, final Component[] enable, final Component[] disable) { 726 master.addItemListener(new ItemListener() { 727 public void itemStateChanged(ItemEvent ie) { 728 if (ie.getStateChange() == ItemEvent.SELECTED) { 729 process(enable, true); 730 process(disable, false); 731 } else { 732 process(enable, false); 733 process(disable, true); 734 } 735 } 736 private void process(final Component[] c, final boolean state) { 737 if (null == c) return; 738 for (int i=0; i<c.length; i++) c[i].setEnabled(state); 739 } 740 }); 741 } -- Albert Cardona http://www.mcdb.ucla.edu/Research/Hartenstein/acardona |
In reply to this post by Wayne Rasband
This is not yet included in the current API docs on the WebSite?! OR? I did
not find it! Cheers Joachim Rasband Wayne <[hidden email]> Gesendet von: An ImageJ Interest [hidden email] Group Kopie <[hidden email]. GOV> Thema WaitForUserDialog 22.02.2008 04:46 Bitte antworten an ImageJ Interest Group <[hidden email]. GOV> > If i wanted to put a pause in my java plugin program so that > the user could select and cut part of the image and then press > an "ok" type button to carry on with the program, is this > possible and if so how? You can use the WaitForUserDialog class that was added in ImageJ 1.39r. For example new WaitForUserDialog("Do something, then click OK.").show(); or new WaitForUserDialog("Title", "Do something, then click OK.").show(); if you want to use a dialog title other than the default "Action Required". In a macro, use waitForUser("Do something, then click OK"); or waitForUser("Title", "Do something, then click OK"); Add new lines characters ("\n") to display multiple lines in the dialog, for example waitForUser("Do something\nthen something else,\nthen click OK."); -wayne ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ |
On Mar 5, 2008, at 8:23 AM, Joachim Wesner wrote:
> This is not yet included in the current API docs on the WebSite?! OR? > I did not find it! The latest ImageJ source code (1.39u) is at http://rsb.info.nih.gov/ij/source/ The WaitForUserDialog class is at http://rsb.info.nih.gov/ij/source/ij/gui/WaitForUserDialog.java The documentation for the waitForUser() macro function is at http://rsbweb.nih.gov/ij/developer/macro/functions.html#waitForUser -wayne > Cheers > > > Joachim > > > > > Rasband Wayne > <[hidden email]> > Gesendet von: > An > ImageJ Interest [hidden email] > Group > Kopie > <[hidden email]. > GOV> > Thema > WaitForUserDialog > > 22.02.2008 04:46 > > > Bitte antworten > an > ImageJ Interest > Group > <[hidden email]. > GOV> > > > > > > >> If i wanted to put a pause in my java plugin program so that >> the user could select and cut part of the image and then press >> an "ok" type button to carry on with the program, is this >> possible and if so how? > > You can use the WaitForUserDialog class that was added in ImageJ > 1.39r. For example > > new WaitForUserDialog("Do something, then click OK.").show(); > > or > > new WaitForUserDialog("Title", "Do something, then click > OK.").show(); > > if you want to use a dialog title other than the default "Action > Required". > > In a macro, use > > waitForUser("Do something, then click OK"); > > or > > waitForUser("Title", "Do something, then click OK"); > > Add new lines characters ("\n") to display multiple lines in the > dialog, for example > > waitForUser("Do something\nthen something else,\nthen click OK."); > > -wayne > > > > ______________________________________________________________________ > This email has been scanned by the MessageLabs Email Security System. > For more information please visit http://www.messagelabs.com/email > ______________________________________________________________________ > |
Free forum by Nabble | Edit this page |