Commit ace015f7 authored by Luc Deschenaux's avatar Luc Deschenaux

Fix Eyesis_Correction and JP46_Reader_camera

Plugins must not extend or instantiate frames in order to be run in headless mode,
they must implement "PlugIn" and the entry point should be method run(); AFIK

- Eyesis_Correction can now be run from macro:
  run("Eyesis Correction","prefs=<path_to_xml>");

- or in headless mode from Fidji command line:
  ImageJ-linux64 --headless --run Eyesis_Correction prefs=<path_to_xml> ...
parent 3d9ac013
This diff is collapsed.
...@@ -30,6 +30,7 @@ import ij.process.*; ...@@ -30,6 +30,7 @@ import ij.process.*;
import ij.gui.*; import ij.gui.*;
import ij.plugin.frame.*; import ij.plugin.frame.*;
import ij.text.*; import ij.text.*;
import ij.plugin.PlugIn;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
...@@ -50,9 +51,8 @@ import org.xml.sax.InputSource; ...@@ -50,9 +51,8 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/* This plugin opens images in Elphel JP4/JP46 format (opens as JPEG, reads MakerNote and converts). */ /* This plugin opens images in Elphel JP4/JP46 format (opens as JPEG, reads MakerNote and converts). */
public class JP46_Reader_camera extends PlugInFrame implements ActionListener { public class JP46_Reader_camera implements PlugIn, ActionListener {
/** /**
* *
...@@ -61,6 +61,7 @@ public class JP46_Reader_camera extends PlugInFrame implements ActionListener { ...@@ -61,6 +61,7 @@ public class JP46_Reader_camera extends PlugInFrame implements ActionListener {
Panel panel1; Panel panel1;
Panel confpanel; Panel confpanel;
Frame instance; Frame instance;
PlugInFrame plugInFrame;
String arg; String arg;
...@@ -72,47 +73,34 @@ public class JP46_Reader_camera extends PlugInFrame implements ActionListener { ...@@ -72,47 +73,34 @@ public class JP46_Reader_camera extends PlugInFrame implements ActionListener {
public String camera_jp46settings = ""; public String camera_jp46settings = "";
public boolean IS_SILENT=true; public boolean IS_SILENT=true;
public boolean ABSOLUTELY_SILENT=false; public boolean ABSOLUTELY_SILENT=false;
public boolean demux=true; public boolean demux=true;
public String imageTitle="cameraImage"; public String imageTitle="cameraImage";
private int ExifOffset=0x0c; private int ExifOffset=0x0c;
private Boolean headless=GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance();
public JP46_Reader_camera() { public void run(String arg) {
super("JP46 Reader Camera"); }
if (IJ.versionLessThan("1.39t")) return;
if (instance!=null) {
instance.toFront();
return;
}
instance = this;
addKeyListener(IJ.getInstance());
panel1 = new Panel();
panel1.setLayout(new GridLayout(6, 1, 50, 5)); public JP46_Reader_camera(Boolean showGui) {
initGui(showGui);
}
addButton("Open JP4/JP46...",panel1); public JP46_Reader_camera() {
addButton("Open JP4/JP46 from camera",panel1); initGui(true);
addButton("Configure...",panel1); }
addButton("Show image properties",panel1);
addButton("Decode image info to properties",panel1);
addButton("Split Bayer",panel1);
add(panel1); private void initGui(Boolean showGui) {
if (headless) return;
pack();
GUI.center(this);
setVisible(true);
}
public JP46_Reader_camera(boolean showGUI) {
super("JP46 Reader Camera");
if (IJ.versionLessThan("1.39t")) return; if (IJ.versionLessThan("1.39t")) return;
if (instance!=null) { if (instance!=null) {
instance.toFront(); instance.toFront();
return; return;
} }
instance = this; plugInFrame=new PlugInFrame("JP46 Reader Camera");
addKeyListener(IJ.getInstance()); instance = (Frame)plugInFrame;
plugInFrame.addKeyListener(IJ.getInstance());
panel1 = new Panel(); panel1 = new Panel();
...@@ -124,12 +112,14 @@ public class JP46_Reader_camera extends PlugInFrame implements ActionListener { ...@@ -124,12 +112,14 @@ public class JP46_Reader_camera extends PlugInFrame implements ActionListener {
addButton("Show image properties",panel1); addButton("Show image properties",panel1);
addButton("Decode image info to properties",panel1); addButton("Decode image info to properties",panel1);
addButton("Split Bayer",panel1); addButton("Split Bayer",panel1);
add(panel1);
pack();
GUI.center(this); plugInFrame.add(panel1);
setVisible(showGUI);
}
plugInFrame.pack();
GUI.center(plugInFrame);
plugInFrame.setVisible(true);
}
void addButton(String label, Panel panel) { void addButton(String label, Panel panel) {
Button b = new Button(label); Button b = new Button(label);
b.addActionListener(this); b.addActionListener(this);
...@@ -1318,10 +1308,9 @@ Exception in thread "Thread-3564" java.lang.ArrayIndexOutOfBoundsException: 8970 ...@@ -1318,10 +1308,9 @@ Exception in thread "Thread-3564" java.lang.ArrayIndexOutOfBoundsException: 8970
* image and calls the plugin, e.g. after setting breakpoints. * image and calls the plugin, e.g. after setting breakpoints.
* Grabbed from https://github.com/imagej/minimal-ij1-plugin * Grabbed from https://github.com/imagej/minimal-ij1-plugin
* @param args unused * @param args unused
*/
public static void main(String[] args) { public static void main(String[] args) {
// set the plugins.dir property to make the plugin appear in the Plugins menu // set the plugins.dir property to make the plugin appear in the Plugins menu
Class<?> clazz = Aberration_Calibration.class; Class<?> clazz = JP46_Reader_camera.class;
String url = clazz.getResource("/" + clazz.getName().replace('.', '/') + ".class").toString(); String url = clazz.getResource("/" + clazz.getName().replace('.', '/') + ".class").toString();
String pluginsDir = url.substring(5, url.length() - clazz.getName().length() - 6); String pluginsDir = url.substring(5, url.length() - clazz.getName().length() - 6);
System.setProperty("plugins.dir", pluginsDir); System.setProperty("plugins.dir", pluginsDir);
...@@ -1330,7 +1319,7 @@ Exception in thread "Thread-3564" java.lang.ArrayIndexOutOfBoundsException: 8970 ...@@ -1330,7 +1319,7 @@ Exception in thread "Thread-3564" java.lang.ArrayIndexOutOfBoundsException: 8970
// run the plugin // run the plugin
IJ.runPlugIn(clazz.getName(), ""); IJ.runPlugIn(clazz.getName(), "");
} }
*/
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment