From 79fc8faf7c7980317a0dae73a59edea3fe35df64 Mon Sep 17 00:00:00 2001 From: "cmzmasek@gmail.com" Date: Thu, 10 Apr 2014 02:47:32 +0000 Subject: [PATCH] inprogress --- .../org/forester/archaeopteryx/TreeColorSet.java | 20 +++--- .../org/forester/archaeopteryx/TreeFontSet.java | 52 +------------- .../src/org/forester/archaeopteryx/TreePanel.java | 75 ++++++++++---------- 3 files changed, 49 insertions(+), 98 deletions(-) diff --git a/forester/java/src/org/forester/archaeopteryx/TreeColorSet.java b/forester/java/src/org/forester/archaeopteryx/TreeColorSet.java index fdbfc8d..44e050b 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreeColorSet.java +++ b/forester/java/src/org/forester/archaeopteryx/TreeColorSet.java @@ -72,7 +72,7 @@ public final class TreeColorSet { new Color( 140, 140, 140 ), // branch_length_color new Color( 255, 255, 255 ), // branch_color new Color( 255, 255, 255 ), // box_color - new Color( 255, 255, 0 ), // collapesed_fill_color + new Color( 255, 255, 255 ), // collapesed_fill_color new Color( 0, 255, 0 ), // found_color 0 new Color( 255, 0, 0 ), // found_color 1 new Color( 255, 255, 0 ), // found_color 1 + 2 @@ -91,7 +91,7 @@ public final class TreeColorSet { new Color( 140, 140, 140 ), // branch_length_color new Color( 255, 255, 255 ), // branch_color new Color( 255, 255, 255 ), // box_color - new Color( 255, 255, 0 ), // collapesed_fill_color + new Color( 255, 255, 255 ), // collapesed_fill_color new Color( 0, 255, 0 ), // found_color 0 new Color( 255, 0, 0 ), // found_color 1 new Color( 255, 255, 0 ), // found_color 1 + 2 @@ -129,7 +129,7 @@ public final class TreeColorSet { new Color( 140, 140, 140 ), // branch_length_color new Color( 240, 240, 240 ), // branch_color new Color( 140, 140, 140 ), // box_color - new Color( 140, 140, 140 ), // collapesed_fill_color + new Color( 240, 240, 240 ), // collapesed_fill_color new Color( 255, 0, 0 ), // found_color 0 new Color( 0, 255, 0 ), // found_color 1 new Color( 255, 255, 0 ), // found_color 1 + 2 @@ -148,7 +148,7 @@ public final class TreeColorSet { new Color( 0, 100, 0 ), // branch_length_color new Color( 0, 155, 0 ), // branch_color new Color( 0, 255, 0 ), // box_color - new Color( 0, 255, 0 ), // collapesed_fill_color + new Color( 0, 155, 0 ), // collapesed_fill_color new Color( 255, 0, 0 ), // found_color 0 new Color( 0, 255, 0 ), // found_color 1 new Color( 255, 255, 0 ), // found_color 1 + 2 @@ -167,7 +167,7 @@ public final class TreeColorSet { new Color( 70, 70, 0 ), // branch_length_color new Color( 0, 20, 200 ), // branch_color new Color( 0, 20, 200 ), // box_color - new Color( 255, 255, 0 ), // collapesed_fill_color + new Color( 0, 20, 200 ), // collapesed_fill_color new Color( 0, 255, 0 ), // found_color 0 new Color( 255, 0, 0 ), // found_color 1 new Color( 0, 0, 255 ), // found_color 0 + 1 @@ -186,7 +186,7 @@ public final class TreeColorSet { new Color( 200, 200, 200 ), // branch_length_color new Color( 0, 255, 255 ), // branch_color new Color( 0, 255, 255 ), // box_color - new Color( 255, 255, 0 ), // collapesed_fill_color + new Color( 0, 255, 255 ), // collapesed_fill_color new Color( 0, 255, 0 ), // found_color 0 new Color( 0, 0, 255 ), // found_color 1 new Color( 0, 255, 255 ), // found_color 0 + 1 @@ -205,7 +205,7 @@ public final class TreeColorSet { new Color( 255, 200, 0 ), // branch_length_color new Color( 255, 200, 0 ), // branch_color new Color( 255, 200, 0 ), // box_color - new Color( 255, 255, 255 ), // collapesed_fill_color + new Color( 255, 200, 0 ), // collapesed_fill_color new Color( 255, 255, 0 ), // found_color 0 new Color( 0, 255, 255 ), // found_color 1 new Color( 255, 255, 255 ), // found_color 0 + 1 @@ -224,7 +224,7 @@ public final class TreeColorSet { new Color( 255, 0, 0 ), // branch_length_color new Color( 255, 0, 0 ), // branch_color new Color( 255, 0, 0 ), // box_color - new Color( 0, 0, 0 ), // collapesed_fill_color + new Color( 255, 0, 0 ), // collapesed_fill_color new Color( 0, 255, 0 ), // found_color new Color( 255, 0, 0 ), // found_color 1 new Color( 255, 255, 0 ), // found_color 1 + 2 @@ -243,7 +243,7 @@ public final class TreeColorSet { new Color( 0, 191, 255 ), // branch_length_color new Color( 0, 191, 255 ), // branch_color new Color( 0, 191, 255 ), // box_color - new Color( 255, 255, 255 ), // collapesed_fill_color + new Color( 0, 191, 255 ), // collapesed_fill_color new Color( 255, 0, 0 ), // found_color 0 new Color( 0, 255, 0 ), // found_color 1 new Color( 255, 255, 0 ), // found_color 0 + 1 @@ -262,7 +262,7 @@ public final class TreeColorSet { new Color( 77, 77, 255 ), // branch_length_color new Color( 234, 173, 234 ), // branch_color new Color( 77, 77, 255 ), // box_color - new Color( 77, 77, 255 ), // collapsed_fill_color + new Color( 234, 173, 234 ), // collapsed_fill_color new Color( 243, 243, 21 ), // found_color 0 new Color( 255, 20, 147 ), // found_color 1 new Color( 255, 255, 255 ), // found_color 1 + 2 diff --git a/forester/java/src/org/forester/archaeopteryx/TreeFontSet.java b/forester/java/src/org/forester/archaeopteryx/TreeFontSet.java index f6e8605..95730b8 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreeFontSet.java +++ b/forester/java/src/org/forester/archaeopteryx/TreeFontSet.java @@ -48,19 +48,12 @@ public final class TreeFontSet { private Font _base_font; private Font _small_font_system; private Font _large_font_system; - private Font _small_italic_font_system; - private Font _large_italic_font_system; private Font _small_font_memory; private Font _large_font_memory; - private Font _small_italic_font_memory; - private Font _large_italic_font_memory; // Handy holders for font metrics public FontMetrics _fm_small; FontMetrics _fm_large; - FontMetrics _fm_small_italic; - FontMetrics _fm_small_italic_bold; - FontMetrics _fm_large_italic; - FontMetrics _fm_large_italic_bold; + FontMetrics _fm_large_bold; // hold font measurements int _small_max_descent = 0; int _small_max_ascent = 0; @@ -83,15 +76,11 @@ public final class TreeFontSet { if ( decreased_size_by_system && !isDecreasedSizeBySystem() ) { _small_font_memory = _small_font; _large_font_memory = _large_font; - _small_italic_font_memory = _small_italic_font; - _large_italic_font_memory = _large_italic_font; } setDecreasedSizeBySystem( decreased_size_by_system ); if ( _large_font.getSize() >= min ) { _small_font = _small_font.deriveFont( _small_font.getSize() - FONT_SIZE_CHANGE_STEP ); _large_font = _large_font.deriveFont( _large_font.getSize() - FONT_SIZE_CHANGE_STEP ); - _small_italic_font = _small_italic_font.deriveFont( _small_italic_font.getSize() - FONT_SIZE_CHANGE_STEP ); - _large_italic_font = _large_italic_font.deriveFont( _large_italic_font.getSize() - FONT_SIZE_CHANGE_STEP ); setupFontMetrics(); } } @@ -108,31 +97,13 @@ public final class TreeFontSet { return _large_font; } - Font getLargeItalicFont() { - return _large_italic_font; - } - - Font getLargeItalicFontSystem() { - return _large_italic_font_system; - } - Font getSmallFontSystem() { return _small_font_system; } - Font getSmallItalicFont() { - return _small_italic_font; - } - - Font getSmallItalicFontSystem() { - return _small_italic_font_system; - } - void increaseFontSize() { _small_font = _small_font.deriveFont( _small_font.getSize() + FONT_SIZE_CHANGE_STEP ); _large_font = _large_font.deriveFont( _large_font.getSize() + FONT_SIZE_CHANGE_STEP ); - _small_italic_font = _small_italic_font.deriveFont( _small_italic_font.getSize() + FONT_SIZE_CHANGE_STEP ); - _large_italic_font = _large_italic_font.deriveFont( _large_italic_font.getSize() + FONT_SIZE_CHANGE_STEP ); setupFontMetrics(); } @@ -144,8 +115,6 @@ public final class TreeFontSet { setDecreasedSizeBySystem( false ); _small_font = _small_font.deriveFont( 12f ); _large_font = _large_font.deriveFont( 14f ); - _small_italic_font = _small_italic_font.deriveFont( 12f ); - _large_italic_font = _large_italic_font.deriveFont( 14f ); setupFontMetrics(); } @@ -153,8 +122,6 @@ public final class TreeFontSet { setDecreasedSizeBySystem( false ); _small_font = _small_font.deriveFont( 8f ); _large_font = _large_font.deriveFont( 10f ); - _small_italic_font = _small_italic_font.deriveFont( 8f ); - _large_italic_font = _large_italic_font.deriveFont( 10f ); setupFontMetrics(); } @@ -171,8 +138,6 @@ public final class TreeFontSet { setDecreasedSizeBySystem( false ); _small_font = _small_font.deriveFont( SMALL_FONTS_BASE - 1 ); _large_font = _large_font.deriveFont( SMALL_FONTS_BASE ); - _small_italic_font = _small_italic_font.deriveFont( SMALL_FONTS_BASE - 1 ); - _large_italic_font = _large_italic_font.deriveFont( SMALL_FONTS_BASE ); setupFontMetrics(); } @@ -180,8 +145,6 @@ public final class TreeFontSet { setDecreasedSizeBySystem( false ); _small_font = _small_font.deriveFont( 2f ); _large_font = _large_font.deriveFont( 3f ); - _small_italic_font = _small_italic_font.deriveFont( 2f ); - _large_italic_font = _large_italic_font.deriveFont( 3f ); setupFontMetrics(); } @@ -189,8 +152,6 @@ public final class TreeFontSet { setDecreasedSizeBySystem( false ); _small_font = _small_font.deriveFont( 5f ); _large_font = _large_font.deriveFont( 6f ); - _small_italic_font = _small_italic_font.deriveFont( 5f ); - _large_italic_font = _large_italic_font.deriveFont( 6f ); setupFontMetrics(); } @@ -206,16 +167,10 @@ public final class TreeFontSet { } _small_font = new Font( getBaseFont().getFontName(), getBaseFont().getStyle(), small_size ); _large_font = new Font( getBaseFont().getFontName(), getBaseFont().getStyle(), getBaseFont().getSize() ); - _small_italic_font = new Font( getBaseFont().getFontName(), italic, small_size ); - _large_italic_font = new Font( getBaseFont().getFontName(), italic, getBaseFont().getSize() ); _small_font_system = new Font( getBaseFont().getFontName(), getBaseFont().getStyle(), small_size ); _large_font_system = new Font( getBaseFont().getFontName(), getBaseFont().getStyle(), getBaseFont().getSize() ); - _small_italic_font_system = new Font( getBaseFont().getFontName(), italic, small_size ); - _large_italic_font_system = new Font( getBaseFont().getFontName(), italic, getBaseFont().getSize() ); _small_font_memory = _small_font; _large_font_memory = _large_font; - _small_italic_font_memory = _small_italic_font; - _large_italic_font_memory = _large_italic_font; setupFontMetrics(); } @@ -226,10 +181,7 @@ public final class TreeFontSet { private void setupFontMetrics() { _fm_small = _owner.getFontMetrics( _small_font ); _fm_large = _owner.getFontMetrics( _large_font ); - _fm_small_italic = _owner.getFontMetrics( _small_italic_font ); - _fm_small_italic_bold = _owner.getFontMetrics( _small_italic_font.deriveFont( Font.BOLD ) ); - _fm_large_italic = _owner.getFontMetrics( _large_italic_font ); - _fm_large_italic_bold = _owner.getFontMetrics( _large_italic_font.deriveFont( Font.BOLD ) ); + _fm_large_bold = _owner.getFontMetrics( _large_font.deriveFont( Font.BOLD ) ); _small_max_descent = _fm_small.getMaxDescent(); _small_max_ascent = _fm_small.getMaxAscent() + 1; } diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanel.java b/forester/java/src/org/forester/archaeopteryx/TreePanel.java index 447a5fd..3ec84a5 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanel.java @@ -640,14 +640,14 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee if ( node.getNodeData().isHasTaxonomy() ) { final Taxonomy tax = node.getNodeData().getTaxonomy(); if ( getControlPanel().isShowTaxonomyCode() && !ForesterUtil.isEmpty( tax.getTaxonomyCode() ) ) { - sum += getTreeFontSet()._fm_large_italic.stringWidth( tax.getTaxonomyCode() + " " ); + sum += getTreeFontSet()._fm_large.stringWidth( tax.getTaxonomyCode() + " " ); } if ( getControlPanel().isShowTaxonomyScientificNames() && !ForesterUtil.isEmpty( tax.getScientificName() ) ) { - sum += getTreeFontSet()._fm_large_italic.stringWidth( tax.getScientificName() + " " ); + sum += getTreeFontSet()._fm_large.stringWidth( tax.getScientificName() + " " ); } if ( getControlPanel().isShowTaxonomyCommonNames() && !ForesterUtil.isEmpty( tax.getCommonName() ) ) { - sum += getTreeFontSet()._fm_large_italic.stringWidth( tax.getCommonName() + " ()" ); + sum += getTreeFontSet()._fm_large.stringWidth( tax.getCommonName() + " ()" ); } } if ( getControlPanel().isShowProperties() && node.getNodeData().isHasProperties() ) { @@ -4201,28 +4201,18 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } _sb.append( propertiesToString( node ) ); } - Font visual_font = null; - if ( getControlPanel().isUseVisualStyles() && ( node.getNodeData().getNodeVisualData() != null ) ) { - visual_font = node.getNodeData().getNodeVisualData().getFont(); - g.setFont( visual_font != null ? visual_font : getTreeFontSet().getLargeFont() ); - } - else { - g.setFont( getTreeFontSet().getLargeFont() ); - } - if ( is_in_found_nodes ) { - g.setFont( getTreeFontSet().getLargeFont().deriveFont( Font.BOLD ) ); - } + final boolean using_visual_font = setFont( g, node, is_in_found_nodes ); double down_shift_factor = 3.0; if ( !node.isExternal() && ( node.getNumberOfDescendants() == 1 ) ) { down_shift_factor = 1; } final double pos_x = node.getXcoord() + x + 2 + half_box_size; double pos_y; - if ( visual_font == null ) { + if ( !using_visual_font ) { pos_y = ( node.getYcoord() + ( getTreeFontSet()._fm_large.getAscent() / down_shift_factor ) ); } else { - pos_y = ( node.getYcoord() + ( getFontMetrics( visual_font ).getAscent() / down_shift_factor ) ); + pos_y = ( node.getYcoord() + ( getFontMetrics( getFont() ).getAscent() / down_shift_factor ) ); } final String sb_str = _sb.toString(); // GUILHEM_BEG ______________ @@ -4346,6 +4336,21 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } } + private boolean setFont( final Graphics2D g, final PhylogenyNode node, final boolean is_in_found_nodes ) { + Font visual_font = null; + if ( getControlPanel().isUseVisualStyles() && ( node.getNodeData().getNodeVisualData() != null ) ) { + visual_font = node.getNodeData().getNodeVisualData().getFont(); + g.setFont( visual_font != null ? visual_font : getTreeFontSet().getLargeFont() ); + } + else if ( is_in_found_nodes ) { + g.setFont( getTreeFontSet().getLargeFont().deriveFont( Font.BOLD ) ); + } + else { + g.setFont( getTreeFontSet().getLargeFont() ); + } + return visual_font != null; + } + private void setColor( final Graphics2D g, final PhylogenyNode node, final boolean to_graphics_file, @@ -4462,10 +4467,11 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee _sb.append( node.getNodeData().getSequence().getName() ); } } - g.setFont( getTreeFontSet().getLargeFont() ); - if ( is_in_found_nodes ) { - g.setFont( getTreeFontSet().getLargeFont().deriveFont( Font.BOLD ) ); - } + final boolean using_visual_font = setFont( g, node, is_in_found_nodes ); + //g.setFont( getTreeFontSet().getLargeFont() ); + //if ( is_in_found_nodes ) { + // g.setFont( getTreeFontSet().getLargeFont().deriveFont( Font.BOLD ) ); + // } if ( _sb.length() > 1 ) { final String sb_str = _sb.toString(); double m = 0; @@ -4680,19 +4686,19 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee if ( node.getNodeData().isHasTaxonomy() ) { if ( getControlPanel().isShowTaxonomyCode() && ( !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getTaxonomyCode() ) ) ) { - x += getTreeFontSet()._fm_large_italic.stringWidth( node.getNodeData().getTaxonomy() + x += getTreeFontSet()._fm_large.stringWidth( node.getNodeData().getTaxonomy() .getTaxonomyCode() + " " ); } if ( getControlPanel().isShowTaxonomyScientificNames() && ( !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getScientificName() ) ) ) { - x += getTreeFontSet()._fm_large_italic.stringWidth( node.getNodeData().getTaxonomy() + x += getTreeFontSet()._fm_large.stringWidth( node.getNodeData().getTaxonomy() .getScientificName() + " " ); } if ( getControlPanel().isShowTaxonomyCommonNames() && ( !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getCommonName() ) ) ) { - x += getTreeFontSet()._fm_large_italic.stringWidth( node.getNodeData().getTaxonomy() + x += getTreeFontSet()._fm_large.stringWidth( node.getNodeData().getTaxonomy() .getCommonName() + " " ); } @@ -4748,7 +4754,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee my_node = getPhylogeny().getFirstExternalNode(); } if ( getControlPanel().isShowTaxonomyCode() && ( PhylogenyMethods.getSpecies( my_node ).length() > 0 ) ) { - x += getTreeFontSet()._fm_large_italic.stringWidth( PhylogenyMethods.getSpecies( my_node ) + " " ); + x += getTreeFontSet()._fm_large.stringWidth( PhylogenyMethods.getSpecies( my_node ) + " " ); } if ( getControlPanel().isShowNodeNames() && ( my_node.getName().length() > 0 ) ) { x += getTreeFontSet()._fm_large.stringWidth( my_node.getName() + " " ); @@ -4875,24 +4881,17 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee final boolean to_graphics_file, final double x_shift ) { final Taxonomy taxonomy = node.getNodeData().getTaxonomy(); - Font visual_font = null; - if ( getControlPanel().isUseVisualStyles() && ( node.getNodeData().getNodeVisualData() != null ) ) { - visual_font = node.getNodeData().getNodeVisualData().getFont(); - g.setFont( visual_font != null ? visual_font : getTreeFontSet().getLargeItalicFont() ); - } - else { - g.setFont( getTreeFontSet().getLargeItalicFont() ); - } + final boolean using_visual_font = setFont( g, node, is_in_found_nodes ); setColor( g, node, to_graphics_file, to_pdf, is_in_found_nodes, getTreeColorSet().getTaxonomyColor() ); final double start_x = node.getXcoord() + 3 + ( getOptions().getDefaultNodeShapeSize() / 2 ) + x_shift; double start_y; - if ( visual_font == null ) { + if ( !using_visual_font ) { start_y = node.getYcoord() + ( getTreeFontSet()._fm_large.getAscent() / ( node.getNumberOfDescendants() == 1 ? 1 : 3.0 ) ); } else { start_y = node.getYcoord() - + ( getFontMetrics( visual_font ).getAscent() / ( node.getNumberOfDescendants() == 1 ? 1 : 3.0 ) ); + + ( getFontMetrics( getFont() ).getAscent() / ( node.getNumberOfDescendants() == 1 ? 1 : 3.0 ) ); } _sb.setLength( 0 ); if ( _control_panel.isShowTaxonomyCode() && !ForesterUtil.isEmpty( taxonomy.getTaxonomyCode() ) ) { @@ -4961,13 +4960,13 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee /* GUILHEM_END */ TreePanel.drawString( label, start_x, start_y, g ); if ( is_in_found_nodes ) { - return getTreeFontSet()._fm_large_italic_bold.stringWidth( label ); + return getTreeFontSet()._fm_large_bold.stringWidth( label ); } else { - if ( visual_font == null ) { - return getTreeFontSet()._fm_large_italic.stringWidth( label ); + if ( !using_visual_font ) { + return getTreeFontSet()._fm_large.stringWidth( label ); } - return getFontMetrics( visual_font ).stringWidth( label ); + return getFontMetrics( getFont() ).stringWidth( label ); } } -- 1.7.10.2