ImageJ base code to get access to all the classes and their methods to test new Plugins. https://imagejdocu.tudor.lu/howto/plugins/the_imagej_eclipse_howto
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.7 KiB

2 years ago
  1. package ij.plugin;
  2. import ij.plugin.*;
  3. import ij.*;
  4. import ij.io.*;
  5. import com.apple.eawt.*;
  6. import java.util.Vector;
  7. /** This Mac-specific plugin is designed to handle the “About ImageJ",
  8. Preferences and “Quit ImageJ" commands in the ImageJ menu, and to
  9. open files dropped on ImageJ.app and to open double-clicked files
  10. with creator code "imgJ". With Java 8, the “About ImageJ" and
  11. “Quit ImageJ” commands work without MacAdapter.
  12. */
  13. public class MacAdapter implements PlugIn, ApplicationListener, Runnable {
  14. static Vector paths = new Vector();
  15. public void run(String arg) {
  16. Application app = new Application();
  17. app.setEnabledPreferencesMenu(true);
  18. app.addApplicationListener(this);
  19. }
  20. public void handleAbout(ApplicationEvent event) {
  21. IJ.doCommand("About ImageJ...");
  22. event.setHandled(true);
  23. }
  24. public void handleOpenFile(ApplicationEvent event) {
  25. paths.add(event.getFilename());
  26. Thread thread = new Thread(this, "Open");
  27. thread.setPriority(thread.getPriority()-1);
  28. thread.start();
  29. }
  30. public void handlePreferences(ApplicationEvent event) {
  31. IJ.error("The ImageJ preferences are in the Edit>Options menu.");
  32. }
  33. public void handleQuit(ApplicationEvent event) {
  34. new Executer("Quit", null); // works with the CommandListener
  35. //IJ.getInstance().quit();
  36. }
  37. public void run() {
  38. if (paths.size() > 0) {
  39. (new Opener()).openAndAddToRecent((String) paths.remove(0));
  40. }
  41. }
  42. public void handleOpenApplication(ApplicationEvent event) {}
  43. public void handleReOpenApplication(ApplicationEvent event) {}
  44. public void handlePrintFile(ApplicationEvent event) {}
  45. }