Search in sources :

Example 1 with ExportDialog

use of org.freehep.util.export.ExportDialog in project abstools by abstools.

the class ExportAction method actionPerformed.

public void actionPerformed(ActionEvent e) {
    Diagram diagram = editor.getUI().getDiagram();
    if (diagram == null) {
        return;
    }
    exportDevice = (PanelPaintDevice) diagram.getPaintDevice();
    if (exportDevice.isEmpty()) {
        return;
    }
    try {
        File file = editor.getUI().getCurrentFile();
        if (exportDialog == null) {
            exportDialog = new ExportDialog("Quick Sequence Diagram Editor");
            LookAndFeelManager.instance().registerOrphan(exportDialog);
            exportDialog.setUserProperties(properties);
            exportDialog.addExportDialogListener(this);
            if (file != null) {
                properties.setProperty(SAVE_AS_FILE_PROPERTY, file.getAbsolutePath());
            }
        } else {
            String fileName = properties.getProperty(SAVE_AS_FILE_PROPERTY);
            File current = fileName != null ? new File(fileName) : null;
            if (current != null && current.exists()) {
                File dir = current.getParentFile();
                if (file == null) {
                    current = new File(dir, "untitled");
                } else {
                    current = new File(dir, file.getName());
                }
                properties.setProperty(SAVE_AS_FILE_PROPERTY, current.getAbsolutePath());
            }
        }
        exportDialog.showExportDialog((Component) editor.getUI(), "Export via FreeHEP library (see http://www.freehep.org/vectorgraphics)", exportDevice.getPanel().asJComponent(), "untitled");
    } catch (Exception ex) {
        ex.printStackTrace();
        editor.getUI().errorMessage("Cannot export due to an exception\n" + "of type " + ex.getClass().getSimpleName() + "\n" + "with the message: " + ex.getMessage());
    } finally {
        exportDevice.setAntialiasing(true);
    }
}
Also used : ExportDialog(org.freehep.util.export.ExportDialog) File(java.io.File) Diagram(net.sf.sdedit.diagram.Diagram)

Aggregations

File (java.io.File)1 Diagram (net.sf.sdedit.diagram.Diagram)1 ExportDialog (org.freehep.util.export.ExportDialog)1