+ _species_order = species_order;
+ }
+
+ @Override
+ public StringBuffer toStringBuffer( final PrintableDomainSimilarity.PRINT_OPTION print_option,
+ final Map<String, Integer> tax_code_to_id_map,
+ final Phylogeny phy ) {
+ switch ( print_option ) {
+ case SIMPLE_TAB_DELIMITED:
+ return toStringBufferSimpleTabDelimited();
+ case HTML:
+ return toStringBufferDetailedHTML( tax_code_to_id_map, phy );
+ default:
+ throw new AssertionError( "Unknown print option: " + print_option );
+ }
+ }
+
+ private void addSpeciesSpecificDomainData( final StringBuffer sb,
+ final Species species,
+ final boolean html,
+ final Map<String, Integer> tax_code_to_id_map,
+ final Phylogeny phy ) {
+ if ( html ) {
+ addTaxWithLink( sb, species.getSpeciesId(), tax_code_to_id_map, phy );
+ }
+ else {
+ sb.append( species.getSpeciesId() );
+ }
+ if ( getDetaildness() != DomainSimilarityCalculator.Detailedness.BASIC ) {
+ if ( html ) {
+ sb.append( ":" );
+ }
+ else {
+ sb.append( "\t" );
+ }
+ sb.append( getSpeciesData().get( species ).toStringBuffer( getDetaildness(), html ) );
+ }
+ if ( html ) {
+ sb.append( "<br>" );
+ }
+ else {
+ sb.append( "\n\t" );
+ }
+ }
+
+ private void addTaxWithLink( final StringBuffer sb,
+ final String tax_code,
+ final Map<String, Integer> tax_code_to_id_map,
+ final Phylogeny phy ) {
+ String hex = null;
+ if ( ( phy != null ) && !phy.isEmpty() ) {
+ hex = SurfacingUtil.obtainHexColorStringDependingOnTaxonomyGroup( tax_code, phy );
+ }
+ sb.append( "<b>" );
+ if ( !ForesterUtil.isEmpty( tax_code )
+ && ( ( tax_code_to_id_map != null ) && tax_code_to_id_map.containsKey( tax_code ) ) ) {
+ if ( !ForesterUtil.isEmpty( hex ) ) {
+ sb.append( "<a href=\"" );
+ sb.append( SurfacingConstants.UNIPROT_TAXONOMY_ID_LINK );
+ sb.append( tax_code_to_id_map.get( tax_code ) );
+ sb.append( "\" target=\"tw\"><span style=\"color:" );
+ sb.append( hex );
+ sb.append( "\">" );
+ sb.append( tax_code );
+ sb.append( "</span></a>" );
+ }
+ else {
+ sb.append( "<a href=\"" );
+ sb.append( SurfacingConstants.UNIPROT_TAXONOMY_ID_LINK );
+ sb.append( tax_code_to_id_map.get( tax_code ) );
+ sb.append( "\" target=\"tw\">" );
+ sb.append( tax_code );
+ sb.append( "</a>" );
+ }
+ }
+ else {
+ sb.append( tax_code );
+ }
+ sb.append( "</b>" );
+ }
+
+ private int compareByDomainId( final DomainSimilarity other ) {
+ return getDomainId().compareToIgnoreCase( other.getDomainId() );
+ }
+
+ private CombinableDomains getCombinableDomains() {
+ return _combinable_domains;
+ }
+
+ private DomainSimilarityCalculator.Detailedness getDetaildness() {
+ return _detailedness;