• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SaveDialog类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中ij.io.SaveDialog的典型用法代码示例。如果您正苦于以下问题:Java SaveDialog类的具体用法?Java SaveDialog怎么用?Java SaveDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: saveText

import ij.io.SaveDialog; //导入依赖的package包/类
private void saveText(String title, double[] data) throws IOException {
  SaveDialog saveDialog = new SaveDialog("Save", title, ".txt");

  File file = new File(saveDialog.getDirectory() + saveDialog.getFileName());
  FileWriter filewriter = new FileWriter(file);

  for (int i=0; i<data.length; i++) {
    filewriter.write(String.valueOf(data[i]) + "\n");
    if (i%10000 == 0) {
      IJ.log((double)i/data.length + "%");
    }
  }
  IJ.log("100%");

  // ProgressBar pb = new ProgressBar(400, 100);
  // for (int i=0; i<data.length; i++) {
  //   filewriter.write(String.valueOf(data[i]));
  //   pb.show((double)i/data.length);
  // }

  filewriter.close();
}
 
开发者ID:Y-Ichioka,项目名称:DigitalWatermarkPlugins,代码行数:23,代码来源:Read_32bit_Image.java


示例2: write

import ij.io.SaveDialog; //导入依赖的package包/类
private static String write(String string, String path, boolean append) {
	if (path==null || path.equals("")) {
		String msg = append?"Append String...":"Save String...";
		SaveDialog sd = new SaveDialog(msg, "Untitled", ".txt");
		String name = sd.getFileName();
		if (name==null) return null;
		path = sd.getDirectory() + name;
	}
	try {
		BufferedWriter out = new BufferedWriter(new FileWriter(path, append));
		out.write(string);
		out.close();
	} catch (IOException e) {
		return ""+e;
	}
	return null;
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:18,代码来源:IJJazzOMR.java


示例3: run

import ij.io.SaveDialog; //导入依赖的package包/类
public void run(String arg) {
	ImagePlus imp = WindowManager.getCurrentImage();
	if (imp == null) {
		IJ.showMessage(noImages);
		return;
	}

	String name = arg;
	if (arg == null || arg.equals("")) {
		name = imp.getTitle();
	}
	
	SaveDialog sd = new SaveDialog(plugInName+"...", name, ".nrrd");
	String file = sd.getFileName();
	if (file == null) return;
	String directory = sd.getDirectory();
	save(imp, directory, file);
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:19,代码来源:NrrdFileWriter.java


示例4: promptForFile

import ij.io.SaveDialog; //导入依赖的package包/类
public static File promptForFile(final String title, final String suggestion,
	final String ending)
{
	final SaveDialog sd = new SaveDialog(title, suggestion, ending);
	final String dir = sd.getDirectory();
	if (null == dir) return null;
	String filename = sd.getFileName();
	if (!filename.toLowerCase().endsWith(ending)) filename += ending;

	final File file = new File(dir, filename);
	// check if file exists
	if (!IJ.isMacOSX()) {
		if (file.exists()) {
			final YesNoCancelDialog yn =
				new YesNoCancelDialog(IJ.getInstance(), "Overwrite?", "File  " +
					filename + " exists!\nOverwrite?");
			if (!yn.yesPressed()) return null;
		}
	}

	return file;
}
 
开发者ID:fiji,项目名称:3D_Viewer,代码行数:23,代码来源:Executer.java


示例5: saveAsU3D

import ij.io.SaveDialog; //导入依赖的package包/类
public void saveAsU3D() {
	final SaveDialog sd = new SaveDialog("Save meshes as u3d...", "", ".u3d");
	final String dir = sd.getDirectory();
	final String name = sd.getFileName();
	if (dir == null || name == null) return;
	try {
		U3DExporter.export(univ, dir + name);
		final String tex = U3DExporter.getTexStub(univ, dir + name);
		IJ.log("% Here are a few latex example lines");
		IJ.log("% You can compile them for example via");
		IJ.log("% pdflatex yourfilename.tex");
		IJ.log("");
		IJ.log(tex);
		record(EXPORT, "U3D", dir + name);
	}
	catch (final Exception e) {
		IJ.error(e.getMessage());
	}
}
 
开发者ID:fiji,项目名称:3D_Viewer,代码行数:20,代码来源:Executer.java


示例6: showPathDialog

import ij.io.SaveDialog; //导入依赖的package包/类
static String showPathDialog(final String title, final String msg) {
	final GenericDialog gd = new GenericDialog(title);
	gd.addMessage(msg);
	final Panel p = new Panel(new FlowLayout());
	final TextField tf = new TextField(30);
	p.add(tf);
	final Button b = new Button("...");
	p.add(b);
	b.addActionListener(new ActionListener() {

		@Override
		public void actionPerformed(final ActionEvent e) {
			final SaveDialog sd = new SaveDialog("Select path", "untitled", ".obj");
			final String dir = sd.getDirectory();
			final String file = sd.getFileName();
			final File f = new File(dir, file);
			tf.setText(f.getAbsolutePath());
		}
	});
	gd.addPanel(p);
	gd.showDialog();
	if (gd.wasCanceled()) return null;
	return new File(tf.getText()).getAbsolutePath();
}
 
开发者ID:fiji,项目名称:3D_Viewer,代码行数:25,代码来源:SaveSession.java


示例7: saveText

import ij.io.SaveDialog; //导入依赖的package包/类
private void saveText(String title, String out) throws IOException {
  SaveDialog saveDialog = new SaveDialog("Save", title, ".txt");

  File file = new File(saveDialog.getDirectory() + saveDialog.getFileName());
  FileWriter filewriter = new FileWriter(file);

  filewriter.write(out);
  filewriter.close();
}
 
开发者ID:Y-Ichioka,项目名称:DigitalWatermarkPlugins,代码行数:10,代码来源:Cross_Correlation_Function.java


示例8: run

import ij.io.SaveDialog; //导入依赖的package包/类
@Override
public void run(String arg) {
	
	List<InterestPoint> ipts = IJFacade.getLastResult();
	if (ipts == null) {
		IJ.error(title, "No cached result.\nRun 'Find Interest Points' first.");
		return;
	}
	
	String proposedName = "surf";
	
	ImagePlus img = WindowManager.getCurrentImage();
	if (img != null) {
		proposedName = img.getTitle().split(":")[0] + "__" + proposedName;
	}
	
	SaveDialog sd = new SaveDialog(title, proposedName, ".txt");
	String dir = sd.getDirectory();
	String fileName = sd.getFileName();
	if (fileName == null) 
		return;
	String fullName = dir + fileName;
	boolean inclDescriptor = true; // TODO make true by default + dialog!
	IJ.showStatus("SURF: Saving Interest Points to File " + fullName);
	
	InterestPoint.saveToFile(ipts, fullName, inclDescriptor);
	
}
 
开发者ID:remipassmoilesel,项目名称:imagej-surf,代码行数:29,代码来源:Save_Interest_Points_To_File.java


示例9: save

import ij.io.SaveDialog; //导入依赖的package包/类
void save() {
	TextArea ta1 = gd.getTextArea1();
	ta1.selectAll();
	String text = ta1.getText();
	ta1.select(0, 0);
	if (text==null || text.length()==0)
		return;
	text += "\n";
	SaveDialog sd = new SaveDialog("Save as Text...", "kernel", ".txt");
	String name = sd.getFileName();
	if (name == null)
		return;
	String directory = sd.getDirectory();
	PrintWriter pw = null;
	try {
		FileOutputStream fos = new FileOutputStream(directory+name);
		BufferedOutputStream bos = new BufferedOutputStream(fos);
		pw = new PrintWriter(bos);
	}
	catch (IOException e) {
		IJ.error("" + e);
		return;
	}
	IJ.wait(250);  // give system time to redraw ImageJ window
	pw.print(text);
	pw.close();
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:28,代码来源:SME_ENS_Convolver.java


示例10: run

import ij.io.SaveDialog; //导入依赖的package包/类
/**
 * Main processing method for the VtkEncoder plugin
 *
 * @param arg If equal "ASCII" file will be saved in text format otherwise in binary format
 *            (MSB).
 */
@Override
public void run(final String arg) {

    final ImagePlus imp = WindowManager.getCurrentImage();
    if (imp == null) {
        IJ.showMessage(DIALOG_CAPTION, "No image to save.");
        return;
    }

    final SaveDialog saveDialog = new SaveDialog("Save as VTK", imp.getTitle(), ".vtk");

    if (saveDialog.getFileName() == null) {
        return;
    }

    IJ.showStatus("Saving current image as '" + saveDialog.getFileName() + "'...");
    final String fileName = saveDialog.getDirectory() + File.separator + saveDialog.getFileName();

    try {
        final long tStart = System.currentTimeMillis();
        VtkEncoder.save(fileName, imp, "ASCII".compareToIgnoreCase(arg) == 0);
        final long tStop = System.currentTimeMillis();
        IJ.showStatus("Saving of '" + saveDialog.getFileName() + "' completed in " + (tStop - tStart) + " ms.");
    } catch (final Exception ex) {
        ex.printStackTrace();
        String msg = ex.getMessage();
        if (msg == null) {
            msg = "";
        } else {
            msg = "\n" + msg;
        }

        IJ.showMessage(DIALOG_CAPTION, "Error writing file '" + fileName + "'." + msg);
    }
}
 
开发者ID:ij-plugins,项目名称:ijp-toolkit,代码行数:42,代码来源:VtkWriterPlugin.java


示例11: run

import ij.io.SaveDialog; //导入依赖的package包/类
public void run(String arg) {   
    ImagePlus imp = WindowManager.getCurrentImage();   
    if (null == imp) return;   
    SaveDialog sd = new SaveDialog("Save Viva File", "copy_"+imp.getTitle(), ".viv");  
    if(sd.getDirectory()!=null & sd.getFileName()!=null){
        String dir = sd.getDirectory();   
        if (null == dir) return; // user canceled dialog   
        dir = dir.replace('\\', '/'); // Windows safe   
        if (!dir.endsWith("/")) dir += "/";   

        new SEQProjectionSource().saveViva(imp, dir + sd.getFileName());   
    }

}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:15,代码来源:SaveAs_Viva.java


示例12: saveView

import ij.io.SaveDialog; //导入依赖的package包/类
public void saveView() {
	final SaveDialog sd = new SaveDialog("Save view...", "", ".view");
	final String dir = sd.getDirectory();
	final String name = sd.getFileName();
	if (dir == null || name == null) return;
	try {
		univ.saveView(dir + name);
	}
	catch (final Exception e) {
		IJ.error(e.getMessage());
	}
}
 
开发者ID:fiji,项目名称:3D_Viewer,代码行数:13,代码来源:Executer.java


示例13: saveSession

import ij.io.SaveDialog; //导入依赖的package包/类
public void saveSession() {
	final SaveDialog sd =
		new SaveDialog("Save session...", "session", ".scene");
	final String dir = sd.getDirectory();
	final String name = sd.getFileName();
	if (dir == null || name == null) return;
	try {
		univ.saveSession(dir + name);
	}
	catch (final Exception e) {
		IJ.error(e.getMessage());
	}
}
 
开发者ID:fiji,项目名称:3D_Viewer,代码行数:14,代码来源:Executer.java


示例14: savePointList

import ij.io.SaveDialog; //导入依赖的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


示例15: exportChart

import ij.io.SaveDialog; //导入依赖的package包/类
/**
 * Exports the specified JFreeChart to a SVG or PDF file. Destination file
 * is specified by the user in a save dialog prompt. An error message is
 * displayed if the file could not be saved. Does nothing if {@code chart}
 * is {@code null}.
 *
 * @param chart
 *            the <a href="http://javadoc.imagej.net/JFreeChart/" target=
 *            "_blank">JFreeChart </a> to export.
 * @param bounds
 *            the Rectangle delimiting the boundaries within which the chart
 *            should be drawn.
 * @param extension
 *            The file extension. Either ".svg" or ".pdf"
 * @see #exportChartAsSVG(JFreeChart, Rectangle)
 * @see #exportChartAsPDF(JFreeChart, Rectangle)
 */
static void exportChart(final JFreeChart chart, final Rectangle bounds, final String extension) {
	if (chart == null)
		return;
	final String defaultName = (chart.getTitle() == null) ? "Chart" : chart.getTitle().getText();
	final SaveDialog sd = new SaveDialog("Export graph as...", defaultName, extension);
	if (sd.getFileName() == null)
		return;
	final File saveFile = new File(sd.getDirectory(), sd.getFileName());
	if ((saveFile != null) && saveFile.exists()) {
		if (!IJ.showMessageWithCancel("Export graph...",
				saveFile.getAbsolutePath() + " already exists.\nReplace it?"))
			return;
	}
	try {
		if (extension.toLowerCase().endsWith(".svg"))
			exportChartAsSVG(chart, bounds, saveFile);
		else if (extension.toLowerCase().endsWith(".pdf"))
			exportChartAsPDF(chart, bounds, saveFile);
		IJ.showStatus("Graph saved, " + saveFile.getAbsolutePath());
	} catch (final Exception e) {
		IJ.error("Error", "Saving to " + saveFile.getAbsolutePath() + " failed");
		if (IJ.debugMode)
			IJ.handleException(e);
		return;
	}
}
 
开发者ID:tferr,项目名称:Scripts,代码行数:44,代码来源:PlotUtils.java


示例16: chooseFile

import ij.io.SaveDialog; //导入依赖的package包/类
/** Select a file from the file system, for saving purposes. Prompts for overwritting if the file exists, unless the ControlWindow.isGUIEnabled() returns false (i.e. there is no GUI). */
static public final File chooseFile(final String default_dir, final String name, final String extension) {
	try { return new TaskOnEDT<File>(new Callable<File>() { @Override
	public File call() {
	// using ImageJ's JFileChooser or internal FileDialog, according to user preferences.
	String name2 = null;
	if (null != name && null != extension) name2 = name + extension;
	else if (null != name) name2 = name;
	else if (null != extension) name2 = "untitled" + extension;
	if (null != default_dir) {
		OpenDialog.setDefaultDirectory(default_dir);
	}
	final SaveDialog sd = new SaveDialog("Save",
					OpenDialog.getDefaultDirectory(),
					name2,
					extension);

	final String filename = sd.getFileName();
	if (null == filename || filename.toLowerCase().startsWith("null")) return null;
	String dir = sd.getDirectory();
	if (IJ.isWindows()) dir = dir.replace('\\', '/');
	if (!dir.endsWith("/")) dir += "/";
	final File f = new File(dir + filename);
	if (f.exists() && ControlWindow.isGUIEnabled()) {
		final YesNoCancelDialog d = new YesNoCancelDialog(IJ.getInstance(), "Overwrite?", "File " + filename + " exists! Overwrite?");
		if (d.cancelPressed()) {
			return null;
		} else if (!d.yesPressed()) {
			return chooseFile(name, extension);
		}
		// else if yes pressed, overwrite.
	}
	return f;
	}}).get(); } catch (final Throwable t) { IJError.print(t); return null; }
}
 
开发者ID:trakem2,项目名称:TrakEM2,代码行数:36,代码来源:Utils.java


示例17: run

import ij.io.SaveDialog; //导入依赖的package包/类
@Override
public void run(final String arg) {
    // Get current image
    final ImagePlus imp = WindowManager.getCurrentImage();
    if (imp == null) {
        IJ.noImage();
        return;
    }

    // Verify type
    if (imp.getType() == ImagePlus.COLOR_256 || imp.getType() == ImagePlus.COLOR_RGB) {
        IJ.error(TITLE, "COLOR_256 and COLOR_RGB images are not supported.");
        return;
    }

    // Should the image be single file
    final GenericDialog dialog = new GenericDialog(TITLE);
    dialog.addCheckbox("Save_in_single_file", saveInSingleFile);
    dialog.addMessage("" +
            "Write current image in MetaImage format used by ITK. \n" +
            "Option \"Save in single file\" indicates whether the image should be saved in a single \n" +
            "file (extension *.mha) or the header and the image data should be saved in separate \n" +
            "files (with extensions *.mhd and *.raw respectively.) ");
    dialog.addHelp(HELP_URL);
    dialog.showDialog();

    if (dialog.wasCanceled()) {
        return;
    }

    saveInSingleFile = dialog.getNextBoolean();

    // Get file name
    final String extension = saveInSingleFile ? ".mha" : ".mhd";
    final SaveDialog saveDialog = new SaveDialog(TITLE, imp.getTitle(), extension);
    if (saveDialog.getFileName() == null) {
        return;
    }

    // Save the image
    final File file = new File(saveDialog.getDirectory(), saveDialog.getFileName());
    try {
        MiEncoder.write(imp, file.getAbsolutePath(), saveInSingleFile);
    } catch (final MiException ex) {
        ex.printStackTrace();
        IJ.error(TITLE, ex.getMessage());
        return;
    }

    IJ.showStatus("MetaImage " + saveDialog.getFileName() + " saved.");
}
 
开发者ID:ij-plugins,项目名称:ijp-toolkit,代码行数:52,代码来源:MetaImageWriterPlugin.java


示例18: run

import ij.io.SaveDialog; //导入依赖的package包/类
@Override
public void run(final String arg) {
    // Get current image
    final ImagePlus imp = IJ.getImage();
    if (imp == null) {
        return;
    }

    // Ask for options
    final GenericDialog dialog = new GenericDialog(TITLE);
    final FileType[] fileTypes = FileType.values();
    final String[] fileTypeStrings = new String[fileTypes.length];
    for (int i = 0; i < fileTypes.length; i++) {
        fileTypeStrings[i] = fileTypes[i].toString().toLowerCase();
    }
    dialog.addChoice("File_encoding", fileTypeStrings, fileType.toString().toLowerCase());
    dialog.addCheckbox("Save_sides", saveSides);
    dialog.addHelp(HELP_URL);
    dialog.showDialog();

    if (dialog.wasCanceled()) {
        return;
    }

    fileType = fileTypes[dialog.getNextChoiceIndex()];
    saveSides = dialog.getNextBoolean();

    // Ask for file name to save to
    final SaveDialog sd = new SaveDialog(TITLE, imp.getTitle(), ".stl");
    if (sd.getFileName() == null) {
        return;
    }

    // Write to STL
    final File file = new File(sd.getDirectory(), sd.getFileName());
    final ImageProcessor ip = imp.getProcessor();
    final Calibration c = imp.getCalibration();

    final ExportAsSTL exporter = new ExportAsSTL();
    exporter.addProgressListener(new IJProgressBarAdapter());
    final Calibration cal = imp.getCalibration();
    try {
        if (FileType.BINARY == fileType) {
            exporter.writeBinary(file, ip, c.pixelWidth, c.pixelHeight, cal.xOrigin, cal.yOrigin, saveSides);
        } else {
            exporter.writeASCII(file, ip, c.pixelWidth, c.pixelHeight, cal.xOrigin, cal.yOrigin, saveSides);
        }
    } catch (final IJPluginsException e) {
        IJ.error(TITLE, e.getMessage() + "\n" + TextUtil.toString(e));
    } finally {
        exporter.removeAllProgressListener();
    }
}
 
开发者ID:ij-plugins,项目名称:ijp-toolkit,代码行数:54,代码来源:ExportAsSTLPlugIn.java


示例19: exportSVG

import ij.io.SaveDialog; //导入依赖的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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IMetaPrimitive类代码示例发布时间:2022-05-22
下一篇:
Java InputSampler类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap