inprogress
[jalview.git] / forester / java / src / org / forester / archaeopteryx / TreePanel.java
index 1a4fef3..8f8baa4 100644 (file)
@@ -100,6 +100,7 @@ import org.forester.archaeopteryx.phylogeny.data.RenderableVector;
 import org.forester.archaeopteryx.tools.Blast;
 import org.forester.archaeopteryx.tools.ImageLoader;
 import org.forester.io.parsers.phyloxml.PhyloXmlUtil;
+import org.forester.io.writers.SequenceWriter;
 import org.forester.phylogeny.Phylogeny;
 import org.forester.phylogeny.PhylogenyMethods;
 import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;
@@ -129,113 +130,112 @@ import org.forester.util.SequenceIdParser;
 
 public final class TreePanel extends JPanel implements ActionListener, MouseWheelListener, Printable {
 
-    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 );
-    private static final float              HALF_PI                                            = ( float ) ( Math.PI / 2.0 );
-    private static final float              ANGLE_ROTATION_UNIT                                = ( float ) ( Math.PI / 32 );
-    private static final short              OV_BORDER                                          = 10;
-    final static Cursor                     CUT_CURSOR                                         = Cursor.getPredefinedCursor( Cursor.CROSSHAIR_CURSOR );
-    final static Cursor                     MOVE_CURSOR                                        = Cursor.getPredefinedCursor( Cursor.MOVE_CURSOR );
-    final static Cursor                     ARROW_CURSOR                                       = Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR );
-    final static Cursor                     HAND_CURSOR                                        = Cursor.getPredefinedCursor( Cursor.HAND_CURSOR );
-    final static Cursor                     WAIT_CURSOR                                        = Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR );
-    private final static long               serialVersionUID                                   = -978349745916505029L;
-    private final static int                EURO_D                                             = 10;
-    private final static String             NODE_POPMENU_NODE_CLIENT_PROPERTY                  = "node";
-    private final static int                MIN_ROOT_LENGTH                                    = 3;
-    private final static int                MAX_SUBTREES                                       = 100;
-    private final static int                MAX_NODE_FRAMES                                    = 10;
-    private final static int                MOVE                                               = 20;
-    private final static NumberFormat       FORMATTER_CONFIDENCE;
-    private final static NumberFormat       FORMATTER_BRANCH_LENGTH;
-    private final static int                WIGGLE                                             = 2;
-    private final static int                LIMIT_FOR_HQ_RENDERING                             = 1000;
-    private final static int                CONFIDENCE_LEFT_MARGIN                             = 4;
-    private final RenderingHints            _rendering_hints                                   = new RenderingHints( RenderingHints.KEY_RENDERING,
-                                                                                                                     RenderingHints.VALUE_RENDER_DEFAULT );
-    private File                            _treefile                                          = null;
-    private Configuration                   _configuration                                     = null;
-    private final NodeFrame[]               _node_frames                                       = new NodeFrame[ TreePanel.MAX_NODE_FRAMES ];
-    private int                             _node_frame_index                                  = 0;
-    private Phylogeny                       _phylogeny                                         = null;
-    private final Phylogeny[]               _sub_phylogenies                                   = new Phylogeny[ TreePanel.MAX_SUBTREES ];
-    private final PhylogenyNode[]           _sub_phylogenies_temp_roots                        = new PhylogenyNode[ TreePanel.MAX_SUBTREES ];
-    private int                             _subtree_index                                     = 0;
-    private MainPanel                       _main_panel                                        = null;
-    private Set<Integer>                    _found_nodes                                       = null;
-    private PhylogenyNode                   _highlight_node                                    = null;
-    private JPopupMenu                      _node_popup_menu                                   = null;
-    private JMenuItem                       _node_popup_menu_items[]                           = null;
-    private int                             _longest_ext_node_info                             = 0;
-    private float                           _x_correction_factor                               = 0.0f;
-    private float                           _ov_x_correction_factor                            = 0.0f;
-    private float                           _x_distance                                        = 0.0f;
-    private float                           _y_distance                                        = 0.0f;
-    private PHYLOGENY_GRAPHICS_TYPE         _graphics_type                                     = PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR;
-    private double                          _domain_structure_width                            = Constants.DOMAIN_STRUCTURE_DEFAULT_WIDTH;
-    private int                             _domain_structure_e_value_thr_exp                  = Constants.DOMAIN_STRUCTURE_E_VALUE_THR_DEFAULT_EXP;
-    private float                           _last_drag_point_x                                 = 0;
-    private float                           _last_drag_point_y                                 = 0;
-    private ControlPanel                    _control_panel                                     = null;
-    private int                             _external_node_index                               = 0;
-    private final Polygon                   _polygon                                           = new Polygon();
-    private final StringBuilder             _sb                                                = new StringBuilder();
-    private JColorChooser                   _color_chooser                                     = null;
-    private double                          _scale_distance                                    = 0.0;
-    private String                          _scale_label                                       = null;
-    private final CubicCurve2D              _cubic_curve                                       = new CubicCurve2D.Float();
-    private final QuadCurve2D               _quad_curve                                        = new QuadCurve2D.Float();
-    private final Line2D                    _line                                              = new Line2D.Float();
-    private final Ellipse2D                 _ellipse                                           = new Ellipse2D.Float();
-    private final Rectangle2D               _rectangle                                         = new Rectangle2D.Float();
-    private Options                         _options                                           = null;
-    private float                           _ov_max_width                                      = 0;
-    private float                           _ov_max_height                                     = 0;
-    private int                             _ov_x_position                                     = 0;
-    private int                             _ov_y_position                                     = 0;
-    private int                             _ov_y_start                                        = 0;
-    private float                           _ov_y_distance                                     = 0;
-    private float                           _ov_x_distance                                     = 0;
-    private boolean                         _ov_on                                             = false;
-    private double                          _urt_starting_angle                                = ( float ) ( Math.PI / 2 );
-    private float                           _urt_factor                                        = 1;
-    private float                           _urt_factor_ov                                     = 1;
-    private final boolean                   _phy_has_branch_lengths;
-    private final Rectangle2D               _ov_rectangle                                      = new Rectangle2D.Float();
-    private boolean                         _in_ov_rect                                        = false;
-    private boolean                         _in_ov                                             = false;
-    private final Rectangle                 _ov_virtual_rectangle                              = new Rectangle();
-    final private static double             _180_OVER_PI                                       = 180.0 / Math.PI;
-    private static final float              ROUNDED_D                                          = 8;
-    private int                             _circ_max_depth;
-    private PhylogenyNode                   _root;
-    final private Arc2D                     _arc                                               = new Arc2D.Double();
-    final private HashMap<Integer, Double>  _urt_nodeid_angle_map                              = new HashMap<Integer, Double>();
-    final private HashMap<Integer, Integer> _urt_nodeid_index_map                              = new HashMap<Integer, Integer>();
-    final private Set<Integer>              _collapsed_external_nodeid_set                     = new HashSet<Integer>();
-    HashMap<Integer, Short>                 _nodeid_dist_to_leaf                               = new HashMap<Integer, Short>();
-    private AffineTransform                 _at;
-    private double                          _max_distance_to_root                              = -1;
-    private int                             _dynamic_hiding_factor                             = 0;
-    private boolean                         _edited                                            = false;
-    private Popup                           _node_desc_popup;
-    private JTextArea                       _rollover_popup;
-    private final StringBuffer              _popup_buffer                                      = new StringBuffer();
-    final private static Font               POPUP_FONT                                         = new Font( Configuration
-                                                                                                                   .getDefaultFontFamilyName(),
-                                                                                                           Font.PLAIN,
-                                                                                                           12 );
-    private Sequence                        _query_sequence                                    = null;
-    private final FontRenderContext         _frc                                               = new FontRenderContext( null,
-                                                                                                                        false,
-                                                                                                                        false );
+    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 );
+    private static final float           HALF_PI                                            = ( float ) ( Math.PI / 2.0 );
+    private static final float           ANGLE_ROTATION_UNIT                                = ( float ) ( Math.PI / 32 );
+    private static final short           OV_BORDER                                          = 10;
+    final static Cursor                  CUT_CURSOR                                         = Cursor.getPredefinedCursor( Cursor.CROSSHAIR_CURSOR );
+    final static Cursor                  MOVE_CURSOR                                        = Cursor.getPredefinedCursor( Cursor.MOVE_CURSOR );
+    final static Cursor                  ARROW_CURSOR                                       = Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR );
+    final static Cursor                  HAND_CURSOR                                        = Cursor.getPredefinedCursor( Cursor.HAND_CURSOR );
+    final static Cursor                  WAIT_CURSOR                                        = Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR );
+    private final static long            serialVersionUID                                   = -978349745916505029L;
+    private final static int             EURO_D                                             = 10;
+    private final static String          NODE_POPMENU_NODE_CLIENT_PROPERTY                  = "node";
+    private final static int             MIN_ROOT_LENGTH                                    = 3;
+    private final static int             MAX_SUBTREES                                       = 100;
+    private final static int             MAX_NODE_FRAMES                                    = 10;
+    private final static int             MOVE                                               = 20;
+    private final static NumberFormat    FORMATTER_CONFIDENCE;
+    private final static NumberFormat    FORMATTER_BRANCH_LENGTH;
+    private final static int             WIGGLE                                             = 2;
+    private final static int             LIMIT_FOR_HQ_RENDERING                             = 1000;
+    private final static int             CONFIDENCE_LEFT_MARGIN                             = 4;
+    private final RenderingHints         _rendering_hints                                   = new RenderingHints( RenderingHints.KEY_RENDERING,
+                                                                                                                  RenderingHints.VALUE_RENDER_DEFAULT );
+    private File                         _treefile                                          = null;
+    private Configuration                _configuration                                     = null;
+    private final NodeFrame[]            _node_frames                                       = new NodeFrame[ TreePanel.MAX_NODE_FRAMES ];
+    private int                          _node_frame_index                                  = 0;
+    private Phylogeny                    _phylogeny                                         = null;
+    private final Phylogeny[]            _sub_phylogenies                                   = new Phylogeny[ TreePanel.MAX_SUBTREES ];
+    private final PhylogenyNode[]        _sub_phylogenies_temp_roots                        = new PhylogenyNode[ TreePanel.MAX_SUBTREES ];
+    private int                          _subtree_index                                     = 0;
+    private MainPanel                    _main_panel                                        = null;
+    private Set<Long>                    _found_nodes                                       = null;
+    private PhylogenyNode                _highlight_node                                    = null;
+    private JPopupMenu                   _node_popup_menu                                   = null;
+    private JMenuItem                    _node_popup_menu_items[]                           = null;
+    private int                          _longest_ext_node_info                             = 0;
+    private float                        _x_correction_factor                               = 0.0f;
+    private float                        _ov_x_correction_factor                            = 0.0f;
+    private float                        _x_distance                                        = 0.0f;
+    private float                        _y_distance                                        = 0.0f;
+    private PHYLOGENY_GRAPHICS_TYPE      _graphics_type                                     = PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR;
+    private double                       _domain_structure_width                            = Constants.DOMAIN_STRUCTURE_DEFAULT_WIDTH;
+    private int                          _domain_structure_e_value_thr_exp                  = Constants.DOMAIN_STRUCTURE_E_VALUE_THR_DEFAULT_EXP;
+    private float                        _last_drag_point_x                                 = 0;
+    private float                        _last_drag_point_y                                 = 0;
+    private ControlPanel                 _control_panel                                     = null;
+    private int                          _external_node_index                               = 0;
+    private final Polygon                _polygon                                           = new Polygon();
+    private final StringBuilder          _sb                                                = new StringBuilder();
+    private JColorChooser                _color_chooser                                     = null;
+    private double                       _scale_distance                                    = 0.0;
+    private String                       _scale_label                                       = null;
+    private final CubicCurve2D           _cubic_curve                                       = new CubicCurve2D.Float();
+    private final QuadCurve2D            _quad_curve                                        = new QuadCurve2D.Float();
+    private final Line2D                 _line                                              = new Line2D.Float();
+    private final Ellipse2D              _ellipse                                           = new Ellipse2D.Float();
+    private final Rectangle2D            _rectangle                                         = new Rectangle2D.Float();
+    private Options                      _options                                           = null;
+    private float                        _ov_max_width                                      = 0;
+    private float                        _ov_max_height                                     = 0;
+    private int                          _ov_x_position                                     = 0;
+    private int                          _ov_y_position                                     = 0;
+    private int                          _ov_y_start                                        = 0;
+    private float                        _ov_y_distance                                     = 0;
+    private float                        _ov_x_distance                                     = 0;
+    private boolean                      _ov_on                                             = false;
+    private double                       _urt_starting_angle                                = ( float ) ( Math.PI / 2 );
+    private float                        _urt_factor                                        = 1;
+    private float                        _urt_factor_ov                                     = 1;
+    private final boolean                _phy_has_branch_lengths;
+    private final Rectangle2D            _ov_rectangle                                      = new Rectangle2D.Float();
+    private boolean                      _in_ov_rect                                        = false;
+    private boolean                      _in_ov                                             = false;
+    private final Rectangle              _ov_virtual_rectangle                              = new Rectangle();
+    final private static double          _180_OVER_PI                                       = 180.0 / Math.PI;
+    private static final float           ROUNDED_D                                          = 8;
+    private int                          _circ_max_depth;
+    private PhylogenyNode                _root;
+    final private Arc2D                  _arc                                               = new Arc2D.Double();
+    final private HashMap<Long, Double>  _urt_nodeid_angle_map                              = new HashMap<Long, Double>();
+    final private HashMap<Long, Integer> _urt_nodeid_index_map                              = new HashMap<Long, Integer>();
+    final private Set<Long>              _collapsed_external_nodeid_set                     = new HashSet<Long>();
+    HashMap<Long, Short>                 _nodeid_dist_to_leaf                               = new HashMap<Long, Short>();
+    private AffineTransform              _at;
+    private double                       _max_distance_to_root                              = -1;
+    private int                          _dynamic_hiding_factor                             = 0;
+    private boolean                      _edited                                            = false;
+    private Popup                        _node_desc_popup;
+    private JTextArea                    _rollover_popup;
+    private final StringBuffer           _popup_buffer                                      = new StringBuffer();
+    final private static Font            POPUP_FONT                                         = new Font( Configuration.getDefaultFontFamilyName(),
+                                                                                                        Font.PLAIN,
+                                                                                                        12 );
+    private Sequence                     _query_sequence                                    = null;
+    private final FontRenderContext      _frc                                               = new FontRenderContext( null,
+                                                                                                                     false,
+                                                                                                                     false );
     // expression values menu:
