From: cmzmasek@gmail.com Date: Wed, 9 Mar 2011 19:36:18 +0000 (+0000) Subject: in progress (broken, at the moment)... X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=aecd652a29342d239f7d90e21e6526d71f44bd33;p=jalview.git in progress (broken, at the moment)... --- diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanel.java b/forester/java/src/org/forester/archaeopteryx/TreePanel.java index a82f574..2f3df26 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanel.java @@ -228,6 +228,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee false ); // expression values menu: private DescriptiveStatistics _statistics_for_vector_data; + private PhylogenyNode[] _nodes_in_preorder = null; // private Image offscreenImage; // private Graphics offscreenGraphics; // private Dimension offscreenDimension; @@ -3468,9 +3469,21 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee getControlPanel().setDynamicHidingIsOn( false ); } } - final PhylogenyNodeIterator it; - for( it = _phylogeny.iteratorPreorder(); it.hasNext(); ) { - paintNodeRectangular( g, it.next(), to_pdf, getControlPanel().isDynamicallyHideData() + if ( _nodes_in_preorder == null ) { + _nodes_in_preorder = new PhylogenyNode[ _phylogeny.getNodeCount() ]; + System.out.println( "total nodes: " + _nodes_in_preorder.length ); + int i = 0; + for( final PhylogenyNodeIterator it = _phylogeny.iteratorPreorder(); it.hasNext(); ) { + _nodes_in_preorder[ i++ ] = it.next(); + } + } + //final PhylogenyNodeIterator it; + //for( it = _phylogeny.iteratorPreorder(); it.hasNext(); ) { + // paintNodeRectangular( g, it.next(), to_pdf, getControlPanel().isDynamicallyHideData() + // && ( dynamic_hiding_factor > 1 ), dynamic_hiding_factor, to_graphics_file ); + //} + for( int i = 0; i < _nodes_in_preorder.length; ++i ) { + paintNodeRectangular( g, _nodes_in_preorder[ i ], to_pdf, getControlPanel().isDynamicallyHideData() && ( dynamic_hiding_factor > 1 ), dynamic_hiding_factor, to_graphics_file ); } if ( getOptions().isShowScale() && getControlPanel().isDrawPhylogram() && ( getScaleDistance() > 0.0 ) ) { @@ -3591,9 +3604,12 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee .setXSecondary( ( float ) ( getVisibleRect().x + getOvXPosition() + ( MOVE / ( getVisibleRect().width / getOvRectangle() .getWidth() ) ) ) ); _phylogeny.getRoot().setYSecondary( ( getVisibleRect().y + getOvYStart() ) ); - final PhylogenyNodeIterator it; - for( it = _phylogeny.iteratorPreorder(); it.hasNext(); ) { - paintNodeLite( g, it.next() ); + //final PhylogenyNodeIterator it; + //for( it = _phylogeny.iteratorPreorder(); it.hasNext(); ) { + // paintNodeLite( g, it.next() ); + //} + for( int i = 0; i < _nodes_in_preorder.length; ++i ) { + paintNodeLite( g, _nodes_in_preorder[ i ] ); } paintOvRectangle( g ); } diff --git a/forester/java/src/org/forester/phylogeny/Phylogeny.java b/forester/java/src/org/forester/phylogeny/Phylogeny.java index 1a4892d..4d0dae6 100644 --- a/forester/java/src/org/forester/phylogeny/Phylogeny.java +++ b/forester/java/src/org/forester/phylogeny/Phylogeny.java @@ -563,6 +563,21 @@ public class Phylogeny { return nodes.get( 0 ); } + /** + * This is time-inefficient since it runs a iterator each time it is called. + * + */ + public int getNodeCount() { + if ( isEmpty() ) { + return 0; + } + int c = 0; + for( PhylogenyNodeIterator it = iteratorPreorder(); it.hasNext(); it.next() ) { + ++c; + } + return c; + } + public int getNumberOfBranches() { if ( isEmpty() ) { return 0;