From e187f3c61f7eea7dcb2cc6d0c0a7556f384d98d8 Mon Sep 17 00:00:00 2001 From: "cmzmasek@gmail.com" Date: Mon, 1 Apr 2013 23:16:10 +0000 Subject: [PATCH] inprogress --- .../src/org/forester/archaeopteryx/AptxUtil.java | 24 +------ .../org/forester/archaeopteryx/Configuration.java | 13 ++-- .../src/org/forester/archaeopteryx/Constants.java | 4 +- .../org/forester/archaeopteryx/ControlPanel.java | 2 +- .../archaeopteryx/MainFrameApplication.java | 2 +- .../org/forester/archaeopteryx/PdfExporter.java | 5 +- .../src/org/forester/archaeopteryx/TreePanel.java | 67 ++++++++++++++------ .../src/org/forester/util/ForesterConstants.java | 4 +- .../java/src/org/forester/util/ForesterUtil.java | 21 +++++- 9 files changed, 85 insertions(+), 57 deletions(-) diff --git a/forester/java/src/org/forester/archaeopteryx/AptxUtil.java b/forester/java/src/org/forester/archaeopteryx/AptxUtil.java index 35b0e2b..3329a3a 100644 --- a/forester/java/src/org/forester/archaeopteryx/AptxUtil.java +++ b/forester/java/src/org/forester/archaeopteryx/AptxUtil.java @@ -919,17 +919,6 @@ public final class AptxUtil { return true; } - final static boolean isMac() { - try { - final String s = ForesterUtil.OS_NAME.toLowerCase(); - return s.startsWith( "mac" ); - } - catch ( final Exception e ) { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "minor error: " + e ); - return false; - } - } - final static boolean isUsOrCanada() { try { if ( ( Locale.getDefault().equals( Locale.CANADA ) ) || ( Locale.getDefault().equals( Locale.US ) ) ) { @@ -942,17 +931,6 @@ public final class AptxUtil { return false; } - final static boolean isWindows() { - try { - final String s = ForesterUtil.OS_NAME.toLowerCase(); - return s.indexOf( "win" ) > -1; - } - catch ( final Exception e ) { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "minor error: " + e ); - return false; - } - } - final static void lookAtSomeTreePropertiesForAptxControlSettings( final Phylogeny t, final ControlPanel atv_control, final Configuration configuration ) { @@ -1298,7 +1276,7 @@ public final class AptxUtil { if ( os.toLowerCase().startsWith( "win" ) ) { Runtime.getRuntime().exec( "rundll32 url.dll,FileProtocolHandler " + url ); } - else if ( isMac() ) { + else if ( ForesterUtil.isMac() ) { final Class file_mgr = Class.forName( "com.apple.eio.FileManager" ); final Method open_url = file_mgr.getDeclaredMethod( "openURL", new Class[] { String.class } ); open_url.invoke( null, new Object[] { url } ); diff --git a/forester/java/src/org/forester/archaeopteryx/Configuration.java b/forester/java/src/org/forester/archaeopteryx/Configuration.java index 1f89033..3839128 100644 --- a/forester/java/src/org/forester/archaeopteryx/Configuration.java +++ b/forester/java/src/org/forester/archaeopteryx/Configuration.java @@ -723,10 +723,10 @@ public final class Configuration { } boolean isAntialiasScreen() { - if ( AptxUtil.isMac() ) { - // Apple Macintosh graphics are slow, turn off anti-alias. - return false; - } + // if ( AptxUtil.isMac() ) { + // Apple Macintosh graphics are slow, turn off anti-alias. + // return false; + //} return _antialias_screen; } @@ -772,7 +772,7 @@ public final class Configuration { } final boolean isUseNativeUI() { - if ( ( _ui == UI.UNKNOWN ) && AptxUtil.isMac() ) { + if ( ( _ui == UI.UNKNOWN ) && ForesterUtil.isMac() ) { _ui = UI.NATIVE; } return _ui == UI.NATIVE; @@ -1615,7 +1615,8 @@ public final class Configuration { } } else if ( key.equals( "species_color" ) ) { - getSpeciesColors().put( ( ( String ) st.nextElement() ).replace( '_', ' ' ), Color.decode( ( String ) st.nextElement() ) ); + getSpeciesColors().put( ( ( String ) st.nextElement() ).replace( '_', ' ' ), + Color.decode( ( String ) st.nextElement() ) ); } else if ( key.equals( "domain_color" ) ) { getDomainColors().put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) ); diff --git a/forester/java/src/org/forester/archaeopteryx/Constants.java b/forester/java/src/org/forester/archaeopteryx/Constants.java index 09e5912..8dd077f 100644 --- a/forester/java/src/org/forester/archaeopteryx/Constants.java +++ b/forester/java/src/org/forester/archaeopteryx/Constants.java @@ -42,8 +42,8 @@ public final class Constants { public final static boolean __SYNTH_LF = false; // TODO remove me public final static boolean ALLOW_DDBJ_BLAST = false; public final static String PRG_NAME = "Archaeopteryx"; - final static String VERSION = "0.9811 A1ST"; - final static String PRG_DATE = "130327"; + final static String VERSION = "0.9812 A1ST"; + final static String PRG_DATE = "130401"; final static String DEFAULT_CONFIGURATION_FILE_NAME = "_aptx_configuration_file"; final static String[] DEFAULT_FONT_CHOICES = { "Arial", "Helvetica", "Verdana", "Tahoma", "Dialog", "Lucida Sans", "SansSerif", "Sans-serif", "Sans" }; diff --git a/forester/java/src/org/forester/archaeopteryx/ControlPanel.java b/forester/java/src/org/forester/archaeopteryx/ControlPanel.java index d1c071c..95a53b4 100644 --- a/forester/java/src/org/forester/archaeopteryx/ControlPanel.java +++ b/forester/java/src/org/forester/archaeopteryx/ControlPanel.java @@ -475,7 +475,7 @@ final class ControlPanel extends JPanel implements ActionListener { _zoom_in_y.setToolTipText( "To zoom in vertically [Shift+cursor-up]" ); _zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+cursor-left]" ); _zoom_out_y.setToolTipText( "To zoom out vertically [Shift+cursor-down]" ); - if ( getConfiguration().isUseNativeUI() && AptxUtil.isMac() ) { + if ( getConfiguration().isUseNativeUI() && ForesterUtil.isMac() ) { _zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) ); _zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) ); } diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java index ebb8fd1..53ca7cb 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java @@ -1875,7 +1875,7 @@ public final class MainFrameApplication extends MainFrame { private File getCurrentDir() { if ( ( _current_dir == null ) || !_current_dir.canRead() ) { - if ( ForesterUtil.isWindowns() ) { + if ( ForesterUtil.isWindows() ) { try { _current_dir = new File( WindowsUtils.getCurrentUserDesktopPath() ); } diff --git a/forester/java/src/org/forester/archaeopteryx/PdfExporter.java b/forester/java/src/org/forester/archaeopteryx/PdfExporter.java index 6305a85..9a422d3 100644 --- a/forester/java/src/org/forester/archaeopteryx/PdfExporter.java +++ b/forester/java/src/org/forester/archaeopteryx/PdfExporter.java @@ -34,6 +34,7 @@ import java.io.FileOutputStream; import java.io.IOException; import org.forester.phylogeny.Phylogeny; +import org.forester.util.ForesterUtil; import com.itextpdf.text.Document; import com.itextpdf.text.DocumentException; @@ -92,10 +93,10 @@ final class PdfExporter { document.open(); final DefaultFontMapper mapper = new DefaultFontMapper(); FontFactory.registerDirectories(); - if ( AptxUtil.isWindows() ) { + if ( ForesterUtil.isWindows() ) { mapper.insertDirectory( "C:\\WINDOWS\\Fonts\\" ); } - else if ( AptxUtil.isMac() ) { + else if ( ForesterUtil.isMac() ) { mapper.insertDirectory( "/Library/Fonts/" ); mapper.insertDirectory( "/System/Library/Fonts/" ); } diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanel.java b/forester/java/src/org/forester/archaeopteryx/TreePanel.java index 1a5fc6f..fce060b 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanel.java @@ -131,6 +131,13 @@ import org.forester.util.SequenceIdParser; public final class TreePanel extends JPanel implements ActionListener, MouseWheelListener, Printable { + private static final BasicStroke STROKE_2 = new BasicStroke( 2f ); + private static final BasicStroke STROKE_1 = new BasicStroke( 1f ); + private static final BasicStroke STROKE_075 = new BasicStroke( 0.75f ); + private static final BasicStroke STROKE_05 = new BasicStroke( 0.5f ); + private static final BasicStroke STROKE_025 = new BasicStroke( 0.25f ); + private static final BasicStroke STROKE_01 = new BasicStroke( 0.1f ); + private static final BasicStroke STROKE_005 = new BasicStroke( 0.05f ); private static final float PI = ( float ) ( Math.PI ); private static final double TWO_PI = 2 * Math.PI; private static final float ONEHALF_PI = ( float ) ( 1.5 * Math.PI ); @@ -696,7 +703,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee if ( !ForesterUtil.isEmpty( tax.getTaxonomyCode() ) ) { c = getControlPanel().getSpeciesColors().get( tax.getTaxonomyCode() ); } - if ( c == null && !ForesterUtil.isEmpty( tax.getScientificName() ) ) { + if ( ( c == null ) && !ForesterUtil.isEmpty( tax.getScientificName() ) ) { c = getControlPanel().getSpeciesColors().get( tax.getScientificName() ); } if ( c == null ) { @@ -704,7 +711,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee c = AptxUtil.calculateColorFromString( tax.getTaxonomyCode() ); getControlPanel().getSpeciesColors().put( tax.getTaxonomyCode(), c ); } - else { + else { c = AptxUtil.calculateColorFromString( tax.getScientificName() ); getControlPanel().getSpeciesColors().put( tax.getScientificName(), c ); } @@ -1526,7 +1533,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee g.fillRect( graphics_file_x, graphics_file_y, graphics_file_width, graphics_file_height ); } } - g.setStroke( new BasicStroke( 1 ) ); + setupStroke( g ); } else { g.setStroke( new BasicStroke( getOptions().getPrintLineWidth() ) ); @@ -2906,6 +2913,20 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee return Blast.isContainsQueryForBlast( node ); } + final private String isCanOpenSeqWeb( final PhylogenyNode node ) { + String v = ForesterUtil.extractUniProtKbProteinSeqIdentifier( node ); + if ( ForesterUtil.isEmpty( v ) ) { + v = ForesterUtil.extractGenbankAccessor( node ); + } + if ( ForesterUtil.isEmpty( v ) ) { + v = ForesterUtil.extractRefSeqAccessorAccessor( node ); + } + if ( ForesterUtil.isEmpty( v ) ) { + v = ForesterUtil.extractGInumber( node ); + } + return v; + } + final private boolean isCanOpenTaxWeb( final PhylogenyNode node ) { if ( node.getNodeData().isHasTaxonomy() && ( ( !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getScientificName() ) ) @@ -3230,20 +3251,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } } - final private String isCanOpenSeqWeb( final PhylogenyNode node ) { - String v = ForesterUtil.extractUniProtKbProteinSeqIdentifier( node ); - if ( ForesterUtil.isEmpty( v ) ) { - v = ForesterUtil.extractGenbankAccessor( node ); - } - if ( ForesterUtil.isEmpty( v ) ) { - v = ForesterUtil.extractRefSeqAccessorAccessor( node ); - } - if ( ForesterUtil.isEmpty( v ) ) { - v = ForesterUtil.extractGInumber( node ); - } - return v; - } - final private void openSeqWeb( final PhylogenyNode node ) { if ( ForesterUtil.isEmpty( isCanOpenSeqWeb( node ) ) ) { cannotOpenBrowserWarningMessage( "sequence" ); @@ -4560,7 +4567,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee .getWidth() ) ) ) ); _phylogeny.getRoot().setYSecondary( ( getVisibleRect().y + getOvYStart() ) ); final Stroke s = g.getStroke(); - g.setStroke( new BasicStroke( 0.5f ) ); //TODO + g.setStroke( STROKE_05 ); for( final PhylogenyNode element : _nodes_in_preorder ) { paintNodeLite( g, element ); } @@ -5002,6 +5009,30 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee _scale_label = scale_label; } + private final void setupStroke( final Graphics2D g ) { + if ( getYdistance() < 0.001 ) { + g.setStroke( STROKE_005 ); + } + else if ( getYdistance() < 0.01 ) { + g.setStroke( STROKE_01 ); + } + else if ( getYdistance() < 0.5 ) { + g.setStroke( STROKE_025 ); + } + else if ( getYdistance() < 1 ) { + g.setStroke( STROKE_05 ); + } + else if ( getYdistance() < 2 ) { + g.setStroke( STROKE_075 ); + } + else if ( getYdistance() < 20 ) { + g.setStroke( STROKE_1 ); + } + else { + g.setStroke( STROKE_2 ); + } + } + final private void setUpUrtFactor() { final int d = getVisibleRect().width < getVisibleRect().height ? getVisibleRect().width : getVisibleRect().height; diff --git a/forester/java/src/org/forester/util/ForesterConstants.java b/forester/java/src/org/forester/util/ForesterConstants.java index 7fd321c..823fd96 100644 --- a/forester/java/src/org/forester/util/ForesterConstants.java +++ b/forester/java/src/org/forester/util/ForesterConstants.java @@ -27,8 +27,8 @@ package org.forester.util; public final class ForesterConstants { - public final static String FORESTER_VERSION = "1.026"; - public final static String FORESTER_DATE = "130326"; + public final static String FORESTER_VERSION = "1.027"; + public final static String FORESTER_DATE = "130401"; public final static String PHYLO_XML_VERSION = "1.10"; public final static String PHYLO_XML_LOCATION = "http://www.phyloxml.org"; public final static String PHYLO_XML_XSD = "phyloxml.xsd"; diff --git a/forester/java/src/org/forester/util/ForesterUtil.java b/forester/java/src/org/forester/util/ForesterUtil.java index a8c81b0..c98edc0 100644 --- a/forester/java/src/org/forester/util/ForesterUtil.java +++ b/forester/java/src/org/forester/util/ForesterUtil.java @@ -62,6 +62,7 @@ import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.forester.archaeopteryx.Constants; import org.forester.phylogeny.PhylogenyNode; import org.forester.phylogeny.data.Distribution; import org.forester.phylogeny.data.Sequence; @@ -683,8 +684,24 @@ public final class ForesterUtil { return isReadableFile( new File( s ) ); } - public static boolean isWindowns() { - return ForesterUtil.OS_NAME.toLowerCase().indexOf( "win" ) > -1; + public final static boolean isWindows() { + try { + return OS_NAME.toLowerCase().indexOf( "win" ) > -1; + } + catch ( final Exception e ) { + ForesterUtil.printWarningMessage( Constants.PRG_NAME, "minor error: " + e ); + return false; + } + } + + public final static boolean isMac() { + try { + return OS_NAME.toLowerCase().startsWith( "mac" ); + } + catch ( final Exception e ) { + ForesterUtil.printWarningMessage( Constants.PRG_NAME, "minor error: " + e ); + return false; + } } final public static String isWritableFile( final File f ) { -- 1.7.10.2