-    private DescriptiveStatistics           _statistics_for_vector_data;
-    private PhylogenyNode[]                 _nodes_in_preorder                                 = null;
-    private StringBuilder                   _current_external_nodes_data_buffer                = new StringBuilder();
-    private int                             _current_external_nodes_data_buffer_change_counter = 0;
-    private Set<Integer>                    _current_external_nodes                            = null;
+    private DescriptiveStatistics        _statistics_for_vector_data;
+    private PhylogenyNode[]              _nodes_in_preorder                                 = null;
+    private StringBuilder                _current_external_nodes_data_buffer                = new StringBuilder();
+    private int                          _current_external_nodes_data_buffer_change_counter = 0;
+    private Set<Long>                    _current_external_nodes                            = null;
     //  private Image                           offscreenImage;
     //  private Graphics                        offscreenGraphics;
     //  private Dimension                       offscreenDimension;
@@ -307,65 +307,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         requestFocusInWindow();
     }
 
-    public void checkForVectorProperties( final Phylogeny phy ) {
-        final DescriptiveStatistics stats = new BasicDescriptiveStatistics();
-        for( final PhylogenyNodeIterator iter = phy.iteratorPreorder(); iter.hasNext(); ) {
-            final PhylogenyNode node = iter.next();
-            if ( node.getNodeData().getProperties() != null ) {
-                final PropertiesMap pm = node.getNodeData().getProperties();
-                final double[] vector = new double[ pm.getProperties().size() ];
-                int counter = 0;
-                for( final String ref : pm.getProperties().keySet() ) {
-                    if ( ref.startsWith( PhyloXmlUtil.VECTOR_PROPERTY_REF ) ) {
-                        final Property p = pm.getProperty( ref );
-                        final String value_str = p.getValue();
-                        final String index_str = ref
-                                .substring( PhyloXmlUtil.VECTOR_PROPERTY_REF.length(), ref.length() );
-                        double d = -100;
-                        try {
-                            d = Double.parseDouble( value_str );
-                        }
-                        catch ( final NumberFormatException e ) {
-                            JOptionPane.showMessageDialog( this, "Could not parse \"" + value_str
-                                    + "\" into a decimal value", "Problem with Vector Data", JOptionPane.ERROR_MESSAGE );
-                            return;
-                        }
-                        int i = -1;
-                        try {
-                            i = Integer.parseInt( index_str );
-                        }
-                        catch ( final NumberFormatException e ) {
-                            JOptionPane.showMessageDialog( this,
-                                                           "Could not parse \"" + index_str
-                                                                   + "\" into index for vector data",
-                                                           "Problem with Vector Data",
-                                                           JOptionPane.ERROR_MESSAGE );
-                            return;
-                        }
-                        if ( i < 0 ) {
-                            JOptionPane.showMessageDialog( this,
-                                                           "Attempt to use negative index for vector data",
-                                                           "Problem with Vector Data",
-                                                           JOptionPane.ERROR_MESSAGE );
-                            return;
-                        }
-                        vector[ i ] = d;
-                        ++counter;
-                        stats.addValue( d );
-                    }
-                }
-                final List<Double> vector_l = new ArrayList<Double>( counter );
-                for( int i = 0; i < counter; ++i ) {
-                    vector_l.add( vector[ i ] );
-                }
-                node.getNodeData().setVector( vector_l );
-            }
-        }
-        if ( stats.getN() > 0 ) {
-            _statistics_for_vector_data = stats;
-        }
-    }
-
     public synchronized Hashtable<String, BufferedImage> getImageMap() {
         return getMainPanel().getImageMap();
     }
