Commit b106acf0 authored by Andrey Filippov's avatar Andrey Filippov

Converting 3D reconstruction program to support multiple camera

resolutions
parent 6b59db60
...@@ -2113,8 +2113,8 @@ if (MORE_BUTTONS) { ...@@ -2113,8 +2113,8 @@ if (MORE_BUTTONS) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL; DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
LENS_DISTORTIONS=new Distortions(LENS_DISTORTION_PARAMETERS,PATTERN_PARAMETERS,REFINE_PARAMETERS,this.SYNC_COMMAND.stopRequested); LENS_DISTORTIONS=new Distortions(LENS_DISTORTION_PARAMETERS,PATTERN_PARAMETERS,REFINE_PARAMETERS,this.SYNC_COMMAND.stopRequested);
String [] extensions={".tif",".tiff"}; String [] extensions={".tif",".tiff"};
CalibrationFileManagement.MultipleExtensionsFileFilter gridFilter = MultipleExtensionsFileFilter gridFilter =
new CalibrationFileManagement.MultipleExtensionsFileFilter("grid",extensions,"Calibrated grid files"); new MultipleExtensionsFileFilter("grid",extensions,"Calibrated grid files");
GenericDialog gd = new GenericDialog("Setup Goniometer/Camera Stations"); GenericDialog gd = new GenericDialog("Setup Goniometer/Camera Stations");
gd.addMessage("Setting up calibration that includes multiple camera tripod or goniometer positions."); gd.addMessage("Setting up calibration that includes multiple camera tripod or goniometer positions.");
gd.addMessage("File selection dialog will open for each station separateley."); gd.addMessage("File selection dialog will open for each station separateley.");
...@@ -2623,7 +2623,7 @@ if (MORE_BUTTONS) { ...@@ -2623,7 +2623,7 @@ if (MORE_BUTTONS) {
return; return;
} }
String [] extensions={".mask-tiff","-masks.tiff"}; String [] extensions={".mask-tiff","-masks.tiff"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"*.mask-tiff files"); MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"*.mask-tiff files");
String pathname=CalibrationFileManagement.selectFile(true, String pathname=CalibrationFileManagement.selectFile(true,
"Save Sensor Masks file", "Save Sensor Masks file",
"Save", "Save",
...@@ -2645,7 +2645,7 @@ if (MORE_BUTTONS) { ...@@ -2645,7 +2645,7 @@ if (MORE_BUTTONS) {
DISTORTION_CALIBRATION_DATA.updateStatus=UPDATE_STATUS; DISTORTION_CALIBRATION_DATA.updateStatus=UPDATE_STATUS;
String [] extensions={".mask-tiff","-masks.tiff"}; String [] extensions={".mask-tiff","-masks.tiff"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"Sensor masks *.mask-tiff files"); MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"Sensor masks *.mask-tiff files");
String pathname=CalibrationFileManagement.selectFile(false, String pathname=CalibrationFileManagement.selectFile(false,
"Restore Sensor Masks", "Restore Sensor Masks",
"Restore", "Restore",
...@@ -2860,7 +2860,7 @@ if (MORE_BUTTONS) { ...@@ -2860,7 +2860,7 @@ if (MORE_BUTTONS) {
} }
LENS_DISTORTIONS.debugLevel=DEBUG_LEVEL; LENS_DISTORTIONS.debugLevel=DEBUG_LEVEL;
String [] extensions={".calib-tiff"}; String [] extensions={".calib-tiff"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"distortion calibration .calib-tiff files"); MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"distortion calibration .calib-tiff files");
String pathname=CalibrationFileManagement.selectFile(false, String pathname=CalibrationFileManagement.selectFile(false,
"Restore distortion calibration for sensor", "Restore distortion calibration for sensor",
"Restore", "Restore",
...@@ -2975,7 +2975,7 @@ if (MORE_BUTTONS) { ...@@ -2975,7 +2975,7 @@ if (MORE_BUTTONS) {
} }
LENS_DISTORTIONS.debugLevel=DEBUG_LEVEL; LENS_DISTORTIONS.debugLevel=DEBUG_LEVEL;
String [] extensions={".calib-tiff"}; String [] extensions={".calib-tiff"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"distortion calibration .calib-tiff files"); MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"distortion calibration .calib-tiff files");
String pathname=CalibrationFileManagement.selectFile(true, String pathname=CalibrationFileManagement.selectFile(true,
"Save distortion calibration for sensor (will add channel number when saving all)", "Save distortion calibration for sensor (will add channel number when saving all)",
"Save", "Save",
...@@ -6648,7 +6648,7 @@ if (MORE_BUTTONS) { ...@@ -6648,7 +6648,7 @@ if (MORE_BUTTONS) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL; DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
if (PIXEL_MAPPING==null) PIXEL_MAPPING=new PixelMapping((String)null,DEBUG_LEVEL); // ask for and load sensor calibration files if (PIXEL_MAPPING==null) PIXEL_MAPPING=new PixelMapping((String)null,DEBUG_LEVEL); // ask for and load sensor calibration files
String [] extensions={".eqr-tiff",".eqrect-tiff"}; String [] extensions={".eqr-tiff",".eqrect-tiff"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"equirectangular map "+extensions[0]+" files"); MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"equirectangular map "+extensions[0]+" files");
String pathname=CalibrationFileManagement.selectFile(true, String pathname=CalibrationFileManagement.selectFile(true,
"Save equirectangular calibration file (will add channel number suffix)", "Save equirectangular calibration file (will add channel number suffix)",
"Save", "Save",
...@@ -6838,8 +6838,8 @@ if (MORE_BUTTONS) { ...@@ -6838,8 +6838,8 @@ if (MORE_BUTTONS) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL; DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
if (PIXEL_MAPPING==null) PIXEL_MAPPING=new PixelMapping(null,true,DEBUG_LEVEL); if (PIXEL_MAPPING==null) PIXEL_MAPPING=new PixelMapping(null,true,DEBUG_LEVEL);
String [] extensions={".tiff",".jpeg"}; String [] extensions={".tiff",".jpeg"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = MultipleExtensionsFileFilter parFilter =
new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"channel images, may be scaled"); new MultipleExtensionsFileFilter("",extensions,"channel images, may be scaled");
String [] files=CalibrationFileManagement.selectFiles(false, String [] files=CalibrationFileManagement.selectFiles(false,
"Select channel images to warp to equirectangular", "Select channel images to warp to equirectangular",
"Select", "Select",
...@@ -6949,7 +6949,7 @@ if (MORE_BUTTONS) { ...@@ -6949,7 +6949,7 @@ if (MORE_BUTTONS) {
if (gd.wasCanceled()) return; if (gd.wasCanceled()) return;
String resultPath=gd.getNextString(); String resultPath=gd.getNextString();
if (gd.getNextBoolean() || (resultPath==null) || (resultPath.length()==0)){ if (gd.getNextBoolean() || (resultPath==null) || (resultPath.length()==0)){
CalibrationFileManagement.MultipleExtensionsFileFilter filter= new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"sensors map file ("+extList+")"); MultipleExtensionsFileFilter filter= new MultipleExtensionsFileFilter("",extensions,"sensors map file ("+extList+")");
resultPath=CalibrationFileManagement.selectFile( resultPath=CalibrationFileManagement.selectFile(
false, // smart false, // smart
true, // save true, // save
...@@ -9789,10 +9789,10 @@ if (MORE_BUTTONS) { ...@@ -9789,10 +9789,10 @@ if (MORE_BUTTONS) {
numStations= (int) gd.getNextNumber(); numStations= (int) gd.getNextNumber();
String [] grid_extensions={".tif",".tiff"}; String [] grid_extensions={".tif",".tiff"};
String [] src_extensions={".tif",".tiff"}; String [] src_extensions={".tif",".tiff"};
CalibrationFileManagement.MultipleExtensionsFileFilter gridFilter = MultipleExtensionsFileFilter gridFilter =
new CalibrationFileManagement.MultipleExtensionsFileFilter("grid",grid_extensions,"Calibrated grid files"); new MultipleExtensionsFileFilter("grid",grid_extensions,"Calibrated grid files");
CalibrationFileManagement.MultipleExtensionsFileFilter sourceFilter = MultipleExtensionsFileFilter sourceFilter =
new CalibrationFileManagement.MultipleExtensionsFileFilter("",src_extensions,"Source calibration images"); new MultipleExtensionsFileFilter("",src_extensions,"Source calibration images");
// CalibrationFileManagement.DirectoryContentsFilter gridDirFilter = // CalibrationFileManagement.DirectoryContentsFilter gridDirFilter =
// new CalibrationFileManagement.DirectoryContentsFilter (gridFilter, min_files, 0, null); // new CalibrationFileManagement.DirectoryContentsFilter (gridFilter, min_files, 0, null);
...@@ -9801,7 +9801,7 @@ if (MORE_BUTTONS) { ...@@ -9801,7 +9801,7 @@ if (MORE_BUTTONS) {
String [] sourceStationDirs = new String [numStations]; // directories of the source files per station String [] sourceStationDirs = new String [numStations]; // directories of the source files per station
for (int numStation=0;numStation<numStations;numStation++){ for (int numStation=0;numStation<numStations;numStation++){
CalibrationFileManagement.DirectoryChoser dc = new CalibrationFileManagement.DirectoryChoser( DirectoryChoser dc = new DirectoryChoser(
gridFilter, gridFilter,
min_files, min_files,
0, 0,
...@@ -10496,7 +10496,7 @@ if (MORE_BUTTONS) { ...@@ -10496,7 +10496,7 @@ if (MORE_BUTTONS) {
public void viewCSVFile(){ public void viewCSVFile(){
String [] extensions={".csv","CSV"}; String [] extensions={".csv","CSV"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"CSV table *.csv files"); MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"CSV table *.csv files");
String pathname=CalibrationFileManagement.selectFile( String pathname=CalibrationFileManagement.selectFile(
true, // smart, true, // smart,
false, false,
...@@ -15339,7 +15339,7 @@ private double [][] jacobianByJacobian(double [][] jacobian, boolean [] mask) { ...@@ -15339,7 +15339,7 @@ private double [][] jacobianByJacobian(double [][] jacobian, boolean [] mask) {
path= CalibrationFileManagement.selectFile(true, // save path= CalibrationFileManagement.selectFile(true, // save
"Save configuration selection", // title "Save configuration selection", // title
"Select configuration file", // button "Select configuration file", // button
new CalibrationFileManagement.MultipleExtensionsFileFilter(patterns, (useXML?"XML ":"")+"Configuration files ("+(useXML?"*.conf-xml":"*.conf")+")"), // filter new MultipleExtensionsFileFilter(patterns, (useXML?"XML ":"")+"Configuration files ("+(useXML?"*.conf-xml":"*.conf")+")"), // filter
directory); // may be "" directory); // may be ""
} else path+=patterns[0]; } else path+=patterns[0];
if (path==null) return; if (path==null) return;
...@@ -15392,7 +15392,7 @@ private double [][] jacobianByJacobian(double [][] jacobian, boolean [] mask) { ...@@ -15392,7 +15392,7 @@ private double [][] jacobianByJacobian(double [][] jacobian, boolean [] mask) {
path= CalibrationFileManagement.selectFile(false, // save path= CalibrationFileManagement.selectFile(false, // save
"Configuration file selection", // title "Configuration file selection", // title
"Read configuration file", // button "Read configuration file", // button
new CalibrationFileManagement.MultipleExtensionsFileFilter(patterns,(useXML?"XML ":"")+"Configuration files ("+(useXML?"*.conf-xml":"*.conf")+")"), // filter new MultipleExtensionsFileFilter(patterns,(useXML?"XML ":"")+"Configuration files ("+(useXML?"*.conf-xml":"*.conf")+")"), // filter
directory); // may be "" directory); // may be ""
} else { } else {
// do not add extension if it already exists // do not add extension if it already exists
...@@ -2,7 +2,6 @@ package com.elphel.imagej.calibration; ...@@ -2,7 +2,6 @@ package com.elphel.imagej.calibration;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.FilenameFilter;
import java.io.IOException; import java.io.IOException;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
...@@ -204,148 +203,4 @@ public class CalibrationFileManagement { ...@@ -204,148 +203,4 @@ public class CalibrationFileManagement {
} }
} }
} }
/* ======================================================================== */
public static class MultipleExtensionsFileFilter extends FileFilter implements FilenameFilter {
protected String [] patterns; // case insensitive
protected String description="JP4 files";
protected String prefix=""; // case sensitive
public MultipleExtensionsFileFilter (String prefix, String [] patterns,String description) {
this.prefix= prefix;
this.description=description;
this.patterns= patterns.clone();
}
public MultipleExtensionsFileFilter (String [] patterns,String description) {
this.description=description;
this.patterns=patterns.clone();
}
public MultipleExtensionsFileFilter (String [] patterns) {
this.patterns=patterns.clone();
}
@Override
public boolean accept (File file) {
int i;
String name=file.getName();
if (file.isDirectory()) return true;
if (!name.startsWith(this.prefix)) return false; // empty prefix OK
for (i=0;i<patterns.length;i++) {
if (name.toLowerCase().endsWith(patterns[i].toLowerCase())) return true;
}
return false;
}
@Override
public boolean accept (File dir, String name) { // directory - don't care here, only name
if (!name.startsWith(this.prefix)) return false; // empty prefix OK
for (int i=0;i<patterns.length;i++) {
if (name.toLowerCase().endsWith(patterns[i].toLowerCase())) return true;
}
return false;
}
@Override
public String getDescription() {
return description;
}
}
// select directory that contains matching MultipleExtensionsFileFilter in specified min/max quantities
//https://stackoverflow.com/questions/22302199/java-filefilter-to-select-certain-directories
// public static class DirectoryContentsFilter extends FileFilter implements FilenameFilter {
public static class DirectoryChoser extends javax.swing.JFileChooser {
private static final long serialVersionUID = 390855361964415146L;
protected MultipleExtensionsFileFilter multipleExtensionsFileFilter;
protected int min_files;
protected int max_files;
protected String description;
public DirectoryChoser (
MultipleExtensionsFileFilter multipleExtensionsFileFilter,
int min_files,
int max_files,
String description) // may be null;
{
this.multipleExtensionsFileFilter= multipleExtensionsFileFilter;
this.min_files = min_files;
this.max_files = max_files;
this.description = description;
}
@Override
public boolean isDirectorySelectionEnabled() {
// setOpenButtonState(this, false);
File file = getSelectedFile();
// File [] files = getSelectedFiles();
if(file == null){
// setOpenButtonState(this, true);
return true; // false;
}
// setOpenButtonState(this, false);
if (!file.isDirectory()) return false;
/*
// Can not make it work correctly with multiple selection, giving up for now
// get a list of all matching files
int num_match = file.list(multipleExtensionsFileFilter).length;
if (num_match < min_files) return false;
if ((max_files > 0) && (num_match > max_files)) {
return false;
}
*/
setOpenButtonState(this, true);
return true;
}
private void setOpenButtonState(java.awt.Container c, boolean flag) {
int len = c.getComponentCount();
for (int i = 0; i < len; i++) {
java.awt.Component comp = c.getComponent(i);
if (comp instanceof javax.swing.JButton) {
javax.swing.JButton b = (javax.swing.JButton)comp;
if ( b != null && b.getText() != null && b.getText().equals("Select") ) {
b.setEnabled(flag);
}
} else if (comp instanceof java.awt.Container) {
setOpenButtonState((java.awt.Container) comp, flag);
}
}
}
/*
@Override
public boolean accept (File file) {
if (!file.isDirectory()) return false;
// get a list of all matching files
int num_match = file.list(multipleExtensionsFileFilter).length;
if (num_match < min_files) return false;
if ((max_files > 0) && (num_match > max_files)) return false;
return true;
}
@Override
public boolean accept (File dir, String name) {
// No name filter, need to resolve
// Path dir_path = dir.toPath();
File target = Paths.get(dir.toString(),name).toFile();
return accept(target);
}
@Override
public String getDescription() { // if description is null - generate it
if (description == null) {
description = "Directories containing";
if (min_files > 0) description +=" not less than "+min_files;
if (max_files > 0) description +=" not more than "+max_files;
description += " "+multipleExtensionsFileFilter.description;
}
return description;
}
*/
}
} }
package com.elphel.imagej.calibration;
import java.io.File;
// select directory that contains matching MultipleExtensionsFileFilter in specified min/max quantities
//https://stackoverflow.com/questions/22302199/java-filefilter-to-select-certain-directories
// public static class DirectoryContentsFilter extends FileFilter implements FilenameFilter {
public class DirectoryChoser extends javax.swing.JFileChooser {
private static final long serialVersionUID = 390855361964415146L;
protected MultipleExtensionsFileFilter multipleExtensionsFileFilter;
protected int min_files;
protected int max_files;
protected String description;
public DirectoryChoser (
MultipleExtensionsFileFilter multipleExtensionsFileFilter,
int min_files,
int max_files,
String description) // may be null;
{
this.multipleExtensionsFileFilter= multipleExtensionsFileFilter;
this.min_files = min_files;
this.max_files = max_files;
this.description = description;
}
@Override
public boolean isDirectorySelectionEnabled() {
// setOpenButtonState(this, false);
File file = getSelectedFile();
// File [] files = getSelectedFiles();
if(file == null){
// setOpenButtonState(this, true);
return true; // false;
}
// setOpenButtonState(this, false);
if (!file.isDirectory()) return false;
/*
// Can not make it work correctly with multiple selection, giving up for now
// get a list of all matching files
int num_match = file.list(multipleExtensionsFileFilter).length;
if (num_match < min_files) return false;
if ((max_files > 0) && (num_match > max_files)) {
return false;
}
*/
setOpenButtonState(this, true);
return true;
}
private void setOpenButtonState(java.awt.Container c, boolean flag) {
int len = c.getComponentCount();
for (int i = 0; i < len; i++) {
java.awt.Component comp = c.getComponent(i);
if (comp instanceof javax.swing.JButton) {
javax.swing.JButton b = (javax.swing.JButton)comp;
if ( b != null && b.getText() != null && b.getText().equals("Select") ) {
b.setEnabled(flag);
}
} else if (comp instanceof java.awt.Container) {
setOpenButtonState((java.awt.Container) comp, flag);
}
}
}
/*
@Override
public boolean accept (File file) {
if (!file.isDirectory()) return false;
// get a list of all matching files
int num_match = file.list(multipleExtensionsFileFilter).length;
if (num_match < min_files) return false;
if ((max_files > 0) && (num_match > max_files)) return false;
return true;
}
@Override
public boolean accept (File dir, String name) {
// No name filter, need to resolve
// Path dir_path = dir.toPath();
File target = Paths.get(dir.toString(),name).toFile();
return accept(target);
}
@Override
public String getDescription() { // if description is null - generate it
if (description == null) {
description = "Directories containing";
if (min_files > 0) description +=" not less than "+min_files;
if (max_files > 0) description +=" not more than "+max_files;
description += " "+multipleExtensionsFileFilter.description;
}
return description;
}
*/
}
\ No newline at end of file
...@@ -677,8 +677,8 @@ import ij.text.TextWindow; ...@@ -677,8 +677,8 @@ import ij.text.TextWindow;
public DistortionCalibrationData ( public DistortionCalibrationData (
String [][] stationFilenames, String [][] stationFilenames,
String [] source_dirs, // directories of the source files per station String [] source_dirs, // directories of the source files per station
CalibrationFileManagement.MultipleExtensionsFileFilter gridFilter, MultipleExtensionsFileFilter gridFilter,
CalibrationFileManagement.MultipleExtensionsFileFilter sourceFilter, MultipleExtensionsFileFilter sourceFilter,
PatternParameters patternParameters, PatternParameters patternParameters,
EyesisCameraParameters eyesisCameraParameters, EyesisCameraParameters eyesisCameraParameters,
LaserPointer laserPointers, // as a backup if data is not available in the file LaserPointer laserPointers, // as a backup if data is not available in the file
...@@ -767,8 +767,8 @@ import ij.text.TextWindow; ...@@ -767,8 +767,8 @@ import ij.text.TextWindow;
public void setupDirDistortionCalibrationData ( public void setupDirDistortionCalibrationData (
String [][] stationFilenames, // per-station List of image set directories String [][] stationFilenames, // per-station List of image set directories
String [] source_dirs, // directories of the source files per station String [] source_dirs, // directories of the source files per station
CalibrationFileManagement.MultipleExtensionsFileFilter gridFilter, MultipleExtensionsFileFilter gridFilter,
CalibrationFileManagement.MultipleExtensionsFileFilter sourceFilter, MultipleExtensionsFileFilter sourceFilter,
PatternParameters patternParameters, PatternParameters patternParameters,
EyesisCameraParameters eyesisCameraParameters, EyesisCameraParameters eyesisCameraParameters,
LaserPointer laserPointers, // as a backup if data is not available in the file LaserPointer laserPointers, // as a backup if data is not available in the file
...@@ -789,8 +789,8 @@ import ij.text.TextWindow; ...@@ -789,8 +789,8 @@ import ij.text.TextWindow;
String dir, // grid image set directory that contains channel files (may be different timestamps) String dir, // grid image set directory that contains channel files (may be different timestamps)
String sdir, // source super directory that contains image set directories with files String sdir, // source super directory that contains image set directories with files
int num_chn, int num_chn,
CalibrationFileManagement.MultipleExtensionsFileFilter gridFilter, MultipleExtensionsFileFilter gridFilter,
CalibrationFileManagement.MultipleExtensionsFileFilter sourceFilter) MultipleExtensionsFileFilter sourceFilter)
{ {
this.station = station; this.station = station;
// this.dir = dir; // this.dir = dir;
...@@ -2945,7 +2945,7 @@ import ij.text.TextWindow; ...@@ -2945,7 +2945,7 @@ import ij.text.TextWindow;
ImagePlus[] gridImages ){ // null - use specified files ImagePlus[] gridImages ){ // null - use specified files
setupIndices(); setupIndices();
String [] extensions={".dcal-xml","-distcal.xml"}; String [] extensions={".dcal-xml","-distcal.xml"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"Distortion calibration *.dcal-xml files"); MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"Distortion calibration *.dcal-xml files");
String pathname=CalibrationFileManagement.selectFile( String pathname=CalibrationFileManagement.selectFile(
smart, smart,
false, false,
...@@ -3149,7 +3149,7 @@ import ij.text.TextWindow; ...@@ -3149,7 +3149,7 @@ import ij.text.TextWindow;
} }
public String selectAndSaveToXML(boolean smart, String defaultPath, String comment){ public String selectAndSaveToXML(boolean smart, String defaultPath, String comment){
String [] extensions={".dcal-xml","-distcal.xml"}; String [] extensions={".dcal-xml","-distcal.xml"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"Distortion calibration *.dcal-xml files"); MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"Distortion calibration *.dcal-xml files");
String pathname=CalibrationFileManagement.selectFile( String pathname=CalibrationFileManagement.selectFile(
smart, smart,
true, true,
......
...@@ -176,8 +176,8 @@ import ij.gui.GenericDialog; ...@@ -176,8 +176,8 @@ import ij.gui.GenericDialog;
defaultPaths[0]=""; defaultPaths[0]="";
} }
CalibrationFileManagement.MultipleExtensionsFileFilter sourceFilter = MultipleExtensionsFileFilter sourceFilter =
new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"Source files"); new MultipleExtensionsFileFilter("",extensions,"Source files");
String [] sourceFiles=null; String [] sourceFiles=null;
if (allFiles){ if (allFiles){
File dir= new File (this.sourceDirectory); File dir= new File (this.sourceDirectory);
...@@ -193,7 +193,7 @@ import ij.gui.GenericDialog; ...@@ -193,7 +193,7 @@ import ij.gui.GenericDialog;
sourceFiles = new String[fileList.length]; sourceFiles = new String[fileList.length];
for (int i=0;i<sourceFiles.length;i++) sourceFiles[i]=fileList[i].getPath(); for (int i=0;i<sourceFiles.length;i++) sourceFiles[i]=fileList[i].getPath();
} else { } else {
new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"Source files"); new MultipleExtensionsFileFilter("",extensions,"Source files");
sourceFiles=CalibrationFileManagement.selectFiles(false, sourceFiles=CalibrationFileManagement.selectFiles(false,
"Select Source files, saved as TIFF", "Select Source files, saved as TIFF",
"Select", "Select",
......
...@@ -1164,7 +1164,7 @@ public class EyesisAberrations { ...@@ -1164,7 +1164,7 @@ public class EyesisAberrations {
continue; continue;
} }
String [] extensions={filename}; // just this one file String [] extensions={filename}; // just this one file
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,filename); MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,filename);
String pathname=CalibrationFileManagement.selectFile( String pathname=CalibrationFileManagement.selectFile(
false, false,
false, false,
......
...@@ -180,7 +180,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit ...@@ -180,7 +180,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
DistortionCalibrationData distortionCalibrationData // per-image parameters DistortionCalibrationData distortionCalibrationData // per-image parameters
) { ) {
String [] extensions={".stg-xml","-strategy.xml"}; String [] extensions={".stg-xml","-strategy.xml"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"*.stg-xml files"); MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"*.stg-xml files");
String pathname=CalibrationFileManagement.selectFile( String pathname=CalibrationFileManagement.selectFile(
smart, smart,
false, false,
...@@ -359,7 +359,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit ...@@ -359,7 +359,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
boolean smart, boolean smart,
String defaultPath){ String defaultPath){
String [] extensions={".stg-xml","-strategy.xml"}; String [] extensions={".stg-xml","-strategy.xml"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"*.stg-xml files"); MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"*.stg-xml files");
if ((defaultPath==null) || (defaultPath.length()==0)){ if ((defaultPath==null) || (defaultPath.length()==0)){
defaultPath=this.pathName; defaultPath=this.pathName;
} }
......
...@@ -43,7 +43,6 @@ import java.util.concurrent.atomic.AtomicInteger; ...@@ -43,7 +43,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration; import org.apache.commons.configuration.XMLConfiguration;
import com.elphel.imagej.calibration.CalibrationFileManagement.MultipleExtensionsFileFilter;
import com.elphel.imagej.common.ShowDoubleFloatArrays; import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.common.WindowTools; import com.elphel.imagej.common.WindowTools;
...@@ -5037,7 +5036,7 @@ public boolean LevenbergMarquardt( ...@@ -5037,7 +5036,7 @@ public boolean LevenbergMarquardt(
boolean smart, // do not open dialog if default matches boolean smart, // do not open dialog if default matches
String defaultPath){ // x,y,r String defaultPath){ // x,y,r
String [] extensions={".history-xml"}; String [] extensions={".history-xml"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"*.history-xml files"); MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"*.history-xml files");
String pathname=CalibrationFileManagement.selectFile( String pathname=CalibrationFileManagement.selectFile(
smart, smart,
false, false,
...@@ -9589,7 +9588,7 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4] ...@@ -9589,7 +9588,7 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4]
path= CalibrationFileManagement.selectFile(true, // save path= CalibrationFileManagement.selectFile(true, // save
"Save Field LMA Strategy selection", // title "Save Field LMA Strategy selection", // title
"Select Field LMA Strategy file", // button "Select Field LMA Strategy file", // button
new CalibrationFileManagement.MultipleExtensionsFileFilter(patterns, new MultipleExtensionsFileFilter(patterns,
"Strategy files (*.fstg-xml)"), // filter "Strategy files (*.fstg-xml)"), // filter
directory); // may be "" directory); // may be ""
} else path+=patterns[0]; } else path+=patterns[0];
...@@ -9628,7 +9627,7 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4] ...@@ -9628,7 +9627,7 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4]
path= CalibrationFileManagement.selectFile(false, // save path= CalibrationFileManagement.selectFile(false, // save
"Field LMA Strategy selection", // title "Field LMA Strategy selection", // title
"Select Field LMA Strategy file", // button "Select Field LMA Strategy file", // button
new CalibrationFileManagement.MultipleExtensionsFileFilter(patterns, new MultipleExtensionsFileFilter(patterns,
"Strategy files (*.fstg-xml)"), // filter "Strategy files (*.fstg-xml)"), // filter
directory); // may be "" directory); // may be ""
} else { } else {
......
package com.elphel.imagej.calibration;
import java.io.File;
import java.io.FilenameFilter;
import javax.swing.filechooser.FileFilter;
/* ======================================================================== */
public class MultipleExtensionsFileFilter extends FileFilter implements FilenameFilter {
protected String [] patterns; // case insensitive
protected String description="JP4 files";
protected String [] prefixes= {""}; // case sensitive
// prefix/prefixeas can not be null - ambiguity
public MultipleExtensionsFileFilter (String prefix, String [] patterns,String description) {
this.prefixes= new String[1];
this.prefixes[0] = prefix;
this.description=description;
this.patterns= patterns.clone();
}
public MultipleExtensionsFileFilter (String [] prefixes, String [] patterns,String description) {
this.prefixes= prefixes;
this.description=description;
this.patterns= patterns.clone();
}
public MultipleExtensionsFileFilter (String [] patterns,String description) {
this.description=description;
this.patterns=patterns.clone();
}
public MultipleExtensionsFileFilter (String [] patterns) {
this.patterns=patterns.clone();
}
@Override
public boolean accept (File file) {
int i;
String name=file.getName();
if (file.isDirectory()) return true;
if (!testPrefix(name)) return false;
for (i=0;i<patterns.length;i++) {
if (name.toLowerCase().endsWith(patterns[i].toLowerCase())) return true;
}
return false;