inprogress
authorcmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Tue, 24 Sep 2013 23:20:49 +0000 (23:20 +0000)
committercmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Tue, 24 Sep 2013 23:20:49 +0000 (23:20 +0000)
forester/java/src/org/forester/archaeopteryx/AptxUtil.java
forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java
forester/java/src/org/forester/archaeopteryx/Configuration.java
forester/java/src/org/forester/archaeopteryx/MainFrame.java
forester/java/src/org/forester/archaeopteryx/MainFrameApplet.java
forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java
forester/java/src/org/forester/archaeopteryx/Options.java
forester/java/src/org/forester/archaeopteryx/TreePanel.java

index 8ceb398..3f4bd4c 100644 (file)
@@ -566,22 +566,16 @@ public final class AptxUtil {
                 }
             }
             else if ( my_str.length() > 2 ) {
-                third = ( char ) ( Math.abs( str.hashCode() / 16909320 ) );
-                System.out.println( str.hashCode() );
+                third = my_str.charAt( ( my_str.length() - 1 ) / 2 );
             }
         }
         first = AptxUtil.normalizeCharForRGB( first );
         second = AptxUtil.normalizeCharForRGB( second );
-        if ( is_taxonomy ) {
-            third = AptxUtil.normalizeCharForRGB( third );
-        }
-        else {
-            third = third > 255 ? 255 : third;
-        }
+        third = AptxUtil.normalizeCharForRGB( third );
         if ( ( first > 235 ) && ( second > 235 ) && ( third > 235 ) ) {
             first = 0;
         }
