From 6a3cf9e7d44679a89060990327dd4a9c6be84a2b Mon Sep 17 00:00:00 2001 From: cmzmasek Date: Sun, 30 Dec 2012 00:31:31 +0000 Subject: [PATCH] Can now set the initial window size via configuration file for application and ArchA applet. --- .../org/forester/archaeopteryx/Configuration.java | 44 ++++++++++++++++++-- .../forester/archaeopteryx/MainFrameApplet.java | 6 ++- .../archaeopteryx/MainFrameApplication.java | 4 +- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/forester/java/src/org/forester/archaeopteryx/Configuration.java b/forester/java/src/org/forester/archaeopteryx/Configuration.java index 679ec85..8a108dd 100644 --- a/forester/java/src/org/forester/archaeopteryx/Configuration.java +++ b/forester/java/src/org/forester/archaeopteryx/Configuration.java @@ -218,6 +218,8 @@ public final class Configuration { private NODE_DATA _ext_desc_data_to_return = NODE_DATA.UNKNOWN; private String _label_for_get_ext_descendents_data = ""; 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 static String DEFAULT_FONT_FAMILY = ""; static { for( final String font_name : Constants.DEFAULT_FONT_CHOICES ) { @@ -1028,17 +1030,23 @@ public final class Configuration { else if ( key.equals( "font_size" ) ) { final String size_str = ( ( String ) st.nextElement() ).trim(); final int i = parseInt( size_str ); - setBaseFontSize( i ); + if ( i > 0 ) { + setBaseFontSize( i ); + } } else if ( key.equals( "graphics_export_x" ) ) { final String str = ( ( String ) st.nextElement() ).trim(); final int i = parseInt( str ); - setGraphicsExportX( i ); + if ( i > 0 ) { + setGraphicsExportX( i ); + } } else if ( key.equals( "graphics_export_y" ) ) { final String str = ( ( String ) st.nextElement() ).trim(); final int i = parseInt( str ); - setGraphicsExportY( i ); + if ( i > 0 ) { + setGraphicsExportY( i ); + } } else if ( key.equals( "pdf_export_line_width" ) ) { final String str = ( ( String ) st.nextElement() ).trim(); @@ -1051,6 +1059,20 @@ public final class Configuration { "value for [pdf_export_line_width] cannot be zero or negative" ); } } + else if ( key.equals( "window_initial_size_x" ) ) { + final String str = ( ( String ) st.nextElement() ).trim(); + final int i = parseInt( str ); + if ( i > 0 ) { + setFrameXSize( i ); + } + } + else if ( key.equals( "window_initial_size_y" ) ) { + final String str = ( ( String ) st.nextElement() ).trim(); + final int i = parseInt( str ); + if ( i > 0 ) { + setFrameYSize( i ); + } + } else if ( key.equals( "default_number_of_bootstrap_resamples" ) ) { final String str = ( ( String ) st.nextElement() ).trim(); final int i = parseInt( str ); @@ -1676,4 +1698,20 @@ public final class Configuration { private void setExtNodeDataReturnOn( final EXT_NODE_DATA_RETURN_ON ext_node_data_return_on ) { _ext_node_data_return_on = ext_node_data_return_on; } + + public int getFrameXSize() { + return _frame_x_size; + } + + public int getFrameYSize() { + return _frame_y_size; + } + + public void setFrameXSize( final int frame_x_size ) { + _frame_x_size = frame_x_size; + } + + public void setFrameYSize( final int frame_y_size ) { + _frame_y_size = frame_y_size; + } } diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrameApplet.java b/forester/java/src/org/forester/archaeopteryx/MainFrameApplet.java index 2bf378a..492ecc0 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrameApplet.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrameApplet.java @@ -53,7 +53,8 @@ import org.forester.util.ForesterUtil; public final class MainFrameApplet extends MainFrame { private static final long serialVersionUID = 1941019292746717053L; - private final static int FRAME_X_SIZE = 640, FRAME_Y_SIZE = 580; + private final static int DEFAULT_FRAME_X_SIZE = 640; + private final static int DEFAULT_FRAME_Y_SIZE = 580; private final ArchaeopteryxA _applet; private ButtonGroup _radio_group_1; @@ -122,7 +123,8 @@ public final class MainFrameApplet extends MainFrame { _contentpane = getContentPane(); _contentpane.setLayout( new BorderLayout() ); _contentpane.add( _mainpanel, BorderLayout.CENTER ); - setSize( FRAME_X_SIZE, FRAME_Y_SIZE ); + setSize( getConfiguration().getFrameXSize() > 40 ? getConfiguration().getFrameXSize() : DEFAULT_FRAME_X_SIZE, + getConfiguration().getFrameYSize() > 40 ? getConfiguration().getFrameYSize() : DEFAULT_FRAME_Y_SIZE ); addWindowListener( new WindowAdapter() { @Override diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java index ca14a87..7c13694 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java @@ -350,7 +350,9 @@ public final class MainFrameApplication extends MainFrame { _contentpane.setLayout( new BorderLayout() ); _contentpane.add( _mainpanel, BorderLayout.CENTER ); // App is this big - setSize( MainFrameApplication.FRAME_X_SIZE, MainFrameApplication.FRAME_Y_SIZE ); + setSize( getConfiguration().getFrameXSize() > 40 ? getConfiguration().getFrameXSize() : FRAME_X_SIZE, + getConfiguration().getFrameYSize() > 40 ? getConfiguration().getFrameYSize() : FRAME_Y_SIZE ); + // addWindowFocusListener( new WindowAdapter() { // // @Override -- 1.7.10.2