@@ -404,7 +345,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                 getControlPanel().displayedPhylogenyMightHaveChanged( true );
             }
             else {
-                getTreeFontSet().decreaseFontSize( 1 );
+                getTreeFontSet().decreaseFontSize( 1, false );
                 getControlPanel().displayedPhylogenyMightHaveChanged( true );
             }
         }
@@ -499,11 +440,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         }
     }
 
-    public final void setArrowCursor() {
-        setCursor( ARROW_CURSOR );
-        repaint();
-    }
-
     public final void setEdited( final boolean edited ) {
         _edited = edited;
     }
@@ -513,20 +449,60 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
     }
 
     /**
+     * Set a phylogeny tree.
+     * 
+     * @param t
+     *            an instance of a Phylogeny
+     */
+    public final void setTree( final Phylogeny t ) {
+        setNodeInPreorderToNull();
+        _phylogeny = t;
+    }
+
+    public final void setWaitCursor() {
+        setCursor( WAIT_CURSOR );
+        repaint();
+    }
+
+    @Override
+    public void update( final Graphics g ) {
+        paint( g );
+    }
+
+    final void calcMaxDepth() {
+        if ( _phylogeny != null ) {
+            _circ_max_depth = PhylogenyMethods.calculateMaxDepth( _phylogeny );
+        }
+    }
+
+    /**
      * Set parameters for printing the displayed tree
      * 
-     * @param x
-     * @param y
      */
