SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
for (int i = 0; i < imageVals.length; i++) {
LsmFileInfo openLSM = (LsmFileInfo) ((ImagePlus) WindowManager
.getImage(imageVals[i]))
.getOriginalFileInfo();
CZ_LSMInfo cz = (CZ_LSMInfo) ((ImageDirectory) openLSM.imageDirectories
.get(0)).TIF_CZ_LSMINFO;
Reader reader = new Reader(masterModel);
ImagePlus[] imp = reader
.open(openLSM.directory,
openLSM.fileName, true,
true, false);
Class i5Dc = null;
if (imp == null || imp.length == 0) {
IJ.error("Could not open file.");
return;
}
try {
i5Dc = Class.forName("i5d.Image5D");
} catch (ClassNotFoundException e1) {
try {
i5Dc = Class.forName("Image5D");
} catch (ClassNotFoundException e2) {
e2.printStackTrace();
}
}
Constructor i5Dcon = null;
Object o = null;
try {
i5Dcon = i5Dc
.getConstructor(new Class[] {
String.class,
int.class, int.class,
int.class, int.class,
int.class, int.class,
boolean.class });
o = i5Dcon
.newInstance(new Object[] {
openLSM.fileName,
new Integer(imp[0]
.getType()),
new Integer(imp[0]
.getWidth()),
new Integer(imp[0]
.getHeight()),
new Integer(imp.length),
new Integer(
(int) cz.DimensionZ),
new Integer(
(int) cz.DimensionTime),
new Boolean(false) });
Method i5DsetCurrentPosition = o
.getClass().getMethod(
"setCurrentPosition",
new Class[] {
int.class,
int.class,
int.class,
int.class,
int.class });
Method i5DsetPixels = o
.getClass()
.getMethod(
"setPixels",
new Class[] { Object.class });
Method i5DsetCalibration = o
.getClass()
.getMethod(
"setCalibration",
new Class[] { Calibration.class });
Method i5Dshow = o.getClass()
.getMethod("show",
new Class[] {});
Method i5DgetWindow = o.getClass()
.getMethod("getWindow",
new Class[] {});
Method i5DsetChannelColorModel = o
.getClass()
.getMethod(
"setChannelColorModel",
new Class[] {
int.class,
ColorModel.class });
for (int c = 0; c < imp.length; c++) {
for (int z = 0; z < cz.DimensionZ; z++) {
for (int t = 0; t < cz.DimensionTime; t++) {
i5DsetCurrentPosition
.invoke(
o,
new Object[] {
new Integer(
0),
new Integer(
0),
new Integer(
c),
new Integer(
z),
new Integer(
t) });
imp[c]
.setSlice(t
* ((int) cz.DimensionZ * 1)
+ z * 1 + 1);
i5DsetPixels
.invoke(
o,
new Object[] { imp[c]
.getProcessor()
.getPixels() });
}
}
i5DsetChannelColorModel
.invoke(
o,
new Object[] {
new Integer(
c + 1),
imp[c]
.getProcessor()
.getColorModel() });
}
i5DsetCalibration.invoke(o,
new Object[] { imp[0]
.getCalibration()
.copy() });
final LsmFileInfo lsm = openLSM;
i5Dshow.invoke(o, new Object[] {});
((ImageWindow) i5DgetWindow.invoke(o,
new Object[] {}))
.addFocusListener(new FocusListener() {
final LsmFileInfo lsmfi = lsm;