Hello,
I have two questions... First: I can't wrap my head around the different behaviors I see between TextWindow and TextPanel. I can realize a TextWindow with rows of tab-delimited columns, but I can't do the same thing with TextPanel. I have pasted simple examples of each in the space below. Of course, I may be barking up the wrong tree to start with. The functionality I really want is to allow the user to select a row (associated with an image) and then have the image loaded and displayed. I have been thinking that I really need to have a plugin class that inherits from TextPanel so that I can override the "actionPerformed" method, etc. to handle user events. I haven't found any examples that inherit from TextPanel or TextWindow - just plugins that create them (like those shown below). Second: So that leads me to wonder if plugins that implement the PlugIn interface don't also inherit from objects (other than Object). Instead I wonder if I am supposed to implement other interfaces such as MouseListener. Well, you can see that I'm lost! (And that I can't wait for the English version of Digital Image Processing in Java by Wilhelm Burger, Mark Burge to be published!) Thanks for any help, Ben /* PanelTest2_ uses TextPanel */ import ij.*; import ij.process.*; import ij.gui.*; import ij.plugin.PlugIn; import ij.text.*; public class PanelTest2_ implements PlugIn { //run for ImageJ public void run(String arg) { TextPanel tp = new TextPanel("Panel Test"); tp.setColumnHeadings("ID\tName\tValue"); tp.appendLine("0\tRed\t0.1"); tp.appendLine("1\tGreen\t2.04"); tp.appendLine("3\tYellow\t1.1"); tp.setVisible(true); }//end of run } /* PanelTest3_ uses TextWindow */ import ij.*; import ij.process.*; import ij.gui.*; import ij.plugin.PlugIn; import ij.text.*; public class PanelTest3_ implements PlugIn { //run for ImageJ public void run(String arg) { String title = "Panel Test"; String headerNames = "ID\tName\tValue"; String data = "0\tRed\t0.1" + "\n" + "1\tGreen\t2.04"+ "\n" + "3\tYellow\t1.1"+ "\n"; TextWindow tw = new TextWindow(title, headerNames, data, 200, 200); }//end of run } |
> I have two questions...
> > First: > I can't wrap my head around the different behaviors I see between > TextWindow and TextPanel. I can realize a TextWindow with rows of > tab-delimited columns, but I can't do the same thing with TextPanel. I > have pasted simple examples of each in the space below. > > Of course, I may be barking up the wrong tree to start with. The > functionality I really want is to allow the user to select a row > (associated with an image) and then have the image loaded and > displayed. This is built into ImageJ 1.37i and later. Double click on a file path in a TextWindow (e.g., the "Log" window) and that file is opened. This is very handy with macros that generate file lists, such as the ListFilesRecursively macro at http://rsb.info.nih.gov/ij/macros/ListFilesRecursively.txt I also plan to add a File>Open Selected Files menu command that will allow users to open multiple files. > I have been thinking that I really need to have a plugin class that > inherits from TextPanel so that I can override the "actionPerformed" > method, etc. to handle user events. I haven't found any examples that > inherit from TextPanel or TextWindow - just plugins that create them > (like those shown below). > > Second: > So that leads me to wonder if plugins that implement the PlugIn > interface don't also inherit from objects (other than Object). > Instead I wonder if I am supposed to implement other interfaces such > as MouseListener. Plugins can implement more than one interface. For examples, look at the Mouse_Listener, Key_Listener and Image_Listener example plugins. http://rsb.info.nih.gov/ij/plugins/mouse-listener.html http://rsb.info.nih.gov/ij/plugins/key-listener.html http://rsb.info.nih.gov/ij/plugins/image-listener.html -wayne |
Free forum by Nabble | Edit this page |