import javax.swing.Popup;
import javax.swing.PopupFactory;
+import org.forester.archaeopteryx.Configuration.EXT_NODE_DATA_RETURN_ON;
import org.forester.archaeopteryx.ControlPanel.NodeClickAction;
import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
import org.forester.phylogeny.data.BranchColor;
import org.forester.phylogeny.data.Confidence;
import org.forester.phylogeny.data.Event;
+import org.forester.phylogeny.data.NodeData.NODE_DATA;
import org.forester.phylogeny.data.NodeVisualization;
import org.forester.phylogeny.data.NodeVisualization.NodeFill;
import org.forester.phylogeny.data.NodeVisualization.NodeShape;
import org.forester.util.DescriptiveStatistics;
import org.forester.util.ForesterConstants;
import org.forester.util.ForesterUtil;
+import org.forester.util.SequenceIdParser;
public final class TreePanel extends JPanel implements ActionListener, MouseWheelListener, Printable {
final private static Font POPUP_FONT = new Font( Configuration.getDefaultFontFamilyName(),
Font.PLAIN,
12 );
- private static final boolean DRAW_MEAN_COUNTS = true; //TODO remove me later
private Sequence _query_sequence = null;
private final FontRenderContext _frc = new FontRenderContext( null,
false,
}
}
+ @Override
final public void actionPerformed( final ActionEvent e ) {
boolean done = false;
final JMenuItem node_popup_menu_item = ( JMenuItem ) e.getSource();
errorMessageNoCutCopyPasteInUnrootedDisplay();
return;
}
- final String label = getASimpleTextRepresentationOfANode( node );
+ final String label = createASimpleTextRepresentationOfANode( node );
String msg = "";
if ( ForesterUtil.isEmpty( label ) ) {
msg = "How to add the new, empty node?";
}
setNodeInPreorderToNull();
_phylogeny.externalNodesHaveChanged();
- _phylogeny.hashIDs();
+ _phylogeny.clearHashIdToNodeMap();
_phylogeny.recalculateNumberOfExternalDescendants( true );
resetNodeIdToDistToLeafMap();
setEdited( true );
final private void blast( final PhylogenyNode node ) {
if ( !isCanBlast( node ) ) {
JOptionPane.showMessageDialog( this,
- "No sequence information present",
+ "Insufficient information present",
"Cannot Blast",
- JOptionPane.WARNING_MESSAGE );
+ JOptionPane.INFORMATION_MESSAGE );
return;
}
- if ( node.getNodeData().isHasSequence() ) {
+ else {
final String query = Blast.obtainQueryForBlast( node );
- boolean nucleotide = false;
- if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getType() ) ) {
- if ( !node.getNodeData().getSequence().getType().toLowerCase().equals( PhyloXmlUtil.SEQ_TYPE_PROTEIN ) ) {
- nucleotide = true;
- }
- }
- else if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) {
- nucleotide = !ForesterUtil.seqIsLikelyToBeAa( node.getNodeData().getSequence().getMolecularSequence() );
- }
+ System.out.println( "query for BLAST is: " + query );
+ char type = '?';
if ( !ForesterUtil.isEmpty( query ) ) {
+ if ( node.getNodeData().isHasSequence() ) {
+ if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getType() ) ) {
+ if ( node.getNodeData().getSequence().getType().toLowerCase()
+ .equals( PhyloXmlUtil.SEQ_TYPE_PROTEIN ) ) {
+ type = 'p';
+ }
+ else {
+ type = 'n';
+ }
+ }
+ else if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) {
+ if ( ForesterUtil.seqIsLikelyToBeAa( node.getNodeData().getSequence().getMolecularSequence() ) ) {
+ type = 'p';
+ }
+ else {
+ type = 'n';
+ }
+ }
+ }
+ if ( type == '?' ) {
+ if ( SequenceIdParser.isProtein( query ) ) {
+ type = 'p';
+ }
+ else {
+ type = 'n';
+ }
+ }
JApplet applet = null;
if ( isApplet() ) {
applet = obtainApplet();
}
try {
- Blast.openNcbiBlastWeb( query, nucleotide, applet, this );
+ Blast.openNcbiBlastWeb( query, type == 'n', applet, this );
}
catch ( final Exception e ) {
e.printStackTrace();
JOptionPane.ERROR_MESSAGE );
return;
}
- final String label = getASimpleTextRepresentationOfANode( node );
+ final String label = createASimpleTextRepresentationOfANode( node );
final int r = JOptionPane.showConfirmDialog( null,
"Cut subtree" + label + "?",
"Confirm Cutting of Subtree",
setCopiedAndPastedNodes( null );
setCutOrCopiedTree( _phylogeny.copy( node ) );
_phylogeny.deleteSubtree( node, true );
- _phylogeny.hashIDs();
+ _phylogeny.clearHashIdToNodeMap();
_phylogeny.recalculateNumberOfExternalDescendants( true );
resetNodeIdToDistToLeafMap();
setEdited( true );
JOptionPane.ERROR_MESSAGE );
return;
}
- final String label = getASimpleTextRepresentationOfANode( node );
+ final String label = createASimpleTextRepresentationOfANode( node );
final Object[] options = { "Node only", "Entire subtree", "Cancel" };
final int r = JOptionPane.showOptionDialog( this,
"Delete" + label + "?",
_phylogeny.deleteSubtree( node, true );
}
_phylogeny.externalNodesHaveChanged();
- _phylogeny.hashIDs();
+ _phylogeny.clearHashIdToNodeMap();
_phylogeny.recalculateNumberOfExternalDescendants( true );
resetNodeIdToDistToLeafMap();
setEdited( true );
if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) {
return null;
}
- final int half_box_size_plus_wiggle = getOptions().getDefaultNodeShapeSize() / 2 + WIGGLE;
+ final int half_box_size_plus_wiggle = ( getOptions().getDefaultNodeShapeSize() / 2 ) + WIGGLE;
for( final PhylogenyNodeIterator iter = _phylogeny.iteratorPostorder(); iter.hasNext(); ) {
final PhylogenyNode node = iter.next();
if ( ( _phylogeny.isRooted() || !node.isRoot() || ( node.getNumberOfDescendants() > 2 ) )
return null;
}
- final private String getASimpleTextRepresentationOfANode( final PhylogenyNode node ) {
+ final private String createASimpleTextRepresentationOfANode( final PhylogenyNode node ) {
final String tax = PhylogenyMethods.getSpecies( node );
String label = node.getName();
if ( !ForesterUtil.isEmpty( label ) && !ForesterUtil.isEmpty( tax ) ) {
case SORT_DESCENDENTS:
sortDescendants( node );
break;
+ case GET_EXT_DESC_DATA:
+ showExtDescNodeData( node );
+ break;
default:
throw new IllegalArgumentException( "unknown action: " + action );
}
}
+ private void showExtDescNodeData( final PhylogenyNode node ) {
+ final List<String> data = new ArrayList<String>();
+ for( final PhylogenyNode n : node.getAllExternalDescendants() ) {
+ switch ( getOptions().getExtDescNodeDataToReturn() ) {
+ case NODE_NAME:
+ if ( !ForesterUtil.isEmpty( n.getName() ) ) {
+ data.add( n.getName() );
+ }
+ break;
+ case SEQUENCE_NAME:
+ if ( n.getNodeData().isHasSequence()
+ && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getName() ) ) {
+ data.add( n.getNodeData().getSequence().getName() );
+ }
+ break;
+ case SEQUENCE_SYMBOL:
+ if ( n.getNodeData().isHasSequence()
+ && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getSymbol() ) ) {
+ data.add( n.getNodeData().getSequence().getSymbol() );
+ }
+ break;
+ case SEQUENCE_MOL_SEQ:
+ if ( n.getNodeData().isHasSequence()
+ && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getMolecularSequence() ) ) {
+ data.add( n.getNodeData().getSequence().getMolecularSequence() );
+ }
+ break;
+ case SEQUENCE_ACC:
+ if ( n.getNodeData().isHasSequence() && ( n.getNodeData().getSequence().getAccession() != null )
+ && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getAccession().toString() ) ) {
+ data.add( n.getNodeData().getSequence().getAccession().toString() );
+ }
+ break;
+ case TAXONOMY_SCIENTIFIC_NAME:
+ if ( n.getNodeData().isHasTaxonomy()
+ && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() ) ) {
+ data.add( n.getNodeData().getTaxonomy().getScientificName() );
+ }
+ break;
+ case TAXONOMY_CODE:
+ if ( n.getNodeData().isHasTaxonomy()
+ && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getTaxonomyCode() ) ) {
+ data.add( n.getNodeData().getTaxonomy().getTaxonomyCode() );
+ }
+ break;
+ case UNKNOWN:
+ AptxUtil.showExtDescNodeDataUserSelectedHelper( getControlPanel(), n, data );
+ break;
+ default:
+ throw new IllegalArgumentException( "unknown data element: "
+ + getOptions().getExtDescNodeDataToReturn() );
+ }
+ } // for loop
+ if ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.CONSOLE ) {
+ for( final String d : data ) {
+ if ( !ForesterUtil.isEmpty( d ) ) {
+ System.out.println( d );
+ }
+ }
+ }
+ else if ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.WINODW ) {
+ final StringBuilder sb = new StringBuilder();
+ for( final String d : data ) {
+ if ( !ForesterUtil.isEmpty( d ) ) {
+ sb.append( d );
+ sb.append( "\n" );
+ }
+ }
+ if ( sb.length() < 1 ) {
+ AptxUtil.showInformationMessage( this,
+ "No Appropriate Data (" + obtainTitleForExtDescNodeData() + ")",
+ "Descendants of selected node do not contain selected data" );
+ }
+ else {
+ final String title = "External Descendants "
+ + ( getOptions().getExtDescNodeDataToReturn() == NODE_DATA.UNKNOWN ? "Data"
+ : obtainTitleForExtDescNodeData() ) + " (" + data.size() + "/"
+ + node.getNumberOfExternalNodes() + ") For Node " + node;
+ if ( getMainPanel().getMainFrame() == null ) {
+ // Must be "E" applet version.
+ final ArchaeopteryxE ae = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
+ final String s = sb.toString().trim();
+ ae.showTextFrame( s, title );
+ ae.setCurrentExternalNodesDataBuffer( s );
+ }
+ else {
+ getMainPanel().getMainFrame().showTextFrame( sb.toString(), title );
+ }
+ }
+ }
+ }
+
+ private final String obtainTitleForExtDescNodeData() {
+ switch ( getOptions().getExtDescNodeDataToReturn() ) {
+ case NODE_NAME:
+ return "Node Names";
+ case SEQUENCE_NAME:
+ return "Sequence Names";
+ case SEQUENCE_SYMBOL:
+ return "Sequence Symbols";
+ case SEQUENCE_MOL_SEQ:
+ return "Molecular Sequences";
+ case SEQUENCE_ACC:
+ return "Sequence Accessors";
+ case TAXONOMY_SCIENTIFIC_NAME:
+ return "Scientific Names";
+ case TAXONOMY_CODE:
+ return "Taxonomy Codes";
+ case UNKNOWN:
+ return "User Selected Data";
+ default:
+ throw new IllegalArgumentException( "unknown data element: "
+ + getOptions().getExtDescNodeDataToReturn() );
+ }
+ }
+
final void increaseDomainStructureEvalueThreshold() {
if ( _domain_structure_e_value_thr_exp < 3 ) {
_domain_structure_e_value_thr_exp += 1;
}
final private void increaseOvSize() {
- if ( ( getOvMaxWidth() < getMainPanel().getCurrentScrollPane().getViewport().getVisibleRect().getWidth() / 2 )
- && ( getOvMaxHeight() < getMainPanel().getCurrentScrollPane().getViewport().getVisibleRect()
- .getHeight() / 2 ) ) {
+ if ( ( getOvMaxWidth() < ( getMainPanel().getCurrentScrollPane().getViewport().getVisibleRect().getWidth() / 2 ) )
+ && ( getOvMaxHeight() < ( getMainPanel().getCurrentScrollPane().getViewport().getVisibleRect()
+ .getHeight() / 2 ) ) ) {
setOvMaxWidth( getOvMaxWidth() + 5 );
setOvMaxHeight( getOvMaxHeight() + 5 );
updateOvSettings();
setTreeFile( null );
setEdited( false );
initializeOvSettings();
- setStartingAngle( TWO_PI * 3 / 4 );
+ setStartingAngle( ( TWO_PI * 3 ) / 4 );
final ImageLoader il = new ImageLoader( this );
new Thread( il ).start();
}
}
final boolean inOv( final MouseEvent e ) {
- return ( ( e.getX() > getVisibleRect().x + getOvXPosition() + 1 )
- && ( e.getX() < getVisibleRect().x + getOvXPosition() + getOvMaxWidth() - 1 )
- && ( e.getY() > getVisibleRect().y + getOvYPosition() + 1 ) && ( e.getY() < getVisibleRect().y
- + getOvYPosition() + getOvMaxHeight() - 1 ) );
+ return ( ( e.getX() > ( getVisibleRect().x + getOvXPosition() + 1 ) )
+ && ( e.getX() < ( ( getVisibleRect().x + getOvXPosition() + getOvMaxWidth() ) - 1 ) )
+ && ( e.getY() > ( getVisibleRect().y + getOvYPosition() + 1 ) ) && ( e.getY() < ( ( getVisibleRect().y
+ + getOvYPosition() + getOvMaxHeight() ) - 1 ) ) );
}
final boolean inOvRectangle( final MouseEvent e ) {
- return ( ( e.getX() >= getOvRectangle().getX() - 1 )
- && ( e.getX() <= getOvRectangle().getX() + getOvRectangle().getWidth() + 1 )
- && ( e.getY() >= getOvRectangle().getY() - 1 ) && ( e.getY() <= getOvRectangle().getY()
- + getOvRectangle().getHeight() + 1 ) );
+ return ( ( e.getX() >= ( getOvRectangle().getX() - 1 ) )
+ && ( e.getX() <= ( getOvRectangle().getX() + getOvRectangle().getWidth() + 1 ) )
+ && ( e.getY() >= ( getOvRectangle().getY() - 1 ) ) && ( e.getY() <= ( getOvRectangle().getY()
+ + getOvRectangle().getHeight() + 1 ) ) );
}
final private boolean inOvVirtualRectangle( final int x, final int y ) {
- return ( ( x >= getOvVirtualRectangle().x - 1 )
- && ( x <= getOvVirtualRectangle().x + getOvVirtualRectangle().width + 1 )
- && ( y >= getOvVirtualRectangle().y - 1 ) && ( y <= getOvVirtualRectangle().y
- + getOvVirtualRectangle().height + 1 ) );
+ return ( ( x >= ( getOvVirtualRectangle().x - 1 ) )
+ && ( x <= ( getOvVirtualRectangle().x + getOvVirtualRectangle().width + 1 ) )
+ && ( y >= ( getOvVirtualRectangle().y - 1 ) ) && ( y <= ( getOvVirtualRectangle().y
+ + getOvVirtualRectangle().height + 1 ) ) );
}
final private boolean inOvVirtualRectangle( final MouseEvent e ) {
}
final private boolean isCanBlast( final PhylogenyNode node ) {
- return ( node.getNodeData().isHasSequence()
- && ( ( ( node.getNodeData().getSequence().getAccession() != null ) && !ForesterUtil.isEmpty( node
- .getNodeData().getSequence().getAccession().getValue() ) )
- || !ForesterUtil.isEmpty( node.getNodeData().getSequence().getName() ) || !ForesterUtil
- .isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) && Blast
- .isContainsQueryForBlast( node ) );
+ if ( !node.getNodeData().isHasSequence() && ForesterUtil.isEmpty( node.getName() ) ) {
+ return false;
+ }
+ return Blast.isContainsQueryForBlast( node );
}
final boolean isCanCollapse() {
if ( getControlPanel().isShowTaxonomyImages() ) {
y_dist = 40 + ( int ) getYdistance();
}
- return ( ( node.getYcoord() < getVisibleRect().getMinY() - y_dist )
- || ( node.getYcoord() > getVisibleRect().getMaxY() + y_dist ) || ( ( node.getParent() != null ) && ( node
+ return ( ( node.getYcoord() < ( getVisibleRect().getMinY() - y_dist ) )
+ || ( node.getYcoord() > ( getVisibleRect().getMaxY() + y_dist ) ) || ( ( node.getParent() != null ) && ( node
.getParent().getXcoord() > getVisibleRect().getMaxX() ) ) );
}
final private boolean isNodeDataInvisibleUnrootedCirc( final PhylogenyNode node ) {
- return ( ( node.getYcoord() < getVisibleRect().getMinY() - 20 )
- || ( node.getYcoord() > getVisibleRect().getMaxY() + 20 )
- || ( node.getXcoord() < getVisibleRect().getMinX() - 20 ) || ( node.getXcoord() > getVisibleRect()
- .getMaxX() + 20 ) );
+ return ( ( node.getYcoord() < ( getVisibleRect().getMinY() - 20 ) )
+ || ( node.getYcoord() > ( getVisibleRect().getMaxY() + 20 ) )
+ || ( node.getXcoord() < ( getVisibleRect().getMinX() - 20 ) ) || ( node.getXcoord() > ( getVisibleRect()
+ .getMaxX() + 20 ) ) );
}
final private boolean isNonLinedUpCladogram() {
if ( getOptions().isShowOverview() && isOvOn() && isInOv() ) {
final double w_ratio = getVisibleRect().width / getOvRectangle().getWidth();
final double h_ratio = getVisibleRect().height / getOvRectangle().getHeight();
- double x = ( e.getX() - getVisibleRect().x - getOvXPosition() - getOvRectangle().getWidth() / 2.0 )
+ double x = ( e.getX() - getVisibleRect().x - getOvXPosition() - ( getOvRectangle().getWidth() / 2.0 ) )
* w_ratio;
- double y = ( e.getY() - getVisibleRect().y - getOvYPosition() - getOvRectangle().getHeight() / 2.0 )
+ double y = ( e.getY() - getVisibleRect().y - getOvYPosition() - ( getOvRectangle().getHeight() / 2.0 ) )
* h_ratio;
if ( x < 0 ) {
x = 0;
final double w_ratio = getVisibleRect().width / getOvRectangle().getWidth();
final double h_ratio = getVisibleRect().height / getOvRectangle().getHeight();
final Point scroll_position = getMainPanel().getCurrentScrollPane().getViewport().getViewPosition();
- double dx = ( w_ratio * e.getX() - w_ratio * getLastDragPointX() );
- double dy = ( h_ratio * e.getY() - h_ratio * getLastDragPointY() );
+ double dx = ( ( w_ratio * e.getX() ) - ( w_ratio * getLastDragPointX() ) );
+ double dy = ( ( h_ratio * e.getY() ) - ( h_ratio * getLastDragPointY() ) );
scroll_position.x = ForesterUtil.roundToInt( scroll_position.x + dx );
scroll_position.y = ForesterUtil.roundToInt( scroll_position.y + dy );
if ( scroll_position.x <= 0 ) {
setCursor( ARROW_CURSOR );
}
+ @Override
final public void mouseWheelMoved( final MouseWheelEvent e ) {
final int notches = e.getWheelRotation();
if ( inOvVirtualRectangle( e ) ) {
final double root_y = _root.getYcoord();
final double dx = root_x - p.getXcoord();
final double dy = root_y - p.getYcoord();
- final double parent_radius = Math.sqrt( dx * dx + dy * dy );
+ final double parent_radius = Math.sqrt( ( dx * dx ) + ( dy * dy ) );
final double arc = ( _urt_nodeid_angle_map.get( p.getId() ) ) - angle;
assignGraphicsForBranchWithColorForParentBranch( c, false, g, to_pdf, to_graphics_file );
if ( ( c.isFirstChildNode() || c.isLastChildNode() )
if ( c.isExternal() ) {
final boolean is_in_found_nodes = isInFoundNodes( c );
if ( ( _dynamic_hiding_factor > 1 ) && !is_in_found_nodes
- && ( _urt_nodeid_index_map.get( c.getId() ) % _dynamic_hiding_factor != 1 ) ) {
+ && ( ( _urt_nodeid_index_map.get( c.getId() ) % _dynamic_hiding_factor ) != 1 ) ) {
return;
}
paintNodeDataUnrootedCirc( g, c, to_pdf, to_graphics_file, radial_labels, 0, is_in_found_nodes );
final double dx = root_x - p.getXSecondary();
final double dy = root_y - p.getYSecondary();
final double arc = ( _urt_nodeid_angle_map.get( p.getId() ) ) - angle;
- final double parent_radius = Math.sqrt( dx * dx + dy * dy );
+ final double parent_radius = Math.sqrt( ( dx * dx ) + ( dy * dy ) );
g.setColor( getTreeColorSet().getOvColor() );
if ( ( c.isFirstChildNode() || c.isLastChildNode() ) && ( Math.abs( arc ) > 0.02 ) ) {
final double r2 = 2.0 * parent_radius;
|| ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) ) {
if ( !to_graphics_file
&& !to_pdf
- && ( ( ( y2 < getVisibleRect().getMinY() - 20 ) && ( y1 < getVisibleRect().getMinY() - 20 ) ) || ( ( y2 > getVisibleRect()
- .getMaxY() + 20 ) && ( y1 > getVisibleRect().getMaxY() + 20 ) ) ) ) {
+ && ( ( ( y2 < ( getVisibleRect().getMinY() - 20 ) ) && ( y1 < ( getVisibleRect().getMinY() - 20 ) ) ) || ( ( y2 > ( getVisibleRect()
+ .getMaxY() + 20 ) ) && ( y1 > ( getVisibleRect().getMaxY() + 20 ) ) ) ) ) {
// Do nothing.
}
else {
}
// draw the horizontal line
if ( !to_graphics_file && !to_pdf
- && ( ( y2 < getVisibleRect().getMinY() - 20 ) || ( y2 > getVisibleRect().getMaxY() + 20 ) ) ) {
+ && ( ( y2 < ( getVisibleRect().getMinY() - 20 ) ) || ( y2 > ( getVisibleRect().getMaxY() + 20 ) ) ) ) {
return;
}
float x1_r = 0;
double current_angle = starting_angle;
for( final PhylogenyNodeIterator it = phy.iteratorExternalForward(); it.hasNext(); ) {
final PhylogenyNode n = it.next();
- n.setXSecondary( ( float ) ( center_x + radius * Math.cos( current_angle ) ) );
- n.setYSecondary( ( float ) ( center_y + radius * Math.sin( current_angle ) ) );
+ n.setXSecondary( ( float ) ( center_x + ( radius * Math.cos( current_angle ) ) ) );
+ n.setYSecondary( ( float ) ( center_y + ( radius * Math.sin( current_angle ) ) ) );
_urt_nodeid_angle_map.put( n.getId(), current_angle );
current_angle += ( TWO_PI / circ_num_ext_nodes );
}
}
double r = 0;
if ( !n.isRoot() ) {
- r = 1 - ( ( ( double ) _circ_max_depth - PhylogenyMethods.calculateDepth( n ) ) / _circ_max_depth );
+ r = 1 - ( ( ( double ) _circ_max_depth - n.calculateDepth() ) / _circ_max_depth );
}
final double theta = sum / descs.size();
- n.setXcoord( ( float ) ( center_x + r * radius * Math.cos( theta ) ) );
- n.setYcoord( ( float ) ( center_y + r * radius * Math.sin( theta ) ) );
+ n.setXcoord( ( float ) ( center_x + ( r * radius * Math.cos( theta ) ) ) );
+ n.setYcoord( ( float ) ( center_y + ( r * radius * Math.sin( theta ) ) ) );
_urt_nodeid_angle_map.put( n.getId(), theta );
for( final PhylogenyNode desc : descs ) {
paintBranchCircular( n, desc, g, radial_labels, to_pdf, to_graphics_file );
}
float r = 0;
if ( !n.isRoot() ) {
- r = 1 - ( ( ( float ) _circ_max_depth - PhylogenyMethods.calculateDepth( n ) ) / _circ_max_depth );
+ r = 1 - ( ( ( float ) _circ_max_depth - n.calculateDepth() ) / _circ_max_depth );
}
final double theta = _urt_nodeid_angle_map.get( n.getId() );
- n.setXSecondary( ( float ) ( center_x + radius * r * Math.cos( theta ) ) );
- n.setYSecondary( ( float ) ( center_y + radius * r * Math.sin( theta ) ) );
+ n.setXSecondary( ( float ) ( center_x + ( radius * r * Math.cos( theta ) ) ) );
+ n.setYSecondary( ( float ) ( center_y + ( radius * r * Math.sin( theta ) ) ) );
for( final PhylogenyNode desc : descs ) {
paintBranchCircularLite( n, desc, g );
}
x += CONFIDENCE_LEFT_MARGIN + confidenceWidth;
}
}
- if ( x + nodeTextBoundsWidth > 0 ) /* we only underline if there is something displayed */
+ if ( ( x + nodeTextBoundsWidth ) > 0 ) /* we only underline if there is something displayed */
{
if ( nodeTextBoundsWidth == 0 ) {
nodeTextBoundsWidth -= 3; /* the gap between taxonomy code and node name should not be underlined if nothing comes after it */
.getLostCharactersAsStringBuffer().toString() );
}
else {
- if ( DRAW_MEAN_COUNTS && node.isInternal() ) {
- final List<PhylogenyNode> ec = node.getAllExternalDescendants();
- double sum = 0;
- int count = 0;
- for( final PhylogenyNode phylogenyNode : ec ) {
- count++;
- if ( phylogenyNode.getNodeData().getBinaryCharacters() != null ) {
- sum += phylogenyNode.getNodeData().getBinaryCharacters().getPresentCount();
- }
- }
- final double mean = ForesterUtil.round( sum / count, 1 );
- TreePanel.drawString( " " + node.getNodeData().getBinaryCharacters().getPresentCount() + " ["
- + mean + "]", node.getXcoord() + x + 4 + half_box_size, node.getYcoord()
- + ( getTreeFontSet()._fm_large.getAscent() / down_shift_factor ), g );
- }
- else {
- TreePanel.drawString( " " + node.getNodeData().getBinaryCharacters().getPresentCount(),
- node.getXcoord() + x + 4 + half_box_size,
- node.getYcoord()
- + ( getTreeFontSet()._fm_large.getAscent() / down_shift_factor ),
- g );
- }
+ TreePanel.drawString( " " + node.getNodeData().getBinaryCharacters().getPresentCount(),
+ node.getXcoord() + x + 4 + half_box_size,
+ node.getYcoord()
+ + ( getTreeFontSet()._fm_large.getAscent() / down_shift_factor ),
+ g );
paintGainedAndLostCharacters( g, node, "+"
+ node.getNodeData().getBinaryCharacters().getGainedCount(), "-"
+ node.getNodeData().getBinaryCharacters().getLostCount() );
}
// y = y - ( 0.9 * getYdistance() );
final double hs = bi.getHeight() * scaling_factor;
- double ws = bi.getWidth() * scaling_factor + offset;
+ double ws = ( bi.getWidth() * scaling_factor ) + offset;
final double my_y = y - ( 0.5 * hs );
final int x_w = ( int ) ( x + ws + 0.5 );
final int y_h = ( int ) ( my_y + hs + 0.5 );
- if ( ( x_w - x > 7 ) && ( y_h - my_y > 7 ) ) {
+ if ( ( ( x_w - x ) > 7 ) && ( ( y_h - my_y ) > 7 ) ) {
g.drawImage( bi,
( int ) ( x + 0.5 + offset ),
( int ) ( my_y + 0.5 ),
}
if ( dynamically_hide
&& !is_in_found_nodes
- && ( ( node.isExternal() && ( _external_node_index % dynamic_hiding_factor != 1 ) ) || ( !node
- .isExternal() && ( ( new_x_min < 20 ) || ( _y_distance * node.getNumberOfExternalNodes() < getTreeFontSet()._fm_large
+ && ( ( node.isExternal() && ( ( _external_node_index % dynamic_hiding_factor ) != 1 ) ) || ( !node
+ .isExternal() && ( ( new_x_min < 20 ) || ( ( _y_distance * node.getNumberOfExternalNodes() ) < getTreeFontSet()._fm_large
.getHeight() ) ) ) ) ) {
return;
}
if ( rds != null ) {
rds.setRenderingHeight( 6 );
int x = 0;
- if ( getControlPanel().isShowTaxonomyCode()
- && ( !ForesterUtil.isEmpty( PhylogenyMethods.getSpecies( node ) ) ) ) {
- x += getTreeFontSet()._fm_large_italic.stringWidth( PhylogenyMethods.getSpecies( node ) + " " );
- }
- if ( getControlPanel().isShowGeneNames()
- && ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getName() ) ) ) {
- x += getTreeFontSet()._fm_large.stringWidth( node.getNodeData().getSequence().getName() + " " );
- }
- if ( getControlPanel().isShowGeneSymbols()
- && ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getSymbol() ) ) ) {
- x += getTreeFontSet()._fm_large
- .stringWidth( node.getNodeData().getSequence().getSymbol() + " " );
+ if ( node.getNodeData().isHasTaxonomy() ) {
+ if ( getControlPanel().isShowTaxonomyCode()
+ && ( !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getTaxonomyCode() ) ) ) {
+ x += getTreeFontSet()._fm_large_italic.stringWidth( node.getNodeData().getTaxonomy()
+ .getTaxonomyCode()
+ + " " );
+ }
+ if ( getControlPanel().isShowTaxonomyScientificNames()
+ && ( !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getScientificName() ) ) ) {
+ x += getTreeFontSet()._fm_large_italic.stringWidth( node.getNodeData().getTaxonomy()
+ .getScientificName()
+ + " " );
+ }
+ if ( getControlPanel().isShowTaxonomyCommonNames()
+ && ( !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getCommonName() ) ) ) {
+ x += getTreeFontSet()._fm_large_italic.stringWidth( node.getNodeData().getTaxonomy()
+ .getCommonName()
+ + " " );
+ }
}
- if ( getControlPanel().isShowSequenceAcc()
- && ( node.getNodeData().getSequence().getAccession() != null ) ) {
- x += getTreeFontSet()._fm_large.stringWidth( node.getNodeData().getSequence().getAccession()
- .toString()
- + " " );
+ if ( node.getNodeData().isHasSequence() ) {
+ if ( getControlPanel().isShowGeneNames()
+ && ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getName() ) ) ) {
+ x += getTreeFontSet()._fm_large.stringWidth( node.getNodeData().getSequence().getName()
+ + " " );
+ }
+ if ( getControlPanel().isShowGeneSymbols()
+ && ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getSymbol() ) ) ) {
+ x += getTreeFontSet()._fm_large.stringWidth( node.getNodeData().getSequence().getSymbol()
+ + " " );
+ }
+ if ( getControlPanel().isShowSequenceAcc()
+ && ( node.getNodeData().getSequence().getAccession() != null ) ) {
+ x += getTreeFontSet()._fm_large.stringWidth( node.getNodeData().getSequence()
+ .getAccession().toString()
+ + " " );
+ }
}
- if ( getControlPanel().isShowNodeNames() && ( node.getName().length() > 0 ) ) {
+ if ( getControlPanel().isShowNodeNames() && !ForesterUtil.isEmpty( node.getName() ) ) {
x += getTreeFontSet()._fm_large.stringWidth( node.getName() + " " );
}
rds.render( node.getXcoord() + x, node.getYcoord() - 3, g, this, to_pdf );
final float y_ratio = ( float ) getHeight() / getVisibleRect().y;
final float width = getOvMaxWidth() / w_ratio;
final float height = getOvMaxHeight() / h_ratio;
- final float x = getVisibleRect().x + getOvXPosition() + getOvMaxWidth() / x_ratio;
- final float y = getVisibleRect().y + getOvYPosition() + getOvMaxHeight() / y_ratio;
+ final float x = getVisibleRect().x + getOvXPosition() + ( getOvMaxWidth() / x_ratio );
+ final float y = getVisibleRect().y + getOvYPosition() + ( getOvMaxHeight() / y_ratio );
g.setColor( getTreeColorSet().getFoundColor() );
getOvRectangle().setRect( x, y, width, height );
if ( ( width < 6 ) && ( height < 6 ) ) {
final int graphics_file_height,
final int graphics_file_x,
final int graphics_file_y ) {
- if ( _phylogeny == null || _phylogeny.isEmpty() ) {
+ if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) {
return;
}
if ( _control_panel.isShowSequenceRelations() ) {
// 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()
+ for( final PhylogenyNode element : _nodes_in_preorder ) {
+ paintNodeRectangular( g, element, to_pdf, getControlPanel().isDynamicallyHideData()
&& ( dynamic_hiding_factor > 1 ), dynamic_hiding_factor, to_graphics_file );
}
if ( getOptions().isShowScale() && getControlPanel().isDrawPhylogram() && ( getScaleDistance() > 0.0 ) ) {
}
paintUnrooted( _phylogeny.getRoot(),
angle,
- ( float ) ( angle + 2 * Math.PI ),
+ ( float ) ( angle + ( 2 * Math.PI ) ),
radial_labels,
g,
to_pdf,
g.setColor( getTreeColorSet().getOvColor() );
paintUnrootedLite( _phylogeny.getRoot(),
angle,
- angle + 2 * Math.PI,
+ angle + ( 2 * Math.PI ),
g,
( getUrtFactorOv() / ( getVisibleRect().width / getOvMaxWidth() ) ) );
paintOvRectangle( g );
//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 ] );
+ for( final PhylogenyNode element : _nodes_in_preorder ) {
+ paintNodeLite( g, element );
}
paintOvRectangle( g );
}
else {
length = getUrtFactor();
}
- final double mid_angle = current_angle + arc_size / 2;
- final float new_x = ( float ) ( x + Math.cos( mid_angle ) * length );
- final float new_y = ( float ) ( y + Math.sin( mid_angle ) * length );
+ final double mid_angle = current_angle + ( arc_size / 2 );
+ final float new_x = ( float ) ( x + ( Math.cos( mid_angle ) * length ) );
+ final float new_y = ( float ) ( y + ( Math.sin( mid_angle ) * length ) );
desc.setXcoord( new_x );
desc.setYcoord( new_y );
paintUnrooted( desc, current_angle, current_angle + arc_size, radial_labels, g, to_pdf, to_graphics_file );
final Graphics2D g,
final float urt_ov_factor ) {
if ( n.isRoot() ) {
- final int x_pos = ( int ) ( getVisibleRect().x + getOvXPosition() + getOvMaxWidth() / 2 );
- final int y_pos = ( int ) ( getVisibleRect().y + getOvYPosition() + getOvMaxHeight() / 2 );
+ final int x_pos = ( int ) ( getVisibleRect().x + getOvXPosition() + ( getOvMaxWidth() / 2 ) );
+ final int y_pos = ( int ) ( getVisibleRect().y + getOvYPosition() + ( getOvMaxHeight() / 2 ) );
n.setXSecondary( x_pos );
n.setYSecondary( y_pos );
}
else {
length = urt_ov_factor;
}
- final double mid_angle = current_angle + arc_size / 2;
- final float new_x = ( float ) ( x + Math.cos( mid_angle ) * length );
- final float new_y = ( float ) ( y + Math.sin( mid_angle ) * length );
+ final double mid_angle = current_angle + ( arc_size / 2 );
+ final float new_x = ( float ) ( x + ( Math.cos( mid_angle ) * length ) );
+ final float new_y = ( float ) ( y + ( Math.sin( mid_angle ) * length ) );
desc.setXSecondary( new_x );
desc.setYSecondary( new_y );
if ( isInFoundNodes( desc ) ) {
JOptionPane.ERROR_MESSAGE );
return;
}
- final String label = getASimpleTextRepresentationOfANode( getCutOrCopiedTree().getRoot() );
+ final String label = createASimpleTextRepresentationOfANode( getCutOrCopiedTree().getRoot() );
final Object[] options = { "As sibling", "As descendant", "Cancel" };
final int r = JOptionPane.showOptionDialog( this,
"How to paste subtree" + label + "?",
}
final Phylogeny buffer_phy = getCutOrCopiedTree().copy();
buffer_phy.setAllNodesToNotCollapse();
- buffer_phy.preOrderReId();
+ PhylogenyMethods.preOrderReId( buffer_phy );
buffer_phy.setRooted( true );
boolean need_to_show_whole = false;
if ( paste_as_sibling ) {
getCopiedAndPastedNodes().addAll( node_ids );
setNodeInPreorderToNull();
_phylogeny.externalNodesHaveChanged();
- _phylogeny.hashIDs();
+ _phylogeny.clearHashIdToNodeMap();
_phylogeny.recalculateNumberOfExternalDescendants( true );
resetNodeIdToDistToLeafMap();
setEdited( true );
repaint();
}
+ @Override
final public int print( final Graphics g, final PageFormat page_format, final int page_index )
throws PrinterException {
if ( page_index > 0 ) {
_node_frame_index--;
_node_frames[ i ] = null;
if ( i < _node_frame_index ) {
- for( int j = 0; j < _node_frame_index - 1; j++ ) {
+ for( int j = 0; j < ( _node_frame_index - 1 ); j++ ) {
_node_frames[ j ] = _node_frames[ j + 1 ];
}
_node_frames[ _node_frame_index ] = null;
}
}
if ( getMainPanel().getOptions().isAntialiasScreen() ) {
- if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) {
+ if ( ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR )
+ && !getMainPanel().getOptions().isShowDefaultNodeShapes()
+ && ( ( getControlPanel() != null ) && !getControlPanel().isShowDomainArchitectures() ) ) {
_rendering_hints.put( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF );
}
else {
node.swapChildren();
setNodeInPreorderToNull();
_phylogeny.externalNodesHaveChanged();
- _phylogeny.hashIDs();
+ _phylogeny.clearHashIdToNodeMap();
_phylogeny.recalculateNumberOfExternalDescendants( true );
resetNodeIdToDistToLeafMap();
setEdited( true );
PhylogenyMethods.sortNodeDescendents( node, pri );
setNodeInPreorderToNull();
_phylogeny.externalNodesHaveChanged();
- _phylogeny.hashIDs();
+ _phylogeny.clearHashIdToNodeMap();
_phylogeny.recalculateNumberOfExternalDescendants( true );
resetNodeIdToDistToLeafMap();
setEdited( true );
}
final void updateOvSizes() {
- if ( ( getWidth() > 1.05 * getVisibleRect().width ) || ( getHeight() > 1.05 * getVisibleRect().height ) ) {
+ if ( ( getWidth() > ( 1.05 * getVisibleRect().width ) ) || ( getHeight() > ( 1.05 * getVisibleRect().height ) ) ) {
setOvOn( true );
float l = getLongestExtNodeInfo();
final float w_ratio = getOvMaxWidth() / getWidth();