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


Java SaveDialog类代码示例

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


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


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