X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FTreePanel.java;h=559d12033d052e9273027c2b467d6bc62e6e5102;hb=789f3450d14e1f922072f4288833afab71993667;hp=8e786677195e5852271c6044f5057b526312eb3c;hpb=05157d0ba7145aebb34f4d3b6d4c38c380626b2b;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanel.java b/forester/java/src/org/forester/archaeopteryx/TreePanel.java index 8e78667..559d120 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 ); @@ -689,21 +696,25 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } final Color calculateTaxonomyBasedColor( final Taxonomy tax ) { - String species = tax.getTaxonomyCode(); - if ( ForesterUtil.isEmpty( species ) ) { - species = tax.getScientificName(); - if ( ForesterUtil.isEmpty( species ) ) { - species = tax.getCommonName(); - } - } - if ( ForesterUtil.isEmpty( species ) ) { + if ( ForesterUtil.isEmpty( tax.getTaxonomyCode() ) && ForesterUtil.isEmpty( tax.getScientificName() ) ) { return getTreeColorSet().getTaxonomyColor(); } - // Look in species hash - Color c = getControlPanel().getSpeciesColors().get( species ); + Color c = null; + if ( !ForesterUtil.isEmpty( tax.getTaxonomyCode() ) ) { + c = getControlPanel().getSpeciesColors().get( tax.getTaxonomyCode() ); + } + if ( ( c == null ) && !ForesterUtil.isEmpty( tax.getScientificName() ) ) { + c = getControlPanel().getSpeciesColors().get( tax.getScientificName() ); + } if ( c == null ) { - c = AptxUtil.calculateColorFromString( species ); - getControlPanel().getSpeciesColors().put( species, c ); + if ( !ForesterUtil.isEmpty( tax.getTaxonomyCode() ) ) { + c = AptxUtil.calculateColorFromString( tax.getTaxonomyCode() ); + getControlPanel().getSpeciesColors().put( tax.getTaxonomyCode(), c ); + } + else { + c = AptxUtil.calculateColorFromString( tax.getScientificName() ); + getControlPanel().getSpeciesColors().put( tax.getScientificName(), c ); + } } return c; } @@ -1522,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() ) ); @@ -2902,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() ) ) @@ -3226,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" ); @@ -4528,6 +4539,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee final float y = getVisibleRect().y + getOvYPosition() + ( getOvMaxHeight() / y_ratio ); g.setColor( getTreeColorSet().getFoundColor() ); getOvRectangle().setRect( x, y, width, height ); + final Stroke s = g.getStroke(); + g.setStroke( STROKE_1 ); if ( ( width < 6 ) && ( height < 6 ) ) { drawRectFilled( x, y, 6, 6, g ); getOvVirtualRectangle().setRect( x, y, 6, 6 ); @@ -4547,6 +4560,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } getOvVirtualRectangle().setRect( x, y, width, height ); } + g.setStroke( s ); } final private void paintPhylogenyLite( final Graphics2D g ) { @@ -4556,7 +4570,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 ); } @@ -4612,12 +4626,15 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee else { g.setColor( getTreeColorSet().getBranchLengthColor() ); } + final Stroke s = g.getStroke(); + g.setStroke( STROKE_1 ); drawLine( x1, y1, x1, y2, g ); drawLine( x2, y1, x2, y2, g ); drawLine( x1, y3, x2, y3, g ); if ( getScaleLabel() != null ) { g.drawString( getScaleLabel(), ( x1 + 2 ), y3 - 2 ); } + g.setStroke( s ); } final private int paintTaxonomy( final Graphics2D g, @@ -4998,6 +5015,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;