-        else if ( ( first < 80 ) && ( second < 80 ) && ( third < 80 ) ) {
+        else if ( ( first < 60 ) && ( second < 60 ) && ( third < 60 ) ) {
             second = 255;
         }
         return new Color( first, second, third );
@@ -750,7 +744,7 @@ public final class AptxUtil {
         return colorizations;
     }
 
-    final static String createAnnotationString( final SortedSet<Annotation> annotations ) {
+    final static String createAnnotationString( final SortedSet<Annotation> annotations, final boolean show_ref_sources ) {
         final SortedMap<String, List<Annotation>> m = new TreeMap<String, List<Annotation>>();
         for( final Annotation an : annotations ) {
             final String ref_source = ForesterUtil.isEmpty( an.getRefSource() ) ? "?" : an.getRefSource();
@@ -766,7 +760,7 @@ public final class AptxUtil {
             if ( m.size() > 1 ) {
                 sb.append( "[" );
             }
-            if ( !ref_source.equals( "?" ) ) {
+            if ( show_ref_sources && !ref_source.equals( "?" ) ) {
                 sb.append( ref_source );
                 sb.append( ": " );
             }
index aab7b78..286bf47 100644 (file)
@@ -97,6 +97,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
     private JMenuItem                   _aptx_ref_item;
     private JMenuItem                   _remove_branch_color_item;
     private JCheckBoxMenuItem           _show_domain_labels;
+    private JCheckBoxMenuItem           _show_annotation_ref_source;
     private JCheckBoxMenuItem           _color_labels_same_as_parent_branch;
     private JCheckBoxMenuItem           _abbreviate_scientific_names;
     private JCheckBoxMenuItem           _screen_antialias_cbmi;
@@ -745,6 +746,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         customizeCheckBoxMenuItem( _screen_antialias_cbmi, getOptions().isAntialiasScreen() );
         customizeCheckBoxMenuItem( _background_gradient_cbmi, getOptions().isBackgroundColorGradient() );
         customizeCheckBoxMenuItem( _show_domain_labels, getOptions().isShowDomainLabels() );
+        customizeCheckBoxMenuItem( _show_annotation_ref_source, getOptions().isShowAnnotationRefSource() );
         customizeCheckBoxMenuItem( _abbreviate_scientific_names, getOptions().isAbbreviateScientificTaxonNames() );
         customizeCheckBoxMenuItem( _show_default_node_shapes_external_cbmi, getOptions()
                 .isShowDefaultNodeShapesExternal() );
@@ -1280,6 +1282,8 @@ public class ArchaeopteryxE extends JApplet implements ActionListener {
         options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
                 && _background_gradient_cbmi.isSelected() );
         options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
+        options.setShowAnnotationRefSource( ( _show_annotation_ref_source != null )
+                && _show_annotation_ref_source.isSelected() );
         options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
                 && _abbreviate_scientific_names.isSelected() );
         options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
index 1398c25..a81370a 100644 (file)
@@ -89,6 +89,7 @@ public final class Configuration {
     private boolean                         _validate_against_phyloxml_xsd_schema                  = Constants.VALIDATE_AGAINST_PHYLOXML_XSD_SCJEMA_DEFAULT;
     private boolean                         _background_color_gradient                             = false;
     private boolean                         _show_domain_labels                                    = true;
+    private boolean                         _show_annotation_ref_source                            = true;
     private boolean                         _abbreviate_scientific_names                           = false;
     private boolean                         _color_labels_same_as_parent_branch                    = false;
     private boolean                         _show_default_node_shapes_internal                     = false;
@@ -1193,6 +1194,9 @@ public final class Configuration {
         else if ( key.equals( "show_domain_labels" ) ) {
             setShowDomainLabels( parseBoolean( ( String ) st.nextElement() ) );
         }
+        else if ( key.equals( "show_seq_annotation_ref_sources" ) ) {
+            setShowAnnotationRefSource( parseBoolean( ( String ) st.nextElement() ) );
+        }
         else if ( key.equals( "abbreviate_scientific_names" ) ) {
             setAbbreviateScientificTaxonNames( parseBoolean( ( String ) st.nextElement() ) );
         }
@@ -1653,6 +1657,10 @@ public final class Configuration {
         }
     }
 
+    private void setShowAnnotationRefSource( final boolean b ) {
+        _show_annotation_ref_source = b;
+    }
+
     private void setLabelForGetExtDescendentsData( final String label_for_get_ext_descendents_data ) {
         _label_for_get_ext_descendents_data = label_for_get_ext_descendents_data;
     }
@@ -1712,4 +1720,8 @@ public final class Configuration {
     public void setMidpointReroot( final boolean midpoint_root ) {
         _midpoint_root = midpoint_root;
     }
+
+    public boolean isShowAnnotationRefSource() {
+        return _show_annotation_ref_source;
+    }
 }
index bc565ac..ada05c2 100644 (file)
@@ -111,6 +111,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
     static final String         FONT_SIZE_MENU_LABEL                    = "Font Size";
     static final String         NONUNIFORM_CLADOGRAMS_LABEL             = "External Node Sum Dependent Cladograms";
     static final String         SHOW_DOMAIN_LABELS_LABEL                = "Show Domain Labels";
+    static final String         SHOW_ANN_REF_SOURCE_LABEL               = "Show Seq Annotation Ref Sources";
     static final String         COLOR_LABELS_TIP                        = "To use parent branch colors for node labels as well, need to turn off taxonomy dependent colorization and turn on branch colorization for this to become apparent";
     static final String         ABBREV_SN_LABEL                         = "Abbreviate Scientific Taxonomic Names";
     static final String         TAXONOMY_COLORIZE_NODE_SHAPES_LABEL     = "Colorize Node Shapes According to Taxonomy";
@@ -179,6 +180,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
     JCheckBoxMenuItem           _show_scale_cbmi;                                                                                                                                                                                             //TODO fix me
     JCheckBoxMenuItem           _show_overview_cbmi;
     JCheckBoxMenuItem           _show_domain_labels;
+    JCheckBoxMenuItem           _show_annotation_ref_source;
     JCheckBoxMenuItem           _abbreviate_scientific_names;
     JCheckBoxMenuItem           _color_labels_same_as_parent_branch;
     JMenuItem                   _overview_placment_mi;
@@ -388,6 +390,9 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         else if ( o == _show_domain_labels ) {
             updateOptions( getOptions() );
         }
+        else if ( o == _show_annotation_ref_source ) {
+            updateOptions( getOptions() );
+        }
         else if ( o == _abbreviate_scientific_names ) {
             updateOptions( getOptions() );
         }
@@ -1260,6 +1265,8 @@ public abstract class MainFrame extends JFrame implements ActionListener {
         options.setBackgroundColorGradient( ( _background_gradient_cbmi != null )
                 && _background_gradient_cbmi.isSelected() );
         options.setShowDomainLabels( ( _show_domain_labels != null ) && _show_domain_labels.isSelected() );
+        options.setShowAnnotationRefSource( ( _show_annotation_ref_source != null )
+                && _show_annotation_ref_source.isSelected() );
         options.setAbbreviateScientificTaxonNames( ( _abbreviate_scientific_names != null )
                 && _abbreviate_scientific_names.isSelected() );
         options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null )
index 11bbba5..7580196 100644 (file)
@@ -232,6 +232,7 @@ public final class MainFrameApplet extends MainFrame {
         if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
             _options_jmenu.add( _show_domain_labels = new JCheckBoxMenuItem( SHOW_DOMAIN_LABELS_LABEL ) );
         }
+        _options_jmenu.add( _show_annotation_ref_source = new JCheckBoxMenuItem( SHOW_ANN_REF_SOURCE_LABEL ) );
         _options_jmenu.add( _choose_minimal_confidence_mi = new JMenuItem( "" ) );
         _options_jmenu.add( _overview_placment_mi = new JMenuItem( "" ) );
         _options_jmenu.add( _switch_colors_mi = new JMenuItem( "" ) );
@@ -259,6 +260,7 @@ public final class MainFrameApplet extends MainFrame {
         customizeCheckBoxMenuItem( _screen_antialias_cbmi, getOptions().isAntialiasScreen() );
         customizeCheckBoxMenuItem( _background_gradient_cbmi, getOptions().isBackgroundColorGradient() );
         customizeCheckBoxMenuItem( _show_domain_labels, getOptions().isShowDomainLabels() );
+        customizeCheckBoxMenuItem( _show_annotation_ref_source, getOptions().isShowAnnotationRefSource() );
         customizeCheckBoxMenuItem( _abbreviate_scientific_names, getOptions().isAbbreviateScientificTaxonNames() );
         customizeCheckBoxMenuItem( _search_case_senstive_cbmi, getOptions().isSearchCaseSensitive() );
         customizeCheckBoxMenuItem( _show_scale_cbmi, getOptions().isShowScale() );
index 1060a32..774190c 100644 (file)
@@ -912,6 +912,7 @@ public final class MainFrameApplication extends MainFrame {
         if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
             _options_jmenu.add( _show_domain_labels = new JCheckBoxMenuItem( SHOW_DOMAIN_LABELS_LABEL ) );
         }
+        _options_jmenu.add( _show_annotation_ref_source = new JCheckBoxMenuItem( SHOW_ANN_REF_SOURCE_LABEL ) );
         _options_jmenu.add( _choose_minimal_confidence_mi = new JMenuItem( "" ) );
         _options_jmenu.add( _overview_placment_mi = new JMenuItem( "" ) );
         _options_jmenu.add( _switch_colors_mi = new JMenuItem( "" ) );
@@ -984,6 +985,7 @@ public final class MainFrameApplication extends MainFrame {
         customizeCheckBoxMenuItem( _screen_antialias_cbmi, getOptions().isAntialiasScreen() );
         customizeCheckBoxMenuItem( _background_gradient_cbmi, getOptions().isBackgroundColorGradient() );
         customizeCheckBoxMenuItem( _show_domain_labels, getOptions().isShowDomainLabels() );
+        customizeCheckBoxMenuItem( _show_annotation_ref_source, getOptions().isShowAnnotationRefSource() );
         customizeCheckBoxMenuItem( _abbreviate_scientific_names, getOptions().isAbbreviateScientificTaxonNames() );
         customizeCheckBoxMenuItem( _search_case_senstive_cbmi, getOptions().isSearchCaseSensitive() );
         customizeCheckBoxMenuItem( _show_scale_cbmi, getOptions().isShowScale() );
index 5b855fb..ca216c8 100644 (file)
@@ -72,6 +72,7 @@ final public class Options {
     private boolean                           _editable;
     private boolean                           _background_color_gradient;
     private boolean                           _show_domain_labels;
+    private boolean                           _show_annotation_ref_source;
     private boolean                           _color_labels_same_as_parent_branch;
     private boolean                           _abbreviate_scientific_names;
     private NodeVisualization.NodeShape       _default_node_shape;
@@ -96,6 +97,14 @@ final public class Options {
         return _show_domain_labels;
     }
 
+    public final boolean isShowAnnotationRefSource() {
+        return _show_annotation_ref_source;
+    }
+
+    public final void setShowAnnotationRefSource( final boolean show_annotation_ref_source ) {
+        _show_annotation_ref_source = show_annotation_ref_source;
+    }
+
     public void setBackgroundColorGradient( final boolean background_color_gradient ) {
         _background_color_gradient = background_color_gradient;
     }
@@ -461,6 +470,7 @@ final public class Options {
         _taxonomy_extraction = TAXONOMY_EXTRACTION.NO;
         _cladogram_type = Constants.CLADOGRAM_TYPE_DEFAULT;
         _show_domain_labels = true;
+        _show_annotation_ref_source = true;
         setAbbreviateScientificTaxonNames( false );
         _color_labels_same_as_parent_branch = false;
         _show_confidence_stddev = true;
@@ -503,6 +513,7 @@ final public class Options {
             instance.setEditable( configuration.isEditable() );
             instance.setColorLabelsSameAsParentBranch( configuration.isColorLabelsSameAsParentBranch() );
             instance.setShowDomainLabels( configuration.isShowDomainLabels() );
+            instance.setShowAnnotationRefSource( configuration.isShowAnnotationRefSource() );
             instance.setAbbreviateScientificTaxonNames( configuration.isAbbreviateScientificTaxonNames() );
             if ( configuration.getMinConfidenceValue() != MIN_CONFIDENCE_DEFAULT ) {
                 instance.setMinConfidenceValue( configuration.getMinConfidenceValue() );
index 1eaadd3..978b132 100644 (file)
@@ -621,7 +621,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                         && ( node.getNodeData().getSequence().getAnnotations() != null )
                         && !node.getNodeData().getSequence().getAnnotations().isEmpty() ) {
                     sum += getTreeFontSet()._fm_large.stringWidth( AptxUtil.createAnnotationString( node.getNodeData()
-                            .getSequence().getAnnotations() )
+                            .getSequence().getAnnotations(), getOptions().isShowAnnotationRefSource() )
                             + " " );
                 }
                 if ( getControlPanel().isShowDomainArchitectures()
@@ -4095,7 +4095,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
             else if ( getControlPanel().isColorAccordingToAnnotation() ) {
                 g.setColor( calculateColorForAnnotation( ann ) );
             }
-            final String ann_str = AptxUtil.createAnnotationString( ann );
+            final String ann_str = AptxUtil.createAnnotationString( ann, getOptions().isShowAnnotationRefSource() );
             TreePanel.drawString( ann_str, node.getXcoord() + x + 3 + half_box_size, node.getYcoord()
                     + ( getTreeFontSet()._fm_large.getAscent() / down_shift_factor ), g );
             _sb.setLength( 0 );
@@ -4485,6 +4485,14 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                                     .getAccession().toString()
                                     + " " );
                         }
+                        if ( getControlPanel().isShowAnnotation()
+                                && ( node.getNodeData().getSequence().getAnnotations() != null )
+                                && ( !node.getNodeData().getSequence().getAnnotations().isEmpty() ) ) {
+                            x += getTreeFontSet()._fm_large.stringWidth( AptxUtil.createAnnotationString( node
+                                    .getNodeData().getSequence().getAnnotations(), getOptions()
+                                    .isShowAnnotationRefSource() )
+                                    + " " );
+                        }
                     }
                     if ( getControlPanel().isShowNodeNames() && !ForesterUtil.isEmpty( node.getName() ) ) {
                         x += getTreeFontSet()._fm_large.stringWidth( node.getName() + " " );