-    public final void setParametersForPainting( final int x, final int y, final boolean recalc_longest_ext_node_info ) {
+    final void calcParametersForPainting( final int x, final int y, final boolean recalc_longest_ext_node_info ) {
         // updateStyle(); not needed?
         if ( ( _phylogeny != null ) && !_phylogeny.isEmpty() ) {
             initNodeData();
             if ( recalc_longest_ext_node_info ) {
                 calculateLongestExtNodeInfo();
-                while ( ( getLongestExtNodeInfo() > ( x * 0.67 ) ) && ( getTreeFontSet().getLargeFont().getSize() > 2 ) ) {
-                    getMainPanel().getTreeFontSet().decreaseFontSize( getConfiguration().getMinBaseFontSize() );
-                    calculateLongestExtNodeInfo();
+                if ( getOptions().isAllowFontSizeChange() ) {
+                    if ( ( getLongestExtNodeInfo() > ( x * 0.6 ) )
+                            && ( getTreeFontSet().getLargeFont().getSize() > 2 + TreeFontSet.FONT_SIZE_CHANGE_STEP ) ) {
+                        while ( ( getLongestExtNodeInfo() > ( x * 0.7 ) )
+                                && ( getTreeFontSet().getLargeFont().getSize() > 2 ) ) {
+                            getMainPanel().getTreeFontSet().decreaseFontSize( getConfiguration().getMinBaseFontSize(),
+                                                                              true );
+                            calculateLongestExtNodeInfo();
+                        }
+                    }
+                    else {
+                        while ( ( getLongestExtNodeInfo() < ( x * 0.6 ) )
+                                && ( getTreeFontSet().getLargeFont().getSize() <= getTreeFontSet().getLargeFontMemory()
+                                        .getSize() - TreeFontSet.FONT_SIZE_CHANGE_STEP ) ) {
+                            getMainPanel().getTreeFontSet().increaseFontSize();
+                            calculateLongestExtNodeInfo();
+                        }
+                    }
                 }
             }
             int ext_nodes = _phylogeny.getRoot().getNumberOfExternalNodes();
@@ -575,54 +551,29 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
             _circ_max_depth = max_depth;
             setUpUrtFactor();
             //
-            if ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
-                    && ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
-                int dynamic_hiding_factor = calcDynamicHidingFactor();
-                if ( dynamic_hiding_factor > 1 ) {
-                    while ( dynamic_hiding_factor > 1
-                            && getTreeFontSet()._fm_large.getHeight() > TreeFontSet.SMALL_FONTS_BASE ) {
-                        getTreeFontSet().decreaseFontSize( 1 );
-                        dynamic_hiding_factor = calcDynamicHidingFactor();
-                    }
-                }
-                else {
-                    while ( dynamic_hiding_factor < 1 && getTreeFontSet()._fm_large.getHeight() < 12 ) {
-                        getTreeFontSet().increaseFontSize();
-                        dynamic_hiding_factor = calcDynamicHidingFactor();
-                    }
+            if ( getOptions().isAllowFontSizeChange() ) {
+                if ( ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
+                        && ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
+                    //                int dynamic_hiding_factor = calcDynamicHidingFactor();
+                    //                if ( dynamic_hiding_factor > 1 ) {
+                    //                    while ( dynamic_hiding_factor > 1
+                    //                            && getTreeFontSet()._fm_large.getHeight() > TreeFontSet.SMALL_FONTS_BASE ) {
+                    //                        getTreeFontSet().decreaseFontSize( 1, true );
+                    //                        dynamic_hiding_factor = calcDynamicHidingFactor();
+                    //                    }
+                    //                }
+                    //                else if ( getTreeFontSet().isDecreasedSizeBySystem() ) {
+                    //                    while ( dynamic_hiding_factor < 1 && getTreeFontSet()._fm_large.getHeight() < 12 ) {
+                    //                        getTreeFontSet().increaseFontSize();
+                    //                        dynamic_hiding_factor = calcDynamicHidingFactor();
+                    //                    }
+                    //                }
                 }
             }
             //
         }
     }
 
-    /**
-     * Set a phylogeny tree.
-     * 
-     * @param t
-     *            an instance of a Phylogeny
-     */
-    public final void setTree( final Phylogeny t ) {
-        setNodeInPreorderToNull();
-        _phylogeny = t;
-    }
-
-    public final void setWaitCursor() {
-        setCursor( WAIT_CURSOR );
-        repaint();
-    }
-
-    @Override
-    public void update( final Graphics g ) {
-        paint( g );
-    }
-
-    final void calcMaxDepth() {
-        if ( _phylogeny != null ) {
-            _circ_max_depth = PhylogenyMethods.calculateMaxDepth( _phylogeny );
-        }
-    }
-
     final void calculateLongestExtNodeInfo() {
         if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) {
             return;
@@ -756,6 +707,65 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         return c;
     }
 
+    void checkForVectorProperties( final Phylogeny phy ) {
+        final DescriptiveStatistics stats = new BasicDescriptiveStatistics();
+        for( final PhylogenyNodeIterator iter = phy.iteratorPreorder(); iter.hasNext(); ) {
+            final PhylogenyNode node = iter.next();
+            if ( node.getNodeData().getProperties() != null ) {
+                final PropertiesMap pm = node.getNodeData().getProperties();
+                final double[] vector = new double[ pm.getProperties().size() ];
+                int counter = 0;
+                for( final String ref : pm.getProperties().keySet() ) {
+                    if ( ref.startsWith( PhyloXmlUtil.VECTOR_PROPERTY_REF ) ) {
+                        final Property p = pm.getProperty( ref );
+                        final String value_str = p.getValue();
+                        final String index_str = ref
+                                .substring( PhyloXmlUtil.VECTOR_PROPERTY_REF.length(), ref.length() );
+                        double d = -100;
+                        try {
+                            d = Double.parseDouble( value_str );
+                        }
+                        catch ( final NumberFormatException e ) {
+                            JOptionPane.showMessageDialog( this, "Could not parse \"" + value_str
+                                    + "\" into a decimal value", "Problem with Vector Data", JOptionPane.ERROR_MESSAGE );
+                            return;
+                        }
+                        int i = -1;
+                        try {
+                            i = Integer.parseInt( index_str );
+                        }
+                        catch ( final NumberFormatException e ) {
+                            JOptionPane.showMessageDialog( this,
+                                                           "Could not parse \"" + index_str
+                                                                   + "\" into index for vector data",
+                                                           "Problem with Vector Data",
+                                                           JOptionPane.ERROR_MESSAGE );
+                            return;
+                        }
+                        if ( i < 0 ) {
+                            JOptionPane.showMessageDialog( this,
+                                                           "Attempt to use negative index for vector data",
+                                                           "Problem with Vector Data",
+                                                           JOptionPane.ERROR_MESSAGE );
+                            return;
+                        }
+                        vector[ i ] = d;
+                        ++counter;
+                        stats.addValue( d );
+                    }
+                }
+                final List<Double> vector_l = new ArrayList<Double>( counter );
+                for( int i = 0; i < counter; ++i ) {
+                    vector_l.add( vector[ i ] );
+                }
+                node.getNodeData().setVector( vector_l );
+            }
+        }
+        if ( stats.getN() > 0 ) {
+            _statistics_for_vector_data = stats;
+        }
+    }
+
     void clearCurrentExternalNodesDataBuffer() {
         setCurrentExternalNodesDataBuffer( new StringBuilder() );
     }
@@ -919,7 +929,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         return _domain_structure_e_value_thr_exp;
     }
 
-    final Set<Integer> getFoundNodes() {
+    final Set<Long> getFoundNodes() {
         return _found_nodes;
     }
 
@@ -1176,7 +1186,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                 if ( ( e.getModifiers() & InputEvent.SHIFT_MASK ) != 0 ) {
                     // Yes, so add to _found_nodes
                     if ( getFoundNodes() == null ) {
-                        setFoundNodes( new HashSet<Integer>() );
+                        setFoundNodes( new HashSet<Long>() );
                     }
                     getFoundNodes().add( node.getId() );
                     // Check if control key is down
@@ -1669,10 +1679,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         }
     }
 
-    private final int calcDynamicHidingFactor() {
-        return ( int ) ( 0.5 + ( getTreeFontSet()._fm_large.getHeight() / ( 1.5 * getYdistance() ) ) );
-    }
-
     final void recalculateMaxDistanceToRoot() {
         _max_distance_to_root = PhylogenyMethods.calculateMaxDistanceToRoot( getPhylogeny() );
     }
@@ -1733,7 +1739,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
     }
 
     final void resetNodeIdToDistToLeafMap() {
-        _nodeid_dist_to_leaf = new HashMap<Integer, Short>();
+        _nodeid_dist_to_leaf = new HashMap<Long, Short>();
     }
 
     final void resetPreferredSize() {
@@ -1780,13 +1786,18 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
             getControlPanel().getSearchResetButton().setEnabled( true );
             getControlPanel().getSearchResetButton().setVisible( true );
             if ( getFoundNodes() == null ) {
-                setFoundNodes( new HashSet<Integer>() );
+                setFoundNodes( new HashSet<Long>() );
             }
             getFoundNodes().add( node.getId() );
             getControlPanel().setSearchFoundCountsOnLabel( getFoundNodes().size() );
         }
     }
 
