X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FTreePanel.java;h=18baad048113e136e98e6c5846674317ca0c29a6;hb=7c1c5ba99ad4eda61fd946671faa6d13660d464e;hp=fe048b304ad89c9c4bb048a1eb35f72ef68e1b80;hpb=719f80f90c6503fc5a2663524aecc78076211c3a;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanel.java b/forester/java/src/org/forester/archaeopteryx/TreePanel.java index fe048b3..18baad0 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanel.java @@ -111,6 +111,7 @@ import org.forester.phylogeny.data.Accession; import org.forester.phylogeny.data.Annotation; import org.forester.phylogeny.data.BranchColor; import org.forester.phylogeny.data.Confidence; +import org.forester.phylogeny.data.DomainArchitecture; import org.forester.phylogeny.data.Event; import org.forester.phylogeny.data.NodeData.NODE_DATA; import org.forester.phylogeny.data.NodeVisualData; @@ -501,7 +502,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee calculateLongestExtNodeInfo(); if ( getOptions().isAllowFontSizeChange() ) { if ( ( getLongestExtNodeInfo() > ( x * 0.6 ) ) - && ( getTreeFontSet().getLargeFont().getSize() > 2 + TreeFontSet.FONT_SIZE_CHANGE_STEP ) ) { + && ( getTreeFontSet().getLargeFont().getSize() > ( 2 + TreeFontSet.FONT_SIZE_CHANGE_STEP ) ) ) { while ( ( getLongestExtNodeInfo() > ( x * 0.7 ) ) && ( getTreeFontSet().getLargeFont().getSize() > 2 ) ) { getMainPanel().getTreeFontSet().decreaseFontSize( getConfiguration().getMinBaseFontSize(), @@ -511,8 +512,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } else { while ( ( getLongestExtNodeInfo() < ( x * 0.6 ) ) - && ( getTreeFontSet().getLargeFont().getSize() <= getTreeFontSet().getLargeFontMemory() - .getSize() - TreeFontSet.FONT_SIZE_CHANGE_STEP ) ) { + && ( getTreeFontSet().getLargeFont().getSize() <= ( getTreeFontSet() + .getLargeFontMemory().getSize() - TreeFontSet.FONT_SIZE_CHANGE_STEP ) ) ) { getMainPanel().getTreeFontSet().increaseFontSize(); calculateLongestExtNodeInfo(); } @@ -623,6 +624,22 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee sum += getFontMetricsForLargeDefaultFont().stringWidth( node.getNodeData().getBinaryCharacters() .getGainedCharactersAsStringBuffer().toString() ); } + if ( getControlPanel().isShowVectorData() && ( node.getNodeData().getVector() != null ) + && ( node.getNodeData().getVector().size() > 0 ) ) { + if ( getConfiguration() != null ) { + sum += getConfiguration().getVectorDataWidth() + 10; + } + else { + sum += RenderableVector.VECTOR_DEFAULT_WIDTH + 10; + } + } + if ( getControlPanel().isShowDomainArchitectures() && node.getNodeData().isHasSequence() + && ( node.getNodeData().getSequence().getDomainArchitecture() != null ) ) { + // FIXME + // TODO this might need some clean up + final DomainArchitecture d = node.getNodeData().getSequence().getDomainArchitecture(); + sum += ( ( _domain_structure_width / ( ( RenderableDomainArchitecture ) d ).getOriginalSize().getWidth() ) * d.getTotalLength() ) + 10; + } if ( sum >= max_length ) { setLongestExtNodeInfo( max_length ); return; @@ -715,19 +732,19 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee return c; } } - + final Color calculateSequenceBasedColor( final Sequence seq ) { - if ( ForesterUtil.isEmpty( seq.getName() ) ) { - return getTreeColorSet().getSequenceColor(); - } - Color c = null; - final String seq_name = seq.getName(); - c = getControlPanel().getSequenceColors().get( seq_name ); - if ( c == null ) { - c = TreePanelUtil.calculateColorFromString( seq_name, false ); - getControlPanel().getSequenceColors().put( seq_name, c ); - } - return c; + if ( ForesterUtil.isEmpty( seq.getName() ) ) { + return getTreeColorSet().getSequenceColor(); + } + Color c = null; + final String seq_name = seq.getName(); + c = getControlPanel().getSequenceColors().get( seq_name ); + if ( c == null ) { + c = TreePanelUtil.calculateColorFromString( seq_name, false ); + getControlPanel().getSequenceColors().put( seq_name, c ); + } + return c; } void checkForVectorProperties( final Phylogeny phy ) { @@ -855,7 +872,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee if ( _control_panel.getColorAccSpeciesCb() != null ) { _control_panel.getColorAccSpeciesCb().setSelected( false ); } - _options.setColorLabelsSameAsParentBranch( true ); _control_panel.repaint(); } @@ -1001,7 +1017,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee return _statistics_for_vector_data; } - final Color getTaxonomyBasedColor( final PhylogenyNode node ) { if ( node.getNodeData().isHasTaxonomy() ) { return calculateTaxonomyBasedColor( node.getNodeData().getTaxonomy() ); @@ -1009,7 +1024,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee // return non-colorized color return getTreeColorSet().getTaxonomyColor(); } - final Color getSequenceBasedColor( final PhylogenyNode node ) { if ( node.getNodeData().isHasSequence() ) { @@ -1018,7 +1032,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee // return non-colorized color return getTreeColorSet().getSequenceColor(); } - /** * @return pointer to colorset for tree drawing @@ -2360,7 +2373,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee sb.append( !ForesterUtil.isEmpty( a.getRefValue() ) ? a.getRefValue() : a.getDesc() ); } final String ann_str = sb.toString(); - System.out.println( ann_str ); if ( !ForesterUtil.isEmpty( ann_str ) ) { c = getControlPanel().getAnnotationColors().get( ann_str ); if ( c == null ) { @@ -2372,7 +2384,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } } } - System.out.println( c.toString() ); return c; } @@ -2472,8 +2483,10 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } } if ( additional_nodes != null ) { - for( final PhylogenyNode n : additional_nodes ) { - n.getBranchData().setBranchColor( new BranchColor( c ) ); + for( final PhylogenyNode an : additional_nodes ) { + for( final PreorderTreeIterator it = new PreorderTreeIterator( an ); it.hasNext(); ) { + it.next().getBranchData().setBranchColor( new BranchColor( c ) ); + } } } repaint(); @@ -2819,7 +2832,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee return getTreeFontSet().getFontMetricsLarge(); } - private List getFoundNodesAsListOfPhylogenyNodes() { + List getFoundNodesAsListOfPhylogenyNodes() { final List additional_nodes = new ArrayList(); if ( getFoundNodes0() != null ) { for( final Long id : getFoundNodes0() ) { @@ -3971,7 +3984,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee d = box_size; } final float xx = node.getXcoord() - ( 2 * box_size ); - final float xxx = xx > node.getParent().getXcoord() + 1 ? xx : node.getParent().getXcoord() + 1; + final float xxx = xx > ( node.getParent().getXcoord() + 1 ) ? xx : node.getParent().getXcoord() + 1; _polygon.reset(); _polygon.moveTo( xxx, node.getYcoord() ); _polygon.lineTo( node.getXcoord() + 1, node.getYcoord() - d ); @@ -4673,7 +4686,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } float new_x = 0; float new_x_min = Float.MAX_VALUE; - final boolean disallow_shortcutting = dynamic_hiding_factor < 40; + final boolean disallow_shortcutting = ( dynamic_hiding_factor < 40 ); float min_dist = 1.5f; if ( !disallow_shortcutting ) { // System.out.println( dynamic_hiding_factor ); @@ -4748,7 +4761,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee final PhylogenyNode node, final boolean to_graphics_file, final boolean to_pdf ) { - if ( isNodeDataInvisible( node ) && !to_graphics_file ) { + if ( isNodeDataInvisible( node ) && !( to_graphics_file || to_pdf ) ) { return; } if ( ( !getControlPanel().isShowInternalData() && !node.isExternal() ) ) { @@ -4766,7 +4779,27 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } if ( rds != null ) { rds.setRenderingHeight( 6 ); - rds.render( node.getXcoord() + x, node.getYcoord() - 3, g, this, to_pdf ); + if ( getControlPanel().isDrawPhylogram() ) { + rds.render( node.getXcoord() + x, node.getYcoord() - 3, g, this, to_pdf ); + } + else { + int xx = 0; + PhylogenyNode my_node = node; + if ( !getControlPanel().isDrawPhylogram() ) { + my_node = getPhylogeny().getFirstExternalNode(); + } + if ( getControlPanel().isShowTaxonomyCode() + && ( PhylogenyMethods.getSpecies( my_node ).length() > 0 ) ) { + xx += getFontMetricsForLargeDefaultFont() + .stringWidth( PhylogenyMethods.getSpecies( my_node ) + " " ); + } + if ( getControlPanel().isShowNodeNames() && ( my_node.getName().length() > 0 ) ) { + //TODO fixme, need to look at all nodes not only the first + xx += getFontMetricsForLargeDefaultFont().stringWidth( my_node.getName() + " " ); + } + // + rds.render( my_node.getXcoord() + xx, node.getYcoord() - 3, g, this, to_pdf ); + } } } }