+ }
+
+ final void recalculateMaxDistanceToRoot() {
+ _max_distance_to_root = PhylogenyMethods.calculateMaxDistanceToRoot( getPhylogeny() );
+ }
+
+ /**
+ * Remove all edit-node frames
+ */
+ final void removeAllEditNodeJFrames() {
+ for( int i = 0; i <= ( TreePanel.MAX_NODE_FRAMES - 1 ); i++ ) {
+ if ( _node_frames[ i ] != null ) {
+ _node_frames[ i ].dispose();
+ _node_frames[ i ] = null;
+ }
+ }
+ _node_frame_index = 0;
+ }
+
+ /**
+ * Remove a node-edit frame.
+ */
+ final void removeEditNodeFrame( final int i ) {
+ _node_frame_index--;
+ _node_frames[ i ] = null;
+ if ( i < _node_frame_index ) {
+ for( int j = 0; j < ( _node_frame_index - 1 ); j++ ) {
+ _node_frames[ j ] = _node_frames[ j + 1 ];
+ }
+ _node_frames[ _node_frame_index ] = null;
+ }
+ }
+
+ final void reRoot( final PhylogenyNode node ) {
+ if ( !getPhylogeny().isRerootable() ) {
+ JOptionPane.showMessageDialog( this,
+ "This is not rerootable",
+ "Not rerootable",
+ JOptionPane.WARNING_MESSAGE );
+ return;
+ }
+ if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
+ JOptionPane.showMessageDialog( this,
+ "Cannot reroot in unrooted display type",
+ "Attempt to reroot tree in unrooted display",
+ JOptionPane.WARNING_MESSAGE );
+ return;
+ }
+ getPhylogeny().reRoot( node );
+ getPhylogeny().recalculateNumberOfExternalDescendants( true );
+ resetNodeIdToDistToLeafMap();
+ setNodeInPreorderToNull();
+ resetPreferredSize();
+ getMainPanel().adjustJScrollPane();
+ setEdited( true );
+ repaint();
+ if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) {
+ getControlPanel().showWhole();
+ }
+ }
+
+ final void resetNodeIdToDistToLeafMap() {
+ _nodeid_dist_to_leaf = new HashMap<Long, Short>();
+ }
+
+ final void resetPreferredSize() {
+ if ( ( getPhylogeny() == null ) || getPhylogeny().isEmpty() ) {
+ return;
+ }
+ int x = 0;
+ int y = 0;
+ y = TreePanel.MOVE
+ + ForesterUtil.roundToInt( getYdistance() * getPhylogeny().getRoot().getNumberOfExternalNodes() * 2 );
+ if ( getControlPanel().isDrawPhylogram() ) {
+ x = TreePanel.MOVE
+ + getLongestExtNodeInfo()
+ + ForesterUtil
+ .roundToInt( ( getXcorrectionFactor() * getPhylogeny().getHeight() ) + getXdistance() );
+ }
+ else {
+ if ( !isNonLinedUpCladogram() && !isUniformBranchLengthsForCladogram() ) {
+ x = TreePanel.MOVE
+ + getLongestExtNodeInfo()
+ + ForesterUtil.roundToInt( getXdistance()
+ * ( getPhylogeny().getRoot().getNumberOfExternalNodes() + 2 ) );
+ }
+ else {
+ x = TreePanel.MOVE
+ + getLongestExtNodeInfo()
+ + ForesterUtil.roundToInt( getXdistance()
+ * ( PhylogenyMethods.calculateMaxDepth( getPhylogeny() ) + 1 ) );
+ }
+ }
+ setPreferredSize( new Dimension( x, y ) );
+ }
+
+ final void selectNode( final PhylogenyNode node ) {
+ if ( ( getFoundNodes0() != null ) && getFoundNodes0().contains( node.getId() ) ) {
+ getFoundNodes0().remove( node.getId() );
+ getControlPanel().setSearchFoundCountsOnLabel0( getFoundNodes0().size() );
+ if ( getFoundNodes0().size() < 1 ) {
+ getControlPanel().searchReset0();
+ }
+ }
+ else {
+ getControlPanel().getSearchFoundCountsLabel0().setVisible( true );
+ getControlPanel().getSearchResetButton0().setEnabled( true );
+ getControlPanel().getSearchResetButton0().setVisible( true );
+ if ( getFoundNodes0() == null ) {
+ setFoundNodes0( new HashSet<Long>() );
+ }
+ getFoundNodes0().add( node.getId() );
+ getControlPanel().setSearchFoundCountsOnLabel0( getFoundNodes0().size() );
+ }
+ }
+
+ final void setArrowCursor() {
+ setCursor( ARROW_CURSOR );
+ repaint();
+ }
+
+ final void setControlPanel( final ControlPanel atv_control ) {
+ _control_panel = atv_control;
+ }
+
+ void setCurrentExternalNodesDataBuffer( final StringBuilder sb ) {
+ increaseCurrentExternalNodesDataBufferChangeCounter();
+ _current_external_nodes_data_buffer = sb;
+ }
+
+ final void setFoundNodes0( final Set<Long> found_nodes ) {
+ _found_nodes_0 = found_nodes;
+ }
+
+ final void setFoundNodes1( final Set<Long> found_nodes ) {
+ _found_nodes_1 = found_nodes;
+ }
+
+ final void setInOvRect( final boolean in_ov_rect ) {
+ _in_ov_rect = in_ov_rect;
+ }
+
+ final void setLargeFonts() {
+ getTreeFontSet().largeFonts();
+ }
+
+ final void setLastMouseDragPointX( final float x ) {
+ _last_drag_point_x = x;
+ }
+
+ final void setLastMouseDragPointY( final float y ) {
+ _last_drag_point_y = y;
+ }
+
+ final void setMediumFonts() {
+ getTreeFontSet().mediumFonts();
+ }
+
+ final void setNodeInPreorderToNull() {
+ _nodes_in_preorder = null;
+ }
+
+ final void setOvOn( final boolean ov_on ) {
+ _ov_on = ov_on;
+ }
+
+ final void setPhylogenyGraphicsType( final PHYLOGENY_GRAPHICS_TYPE graphics_type ) {
+ _graphics_type = graphics_type;
+ setTextAntialias();
+ }
+
+ final void setSmallFonts() {
+ getTreeFontSet().smallFonts();
+ }
+
+ final void setStartingAngle( final double starting_angle ) {
+ _urt_starting_angle = starting_angle;
+ }
+
+ void setStatisticsForExpressionValues( final DescriptiveStatistics statistics_for_expression_values ) {
+ _statistics_for_vector_data = statistics_for_expression_values;
+ }
+
+ final void setSuperTinyFonts() {
+ getTreeFontSet().superTinyFonts();
+ }
+
+ final void setTextAntialias() {
+ if ( ( _phylogeny != null ) && !_phylogeny.isEmpty() ) {
+ if ( _phylogeny.getNumberOfExternalNodes() <= LIMIT_FOR_HQ_RENDERING ) {
+ _rendering_hints.put( RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY );
+ }
+ else {
+ _rendering_hints.put( RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED );
+ }
+ }
+ if ( getMainPanel().getOptions().isAntialiasScreen() ) {
+ _rendering_hints.put( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
+ // try {
+ _rendering_hints.put( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB );
+ // }
+ // catch ( final Throwable e ) {
+ // _rendering_hints.put( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON );
+ //}
+ }
+ else {
+ _rendering_hints.put( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF );
+ _rendering_hints.put( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF );
+ }
+ }
+
+ final void setTinyFonts() {
+ getTreeFontSet().tinyFonts();
+ }
+
+ final void setTreeFile( final File treefile ) {
+ _treefile = treefile;
+ }
+
+ final void setXcorrectionFactor( final float f ) {
+ _x_correction_factor = f;
+ }
+
+ final void setXdistance( final float x ) {
+ _x_distance = x;
+ }
+
+ final void setYdistance( final float y ) {
+ _y_distance = y;
+ }
+
+ final void sortDescendants( final PhylogenyNode node ) {
+ if ( !node.isExternal() ) {
+ DESCENDANT_SORT_PRIORITY pri = DESCENDANT_SORT_PRIORITY.NODE_NAME;
+ if ( getControlPanel().isShowTaxonomyScientificNames() || getControlPanel().isShowTaxonomyCode() ) {
+ pri = DESCENDANT_SORT_PRIORITY.TAXONOMY;
+ }
+ else if ( getControlPanel().isShowSeqNames() || getControlPanel().isShowSeqSymbols()
+ || getControlPanel().isShowGeneNames() ) {
+ pri = DESCENDANT_SORT_PRIORITY.SEQUENCE;
+ }
+ PhylogenyMethods.sortNodeDescendents( node, pri );
+ setNodeInPreorderToNull();
+ _phylogeny.externalNodesHaveChanged();
+ _phylogeny.clearHashIdToNodeMap();
+ _phylogeny.recalculateNumberOfExternalDescendants( true );
+ resetNodeIdToDistToLeafMap();
+ setEdited( true );
+ }
+ repaint();
+ }
+
+ final void subTree( final PhylogenyNode node ) {
+ if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) {
+ JOptionPane.showMessageDialog( this,
+ "Cannot get a sub/super tree in unrooted display",
+ "Attempt to get sub/super tree in unrooted display",
+ JOptionPane.WARNING_MESSAGE );
+ return;
+ }
+ if ( node.isExternal() ) {
+ JOptionPane.showMessageDialog( this,
+ "Cannot get a subtree of a external node",
+ "Attempt to get subtree of external node",
+ JOptionPane.WARNING_MESSAGE );
+ return;
+ }
+ if ( node.isRoot() && !isCurrentTreeIsSubtree() ) {
+ JOptionPane.showMessageDialog( this,
+ "Cannot get a subtree of the root node",
+ "Attempt to get subtree of root node",
+ JOptionPane.WARNING_MESSAGE );
+ return;
+ }
+ setNodeInPreorderToNull();
+ if ( !node.isExternal() && !node.isRoot() && ( _subtree_index <= ( TreePanel.MAX_SUBTREES - 1 ) ) ) {
+ _sub_phylogenies[ _subtree_index ] = _phylogeny;
+ _sub_phylogenies_temp_roots[ _subtree_index ] = node;
+ ++_subtree_index;
+ _phylogeny = TreePanelUtil.subTree( node, _phylogeny );
+ updateSubSuperTreeButton();
+ }
+ else if ( node.isRoot() && isCurrentTreeIsSubtree() ) {
+ superTree();