Search in sources :

Example 1 with FileNameParameter

use of net.sf.mzmine.parameters.parametertypes.filenames.FileNameParameter in project mzmine2 by mzmine.

the class SpectralMatchPanel method exportToGraphics.

/**
 * Export the whole panel to pdf, emf, eps or all
 *
 * @param format
 */
public void exportToGraphics(String format) {
    // old path
    FileNameParameter param = MZmineCore.getConfiguration().getModuleParameters(SpectraIdentificationResultsModule.class).getParameter(SpectraIdentificationResultsParameters.file);
    final JFileChooser chooser;
    if (param.getValue() != null) {
        chooser = new JFileChooser();
        chooser.setSelectedFile(param.getValue());
    } else
        chooser = new JFileChooser();
    // get file
    if (chooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
        try {
            File f = chooser.getSelectedFile();
            pnExport.setVisible(false);
            pnExport.revalidate();
            pnExport.getParent().revalidate();
            pnExport.getParent().repaint();
            SwingExportUtil.writeToGraphics(this, f.getParentFile(), f.getName(), format);
            // save path
            param.setValue(FileAndPathUtil.eraseFormat(f));
        } catch (Exception ex) {
            logger.log(Level.WARNING, "Cannot export graphics of spectra match panel", ex);
        } finally {
            pnExport.setVisible(true);
            pnExport.getParent().revalidate();
            pnExport.getParent().repaint();
        }
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) FileNameParameter(net.sf.mzmine.parameters.parametertypes.filenames.FileNameParameter) File(java.io.File) InvalidSmilesException(org.openscience.cdk.exception.InvalidSmilesException) CDKException(org.openscience.cdk.exception.CDKException)

Aggregations

File (java.io.File)1 JFileChooser (javax.swing.JFileChooser)1 FileNameParameter (net.sf.mzmine.parameters.parametertypes.filenames.FileNameParameter)1 CDKException (org.openscience.cdk.exception.CDKException)1 InvalidSmilesException (org.openscience.cdk.exception.InvalidSmilesException)1