本文整理汇总了Java中ij.io.OpenDialog类的典型用法代码示例。如果您正苦于以下问题:Java OpenDialog类的具体用法?Java OpenDialog怎么用?Java OpenDialog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OpenDialog类属于ij.io包,在下文中一共展示了OpenDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromFile
import ij.io.OpenDialog; //导入依赖的package包/类
/**
* From file.
*
* @return the image plus
*/
public ImagePlus fromFile(){
File f = getFile();
if(f == null) return null;
OpenDialog.setLastDirectory(f.getParentFile().getAbsolutePath());
ImagePlus inImg = null;
inImg = openImg.openFolder(f.getAbsolutePath());
if (inImg == null)
inImg = open.openImage(f.getAbsolutePath());
if(checkImage(inImg)){
addImageName(inImg.getTitle());
inImg.getTitle();
return inImg;
}else
return null;
}
示例2: loadHomographyMatrixFromFile
import ij.io.OpenDialog; //导入依赖的package包/类
float[][] loadHomographyMatrixFromFile() {
OpenDialog od = new OpenDialog("Choose a file containing 3x3 Homography Matrix" + " (" + title + ")", null);
String dir = od.getDirectory();
String fileName = od.getFileName();
if (fileName == null)
return null;
String fullName = dir + fileName;
float[][] res = new float[3][3];
try {
Scanner in = new Scanner(new File(fullName));
for (int i=0; i<3; i++)
for (int j=0; j<3; j++)
res[i][j] = in.nextFloat();
in.close();
} catch (FileNotFoundException e) {
IJ.error("SURF: loadHomographyFromFile", e.getMessage());
res = null;
}
return res;
}
示例3: run
import ij.io.OpenDialog; //导入依赖的package包/类
@Override
public void run(final String arg) {
final OpenDialog openDialog = new OpenDialog("Open as VTK...", arg);
if (openDialog.getFileName() == null) {
return;
}
final File file = new File(openDialog.getDirectory(), openDialog.getFileName());
try {
IJ.showStatus("Opening VTK image: " + file.getName());
final long tStart = System.currentTimeMillis();
final ImagePlus imp = VtkDecoder.open(file);
final long tStop = System.currentTimeMillis();
imp.show();
IJ.showStatus("VTK image loaded in " + (tStop - tStart) + " ms.");
} catch (final VtkImageException ex) {
IJ.showMessage(DIALOG_CAPTION, "Error opening image: '"
+ file.getAbsolutePath() + "'\n" + ex.getMessage());
}
}
示例4: main
import ij.io.OpenDialog; //导入依赖的package包/类
public static void main(String[] args) {
new ImageJ();
OpenDialog od = new OpenDialog("Please select the reconstruction file.");
RingArtifactCorrector rac = new RingArtifactCorrector();
Grid3D reko = rac.loadReconstruction(od.getDirectory()+od.getFileName());
Grid2D rekoS = reko.getSubGrid(0); //extract single slice from 3D grid
rekoS.show("Original Image");
//option examples
//rac.setShowSteps(true); //displays all interim steps of the correction process
//rac.setRadialFilterWidth(50); //sets the filter width in radial direction
//setAzimuthalFilterWidth (50); //sets the filter width in azimuthal direction
Grid2D correctedReko = rac.getRingArtifactCorrectedImage(rekoS);
correctedReko.show("Ring artifact corrected");
}
示例5: loadPoints
import ij.io.OpenDialog; //导入依赖的package包/类
/**
* Load the points from the point handlers.
*/
private void loadPoints ()
{
final OpenDialog od = new OpenDialog("Load Points", "");
final String path = od.getDirectory();
final String filename = od.getFileName();
if ((path == null) || (filename == null)) return;
Stack <Point> sourceStack = new Stack <Point> ();
Stack <Point> targetStack = new Stack <Point> ();
MiscTools.loadPoints(path+filename,sourceStack,targetStack);
sourcePh.removePoints();
targetPh.removePoints();
while ((!sourceStack.empty()) && (!targetStack.empty())) {
Point sourcePoint = (Point)sourceStack.pop();
Point targetPoint = (Point)targetStack.pop();
sourcePh.addPoint(sourcePoint.x, sourcePoint.y);
targetPh.addPoint(targetPoint.x, targetPoint.y);
}
}
示例6: loadTransformation
import ij.io.OpenDialog; //导入依赖的package包/类
/**
* Load a transformation and apply it to the source image.
*/
private void loadTransformation ()
{
final OpenDialog od = new OpenDialog("Load Elastic Transformation", "");
final String path = od.getDirectory();
final String filename = od.getFileName();
if ((path == null) || (filename == null))
return;
String fn_tnf = path+filename;
int intervals = MiscTools.numberOfIntervalsOfTransformation(fn_tnf);
double [][]cx = new double[intervals+3][intervals+3];
double [][]cy = new double[intervals+3][intervals+3];
MiscTools.loadTransformation(fn_tnf, cx, cy);
// Apply transformation
dialog.applyTransformationToSource(intervals, cx, cy);
}
示例7: loadRawTransformation
import ij.io.OpenDialog; //导入依赖的package包/类
/**
* Load a raw transformation and apply it to the source image.
*/
private void loadRawTransformation ()
{
final OpenDialog od = new OpenDialog("Load Raw Transformation", "");
final String path = od.getDirectory();
final String filename = od.getFileName();
if ((path == null) || (filename == null))
return;
String fn_tnf = path+filename;
double [][]transformation_x = new double[this.targetImp.getHeight()][this.targetImp.getWidth()];
double [][]transformation_y = new double[this.targetImp.getHeight()][this.targetImp.getWidth()];
MiscTools.loadRawTransformation(fn_tnf, transformation_x, transformation_y);
// Apply transformation
dialog.applyRawTransformationToSource(transformation_x, transformation_y);
}
示例8: importFile
import ij.io.OpenDialog; //导入依赖的package包/类
protected void importFile(final String dialogTitle, final String extension,
final String formatDescription)
{
final OpenDialog od =
new OpenDialog(dialogTitle, OpenDialog.getDefaultDirectory(), null);
final String filename = od.getFileName();
if (null == filename) return;
if (!filename.toLowerCase().endsWith(extension)) {
IJ.showMessage("Must select a " + formatDescription + " file!");
return;
}
final String path =
new StringBuilder(od.getDirectory()).append(filename).toString();
IJ.log("path: " + path);
Object ob;
try {
ob = univ.addContentLater(path);
record(IMPORT, path);
}
catch (final Exception e) {
e.printStackTrace();
ob = null;
}
if (null == ob) IJ.showMessage("Could not load the file:\n" + path);
}
示例9: loadSession
import ij.io.OpenDialog; //导入依赖的package包/类
public void loadSession() {
final OpenDialog sd =
new OpenDialog("Open session...", "session", ".scene");
final String dir = sd.getDirectory();
final String name = sd.getFileName();
if (dir == null || name == null) return;
new Thread() {
{
setPriority(Thread.NORM_PRIORITY);
}
@Override
public void run() {
try {
univ.loadSession(dir + name);
}
catch (final Exception e) {
IJ.error(e.getMessage());
}
}
}.start();
}
示例10: run
import ij.io.OpenDialog; //导入依赖的package包/类
@Override
public void run(String arg) {
if (arg.equals("")) {
final OpenDialog od = new OpenDialog("AmiraFile", null);
if (od.getDirectory() == null) return; // canceled
arg = od.getDirectory() + od.getFileName();
}
final Image3DUniverse universe = new Image3DUniverse();
try {
addMeshes(universe, arg);
}
catch (final IOException e) {
IJ.error("Could not read '" + arg + "': " + e);
return;
}
universe.show();
}
示例11: createFilePeakResults
import ij.io.OpenDialog; //导入依赖的package包/类
private TextFilePeakResults createFilePeakResults(MemoryPeakResults results2)
{
if (!saveClassifications)
return null;
String[] path = Utils.decodePath(classificationsFile);
OpenDialog chooser = new OpenDialog("Classifications_File", path[0], path[1]);
if (chooser.getFileName() != null)
{
classificationsFile = chooser.getDirectory() + chooser.getFileName();
TextFilePeakResults r = new TextFilePeakResults(classificationsFile, false, false);
r.copySettings(results2);
r.begin();
return r;
}
return null;
}
示例12: saveImage
import ij.io.OpenDialog; //导入依赖的package包/类
/**
* Save the image to a TIFF file
*
* @param imp
*/
private void saveImage(ImagePlus imp)
{
if (!settings.getSaveImage())
return;
String[] path = Utils.decodePath(settings.getImageFilename());
OpenDialog chooser = new OpenDialog("Image_File", path[0], path[1]);
if (chooser.getFileName() != null)
{
settings.setImageFilename(chooser.getDirectory() + chooser.getFileName());
settings.setImageFilename(Utils.replaceExtension(settings.getImageFilename(), "tiff"));
FileSaver fs = new FileSaver(imp);
boolean ok;
if (imp.getStackSize() > 1)
ok = fs.saveAsTiffStack(settings.getImageFilename());
else
ok = fs.saveAsTiff(settings.getImageFilename());
// The following call throws a NoSuchMethodError.
// ok = IJ.saveAsTiff(imp, settings.imageFilename);
if (!ok)
IJ.log("Failed to save image to file: " + settings.getImageFilename());
}
}
示例13: saveImageResults
import ij.io.OpenDialog; //导入依赖的package包/类
private void saveImageResults(MemoryPeakResults results)
{
if (!settings.getSaveImageResults())
return;
String[] path = Utils.decodePath(settings.getImageResultsFilename());
OpenDialog chooser = new OpenDialog("Image_Results_File", path[0], path[1]);
if (chooser.getFileName() != null)
{
settings.setImageResultsFilename(chooser.getDirectory() + chooser.getFileName());
settings.setImageResultsFilename(Utils.replaceExtension(settings.getImageResultsFilename(), "xls"));
TextFilePeakResults r = new TextFilePeakResults(settings.getImageResultsFilename(), false);
r.copySettings(results);
r.begin();
r.addAll(results.toArray());
r.end();
}
}
示例14: mouseClicked
import ij.io.OpenDialog; //导入依赖的package包/类
public void mouseClicked(MouseEvent e)
{
if (e.getClickCount() > 1) // Double-click
{
TextField text;
String title;
if (e.getSource() == text1)
{
text = text1;
title = "Coordinate_file_1";
}
else
{
text = text2;
title = "Coordinate_file_2";
}
String[] path = decodePath(text.getText());
OpenDialog chooser = new OpenDialog(title, path[0], path[1]);
if (chooser.getFileName() != null)
{
text.setText(chooser.getDirectory() + chooser.getFileName());
}
}
}
示例15: decodePath
import ij.io.OpenDialog; //导入依赖的package包/类
private String[] decodePath(String path)
{
String[] result = new String[2];
int i = path.lastIndexOf('/');
if (i == -1)
i = path.lastIndexOf('\\');
if (i > 0)
{
result[0] = path.substring(0, i + 1);
result[1] = path.substring(i + 1);
}
else
{
result[0] = OpenDialog.getDefaultDirectory();
result[1] = path;
}
return result;
}