+    final void setArrowCursor() {
+        setCursor( ARROW_CURSOR );
+        repaint();
+    }
+
     final void setControlPanel( final ControlPanel atv_control ) {
         _control_panel = atv_control;
     }
@@ -1796,7 +1807,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         _current_external_nodes_data_buffer = sb;
     }
 
-    final void setFoundNodes( final Set<Integer> found_nodes ) {
+    final void setFoundNodes( final Set<Long> found_nodes ) {
         _found_nodes = found_nodes;
     }
 
@@ -2185,9 +2196,9 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         repaint();
     }
 
-    final private void addToCurrentExternalNodes( final int i ) {
+    final private void addToCurrentExternalNodes( final long i ) {
         if ( _current_external_nodes == null ) {
-            _current_external_nodes = new HashSet<Integer>();
+            _current_external_nodes = new HashSet<Long>();
         }
         _current_external_nodes.add( i );
     }
@@ -2284,6 +2295,10 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         }
     }
 
+    private final int calcDynamicHidingFactor() {
+        return ( int ) ( 0.5 + ( getTreeFontSet()._fm_large.getHeight() / ( 1.5 * getYdistance() ) ) );
+    }
+
     /**
      * Calculate the length of the distance between the given node and its
      * parent.
@@ -2399,7 +2414,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         setNodeInPreorderToNull();
         setCutOrCopiedTree( _phylogeny.copy( node ) );
         final List<PhylogenyNode> nodes = PhylogenyMethods.getAllDescendants( node );
-        final Set<Integer> node_ids = new HashSet<Integer>( nodes.size() );
+        final Set<Long> node_ids = new HashSet<Long>( nodes.size() );
         for( final PhylogenyNode n : nodes ) {
             node_ids.add( n.getId() );
         }
@@ -2692,11 +2707,11 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                                        JOptionPane.ERROR_MESSAGE );
     }
 
-    final private Set<Integer> getCopiedAndPastedNodes() {
+    final private Set<Long> getCopiedAndPastedNodes() {
         return getMainPanel().getCopiedAndPastedNodes();
     }
 
-    final private Set<Integer> getCurrentExternalNodes() {
+    final private Set<Long> getCurrentExternalNodes() {
         return _current_external_nodes;
     }
 
@@ -2981,7 +2996,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                 getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( true );
             }
             else if ( ( e.getKeyCode() == KeyEvent.VK_SUBTRACT ) || ( e.getKeyCode() == KeyEvent.VK_MINUS ) ) {
-                getMainPanel().getTreeFontSet().decreaseFontSize( 1 );
+                getMainPanel().getTreeFontSet().decreaseFontSize( 1, false );
                 getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( true );
             }
             else if ( plusPressed( e.getKeyCode() ) ) {
@@ -3213,6 +3228,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                 return "Sequence Symbols";
             case SEQUENCE_MOL_SEQ:
                 return "Molecular Sequences";
+            case SEQUENCE_MOL_SEQ_FASTA:
+                return "Molecular Sequences (Fasta)";
             case SEQUENCE_ACC:
                 return "Sequence Accessors";
             case TAXONOMY_SCIENTIFIC_NAME:
@@ -4898,10 +4915,10 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
             }
         }
         if ( getCopiedAndPastedNodes() == null ) {
-            setCopiedAndPastedNodes( new HashSet<Integer>() );
+            setCopiedAndPastedNodes( new HashSet<Long>() );
         }
         final List<PhylogenyNode> nodes = PhylogenyMethods.obtainAllNodesAsList( buffer_phy );
-        final Set<Integer> node_ids = new HashSet<Integer>( nodes.size() );
+        final Set<Long> node_ids = new HashSet<Long>( nodes.size() );
         for( final PhylogenyNode n : nodes ) {
             node_ids.add( n.getId() );
         }
@@ -4941,7 +4958,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         return sb;
     }
 
-    final private void setCopiedAndPastedNodes( final Set<Integer> nodeIds ) {
+    final private void setCopiedAndPastedNodes( final Set<Long> nodeIds ) {
         getMainPanel().setCopiedAndPastedNodes( nodeIds );
     }
 
@@ -5046,6 +5063,21 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                         data.add( n.getNodeData().getSequence().getMolecularSequence() );
                     }
                     break;
+                case SEQUENCE_MOL_SEQ_FASTA:
+                    final StringBuilder sb = new StringBuilder();
+                    if ( n.getNodeData().isHasSequence()
+                            && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getMolecularSequence() ) ) {
+                        if ( !ForesterUtil.isEmpty( n.getNodeData().getSequence().getName() ) ) {
+                            sb.append( SequenceWriter.toFasta( n.getNodeData().getSequence().getName(), n.getNodeData()
+                                    .getSequence().getMolecularSequence(), 60 ) );
+                        }
+                        else {
+                            sb.append( SequenceWriter.toFasta( n.getName(), n.getNodeData().getSequence()
+                                    .getMolecularSequence(), 60 ) );
+                        }
+                        data.add( sb.toString() );
+                    }
+                    break;
                 case SEQUENCE_ACC:
                     if ( n.getNodeData().isHasSequence() && ( n.getNodeData().getSequence().getAccession() != null )
                             && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getAccession().toString() ) ) {