当前位置: 首页>>代码示例>>Java>>正文


Java OpenDialog.getDefaultDirectory方法代码示例

本文整理汇总了Java中ij.io.OpenDialog.getDefaultDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java OpenDialog.getDefaultDirectory方法的具体用法?Java OpenDialog.getDefaultDirectory怎么用?Java OpenDialog.getDefaultDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ij.io.OpenDialog的用法示例。


在下文中一共展示了OpenDialog.getDefaultDirectory方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
}
 
开发者ID:fiji,项目名称:3D_Viewer,代码行数:26,代码来源:Executer.java

示例2: 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;
}
 
开发者ID:aherbert,项目名称:GDSC,代码行数:19,代码来源:FileMatchCalculator.java

示例3: savePointList

import ij.io.OpenDialog; //导入方法依赖的package包/类
public void savePointList() {
	String dir = OpenDialog.getDefaultDirectory();
	String n = this.getName();
	if (image != null) {
		final FileInfo fi = image.getFileInfo();
		dir = fi.directory;
		n = fi.fileName;
	}
	points.save(dir, n);
}
 
开发者ID:fiji,项目名称:3D_Viewer,代码行数:11,代码来源:ContentInstant.java

示例4: savePointList

import ij.io.OpenDialog; //导入方法依赖的package包/类
public void savePointList() {
	String dir = OpenDialog.getDefaultDirectory();
	String fileName = getName();
	final ImagePlus image = contents.firstEntry().getValue().image;
	if (image != null) {
		final FileInfo fi = image.getFileInfo();
		dir = fi.directory;
		fileName = fi.fileName;
	}
	final SaveDialog sd =
		new SaveDialog("Save points annotation file as...", dir, fileName,
			".points");
	if (sd.getFileName() == null) return;

	final File file = new File(sd.getDirectory(), sd.getFileName());
	if (file.exists() &&
		!IJ.showMessageWithCancel("File exists", "Overwrite " + file + "?")) return;
	try {
		final PrintStream out = new PrintStream(file);
		for (final Integer frame : contents.keySet()) {
			final ContentInstant ci = contents.get(frame);
			if (ci.getPointList().size() != 0) {
				out.println("# frame " + frame);
				ci.savePointList(out);
			}
		}
		out.close();
	}
	catch (final IOException e) {
		IJ.error("Could not save points to " + file);
	}
}
 
开发者ID:fiji,项目名称:3D_Viewer,代码行数:33,代码来源:Content.java

示例5: askForXMLTemplate

import ij.io.OpenDialog; //导入方法依赖的package包/类
/** Ask for the user to provide a template XML file to extract a root TemplateThing. */
public TemplateThing askForXMLTemplate(final Project project) {
	// ask for an .xml file or a .dtd file
	//fd.setFilenameFilter(new XMLFileFilter(XMLFileFilter.BOTH));
	final OpenDialog od = new OpenDialog("Select XML Template",
					OpenDialog.getDefaultDirectory(),
					null);
	final String filename = od.getFileName();
	if (null == filename || filename.toLowerCase().startsWith("null")) return null;
	// if there is a path, read it out if possible
	String dir = od.getDirectory();
	if (null == dir) return null;
	if (IJ.isWindows()) dir = dir.replace('\\', '/');
	if (!dir.endsWith("/")) dir += "/";
	TemplateThing[] roots;
	try {
		roots = DTDParser.extractTemplate(dir + filename);
	} catch (final Exception e) {
		IJError.print(e);
		return null;
	}
	if (null == roots || roots.length < 1) return null;
	if (roots.length > 1) {
		Utils.showMessage("Found more than one root.\nUsing first root only.");
	}
	return roots[0];
}
 
开发者ID:trakem2,项目名称:TrakEM2,代码行数:28,代码来源:Loader.java

示例6: execCommand

import ij.io.OpenDialog; //导入方法依赖的package包/类
/**
 * Executes console commands. Outputs one of the following exit status:
 * <p>
 * "0": Executed a a self-contained command that need no follow-up. null:
 * Failed to retrieve a path. non-null string: A successfully retrieved path
 *
 * @see #interpretCommand
 */
