- final private void showNodeDataPopup( final MouseEvent e, final PhylogenyNode node ) {
- try {
- if ( ( node.getName().length() > 0 )
- || ( node.getNodeData().isHasTaxonomy() && !TreePanelUtil.isTaxonomyEmpty( node.getNodeData()
- .getTaxonomy() ) )
- || ( node.getNodeData().isHasSequence() && !TreePanelUtil.isSequenceEmpty( node.getNodeData()
- .getSequence() ) ) || ( node.getNodeData().isHasDate() )
- || ( node.getNodeData().isHasDistribution() ) || node.getBranchData().isHasConfidences() ) {
- _popup_buffer.setLength( 0 );
- short lines = 0;
- if ( node.getName().length() > 0 ) {
- lines++;
- _popup_buffer.append( node.getName() );
- }
- if ( node.getNodeData().isHasTaxonomy()
- && !TreePanelUtil.isTaxonomyEmpty( node.getNodeData().getTaxonomy() ) ) {
- lines++;
- boolean enc_data = false;
- final Taxonomy tax = node.getNodeData().getTaxonomy();
- if ( _popup_buffer.length() > 0 ) {
- _popup_buffer.append( "\n" );
- }
- if ( !ForesterUtil.isEmpty( tax.getTaxonomyCode() ) ) {
- _popup_buffer.append( "[" );
- _popup_buffer.append( tax.getTaxonomyCode() );
- _popup_buffer.append( "]" );
- enc_data = true;
- }
- if ( !ForesterUtil.isEmpty( tax.getScientificName() ) ) {
- if ( enc_data ) {
- _popup_buffer.append( " " );
- }
- _popup_buffer.append( tax.getScientificName() );
- enc_data = true;
- }
- if ( !ForesterUtil.isEmpty( tax.getCommonName() ) ) {
- if ( enc_data ) {
- _popup_buffer.append( " (" );
- }
- else {
- _popup_buffer.append( "(" );
- }
- _popup_buffer.append( tax.getCommonName() );
- _popup_buffer.append( ")" );
- enc_data = true;
- }
- if ( !ForesterUtil.isEmpty( tax.getAuthority() ) ) {
- if ( enc_data ) {
- _popup_buffer.append( " (" );
- }
- else {
- _popup_buffer.append( "(" );
- }
- _popup_buffer.append( tax.getAuthority() );
- _popup_buffer.append( ")" );
- enc_data = true;
- }
- if ( !ForesterUtil.isEmpty( tax.getRank() ) ) {
- if ( enc_data ) {
- _popup_buffer.append( " [" );
- }
- else {
- _popup_buffer.append( "[" );
- }
- _popup_buffer.append( tax.getRank() );
- _popup_buffer.append( "]" );
- enc_data = true;
- }
- if ( tax.getSynonyms().size() > 0 ) {
- if ( enc_data ) {
- _popup_buffer.append( " " );
- }
- _popup_buffer.append( "[" );
- int counter = 1;
- for( final String syn : tax.getSynonyms() ) {
- if ( !ForesterUtil.isEmpty( syn ) ) {
- enc_data = true;
- _popup_buffer.append( syn );
- if ( counter < tax.getSynonyms().size() ) {
- _popup_buffer.append( ", " );
- }
- }
- counter++;
- }
- _popup_buffer.append( "]" );
- }
- if ( !enc_data ) {
- if ( ( tax.getIdentifier() != null ) && !ForesterUtil.isEmpty( tax.getIdentifier().getValue() ) ) {
- if ( !ForesterUtil.isEmpty( tax.getIdentifier().getProvider() ) ) {
- _popup_buffer.append( "[" );
- _popup_buffer.append( tax.getIdentifier().getProvider() );
- _popup_buffer.append( "] " );
- }
- _popup_buffer.append( tax.getIdentifier().getValue() );
- }
- }
- }
- if ( node.getNodeData().isHasSequence()
- && !TreePanelUtil.isSequenceEmpty( node.getNodeData().getSequence() ) ) {
- lines++;
- boolean enc_data = false;
- if ( _popup_buffer.length() > 0 ) {
- _popup_buffer.append( "\n" );
- }
- final Sequence seq = node.getNodeData().getSequence();
- if ( seq.getAccession() != null ) {
- _popup_buffer.append( "[" );
- if ( !ForesterUtil.isEmpty( seq.getAccession().getSource() ) ) {
- _popup_buffer.append( seq.getAccession().getSource() );
- _popup_buffer.append( ":" );
- }
- _popup_buffer.append( seq.getAccession().getValue() );
- _popup_buffer.append( "]" );
- enc_data = true;
- }
- if ( !ForesterUtil.isEmpty( seq.getSymbol() ) ) {
- if ( enc_data ) {
- _popup_buffer.append( " [" );
- }
- else {
- _popup_buffer.append( "[" );
- }
- _popup_buffer.append( seq.getSymbol() );
- _popup_buffer.append( "]" );
- enc_data = true;
- }
- if ( !ForesterUtil.isEmpty( seq.getGeneName() ) ) {
- if ( enc_data ) {
- _popup_buffer.append( " [" );
- }
- else {
- _popup_buffer.append( "[" );
- }
- _popup_buffer.append( seq.getGeneName() );
- _popup_buffer.append( "]" );
- enc_data = true;
- }
- if ( !ForesterUtil.isEmpty( seq.getName() ) ) {
- if ( enc_data ) {
- _popup_buffer.append( " " );
- }
- _popup_buffer.append( seq.getName() );
- }
- }
- if ( node.getNodeData().isHasDate() ) {
- lines++;
- if ( _popup_buffer.length() > 0 ) {
- _popup_buffer.append( "\n" );
- }
- _popup_buffer.append( node.getNodeData().getDate().asSimpleText() );
- }
- if ( node.getNodeData().isHasDistribution() ) {
- lines++;
- if ( _popup_buffer.length() > 0 ) {
- _popup_buffer.append( "\n" );
- }
- _popup_buffer.append( node.getNodeData().getDistribution().asSimpleText() );
- }
- if ( node.getBranchData().isHasConfidences() ) {
- final List<Confidence> confs = node.getBranchData().getConfidences();
- for( final Confidence confidence : confs ) {
- lines++;
- if ( _popup_buffer.length() > 0 ) {
- _popup_buffer.append( "\n" );
- }
- if ( !ForesterUtil.isEmpty( confidence.getType() ) ) {
- _popup_buffer.append( "[" );
- _popup_buffer.append( confidence.getType() );
- _popup_buffer.append( "] " );
- }
- _popup_buffer
- .append( FORMATTER_CONFIDENCE.format( ForesterUtil.round( confidence.getValue(),
- getOptions()
- .getNumberOfDigitsAfterCommaForConfidenceValues() ) ) );
- if ( confidence.getStandardDeviation() != Confidence.CONFIDENCE_DEFAULT_VALUE ) {
- _popup_buffer.append( " (sd=" );
- _popup_buffer.append( FORMATTER_CONFIDENCE.format( ForesterUtil.round( confidence
- .getStandardDeviation(), getOptions()
- .getNumberOfDigitsAfterCommaForConfidenceValues() ) ) );
- _popup_buffer.append( ")" );
- }
- }
- }
- if ( node.getNodeData().isHasProperties() ) {
- final PropertiesMap properties = node.getNodeData().getProperties();
- for( final String ref : properties.getPropertyRefs() ) {
- _popup_buffer.append( "\n" );
- final Property p = properties.getProperty( ref );
- _popup_buffer.append( TreePanelUtil.getPartAfterColon( p.getRef() ) );
- _popup_buffer.append( "=" );
- _popup_buffer.append( p.getValue() );
- if ( !ForesterUtil.isEmpty( p.getUnit() ) ) {
- _popup_buffer.append( TreePanelUtil.getPartAfterColon( p.getUnit() ) );
- }
- }
- }
- if ( _popup_buffer.length() > 0 ) {
- if ( !getConfiguration().isUseNativeUI() ) {
- _rollover_popup
- .setBorder( BorderFactory.createLineBorder( getTreeColorSet().getBranchColor() ) );
- _rollover_popup.setBackground( getTreeColorSet().getBackgroundColor() );
- if ( isInFoundNodes0( node ) && !isInFoundNodes1( node ) ) {
- _rollover_popup.setForeground( getTreeColorSet().getFoundColor0() );
- }
- else if ( !isInFoundNodes0( node ) && isInFoundNodes1( node ) ) {
- _rollover_popup.setForeground( getTreeColorSet().getFoundColor1() );
- }
- else if ( isInFoundNodes0( node ) && isInFoundNodes1( node ) ) {
- _rollover_popup.setForeground( getTreeColorSet().getFoundColor0and1() );
- }
- else {
- _rollover_popup.setForeground( getTreeColorSet().getSequenceColor() );
- }
- }
- else {
- _rollover_popup.setBorder( BorderFactory.createLineBorder( Color.BLACK ) );
- }
- _rollover_popup.setText( _popup_buffer.toString() );
- _node_desc_popup = PopupFactory.getSharedInstance().getPopup( null,
- _rollover_popup,
- e.getLocationOnScreen().x + 10,
- e.getLocationOnScreen().y
- - ( lines * 20 ) );
- _node_desc_popup.show();
- }
+ 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 );