From f7f0102d3e7eb2fd254f7d22d75a88495133449c Mon Sep 17 00:00:00 2001 From: cmzmasek Date: Thu, 30 Jun 2016 18:00:31 -0700 Subject: [PATCH] fixed issue with cutting off of long names in pdf export + minor changes --- .../_aptx_configuration_file | 11 --- forester/java/build.xml | 3 - .../org/forester/archaeopteryx/AptxConstants.java | 4 - .../src/org/forester/archaeopteryx/AptxUtil.java | 38 +++----- .../org/forester/archaeopteryx/ArchaeopteryxE.java | 85 ----------------- .../org/forester/archaeopteryx/Configuration.java | 43 ++++----- .../src/org/forester/archaeopteryx/MainFrame.java | 96 +------------------- .../forester/archaeopteryx/MainFrameApplet.java | 18 +--- .../archaeopteryx/MainFrameApplication.java | 17 ++-- .../src/org/forester/archaeopteryx/Options.java | 54 +---------- .../org/forester/archaeopteryx/PdfExporter.java | 34 ++++--- .../src/org/forester/archaeopteryx/TreePanel.java | 2 - 12 files changed, 70 insertions(+), 335 deletions(-) diff --git a/forester/aptx/aptx_configuration_files/_aptx_configuration_file b/forester/aptx/aptx_configuration_files/_aptx_configuration_file index 2ca3dc7..8236aa2 100644 --- a/forester/aptx/aptx_configuration_files/_aptx_configuration_file +++ b/forester/aptx/aptx_configuration_files/_aptx_configuration_file @@ -40,15 +40,6 @@ native_ui: ? # ext_node_sum_dep # total_node_sum_dep (for "uniform" branch lengths) # -# Default size for graphics export and printing: 'graphics_export_x' and 'graphics_export_y': -# (Archaeopteryx tries to guess the locale, so setting these is not always necessary) -# Example: For A4 (portrait): -# 'graphics_export_x: 595' -# 'graphics_export_y: 845' -# For US Letter (portrait): -# 'graphics_export_x: 612' -# 'graphics_export_y: 792' -# # Default line width for PDF export: 'pdf_export_line_wdith': # Example: 'pdf_export_line_width: 0.5' # @@ -177,8 +168,6 @@ show_node_shapes_for_nodes_with_vis_data: yes default_node_size: 4 default_node_shape: rectangle default_node_fill: solid -#graphics_export_x: 595 -#graphics_export_y: 792 pdf_export_line_width: 0.5 show_overview: yes overview_width: 120 diff --git a/forester/java/build.xml b/forester/java/build.xml index 41380d2..812c56a 100644 --- a/forester/java/build.xml +++ b/forester/java/build.xml @@ -21,9 +21,6 @@ - diff --git a/forester/java/src/org/forester/archaeopteryx/AptxConstants.java b/forester/java/src/org/forester/archaeopteryx/AptxConstants.java index f2e803a..bd7cd3f 100644 --- a/forester/java/src/org/forester/archaeopteryx/AptxConstants.java +++ b/forester/java/src/org/forester/archaeopteryx/AptxConstants.java @@ -68,10 +68,6 @@ public final class AptxConstants { static final String APPLET_PARAM_NAME_FOR_DEFAULT_QUERY_SEQUENCE = "homology_type_analysis_query_sequence"; static final String APPLET_PARAM_NAME_FOR_DEFAULT_SEQUENCE_RELATION_TYPE = "homology_type_analysis_initial_relation_type"; static final int MAX_TREES_TO_LOAD = 100; - static final int US_LETTER_SIZE_X = 612; - static final int US_LETTER_SIZE_Y = 792; - static final int A4_SIZE_X = 595; - static final int A4_SIZE_Y = 845; final static float PDF_LINE_WIDTH_DEFAULT = 0.5f; final static String APTX_WEB_SITE = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx"; final static String APTX_DOC_SITE = "https://sites.google.com/site/cmzmasek/home/software/archaeopteryx/documentation"; diff --git a/forester/java/src/org/forester/archaeopteryx/AptxUtil.java b/forester/java/src/org/forester/archaeopteryx/AptxUtil.java index 5b3dafa..5f94b35 100644 --- a/forester/java/src/org/forester/archaeopteryx/AptxUtil.java +++ b/forester/java/src/org/forester/archaeopteryx/AptxUtil.java @@ -902,14 +902,7 @@ public final class AptxUtil { final ControlPanel ac, final GraphicsExportType type, final Options options ) throws IOException { - if ( !options.isGraphicsExportUsingActualSize() ) { - if ( options.isGraphicsExportVisibleOnly() ) { - throw new IllegalArgumentException( "cannot export visible rectangle only without exporting in actual size" ); - } - tree_panel.calcParametersForPainting( options.getPrintSizeX(), options.getPrintSizeY() ); - tree_panel.resetPreferredSize(); - tree_panel.repaint(); - } + final RenderingHints rendering_hints = new RenderingHints( RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY ); rendering_hints.put( RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY ); @@ -926,11 +919,11 @@ public final class AptxUtil { return ""; } Rectangle visible = null; - if ( !options.isGraphicsExportUsingActualSize() ) { - width = options.getPrintSizeX(); - height = options.getPrintSizeY(); - } - else if ( options.isGraphicsExportVisibleOnly() ) { +// if ( !options.isGraphicsExportUsingActualSize() ) { +// width = options.getPrintSizeX(); +// height = options.getPrintSizeY(); +// } + /* else*/ if ( options.isGraphicsExportVisibleOnly() ) { visible = tree_panel.getVisibleRect(); width = visible.width; height = visible.height; @@ -967,14 +960,7 @@ public final class AptxUtil { final ControlPanel ac, final GraphicsExportType type, final Options options ) throws IOException { - if ( !options.isGraphicsExportUsingActualSize() ) { - if ( options.isGraphicsExportVisibleOnly() ) { - throw new IllegalArgumentException( "cannot export visible rectangle only without exporting in actual size" ); - } - tree_panel.calcParametersForPainting( options.getPrintSizeX(), options.getPrintSizeY() ); - tree_panel.resetPreferredSize(); - tree_panel.repaint(); - } + final RenderingHints rendering_hints = new RenderingHints( RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY ); rendering_hints.put( RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY ); @@ -995,11 +981,11 @@ public final class AptxUtil { throw new IOException( "\"" + file_name + "\" is a directory" ); } Rectangle visible = null; - if ( !options.isGraphicsExportUsingActualSize() ) { - width = options.getPrintSizeX(); - height = options.getPrintSizeY(); - } - else if ( options.isGraphicsExportVisibleOnly() ) { +// if ( !options.isGraphicsExportUsingActualSize() ) { +// width = options.getPrintSizeX(); +// height = options.getPrintSizeY(); +// } + /*else*/ if ( options.isGraphicsExportVisibleOnly() ) { visible = tree_panel.getVisibleRect(); width = visible.width; height = visible.height; diff --git a/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java b/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java index 6743505..1612aba 100644 --- a/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java +++ b/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java @@ -154,9 +154,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { private JCheckBoxMenuItem _graphics_export_visible_only_cbmi; private JCheckBoxMenuItem _antialias_print_cbmi; private JCheckBoxMenuItem _print_black_and_white_cbmi; - private JCheckBoxMenuItem _print_using_actual_size_cbmi; - private JCheckBoxMenuItem _graphics_export_using_actual_size_cbmi; - private JMenuItem _print_size_mi; private JMenuItem _choose_pdf_width_mi; @Override @@ -492,15 +489,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { else if ( o == _print_black_and_white_cbmi ) { updateOptions( getOptions() ); } - else if ( o == _print_using_actual_size_cbmi ) { - updateOptions( getOptions() ); - } - else if ( o == _graphics_export_using_actual_size_cbmi ) { - updateOptions( getOptions() ); - } - else if ( o == _print_size_mi ) { - choosePrintSize(); - } else if ( o == _choose_pdf_width_mi ) { choosePdfWidth(); } @@ -905,53 +893,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { } } - private void choosePrintSize() { - final String s = ( String ) JOptionPane.showInputDialog( this, - "Please enter values for width and height,\nseparated by a comma.\n" - + "[current values: " - + getOptions().getPrintSizeX() + ", " - + getOptions().getPrintSizeY() + "]\n" - + "[A4: " + AptxConstants.A4_SIZE_X + ", " - + AptxConstants.A4_SIZE_Y + "]\n" + "[US Letter: " - + AptxConstants.US_LETTER_SIZE_X + ", " - + AptxConstants.US_LETTER_SIZE_Y + "]", - "Default Size for Graphics Export", - JOptionPane.QUESTION_MESSAGE, - null, - null, - getOptions().getPrintSizeX() + ", " - + getOptions().getPrintSizeY() ); - if ( !ForesterUtil.isEmpty( s ) && ( s.indexOf( ',' ) > 0 ) ) { - boolean success = true; - int x = 0; - int y = 0; - final String[] str_ary = s.split( "," ); - if ( str_ary.length == 2 ) { - final String x_str = str_ary[ 0 ].trim(); - final String y_str = str_ary[ 1 ].trim(); - if ( !ForesterUtil.isEmpty( x_str ) && !ForesterUtil.isEmpty( y_str ) ) { - try { - x = Integer.parseInt( x_str ); - y = Integer.parseInt( y_str ); - } - catch ( final Exception ex ) { - success = false; - } - } - else { - success = false; - } - } - else { - success = false; - } - if ( success && ( x > 1 ) && ( y > 1 ) ) { - getOptions().setPrintSizeX( x ); - getOptions().setPrintSizeY( y ); - } - } - } - private void customizeRadioButtonMenuItem( final JRadioButtonMenuItem item, final boolean is_selected ) { if ( item != null ) { item.setFont( MainFrame.menu_font ); @@ -1105,7 +1046,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { .setTextMinSupportMenuItem( _choose_minimal_confidence_mi, getOptions(), getCurrentTreePanel() ); MainFrame.setTextForFontChooserMenuItem( _choose_font_mi, MainFrame .createCurrentFontDesc( getMainPanel().getTreeFontSet() ) ); - setTextForGraphicsSizeChooserMenuItem( _print_size_mi, getOptions() ); setTextForPdfLineWidthChooserMenuItem( _choose_pdf_width_mi, getOptions() ); MainFrame.setCycleNodeFillMenuItem( _cycle_node_fill_mi, getOptions() ); MainFrame.setCycleNodeShapeMenuItem( _cycle_node_shape_mi, getOptions() ); @@ -1179,21 +1119,12 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { _options_jmenu.add( _antialias_print_cbmi = new JCheckBoxMenuItem( "Antialias" ) ); _options_jmenu.add( _print_black_and_white_cbmi = new JCheckBoxMenuItem( "Export in Black and White" ) ); _options_jmenu - .add( _print_using_actual_size_cbmi = new JCheckBoxMenuItem( "Use Current Image Size for PDF export and Printing" ) ); - _options_jmenu - .add( _graphics_export_using_actual_size_cbmi = new JCheckBoxMenuItem( "Use Current Image Size for PNG, JPG, and GIF export" ) ); - _options_jmenu .add( _graphics_export_visible_only_cbmi = new JCheckBoxMenuItem( "Limit to Visible ('Screenshot') for PNG, JPG, and GIF export" ) ); - _options_jmenu.add( _print_size_mi = new JMenuItem( "" ) ); _options_jmenu.add( _choose_pdf_width_mi = new JMenuItem( "" ) ); // customizeCheckBoxMenuItem( _antialias_print_cbmi, getOptions().isAntialiasPrint() ); customizeCheckBoxMenuItem( _print_black_and_white_cbmi, getOptions().isPrintBlackAndWhite() ); customizeCheckBoxMenuItem( _graphics_export_visible_only_cbmi, getOptions().isGraphicsExportVisibleOnly() ); - customizeCheckBoxMenuItem( _print_using_actual_size_cbmi, getOptions().isPrintUsingActualSize() ); - customizeCheckBoxMenuItem( _graphics_export_using_actual_size_cbmi, getOptions() - .isGraphicsExportUsingActualSize() ); - customizeJMenuItem( _print_size_mi ); customizeJMenuItem( _choose_pdf_width_mi ); // customizeJMenuItem( _choose_font_mi ); @@ -1781,10 +1712,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { options.setSearchWithRegex( ( _search_with_regex_cbmi != null ) && _search_with_regex_cbmi.isSelected() ); options.setInverseSearchResult( ( _inverse_search_result_cbmi != null ) && _inverse_search_result_cbmi.isSelected() ); - options.setPrintUsingActualSize( ( _print_using_actual_size_cbmi != null ) - && ( _print_using_actual_size_cbmi.isSelected() ) ); - options.setGraphicsExportUsingActualSize( ( _graphics_export_using_actual_size_cbmi != null ) - && ( _graphics_export_using_actual_size_cbmi.isSelected() ) ); options.setAntialiasPrint( ( _antialias_print_cbmi != null ) && _antialias_print_cbmi.isSelected() ); options.setPrintBlackAndWhite( ( _print_black_and_white_cbmi != null ) && _print_black_and_white_cbmi.isSelected() ); @@ -1823,13 +1750,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { } if ( _graphics_export_visible_only_cbmi != null ) { options.setGraphicsExportVisibleOnly( _graphics_export_visible_only_cbmi.isSelected() ); - if ( _graphics_export_visible_only_cbmi.isSelected() && ( _graphics_export_using_actual_size_cbmi != null ) ) { - _graphics_export_using_actual_size_cbmi.setSelected( true ); - _graphics_export_using_actual_size_cbmi.setEnabled( false ); - } - else { - _graphics_export_using_actual_size_cbmi.setEnabled( true ); - } } } @@ -1872,11 +1792,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { } } - static void setTextForGraphicsSizeChooserMenuItem( final JMenuItem mi, final Options o ) { - mi.setText( "Enter Default Size for Graphics Export... (current: " + o.getPrintSizeX() + ", " - + o.getPrintSizeY() + ")" ); - } - static void setTextForPdfLineWidthChooserMenuItem( final JMenuItem mi, final Options o ) { mi.setText( "Enter Default Line Width for PDF Export... (current: " + o.getPrintLineWidth() + ")" ); } diff --git a/forester/java/src/org/forester/archaeopteryx/Configuration.java b/forester/java/src/org/forester/archaeopteryx/Configuration.java index 3bb5d27..79fec13 100644 --- a/forester/java/src/org/forester/archaeopteryx/Configuration.java +++ b/forester/java/src/org/forester/archaeopteryx/Configuration.java @@ -207,8 +207,6 @@ public final class Configuration { private EXT_NODE_DATA_RETURN_ON _ext_node_data_return_on = EXT_NODE_DATA_RETURN_ON.WINODW; private int _frame_x_size; private int _frame_y_size; - private int _graphics_export_x = -1; - private int _graphics_export_y = -1; private Color _gui_background_color = AptxConstants.GUI_BACKGROUND_DEFAULT; private Color _gui_button_background_color = AptxConstants.BUTTON_BACKGROUND_COLOR_DEFAULT; private Color _gui_button_border_color = AptxConstants.BUTTON_BORDER_COLOR_DEFAULT; @@ -853,13 +851,13 @@ public final class Configuration { _ext_node_data_return_on = ext_node_data_return_on; } - private void setGraphicsExportX( final int graphics_export_x ) { - _graphics_export_x = graphics_export_x; - } + //private void setGraphicsExportX( final int graphics_export_x ) { + // _graphics_export_x = graphics_export_x; + //} - private void setGraphicsExportY( final int graphics_export_y ) { - _graphics_export_y = graphics_export_y; - } + //private void setGraphicsExportY( final int graphics_export_y ) { + // _graphics_export_y = graphics_export_y; + //} private void setInternalNumberAreConfidenceForNhParsing( final boolean internal_number_are_confidence_for_nh_parsing ) { _internal_number_are_confidence_for_nh_parsing = internal_number_are_confidence_for_nh_parsing; @@ -971,18 +969,18 @@ public final class Configuration { } } else if ( key.equals( "graphics_export_x" ) ) { - final String str = ( ( String ) st.nextElement() ).trim(); - final int i = parseInt( str ); - if ( i > 0 ) { - setGraphicsExportX( i ); - } + // final String str = ( ( String ) st.nextElement() ).trim(); + // final int i = parseInt( str ); + // if ( i > 0 ) { + // setGraphicsExportX( i ); + // } } else if ( key.equals( "graphics_export_y" ) ) { - final String str = ( ( String ) st.nextElement() ).trim(); - final int i = parseInt( str ); - if ( i > 0 ) { - setGraphicsExportY( i ); - } + //final String str = ( ( String ) st.nextElement() ).trim(); + // final int i = parseInt( str ); + //if ( i > 0 ) { + // setGraphicsExportY( i ); + //} } else if ( key.equals( "pdf_export_line_width" ) ) { final String str = ( ( String ) st.nextElement() ).trim(); @@ -1633,14 +1631,7 @@ public final class Configuration { return _domain_colors; } - int getGraphicsExportX() { - return _graphics_export_x; - } - - int getGraphicsExportY() { - return _graphics_export_y; - } - + Color getGuiBackgroundColor() { return _gui_background_color; } diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrame.java b/forester/java/src/org/forester/archaeopteryx/MainFrame.java index 4c85a4a..100bfbb 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrame.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrame.java @@ -234,9 +234,7 @@ public abstract class MainFrame extends JFrame implements ActionListener { JCheckBoxMenuItem _graphics_export_visible_only_cbmi; JCheckBoxMenuItem _antialias_print_cbmi; JCheckBoxMenuItem _print_black_and_white_cbmi; - JCheckBoxMenuItem _print_using_actual_size_cbmi; - JCheckBoxMenuItem _graphics_export_using_actual_size_cbmi; - JMenuItem _print_size_mi; + //JMenuItem _print_size_mi; JMenuItem _choose_pdf_width_mi; // _ parsing JCheckBoxMenuItem _internal_number_are_confidence_for_nh_parsing_cbmi; @@ -725,15 +723,6 @@ public abstract class MainFrame extends JFrame implements ActionListener { else if ( o == _print_black_and_white_cbmi ) { updateOptions( getOptions() ); } - else if ( o == _print_using_actual_size_cbmi ) { - updateOptions( getOptions() ); - } - else if ( o == _graphics_export_using_actual_size_cbmi ) { - updateOptions( getOptions() ); - } - else if ( o == _print_size_mi ) { - choosePrintSize(); - } else if ( o == _choose_pdf_width_mi ) { choosePdfWidth(); } @@ -1266,53 +1255,6 @@ public abstract class MainFrame extends JFrame implements ActionListener { } } - void choosePrintSize() { - final String s = ( String ) JOptionPane.showInputDialog( this, - "Please enter values for width and height,\nseparated by a comma.\n" - + "[current values: " - + getOptions().getPrintSizeX() + ", " - + getOptions().getPrintSizeY() + "]\n" - + "[A4: " + AptxConstants.A4_SIZE_X + ", " - + AptxConstants.A4_SIZE_Y + "]\n" + "[US Letter: " - + AptxConstants.US_LETTER_SIZE_X + ", " - + AptxConstants.US_LETTER_SIZE_Y + "]", - "Default Size for Graphics Export", - JOptionPane.QUESTION_MESSAGE, - null, - null, - getOptions().getPrintSizeX() + ", " - + getOptions().getPrintSizeY() ); - if ( !ForesterUtil.isEmpty( s ) && ( s.indexOf( ',' ) > 0 ) ) { - boolean success = true; - int x = 0; - int y = 0; - final String[] str_ary = s.split( "," ); - if ( str_ary.length == 2 ) { - final String x_str = str_ary[ 0 ].trim(); - final String y_str = str_ary[ 1 ].trim(); - if ( !ForesterUtil.isEmpty( x_str ) && !ForesterUtil.isEmpty( y_str ) ) { - try { - x = Integer.parseInt( x_str ); - y = Integer.parseInt( y_str ); - } - catch ( final Exception ex ) { - success = false; - } - } - else { - success = false; - } - } - else { - success = false; - } - if ( success && ( x > 1 ) && ( y > 1 ) ) { - getOptions().setPrintSizeX( x ); - getOptions().setPrintSizeY( y ); - } - } - } - void close() { removeAllTextFrames(); if ( _mainpanel != null ) { @@ -1893,10 +1835,6 @@ public abstract class MainFrame extends JFrame implements ActionListener { if ( ( _color_by_taxonomic_group_cbmi != null ) && _color_by_taxonomic_group_cbmi.isEnabled() ) { options.setColorByTaxonomicGroup( _color_by_taxonomic_group_cbmi.isSelected() ); } - options.setPrintUsingActualSize( ( _print_using_actual_size_cbmi != null ) - && ( _print_using_actual_size_cbmi.isSelected() ) ); - options.setGraphicsExportUsingActualSize( ( _graphics_export_using_actual_size_cbmi != null ) - && ( _graphics_export_using_actual_size_cbmi.isSelected() ) ); options.setAntialiasPrint( ( _antialias_print_cbmi != null ) && _antialias_print_cbmi.isSelected() ); if ( ( _use_brackets_for_conf_in_nh_export_cbmi != null ) && _use_brackets_for_conf_in_nh_export_cbmi.isSelected() ) { @@ -1935,14 +1873,7 @@ public abstract class MainFrame extends JFrame implements ActionListener { options.setInverseSearchResult( ( _inverse_search_result_cbmi != null ) && _inverse_search_result_cbmi.isSelected() ); if ( _graphics_export_visible_only_cbmi != null ) { - options.setGraphicsExportVisibleOnly( _graphics_export_visible_only_cbmi.isSelected() ); - if ( _graphics_export_visible_only_cbmi.isSelected() && ( _graphics_export_using_actual_size_cbmi != null ) ) { - _graphics_export_using_actual_size_cbmi.setSelected( true ); - _graphics_export_using_actual_size_cbmi.setEnabled( false ); - } - else { - _graphics_export_using_actual_size_cbmi.setEnabled( true ); - } + options.setGraphicsExportVisibleOnly( _graphics_export_visible_only_cbmi.isSelected() ); } if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) { options.setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ); @@ -2212,11 +2143,6 @@ public abstract class MainFrame extends JFrame implements ActionListener { if ( ( tp == null ) || ( tp.getPhylogeny() == null ) || tp.getPhylogeny().isEmpty() ) { return; } - if ( !op.isPrintUsingActualSize() ) { - tp.calcParametersForPainting( op.getPrintSizeX() - 80, op.getPrintSizeY() - 140 ); - tp.resetPreferredSize(); - tp.repaint(); - } final String job_name = AptxConstants.PRG_NAME; boolean error = false; String printer_name = null; @@ -2243,22 +2169,15 @@ public abstract class MainFrame extends JFrame implements ActionListener { final Options opts, final TreePanel tp, final Component comp ) { - if ( !opts.isPrintUsingActualSize() ) { - tp.calcParametersForPainting( opts.getPrintSizeX(), opts.getPrintSizeY() ); - tp.resetPreferredSize(); - tp.repaint(); - } + String pdf_written_to = ""; boolean error = false; try { if ( opts.isPrintUsingActualSize() ) { - pdf_written_to = PdfExporter.writePhylogenyToPdf( file_name, tp, tp.getWidth(), tp.getHeight() ); + pdf_written_to = PdfExporter.writePhylogenyToPdf( file_name, tp, tp.getWidth() , tp.getHeight() ); } else { - pdf_written_to = PdfExporter.writePhylogenyToPdf( file_name, - tp, - opts.getPrintSizeX(), - opts.getPrintSizeY() ); + // Never false. } } catch ( final IOException e ) { @@ -2337,11 +2256,6 @@ public abstract class MainFrame extends JFrame implements ActionListener { mi.setText( "Select Default Font... (current: " + font_desc + ")" ); } - static void setTextForGraphicsSizeChooserMenuItem( final JMenuItem mi, final Options o ) { - mi.setText( "Enter Default Size for Graphics Export... (current: " + o.getPrintSizeX() + ", " - + o.getPrintSizeY() + ")" ); - } - static void setTextForPdfLineWidthChooserMenuItem( final JMenuItem mi, final Options o ) { mi.setText( "Enter Default Line Width for PDF Export... (current: " + o.getPrintLineWidth() + ")" ); } diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrameApplet.java b/forester/java/src/org/forester/archaeopteryx/MainFrameApplet.java index 5d753af..bc5b737 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrameApplet.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrameApplet.java @@ -186,7 +186,7 @@ public final class MainFrameApplet extends MainFrame { .setTextMinSupportMenuItem( _choose_minimal_confidence_mi, getOptions(), getCurrentTreePanel() ); MainFrame.setTextForFontChooserMenuItem( _choose_font_mi, createCurrentFontDesc( getMainPanel() .getTreeFontSet() ) ); - setTextForGraphicsSizeChooserMenuItem( _print_size_mi, getOptions() ); + // setTextForGraphicsSizeChooserMenuItem( _print_size_mi, getOptions() ); setTextForPdfLineWidthChooserMenuItem( _choose_pdf_width_mi, getOptions() ); MainFrame.setCycleNodeFillMenuItem( _cycle_node_fill_mi, getOptions() ); MainFrame.setCycleNodeShapeMenuItem( _cycle_node_shape_mi, getOptions() ); @@ -251,30 +251,20 @@ public final class MainFrameApplet extends MainFrame { _options_jmenu.add( _search_with_regex_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_REGEX_LABEL ) ); _search_with_regex_cbmi.setToolTipText( MainFrame.SEARCH_WITH_REGEX_TIP ); _options_jmenu.add( _inverse_search_result_cbmi = new JCheckBoxMenuItem( INVERSE_SEARCH_RESULT_LABEL ) ); - // + _options_jmenu.addSeparator(); _options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( "Graphics Export & Printing:" ), getConfiguration() ) ); _options_jmenu.add( _antialias_print_cbmi = new JCheckBoxMenuItem( "Antialias" ) ); _options_jmenu.add( _print_black_and_white_cbmi = new JCheckBoxMenuItem( "Export in Black and White" ) ); _options_jmenu - .add( _print_using_actual_size_cbmi = new JCheckBoxMenuItem( "Use Current Image Size for PDF export and Printing" ) ); - _options_jmenu - .add( _graphics_export_using_actual_size_cbmi = new JCheckBoxMenuItem( "Use Current Image Size for PNG, JPG, and GIF export" ) ); - _options_jmenu .add( _graphics_export_visible_only_cbmi = new JCheckBoxMenuItem( "Limit to Visible ('Screenshot') for PNG, JPG, and GIF export" ) ); - _options_jmenu.add( _print_size_mi = new JMenuItem( "" ) ); _options_jmenu.add( _choose_pdf_width_mi = new JMenuItem( "" ) ); - // + customizeCheckBoxMenuItem( _antialias_print_cbmi, getOptions().isAntialiasPrint() ); customizeCheckBoxMenuItem( _print_black_and_white_cbmi, getOptions().isPrintBlackAndWhite() ); - customizeCheckBoxMenuItem( _graphics_export_visible_only_cbmi, getOptions().isGraphicsExportVisibleOnly() ); - customizeCheckBoxMenuItem( _print_using_actual_size_cbmi, getOptions().isPrintUsingActualSize() ); - customizeCheckBoxMenuItem( _graphics_export_using_actual_size_cbmi, getOptions() - .isGraphicsExportUsingActualSize() ); - customizeJMenuItem( _print_size_mi ); customizeJMenuItem( _choose_pdf_width_mi ); - // + customizeJMenuItem( _choose_font_mi ); customizeJMenuItem( _switch_colors_mi ); customizeJMenuItem( _choose_minimal_confidence_mi ); diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java index d78cf09..1d36727 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java @@ -1776,7 +1776,7 @@ public final class MainFrameApplication extends MainFrame { .setTextMinSupportMenuItem( _choose_minimal_confidence_mi, getOptions(), getCurrentTreePanel() ); MainFrame.setTextForFontChooserMenuItem( _choose_font_mi, MainFrame .createCurrentFontDesc( getMainPanel().getTreeFontSet() ) ); - MainFrame.setTextForGraphicsSizeChooserMenuItem( _print_size_mi, getOptions() ); + // MainFrame.setTextForGraphicsSizeChooserMenuItem( _print_size_mi, getOptions() ); MainFrame.setTextForPdfLineWidthChooserMenuItem( _choose_pdf_width_mi, getOptions() ); MainFrame.setCycleNodeFillMenuItem( _cycle_node_fill_mi, getOptions() ); MainFrame.setCycleNodeShapeMenuItem( _cycle_node_shape_mi, getOptions() ); @@ -1845,13 +1845,13 @@ public final class MainFrameApplication extends MainFrame { getConfiguration() ) ); _options_jmenu.add( _antialias_print_cbmi = new JCheckBoxMenuItem( "Antialias" ) ); _options_jmenu.add( _print_black_and_white_cbmi = new JCheckBoxMenuItem( "Export in Black and White" ) ); - _options_jmenu - .add( _print_using_actual_size_cbmi = new JCheckBoxMenuItem( "Use Current Image Size for PDF export and Printing" ) ); - _options_jmenu - .add( _graphics_export_using_actual_size_cbmi = new JCheckBoxMenuItem( "Use Current Image Size for PNG, JPG, and GIF export" ) ); + //_options_jmenu + //.add( _print_using_actual_size_cbmi = new JCheckBoxMenuItem( "Use Current Image Size for PDF export and Printing" ) ); + //_options_jmenu + //.add( _graphics_export_using_actual_size_cbmi = new JCheckBoxMenuItem( "Use Current Image Size for PNG, JPG, and GIF export" ) ); _options_jmenu .add( _graphics_export_visible_only_cbmi = new JCheckBoxMenuItem( "Limit to Visible ('Screenshot') for PNG, JPG, and GIF export" ) ); - _options_jmenu.add( _print_size_mi = new JMenuItem( "" ) ); + // _options_jmenu.add( _print_size_mi = new JMenuItem( "" ) ); _options_jmenu.add( _choose_pdf_width_mi = new JMenuItem( "" ) ); _options_jmenu.addSeparator(); _options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( "Newick/NHX/Nexus Read:" ), getConfiguration() ) ); @@ -1888,7 +1888,7 @@ public final class MainFrameApplication extends MainFrame { customizeJMenuItem( _choose_font_mi ); customizeJMenuItem( _choose_minimal_confidence_mi ); customizeJMenuItem( _switch_colors_mi ); - customizeJMenuItem( _print_size_mi ); + // customizeJMenuItem( _print_size_mi ); customizeJMenuItem( _choose_pdf_width_mi ); customizeJMenuItem( _overview_placment_mi ); customizeCheckBoxMenuItem( _show_default_node_shapes_external_cbmi, getOptions() @@ -1939,9 +1939,6 @@ public final class MainFrameApplication extends MainFrame { customizeCheckBoxMenuItem( _inverse_search_result_cbmi, getOptions().isInverseSearchResult() ); customizeCheckBoxMenuItem( _color_all_found_nodes_when_coloring_subtree_cbmi, getOptions().isColorAllFoundNodesWhenColoringSubtree() ); customizeCheckBoxMenuItem( _graphics_export_visible_only_cbmi, getOptions().isGraphicsExportVisibleOnly() ); - customizeCheckBoxMenuItem( _print_using_actual_size_cbmi, getOptions().isPrintUsingActualSize() ); - customizeCheckBoxMenuItem( _graphics_export_using_actual_size_cbmi, getOptions() - .isGraphicsExportUsingActualSize() ); customizeCheckBoxMenuItem( _show_confidence_stddev_cbmi, getOptions().isShowConfidenceStddev() ); customizeCheckBoxMenuItem( _use_brackets_for_conf_in_nh_export_cbmi, getOptions() .getNhConversionSupportValueStyle() == NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS ); diff --git a/forester/java/src/org/forester/archaeopteryx/Options.java b/forester/java/src/org/forester/archaeopteryx/Options.java index 4172c52..1143288 100644 --- a/forester/java/src/org/forester/archaeopteryx/Options.java +++ b/forester/java/src/org/forester/archaeopteryx/Options.java @@ -88,7 +88,7 @@ final public class Options { private short _default_node_shape_size; private boolean _editable; private NodeDataField _ext_desc_data_to_return; - private boolean _graphics_export_using_actual_size; + private final boolean _graphics_export_using_actual_size = true; private boolean _graphics_export_visible_only; private boolean _internal_number_are_confidence_for_nh_parsing; private boolean _inverse_search_result; @@ -104,9 +104,7 @@ final public class Options { private PHYLOGENY_GRAPHICS_TYPE _phylogeny_graphics_type; private boolean _print_black_and_white; private float _print_line_width; - private int _print_size_x; - private int _print_size_y; - private boolean _print_using_actual_size; + private final boolean _print_using_actual_size = true; private double _scale_bar_length; private boolean _search_case_sensitive; private boolean _show_annotation_ref_source; @@ -197,18 +195,8 @@ final public class Options { _show_default_node_shapes_external = false; _show_default_node_shapes_for_marked_nodes = false; _color_all_found_nodes_when_coloring_subtree = false; - if ( AptxUtil.isUsOrCanada() ) { - _print_size_x = AptxConstants.US_LETTER_SIZE_X; - _print_size_y = AptxConstants.US_LETTER_SIZE_Y; - } - else { - _print_size_x = AptxConstants.A4_SIZE_X; - _print_size_y = AptxConstants.A4_SIZE_Y; - } _min_confidence_value = MIN_CONFIDENCE_DEFAULT; _print_black_and_white = false; - _print_using_actual_size = true; - _graphics_export_using_actual_size = true; _phylogeny_graphics_type = PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR; _base_font = new Font( Configuration.getDefaultFontFamilyName(), Font.PLAIN, 10 ); _match_whole_terms_only = false; @@ -296,14 +284,6 @@ final public class Options { return _print_line_width; } - final int getPrintSizeX() { - return _print_size_x; - } - - final int getPrintSizeY() { - return _print_size_y; - } - final double getScaleBarLength() { return _scale_bar_length; } @@ -448,18 +428,8 @@ final public class Options { _editable = editable; } - final void setGraphicsExportUsingActualSize( final boolean graphics_export_using_actual_size ) { - _graphics_export_using_actual_size = graphics_export_using_actual_size; - if ( !graphics_export_using_actual_size ) { - setGraphicsExportVisibleOnly( false ); - } - } - final void setGraphicsExportVisibleOnly( final boolean graphics_export_visible_only ) { _graphics_export_visible_only = graphics_export_visible_only; - if ( graphics_export_visible_only ) { - setGraphicsExportUsingActualSize( true ); - } } final void setInternalNumberAreConfidenceForNhParsing( final boolean internal_number_are_confidence_for_nh_parsing ) { @@ -501,19 +471,7 @@ final public class Options { final void setPrintLineWidth( final float print_line_width ) { _print_line_width = print_line_width; } - - final void setPrintSizeX( final int print_size_x ) { - _print_size_x = print_size_x; - } - - final void setPrintSizeY( final int print_size_y ) { - _print_size_y = print_size_y; - } - - final void setPrintUsingActualSize( final boolean print_using_actual_size ) { - _print_using_actual_size = print_using_actual_size; - } - + final void setReplaceUnderscoresInNhParsing( final boolean nh_parsing_replace_underscores ) { _nh_parsing_replace_underscores = nh_parsing_replace_underscores; } @@ -590,12 +548,6 @@ final public class Options { if ( configuration.getMinConfidenceValue() != MIN_CONFIDENCE_DEFAULT ) { instance.setMinConfidenceValue( configuration.getMinConfidenceValue() ); } - if ( configuration.getGraphicsExportX() > 0 ) { - instance.setPrintSizeX( configuration.getGraphicsExportX() ); - } - if ( configuration.getGraphicsExportY() > 0 ) { - instance.setPrintSizeY( configuration.getGraphicsExportY() ); - } if ( configuration.getBaseFontSize() > 0 ) { instance.setBaseFont( instance.getBaseFont().deriveFont( ( float ) configuration.getBaseFontSize() ) ); } diff --git a/forester/java/src/org/forester/archaeopteryx/PdfExporter.java b/forester/java/src/org/forester/archaeopteryx/PdfExporter.java index 2d5bcb0..56b41d6 100644 --- a/forester/java/src/org/forester/archaeopteryx/PdfExporter.java +++ b/forester/java/src/org/forester/archaeopteryx/PdfExporter.java @@ -61,18 +61,28 @@ final class PdfExporter { private static final int HEIGHT_LIMIT = 100; private static final int WIDTH_LIMIT = 60; - + private static final int MARGIN_X = 20; + private static final int MARGIN_Y = 10; + private PdfExporter() { // Empty constructor. } - static String writePhylogenyToPdf( final String file_name, final TreePanel tree_panel, int width, int height ) + static String writePhylogenyToPdf( final String file_name, final TreePanel tree_panel, final int width, final int height ) throws IOException { + final int my_height; + final int my_width; if ( height < HEIGHT_LIMIT ) { - height = HEIGHT_LIMIT; + my_height = HEIGHT_LIMIT + 2 * MARGIN_Y; + } + else { + my_height = height + 2 * MARGIN_Y; } if ( width < WIDTH_LIMIT ) { - width = WIDTH_LIMIT; + my_width = WIDTH_LIMIT + 2 * MARGIN_X; + } + else { + my_width = width + 2 * MARGIN_X; } final Phylogeny phylogeny = tree_panel.getPhylogeny(); if ( ( phylogeny == null ) || phylogeny.isEmpty() ) { @@ -81,13 +91,16 @@ final class PdfExporter { if ( tree_panel.getMainPanel().getTreeFontSet().getSmallFont().getSize() < 1 ) { throw new IOException( "fonts are too small for PDF export" ); } + if ( tree_panel.getMainPanel().getTreeFontSet().getLargeFont().getSize() < 1 ) { + throw new IOException( "fonts are too small for PDF export" ); + } final File file = new File( file_name ); if ( file.isDirectory() ) { throw new IOException( "[" + file_name + "] is a directory" ); } final Document document = new Document(); - document.setPageSize( new Rectangle( width, height ) ); - document.setMargins( WIDTH_LIMIT / 2, WIDTH_LIMIT / 2, HEIGHT_LIMIT / 2, HEIGHT_LIMIT / 2 ); + document.setPageSize( new Rectangle( my_width, my_height ) ); + document.setMargins( MARGIN_X, MARGIN_X, MARGIN_Y, MARGIN_Y ); PdfWriter writer = null; try { writer = PdfWriter.getInstance( document, new FileOutputStream( file_name ) ); @@ -115,10 +128,10 @@ final class PdfExporter { enableUnicode( mapper ); final PdfContentByte cb = writer.getDirectContent(); - final Graphics2D g2 = new PdfGraphics2D(cb, width, height, mapper); + final Graphics2D g2 = new PdfGraphics2D(cb, my_width, my_height, mapper); try { - tree_panel.paintPhylogeny( g2, true, false, width, height, 0, 0 ); + tree_panel.paintPhylogeny( g2, true, false, my_width, my_height, 0, 0 ); } catch ( final Exception e ) { AptxUtil.unexpectedException( e ); @@ -132,10 +145,7 @@ final class PdfExporter { //Do nothing. } } - String msg = file.toString(); - if ( ( width > 0 ) && ( height > 0 ) ) { - msg += " [size: " + width + ", " + height + "]"; - } + final String msg = file.toString() + " [size: " + my_width + ", " + my_height + "]"; return msg; } diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanel.java b/forester/java/src/org/forester/archaeopteryx/TreePanel.java index ff41db5..4b0bf09 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanel.java @@ -4505,8 +4505,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee _longest_ext_node_info = longest; } _length_of_longest_text = calcLengthOfLongestText(); - System.out.println( "_length_of_longest_text=" + _length_of_longest_text ); - //~~ } final void calculateScaleDistance() { -- 1.7.10.2