String execCommand(final String cmd) {

	// Case "0": Self-contained commands that need no follow-up
	String exitStatus = String.valueOf(0);
	if (cmd.startsWith("quit")) {
		quit();
		return exitStatus;
	} else if (cmd.startsWith("help")) {
		new ij.gui.HTMLDialog("Commander Help", helpMessage(), false);
		return exitStatus;
	} else if (cmd.startsWith("ls")) {
		printList();
		return exitStatus;
	} else if (cmd.equals("options")) {
		showOptionsDialog();
		return exitStatus;
	} else if (cmd.startsWith("refresh")) {
		freezeStatusBar = false;
		return exitStatus;
	} else if (cmd.startsWith("..")) {
		selectParentDirectory(path);
		return exitStatus;
	} else if (cmd.equals("bookmark")) {
		addBookmark();
		return exitStatus;
	} else if (cmd.equals("cd")) {
		cdToDirectory(path);
		return exitStatus;
	} else if (cmd.startsWith("info")) {
		showInfo();
		return exitStatus;
	}

	// Remaining cases: Commands that only retrieve paths
	exitStatus = null;
	if (cmd.startsWith("goto")) {
		exitStatus = IJ.getDirectory("Choose new directory");
	} else if (cmd.startsWith("~")) {
		exitStatus = IJ.getDirectory("home");
	} else if (cmd.startsWith("imp")) {
		exitStatus = IJ.getDirectory("image");
	} else if (cmd.equals("luts")) {
		exitStatus = IJ.getDirectory(cmd);
	} else if (cmd.equals("macros")) {
		exitStatus = IJ.getDirectory(cmd);
	} else if (cmd.equals("plugins")) {
		exitStatus = IJ.getDirectory(cmd);
	} else if (cmd.startsWith("pwd")) {
		exitStatus = OpenDialog.getDefaultDirectory();
	} else if (cmd.equals("ij")) {
		exitStatus = IJ.getDirectory("imagej");
	} else if (cmd.startsWith("tmp")) {
		exitStatus = IJ.getDirectory("temp");
	} else if (cmd.equals("myr")) {
		exitStatus = Utils.getMyRoutinesDir();
	} else if (cmd.equals("lib")) {
		exitStatus = Utils.getLibDir();
	} else if (cmd.equals("samples")) {
		exitStatus = IJ.getDirectory("imagej") + cmd;
	} else if (cmd.equals("scripts")) {
		exitStatus = IJ.getDirectory("imagej") + cmd;
	}

	if (exitStatus != null && exitStatus.isEmpty())
		exitStatus = null;

	return exitStatus;

}
 
开发者ID:tferr,项目名称:Scripts,代码行数:78,代码来源:Commander.java

示例7: exportSVG

import ij.io.OpenDialog; //导入方法依赖的package包/类
static public void exportSVG(ProjectThing thing, double z_scale) {
	StringBuffer data = new StringBuffer();
	data.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n")
	    .append("<svg\n")
	    .append("\txmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n")
	    .append("\txmlns:cc=\"http://web.resource.org/cc/\"\n")
	    .append("\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n")
	    .append("\txmlns:svg=\"http://www.w3.org/2000/svg\"\n")
	    .append("\txmlns=\"http://www.w3.org/2000/svg\"\n")
	    //.append("\twidth=\"1500\"\n")
	    //.append("\theight=\"1000\"\n")
	    .append("\tid=\"").append(thing.getProject().toString()).append("\">\n")
	;
	// traverse the tree at node 'thing'
	thing.exportSVG(data, z_scale, "\t");

	data.append("</svg>");

	// save the file
	final SaveDialog sd = new SaveDialog("Save .svg", OpenDialog.getDefaultDirectory(), "svg");
	String dir = sd.getDirectory();
	if (null == dir) return;
	if (IJ.isWindows()) dir = dir.replace('\\', '/');
	if (!dir.endsWith("/")) dir += "/";
	String file_name = sd.getFileName();
	String file_path = dir + file_name;
	File f = new File(file_path);
	if (f.exists()) {
		YesNoCancelDialog d = new YesNoCancelDialog(IJ.getInstance(), "Overwrite?", "File " + file_name + " exists! Overwrite?");
		if (!d.yesPressed()) {
			return;
		}
	}
	String contents = data.toString();
	try {
		DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(f), data.length()));
		dos.writeBytes(contents);
		dos.flush();
	} catch (Exception e) {
		IJError.print(e);
		Utils.log("ERROR: Most likely did NOT save your file.");
	}
}
 
开发者ID:trakem2,项目名称:TrakEM2,代码行数:44,代码来源:Render.java

示例8: openStack

import ij.io.OpenDialog; //导入方法依赖的package包/类
/** A dialog to open a stack, making sure there is enough memory for it. */
synchronized public ImagePlus openStack() {
	final OpenDialog od = new OpenDialog("Select stack", OpenDialog.getDefaultDirectory(), null);
	final String file_name = od.getFileName();
	if (null == file_name || file_name.toLowerCase().startsWith("null")) return null;
	String dir = od.getDirectory().replace('\\', '/');
	if (!dir.endsWith("/")) dir += "/";

	final File f = new File(dir + file_name);
	if (!f.exists()) {
		Utils.showMessage("File " + dir + file_name  + " does not exist.");
		return null;
	}
	// avoid opening trakem2 projects
	if (file_name.toLowerCase().endsWith(".xml")) {
		Utils.showMessage("Cannot import " + file_name + " as a stack.");
		return null;
	}
	// estimate file size: assumes an uncompressed tif, or a zipped tif with an average compression ratio of 2.5
	long size = f.length() / 1024; // in megabytes
	if (file_name.length() -4 == file_name.toLowerCase().lastIndexOf(".zip")) {
		size = (long)(size * 2.5); // 2.5 is a reasonable compression ratio estimate based on my experience
	}
	releaseToFit(size);
	ImagePlus imp_stack = null;
	try {
		IJ.redirectErrorMessages();
		imp_stack = openImagePlus(f.getCanonicalPath());
	} catch (final Exception e) {
		IJError.print(e);
		return null;
	}
	if (null == imp_stack) {
		Utils.showMessage("Can't open the stack.");
		return null;
	} else if (1 == imp_stack.getStackSize()) {
		Utils.showMessage("Not a stack!");
		return null;
	}
	return imp_stack; // the open... command
}
 
开发者ID:trakem2,项目名称:TrakEM2,代码行数:42,代码来源:Loader.java


注:本文中的ij.io.OpenDialog.getDefaultDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。