- final private void openTaxWeb( final PhylogenyNode node ) {
- if ( !isCanOpenTaxWeb( node ) ) {
- cannotOpenBrowserWarningMessage( "taxonomic" );
- return;
- }
- String uri_str = null;
- final Taxonomy tax = node.getNodeData().getTaxonomy();
- if ( ( tax.getIdentifier() != null ) && !ForesterUtil.isEmpty( tax.getIdentifier().getValue() )
- && tax.getIdentifier().getValue().startsWith( "http://" ) ) {
- try {
- uri_str = new URI( tax.getIdentifier().getValue() ).toString();
- }
- catch ( final URISyntaxException e ) {
- AptxUtil.showErrorMessage( this, e.toString() );
- uri_str = null;
- e.printStackTrace();
- }
- }
- else if ( ( tax.getIdentifier() != null )
- && !ForesterUtil.isEmpty( tax.getIdentifier().getValue() )
- && !ForesterUtil.isEmpty( tax.getIdentifier().getProvider() )
- && ( tax.getIdentifier().getProvider().equalsIgnoreCase( "ncbi" ) || tax.getIdentifier().getProvider()
- .equalsIgnoreCase( "uniprot" ) ) ) {
- try {
- uri_str = "http://www.uniprot.org/taxonomy/"
- + URLEncoder.encode( tax.getIdentifier().getValue(), ForesterConstants.UTF8 );
- }
- catch ( final UnsupportedEncodingException e ) {
- AptxUtil.showErrorMessage( this, e.toString() );
- e.printStackTrace();
- }
- }
- else if ( !ForesterUtil.isEmpty( tax.getScientificName() ) ) {
- try {
- uri_str = "http://www.uniprot.org/taxonomy/?query="
- + URLEncoder.encode( tax.getScientificName(), ForesterConstants.UTF8 );
- }
- catch ( final UnsupportedEncodingException e ) {
- AptxUtil.showErrorMessage( this, e.toString() );
- e.printStackTrace();
- }
- }
- else if ( !ForesterUtil.isEmpty( tax.getTaxonomyCode() ) ) {
- try {
- uri_str = "http://www.uniprot.org/taxonomy/?query="
- + URLEncoder.encode( tax.getTaxonomyCode(), ForesterConstants.UTF8 );
- }
- catch ( final UnsupportedEncodingException e ) {
- AptxUtil.showErrorMessage( this, e.toString() );
- e.printStackTrace();
- }
- }
- else if ( !ForesterUtil.isEmpty( tax.getCommonName() ) ) {
- try {
- uri_str = "http://www.uniprot.org/taxonomy/?query="
- + URLEncoder.encode( tax.getCommonName(), ForesterConstants.UTF8 );
- }
- catch ( final UnsupportedEncodingException e ) {
- AptxUtil.showErrorMessage( this, e.toString() );
- e.printStackTrace();
- }
- }
- if ( !ForesterUtil.isEmpty( uri_str ) ) {
- try {
- AptxUtil.launchWebBrowser( new URI( uri_str ),
- isApplet(),
- isApplet() ? obtainApplet() : null,
- "_aptx_tax" );
- }
- catch ( final IOException e ) {
- AptxUtil.showErrorMessage( this, e.toString() );
- e.printStackTrace();
- }
- catch ( final URISyntaxException e ) {
- AptxUtil.showErrorMessage( this, e.toString() );
- e.printStackTrace();
- }
- }
- else {
- cannotOpenBrowserWarningMessage( "taxonomic" );
- }
- }
-
- final private void paintBranchLength( final Graphics2D g,
- final PhylogenyNode node,
- final boolean to_pdf,
- final boolean to_graphics_file ) {
- g.setFont( getTreeFontSet().getSmallFont() );
- if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
- g.setColor( Color.BLACK );
- }
- else {
- g.setColor( getTreeColorSet().getBranchLengthColor() );
- }
- if ( !node.isRoot() ) {
- if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE ) {
- TreePanel.drawString( FORMATTER_BRANCH_LENGTH.format( node.getDistanceToParent() ), node.getParent()
- .getXcoord() + EURO_D, node.getYcoord() - getTreeFontSet()._small_max_descent, g );
- }
- else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) {
- TreePanel.drawString( FORMATTER_BRANCH_LENGTH.format( node.getDistanceToParent() ), node.getParent()
- .getXcoord() + ROUNDED_D, node.getYcoord() - getTreeFontSet()._small_max_descent, g );
- }
- else {
- TreePanel.drawString( FORMATTER_BRANCH_LENGTH.format( node.getDistanceToParent() ), node.getParent()
- .getXcoord() + 3, node.getYcoord() - getTreeFontSet()._small_max_descent, g );
- }
- }
- else {
- TreePanel.drawString( FORMATTER_BRANCH_LENGTH.format( node.getDistanceToParent() ), 3, node.getYcoord()
- - getTreeFontSet()._small_max_descent, g );
- }
- }
-
- final private void paintBranchLite( final Graphics2D g,
- final float x1,
- final float x2,
- final float y1,
- final float y2,
- final PhylogenyNode node ) {
- g.setColor( getTreeColorSet().getOvColor() );
- if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR ) {
- drawLine( x1, y1, x2, y2, g );
- }
- else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CONVEX ) {
- _quad_curve.setCurve( x1, y1, x1, y2, x2, y2 );
- ( g ).draw( _quad_curve );
- }
- else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CURVED ) {
- final float dx = x2 - x1;
- final float dy = y2 - y1;
- _cubic_curve.setCurve( x1, y1, x1 + ( dx * 0.4f ), y1 + ( dy * 0.2f ), x1 + ( dx * 0.6f ), y1
- + ( dy * 0.8f ), x2, y2 );
- ( g ).draw( _cubic_curve );
- }
- else {
- final float x2a = x2;
- final float x1a = x1;
- // draw the vertical line
- if ( node.isFirstChildNode() || node.isLastChildNode() ) {
- drawLine( x1, y1, x1, y2, g );
- }
- // draw the horizontal line
- drawLine( x1a, y2, x2a, y2, g );
- }
- }
-
- /**
- * Paint a branch which consists of a vertical and a horizontal bar
- * @param is_ind_found_nodes
- */
- final private void paintBranchRectangular( final Graphics2D g,
- final float x1,
- final float x2,
- final float y1,
- final float y2,
- final PhylogenyNode node,
- final boolean to_pdf,
- final boolean to_graphics_file ) {
- assignGraphicsForBranchWithColorForParentBranch( node, false, g, to_pdf, to_graphics_file );
- if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR ) {
- drawLine( x1, y1, x2, y2, g );
- }
- else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CONVEX ) {
- _quad_curve.setCurve( x1, y1, x1, y2, x2, y2 );
- g.draw( _quad_curve );
- }
- else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CURVED ) {
- final float dx = x2 - x1;
- final float dy = y2 - y1;
- _cubic_curve.setCurve( x1, y1, x1 + ( dx * 0.4f ), y1 + ( dy * 0.2f ), x1 + ( dx * 0.6f ), y1
- + ( dy * 0.8f ), x2, y2 );
- g.draw( _cubic_curve );
- }
- else {
- final float x2a = x2;
- final float x1a = x1;
- float y2_r = 0;
- if ( node.isFirstChildNode() || node.isLastChildNode()
- || ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE )
- || ( 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 ) ) ) ) ) {
- // Do nothing.