From 3087ea10ac51cf1a8b2eb8d8abe010513ce9998f Mon Sep 17 00:00:00 2001 From: kjvdheide Date: Mon, 27 Nov 2017 16:19:11 +0000 Subject: [PATCH] JAL-2852 added framework for saving as EPS file --- .../src/org/forester/archaeopteryx/AptxUtil.java | 8 +++ .../src/org/forester/archaeopteryx/MainFrame.java | 75 ++++++++++++-------- .../archaeopteryx/MainFrameApplication.java | 2 + 3 files changed, 56 insertions(+), 29 deletions(-) diff --git a/forester/java/src/org/forester/archaeopteryx/AptxUtil.java b/forester/java/src/org/forester/archaeopteryx/AptxUtil.java index a2cf351..57e9e78 100644 --- a/forester/java/src/org/forester/archaeopteryx/AptxUtil.java +++ b/forester/java/src/org/forester/archaeopteryx/AptxUtil.java @@ -89,7 +89,9 @@ public final class AptxUtil { JPG( "jpg" ), PDF( "pdf" ), PNG( "png" ), + EPS("eps"), TIFF( "tif" ); + private final String _suffix; @@ -1085,6 +1087,9 @@ public final class AptxUtil { if ( type == GraphicsExportType.TIFF ) { writeToTiff( file, buffered_img ); } + else if (type == GraphicsExportType.EPS) { + writeToEps(); + } else { ImageIO.write( buffered_img, type.toString(), file ); } @@ -1099,6 +1104,9 @@ public final class AptxUtil { } return msg; } + final static void writeToEps() { + + } final static void writeToTiff( final File file, final BufferedImage image ) throws IOException { // See: http://log.robmeek.com/2005/08/write-tiff-in-java.html diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrame.java b/forester/java/src/org/forester/archaeopteryx/MainFrame.java index e15becb..0378d5b 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrame.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrame.java @@ -177,6 +177,7 @@ public abstract class MainFrame extends JInternalFrame implements ActionListener JMenuItem _write_to_tif_item; JMenuItem _write_to_png_item; JMenuItem _write_to_bmp_item; + JMenuItem _write_to_eps_item; // tools menu: JMenuItem _midpoint_root_item; JMenuItem _taxcolor_item; @@ -729,6 +730,18 @@ public abstract class MainFrame extends JInternalFrame implements ActionListener setCurrentDir( new_dir ); } } + else if (o == _write_to_eps_item) { + final File new_dir = writeToGraphicsFile(_mainpanel.getCurrentPhylogeny(), + GraphicsExportType.EPS, + _mainpanel, + _writetographics_filechooser, + this, + getContentPane(), + _current_dir ); + if (new_dir != null) { + setCurrentDir(new_dir); + } + } else if ( o == _print_item ) { print( getCurrentTreePanel(), getOptions(), this ); } @@ -1139,35 +1152,39 @@ public abstract class MainFrame extends JInternalFrame implements ActionListener } void buildFileMenu() { - _file_jmenu = MainFrame.createMenu( "File", getConfiguration() ); - _file_jmenu.add( _save_item = new JMenuItem( "Save Tree As..." ) ); - _file_jmenu.addSeparator(); - _file_jmenu.add( _write_to_pdf_item = new JMenuItem( "Export to PDF file ..." ) ); - if ( AptxUtil.canWriteFormat( "tif" ) || AptxUtil.canWriteFormat( "tiff" ) || AptxUtil.canWriteFormat( "TIF" ) ) { - _file_jmenu.add( _write_to_tif_item = new JMenuItem( "Export to TIFF file..." ) ); - } - _file_jmenu.add( _write_to_png_item = new JMenuItem( "Export to PNG file..." ) ); - _file_jmenu.add( _write_to_jpg_item = new JMenuItem( "Export to JPG file..." ) ); - if ( AptxUtil.canWriteFormat( "gif" ) ) { - _file_jmenu.add( _write_to_gif_item = new JMenuItem( "Export to GIF file..." ) ); - } - if ( AptxUtil.canWriteFormat( "bmp" ) ) { - _file_jmenu.add( _write_to_bmp_item = new JMenuItem( "Export to BMP file..." ) ); - } - _file_jmenu.addSeparator(); - _file_jmenu.add( _print_item = new JMenuItem( "Print..." ) ); - _file_jmenu.addSeparator(); - _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) ); - customizeJMenuItem( _save_item ); - customizeJMenuItem( _write_to_pdf_item ); - customizeJMenuItem( _write_to_png_item ); - customizeJMenuItem( _write_to_jpg_item ); - customizeJMenuItem( _write_to_gif_item ); - customizeJMenuItem( _write_to_tif_item ); - customizeJMenuItem( _write_to_bmp_item ); - customizeJMenuItem( _print_item ); - customizeJMenuItem( _exit_item ); - _jmenubar.add( _file_jmenu ); +// _file_jmenu = MainFrame.createMenu( "File", getConfiguration() ); +// _file_jmenu.add( _save_item = new JMenuItem( "Save Tree As..." ) ); +// _file_jmenu.addSeparator(); +// _file_jmenu.add( _write_to_pdf_item = new JMenuItem( "Export to PDF file ..." ) ); +// if ( AptxUtil.canWriteFormat( "tif" ) || AptxUtil.canWriteFormat( "tiff" ) || AptxUtil.canWriteFormat( "TIF" ) ) { +// _file_jmenu.add( _write_to_tif_item = new JMenuItem( "Export to TIFF file..." ) ); +// } +// _file_jmenu.add( _write_to_png_item = new JMenuItem( "Export to PNG file..." ) ); +// _file_jmenu.add( _write_to_jpg_item = new JMenuItem( "Export to JPG file..." ) ); +// if ( AptxUtil.canWriteFormat( "gif" ) ) { +// _file_jmenu.add( _write_to_gif_item = new JMenuItem( "Export to GIF file..." ) ); +// } +// if ( AptxUtil.canWriteFormat( "bmp" ) ) { +// _file_jmenu.add( _write_to_bmp_item = new JMenuItem( "Export to BMP file..." ) ); +// } +// +// _file_jmenu.add( _write_to_eps_item = new JMenuItem("Export to EPS file...") ); +// +// _file_jmenu.addSeparator(); +// _file_jmenu.add( _print_item = new JMenuItem( "Print..." ) ); +// _file_jmenu.addSeparator(); +// _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) ); +// customizeJMenuItem( _save_item ); +// customizeJMenuItem( _write_to_pdf_item ); +// customizeJMenuItem( _write_to_png_item ); +// customizeJMenuItem( _write_to_jpg_item ); +// customizeJMenuItem( _write_to_gif_item ); +// customizeJMenuItem( _write_to_tif_item ); +// customizeJMenuItem( _write_to_bmp_item ); +// customizeJMenuItem(_write_to_eps_item); +// customizeJMenuItem( _print_item ); +// customizeJMenuItem( _exit_item ); +// _jmenubar.add( _file_jmenu ); } void buildFontSizeMenu() { diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java index 9349f8c..ab6e57f 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java @@ -1744,6 +1744,7 @@ public final class MainFrameApplication extends MainFrame { if ( AptxUtil.canWriteFormat( "bmp" ) ) { _file_jmenu.add( _write_to_bmp_item = new JMenuItem( "Export to BMP file..." ) ); } + _file_jmenu.add( _write_to_eps_item = new JMenuItem("Export to EPS file...") ); _file_jmenu.addSeparator(); _file_jmenu.add( _print_item = new JMenuItem( "Print..." ) ); _file_jmenu.addSeparator(); @@ -1772,6 +1773,7 @@ public final class MainFrameApplication extends MainFrame { customizeJMenuItem( _write_to_gif_item ); customizeJMenuItem( _write_to_tif_item ); customizeJMenuItem( _write_to_bmp_item ); + customizeJMenuItem( _write_to_eps_item ); customizeJMenuItem( _print_item ); customizeJMenuItem( _exit_item ); _jmenubar.add( _file_jmenu ); -- 1.7.10.2