JAL-2360 ColourSchemes holds configured schemes, AlignFrame colour menu
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 20 Dec 2016 14:06:42 +0000 (14:06 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 20 Dec 2016 14:06:42 +0000 (14:06 +0000)
construction and actions done dynamically

45 files changed:
resources/lang/Messages.properties
resources/lang/Messages_es.properties
src/MCview/AppletPDBViewer.java
src/MCview/PDBViewer.java
src/jalview/appletgui/APopupMenu.java
src/jalview/appletgui/AlignFrame.java
src/jalview/appletgui/AppletJmol.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/PopupMenu.java
src/jalview/gui/Preferences.java
src/jalview/gui/UserDefinedColours.java
src/jalview/jbgui/GAlignFrame.java
src/jalview/jbgui/GStructureViewer.java
src/jalview/schemes/AnnotationColourGradient.java
src/jalview/schemes/Blosum62ColourScheme.java
src/jalview/schemes/BuriedColourScheme.java
src/jalview/schemes/ClustalxColourScheme.java
src/jalview/schemes/ColourSchemeI.java
src/jalview/schemes/ColourSchemeProperty.java
src/jalview/schemes/ColourSchemes.java [new file with mode: 0644]
src/jalview/schemes/CovariationColourScheme.java
src/jalview/schemes/FollowerColourScheme.java
src/jalview/schemes/HelixColourScheme.java
src/jalview/schemes/HydrophobicColourScheme.java
src/jalview/schemes/JalviewColourScheme.java
src/jalview/schemes/NucleotideColourScheme.java
src/jalview/schemes/PIDColourScheme.java
src/jalview/schemes/PurinePyrimidineColourScheme.java
src/jalview/schemes/RNAHelicesColour.java
src/jalview/schemes/RNAHelicesColourChooser.java
src/jalview/schemes/RNAInteractionColourScheme.java
src/jalview/schemes/ResidueColourScheme.java
src/jalview/schemes/ScoreColourScheme.java
src/jalview/schemes/StrandColourScheme.java
src/jalview/schemes/TCoffeeColourScheme.java
src/jalview/schemes/TaylorColourScheme.java
src/jalview/schemes/TurnColourScheme.java
src/jalview/schemes/UserColourScheme.java
src/jalview/schemes/ZappoColourScheme.java
src/jalview/viewmodel/AlignmentViewport.java
test/jalview/io/Jalview2xmlTests.java
test/jalview/schemes/ColourSchemePropertyTest.java
test/jalview/schemes/ColourSchemesTest.java [new file with mode: 0644]
test/jalview/schemes/JalviewColourSchemeTest.java
test/jalview/schemes/ResidueColourSchemeTest.java

index 2a69f14..5f47d2c 100644 (file)
@@ -61,7 +61,6 @@ action.set_as_reference = Set as Reference
 action.remove = Remove
 action.remove_redundancy = Remove Redundancy...
 action.pairwise_alignment = Pairwise Alignment
-action.by_rna_helixes = By RNA Helices
 action.user_defined = User Defined...
 action.by_conservation = By Conservation
 action.wrap = Wrap
@@ -179,26 +178,30 @@ label.score_model_conservation = Physicochemical property conservation
 label.score_model_enhconservation = Physicochemical property conservation
 label.status_bar = Status bar
 label.out_to_textbox = Output to Textbox
-label.clustalx = Clustalx
+# delete Clustal - use FileFormat name instead
 label.clustal = Clustal
-label.zappo = Zappo
-label.taylor = Taylor
+# label.colourScheme_<schemeName> as in JalviewColourScheme
+label.colourScheme_clustal = Clustalx
+label.colourScheme_blosum62 = BLOSUM62 Score
+label.colourScheme_%_identity = Percentage Identity
+label.colourScheme_zappo = Zappo
+label.colourScheme_taylor = Taylor
+label.colourScheme_hydrophobic = Hydrophobicity
+label.colourScheme_helix_propensity = Helix Propensity
+label.colourScheme_strand_propensity = Strand Propensity
+label.colourScheme_turn_propensity = Turn Propensity
+label.colourScheme_buried_index = Buried Index
+label.colourScheme_purine/pyrimidine = Purine/Pyrimidine
+label.colourScheme_nucleotide = Nucleotide
+label.colourScheme_t-coffee_scores = T-Coffee Scores
+label.colourScheme_rna_helices = By RNA Helices
 label.blc = BLC
 label.fasta = Fasta
 label.msf = MSF
 label.pfam = PFAM
 label.pileup = Pileup
 label.pir = PIR
-label.hydrophobicity = Hydrophobicity
-label.helix_propensity = Helix Propensity
-label.strand_propensity = Strand Propensity
-label.turn_propensity = Turn Propensity
-label.buried_index = Buried Index
-label.purine_pyrimidine = Purine/Pyrimidine
-label.percentage_identity = Percentage Identity
-label.blosum62_score = BLOSUM62 Score
-label.tcoffee_scores = T-Coffee Scores
-label.average_distance_bloslum62 = Average Distance Using BLOSUM62
+label.average_distance_blosum62 = Average Distance Using BLOSUM62
 label.neighbour_blosum62 = Neighbour Joining Using BLOSUM62
 label.show_annotations = Show annotations
 label.hide_annotations = Hide annotations
@@ -957,7 +960,6 @@ error.implementation_error_maplist_is_null = Implementation error. MapList is nu
 error.implementation_error_cannot_have_null_alignment = Implementation error: Cannot have null alignment property key
 error.implementation_error_null_fileparse = Implementation error. Null FileParse in copy constructor
 error.implementation_error_cannot_map_alignment_sequences = IMPLEMENTATION ERROR: Cannot map an alignment of sequences from different datasets into a single alignment in the vamsas document.
-error.implementation_error_cannot_duplicate_colour_scheme = Serious implementation error: cannot duplicate colourscheme {0}
 error.implementation_error_structure_selection_manager_null = Implementation error. Structure selection manager's context is 'null'
 exception.ssm_context_is_null = SSM context is null
 error.idstring_seqstrings_only_one_per_sequence = idstrings and seqstrings contain one string each per sequence
@@ -1022,7 +1024,6 @@ exception.replace_null_regex_pointer = Replacer has null Regex pointer
 exception.bad_pattern_to_regex_perl_code = bad pattern to Regex.perlCode: {0}
 exception.no_stub_implementation_for_interface = There is no stub implementation for the interface: {0}
 exception.cannot_set_endpoint_address_unknown_port = Cannot set Endpoint Address for Unknown Port {0}
-exception.querying_matching_opening_parenthesis_for_non_closing_parenthesis = Querying matching opening parenthesis for non-closing parenthesis character {0}
 exception.mismatched_unseen_closing_char = Mismatched (unseen) closing character {0}
 exception.mismatched_closing_char = Mismatched closing character {0}
 exception.mismatched_opening_char = Mismatched opening character {0} at {1}
@@ -1033,7 +1034,6 @@ exception.couldnt_parse_responde_from_annotated3d_server = Couldn't parse respon
 exception.application_test_npe = Application test: throwing an NullPointerException It should arrive at the console
 exception.overwriting_vamsas_id_binding = Overwriting vamsas id binding
 exception.overwriting_jalview_id_binding = Overwriting jalview id binding
-error.implementation_error_unknown_file_format_string = Implementation error: Unknown file format string
 exception.failed_to_resolve_gzip_stream = Failed to resolve GZIP stream
 exception.problem_opening_file_also_tried = Problem opening {0} (also tried {1}) : {2}
 exception.problem_opening_file = Problem opening {0} : {1}
@@ -1229,7 +1229,6 @@ action.export_hidden_columns = Export Hidden Columns
 action.export_hidden_sequences = Export Hidden Sequences
 action.export_features = Export Features
 label.export_settings = Export Settings
-label.save_as_biojs_html = Save as BioJs HTML
 label.pdb_web-service_error = PDB Web-service Error
 label.structure_chooser_manual_association = Structure Chooser - Manual association
 label.structure_chooser_filter_time = Structure Chooser - Filter time ({0})
index 9756ab4..5ba1408 100644 (file)
@@ -59,7 +59,6 @@ action.by_group = Por grupo
 action.remove = Eliminar
 action.remove_redundancy = Eliminar redundancia...
 action.pairwise_alignment = Alineamiento de pares...
-action.by_rna_helixes = Por hélices de RNA
 action.user_defined = Definido por el usuario...
 action.by_conservation = Por conservación
 action.wrap = Envolver
@@ -176,26 +175,29 @@ label.score_model_conservation = Conservaci
 label.score_model_enhconservation = Conservación de las propiedades físico-químicas
 label.status_bar = Barra de estado
 label.out_to_textbox = Generar cuadro de texto
-label.clustalx = Clustalx
 label.clustal = Clustal
-label.zappo = Zappo
-label.taylor = Taylor
+# label.colourScheme_<schemeName> as in JalviewColourScheme
+label.colourScheme_clustal = Clustalx
+label.colourScheme_blosum62 = Puntuación del BLOSUM62
+label.colourScheme_%_identity = Porcentaje de identidad
+label.colourScheme_zappo = Zappo
+label.colourScheme_taylor = Taylor
+label.colourScheme_hydrophobic = Hidrofobicidad
+label.colourScheme_helix_propensity = Tendencia de la hélice
+label.colourScheme_strand_propensity = Tendencia de la hebra
+label.colourScheme_turn_propensity = Tendencia de giro
+label.colourScheme_buried_index = Índice de encubrimiento
+label.colourScheme_purine/pyrimidine = Purina/Pirimidina
+label.colourScheme_nucleotide = Nucleótido
+label.colourScheme_t-coffee_scores = Puntuación del T-Coffee
+label.colourScheme_rna_helices = Por hélices de RNA
 label.blc = BLC
 label.fasta = Fasta
 label.msf = MSF
 label.pfam = PFAM
 label.pileup = Pileup
 label.pir = PIR
-label.hydrophobicity = Hidrofobicidad
-label.helix_propensity = Tendencia de la hélice
-label.strand_propensity = Tendencia de la hebra
-label.turn_propensity = Tendencia de giro
-label.buried_index = Índice de encubrimiento
-label.purine_pyrimidine = Purina/Pirimidina
-label.percentage_identity = Porcentaje de identidad
-label.blosum62_score = Puntuación del BLOSUM62 
-label.tcoffee_scores = Puntuación del T-Coffee
-label.average_distance_bloslum62 = Distancia Media Usando BLOSUM62
+label.average_distance_blosum62 = Distancia Media Usando BLOSUM62
 label.neighbour_blosum62 = Neighbour Joining usando BLOSUM62
 label.show_annotations = Mostrar anotaciones
 label.colour_text = Color del texto
@@ -890,7 +892,6 @@ error.implementation_error_maplist_is_null = Error de implementaci
 error.implementation_error_cannot_have_null_alignment = Error de implementación: no es posible tener una clave nula en el alineamiento
 error.implementation_error_null_fileparse = Error de implementación. FileParse nulo en el construictor de copia
 error.implementation_error_cannot_map_alignment_sequences = Error de implementación: no es posible maper un alineamiento de secuencias desde distintos conjuntos de datos en un único alineamiento en el documento VAMSAS.
-error.implementation_error_cannot_duplicate_colour_scheme = Error grave de implementación: no es posible duplicar el esquema cromático {0}
 error.implementation_error_structure_selection_manager_null = Error de implementación. El contexto structure selection manager's es nulo
 exception.ssm_context_is_null = El contexto SSM es nulo
 error.idstring_seqstrings_only_one_per_sequence = idstrings y seqstrings contienen una cadena por cada secuencia
@@ -955,7 +956,6 @@ exception.replace_null_regex_pointer = Reemplazador tiene un puntero Regex nulo
 exception.bad_pattern_to_regex_perl_code = patrón erróneo en Regex.perlCode: {0}
 exception.no_stub_implementation_for_interface = No existe una implementación del stub para la interfaz: {0}
 exception.cannot_set_endpoint_address_unknown_port = No es posible estabelcer la dirección de punto final para el puerto desconocido {0}
-exception.querying_matching_opening_parenthesis_for_non_closing_parenthesis = Consultando la coincidencia de apertura de paréntesis para paréntesis sin cerrar (?)
 exception.mismatched_unseen_closing_char = Discordancia (no vista) en el carácter de cierre {0}
 exception.mismatched_closing_char = Carácter de cierre discordante {0}
 exception.mismatched_opening_char = Carácter de apertura discordante {0} en {1}
@@ -966,7 +966,6 @@ exception.couldnt_parse_responde_from_annotated3d_server = No es posible parsear
 exception.application_test_npe = Prueba de aplicación: lanzando un NullPointerException que debe aparecer en la consola
 exception.overwriting_vamsas_id_binding = Sobreescribiendo la asociación al VAMSAS id
 exception.overwriting_jalview_id_binding = Sobreescribiendo la asociación al Jalview id
-error.implementation_error_unknown_file_format_string = Error de implementación: cadena de formato de fichero desconocido
 exception.failed_to_resolve_gzip_stream = Fallo al resolver el flujo GZIP 
 exception.problem_opening_file_also_tried = Problema abriendo {0} (también se intentó {1}) : {2}
 exception.problem_opening_file = Problema abriendo {0} : {1}
@@ -1230,7 +1229,6 @@ tooltip.aacon_calculations=Actualizar c
 info.select_filter_option=Escoger Opción de Filtro / Entrada Manual
 info.invalid_msa_input_mininfo=Necesita por lo menos dos secuencias con al menos 3 residuos cada una, sin regiones ocultas entre ellas.
 label.chimera_missing=Visualizador de estructura Chimera no encontrado.<br/>Por favor, introduzca la ruta de Chimera,<br/>o descargar e instalar la UCSF Chimera.
-label.save_as_biojs_html=Guardar como HTML BioJs
 exception.fts_server_unreachable=Jalview no puede conectar con el servidor {0}. \nPor favor asegúrese de que está conectado a Internet y vuelva a intentarlo.
 exception.outofmemory_loading_mmcif_file=Sin memoria al cargar el fichero mmCIF
 label.hide_columns_not_containing=Ocultar las columnas que no contengan
index 76ee4b0..133565c 100644 (file)
@@ -185,7 +185,8 @@ public class AppletPDBViewer extends EmbmenuFrame implements
     zbuffer.addItemListener(this);
     charge.setLabel(MessageManager.getString("label.charge_cysteine"));
     charge.addActionListener(this);
-    hydro.setLabel(MessageManager.getString("label.hydrophobicity"));
+    hydro.setLabel(MessageManager
+            .getString("label.colourScheme_hydrophobic"));
     hydro.addActionListener(this);
     chain.setLabel(MessageManager.getString("action.by_chain"));
     chain.addActionListener(this);
@@ -195,17 +196,21 @@ public class AppletPDBViewer extends EmbmenuFrame implements
             .setLabel(MessageManager.getString("label.all_chains_visible"));
     allchains.addItemListener(this);
     viewMenu.setLabel(MessageManager.getString("action.view"));
-    zappo.setLabel(MessageManager.getString("label.zappo"));
+    zappo.setLabel(MessageManager.getString("label.colourScheme_zappo"));
     zappo.addActionListener(this);
-    taylor.setLabel(MessageManager.getString("label.taylor"));
+    taylor.setLabel(MessageManager.getString("label.colourScheme_taylor"));
     taylor.addActionListener(this);
-    helix.setLabel(MessageManager.getString("label.helix_propensity"));
+    helix.setLabel(MessageManager
+            .getString("label.colourScheme_helix_propensity"));
     helix.addActionListener(this);
-    strand.setLabel(MessageManager.getString("label.strand_propensity"));
+    strand.setLabel(MessageManager
+            .getString("label.colourScheme_strand_propensity"));
     strand.addActionListener(this);
-    turn.setLabel(MessageManager.getString("label.turn_propensity"));
+    turn.setLabel(MessageManager
+            .getString("label.colourScheme_turn_propensity"));
     turn.addActionListener(this);
-    buried.setLabel(MessageManager.getString("label.buried_index"));
+    buried.setLabel(MessageManager
+            .getString("label.colourScheme_buried_index"));
     buried.addActionListener(this);
     user.setLabel(MessageManager.getString("action.user_defined"));
     user.addActionListener(this);
index 1c7a6ee..721b6a7 100755 (executable)
@@ -277,7 +277,7 @@ public class PDBViewer extends JInternalFrame implements Runnable
         allchains_itemStateChanged(e);
       }
     });
-    zappo.setText(MessageManager.getString("label.zappo"));
+    zappo.setText(MessageManager.getString("label.colourScheme_zappo"));
     zappo.addActionListener(new ActionListener()
     {
       @Override
@@ -286,7 +286,7 @@ public class PDBViewer extends JInternalFrame implements Runnable
         zappo_actionPerformed(e);
       }
     });
-    taylor.setText(MessageManager.getString("label.taylor"));
+    taylor.setText(MessageManager.getString("label.colourScheme_taylor"));
     taylor.addActionListener(new ActionListener()
     {
       @Override
@@ -295,7 +295,8 @@ public class PDBViewer extends JInternalFrame implements Runnable
         taylor_actionPerformed(e);
       }
     });
-    hydro.setText(MessageManager.getString("label.hydrophobicity"));
+    hydro.setText(MessageManager
+            .getString("label.colourScheme_hydrophobic"));
     hydro.addActionListener(new ActionListener()
     {
       @Override
@@ -304,7 +305,8 @@ public class PDBViewer extends JInternalFrame implements Runnable
         hydro_actionPerformed(e);
       }
     });
-    helix.setText(MessageManager.getString("label.helix_propensity"));
+    helix.setText(MessageManager
+            .getString("label.colourScheme_helix_propensity"));
     helix.addActionListener(new ActionListener()
     {
       @Override
@@ -313,7 +315,8 @@ public class PDBViewer extends JInternalFrame implements Runnable
         helix_actionPerformed(e);
       }
     });
-    strand.setText(MessageManager.getString("label.strand_propensity"));
+    strand.setText(MessageManager
+            .getString("label.colourScheme_strand_propensity"));
     strand.addActionListener(new ActionListener()
     {
       @Override
@@ -322,7 +325,8 @@ public class PDBViewer extends JInternalFrame implements Runnable
         strand_actionPerformed(e);
       }
     });
-    turn.setText(MessageManager.getString("label.turn_propensity"));
+    turn.setText(MessageManager
+            .getString("label.colourScheme_turn_propensity"));
     turn.addActionListener(new ActionListener()
     {
       @Override
@@ -331,7 +335,8 @@ public class PDBViewer extends JInternalFrame implements Runnable
         turn_actionPerformed(e);
       }
     });
-    buried.setText(MessageManager.getString("label.buried_index"));
+    buried.setText(MessageManager
+            .getString("label.colourScheme_buried_index"));
     buried.addActionListener(new ActionListener()
     {
       @Override
index 39c6a8b..2f5ac3a 100644 (file)
@@ -898,14 +898,6 @@ public class APopupMenu extends java.awt.PopupMenu implements
             .getString("action.create_group"));
     createGroupMenuItem.addActionListener(this);
 
-    nucleotideMenuItem.setLabel(MessageManager
-            .getString("label.nucleotide"));
-    nucleotideMenuItem.addActionListener(this);
-    purinePyrimidineMenuItem.setLabel(MessageManager
-            .getString("label.purine_pyrimidine"));
-    purinePyrimidineMenuItem.addActionListener(this);
-    conservationMenuItem.addItemListener(this);
-    abovePIDColour.addItemListener(this);
     colourMenu.setLabel(MessageManager.getString("label.group_colour"));
     showBoxes.setLabel(MessageManager.getString("action.boxes"));
     showBoxes.setState(true);
@@ -967,24 +959,29 @@ public class APopupMenu extends java.awt.PopupMenu implements
     noColourmenuItem.setLabel(MessageManager.getString("label.none"));
     noColourmenuItem.addActionListener(this);
 
-    clustalColour.setLabel(MessageManager.getString("label.clustalx"));
+    clustalColour.setLabel(MessageManager
+            .getString("label.colourScheme_clustal"));
     clustalColour.addActionListener(this);
-    zappoColour.setLabel(MessageManager.getString("label.zappo"));
+    zappoColour.setLabel(MessageManager
+            .getString("label.colourScheme_zappo"));
     zappoColour.addActionListener(this);
-    taylorColour.setLabel(MessageManager.getString("label.taylor"));
+    taylorColour.setLabel(MessageManager
+            .getString("label.colourScheme_taylor"));
     taylorColour.addActionListener(this);
     hydrophobicityColour.setLabel(MessageManager
-            .getString("label.hydrophobicity"));
+            .getString("label.colourScheme_hydrophobic"));
     hydrophobicityColour.addActionListener(this);
-    helixColour
-            .setLabel(MessageManager.getString("label.helix_propensity"));
+    helixColour.setLabel(MessageManager
+            .getString("label.colourScheme_helix_propensity"));
     helixColour.addActionListener(this);
     strandColour.setLabel(MessageManager
-            .getString("label.strand_propensity"));
+            .getString("label.colourScheme_strand_propensity"));
     strandColour.addActionListener(this);
-    turnColour.setLabel(MessageManager.getString("label.turn_propensity"));
+    turnColour.setLabel(MessageManager
+            .getString("label.colourScheme_turn_propensity"));
     turnColour.addActionListener(this);
-    buriedColour.setLabel(MessageManager.getString("label.buried_index"));
+    buriedColour.setLabel(MessageManager
+            .getString("label.colourScheme_buried_index"));
     buriedColour.addActionListener(this);
     abovePIDColour.setLabel(MessageManager
             .getString("label.above_identity_threshold"));
@@ -993,13 +990,21 @@ public class APopupMenu extends java.awt.PopupMenu implements
             .getString("action.user_defined"));
     userDefinedColour.addActionListener(this);
     PIDColour.setLabel(MessageManager
-            .getString("label.percentage_identity"));
+            .getString("label.colourScheme_%_identity"));
     PIDColour.addActionListener(this);
     BLOSUM62Colour.setLabel(MessageManager
-            .getString("label.blosum62_score"));
+            .getString("label.colourScheme_blosum62"));
     BLOSUM62Colour.addActionListener(this);
     conservationMenuItem.setLabel(MessageManager
             .getString("label.conservation"));
+    nucleotideMenuItem.setLabel(MessageManager
+            .getString("label.colourScheme_nucleotide"));
+    nucleotideMenuItem.addActionListener(this);
+    purinePyrimidineMenuItem.setLabel(MessageManager
+            .getString("label.colourScheme_purine/pyrimidine"));
+    purinePyrimidineMenuItem.addActionListener(this);
+    conservationMenuItem.addItemListener(this);
+    abovePIDColour.addItemListener(this);
 
     editMenu.add(copy);
     copy.addActionListener(this);
index 14b3e6a..665b3f4 100644 (file)
@@ -62,6 +62,7 @@ import jalview.schemes.HydrophobicColourScheme;
 import jalview.schemes.NucleotideColourScheme;
 import jalview.schemes.PIDColourScheme;
 import jalview.schemes.PurinePyrimidineColourScheme;
+import jalview.schemes.RNAHelicesColour;
 import jalview.schemes.RNAHelicesColourChooser;
 import jalview.schemes.StrandColourScheme;
 import jalview.schemes.TCoffeeColourScheme;
@@ -1256,7 +1257,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     // }
     else if (source == RNAHelixColour)
     {
-      new RNAHelicesColourChooser(viewport, alignPanel);
+      changeColour(new RNAHelicesColour(viewport.getAlignment()));
+      // new RNAHelicesColourChooser(viewport, alignPanel);
     }
     else if (source == modifyPID)
     {
@@ -3460,45 +3462,50 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
             .getString("label.apply_colour_to_all_groups"));
     applyToAllGroups.setState(true);
     applyToAllGroups.addItemListener(this);
-    clustalColour.setLabel(MessageManager.getString("label.clustalx"));
+    clustalColour.setLabel(MessageManager
+            .getString("label.colourScheme_clustal"));
     clustalColour.addActionListener(this);
-    zappoColour.setLabel(MessageManager.getString("label.zappo"));
+    zappoColour.setLabel(MessageManager
+            .getString("label.colourScheme_zappo"));
     zappoColour.addActionListener(this);
-    taylorColour.setLabel(MessageManager.getString("label.taylor"));
+    taylorColour.setLabel(MessageManager
+            .getString("label.colourScheme_taylor"));
     taylorColour.addActionListener(this);
     hydrophobicityColour.setLabel(MessageManager
-            .getString("label.hydrophobicity"));
+            .getString("label.colourScheme_hydrophobic"));
     hydrophobicityColour.addActionListener(this);
-    helixColour
-            .setLabel(MessageManager.getString("label.helix_propensity"));
+    helixColour.setLabel(MessageManager
+            .getString("label.colourScheme_helix_propensity"));
     helixColour.addActionListener(this);
     strandColour.setLabel(MessageManager
-            .getString("label.strand_propensity"));
+            .getString("label.colourScheme_strand_propensity"));
     strandColour.addActionListener(this);
-    turnColour.setLabel(MessageManager.getString("label.turn_propensity"));
+    turnColour.setLabel(MessageManager
+            .getString("label.colourScheme_turn_propensity"));
     turnColour.addActionListener(this);
-    buriedColour.setLabel(MessageManager.getString("label.buried_index"));
+    buriedColour.setLabel(MessageManager
+            .getString("label.colourScheme_buried_index"));
     buriedColour.addActionListener(this);
     purinePyrimidineColour.setLabel(MessageManager
-            .getString("label.purine_pyrimidine"));
+            .getString("label.colourScheme_purine/pyrimidine"));
     purinePyrimidineColour.addActionListener(this);
     // RNAInteractionColour.setLabel(MessageManager
     // .getString("label.rna_interaction"));
     // RNAInteractionColour.addActionListener(this);
     RNAHelixColour.setLabel(MessageManager
-            .getString("action.by_rna_helixes"));
+            .getString("label.colourScheme_rna_helices"));
     RNAHelixColour.addActionListener(this);
     userDefinedColour.setLabel(MessageManager
             .getString("action.user_defined"));
     userDefinedColour.addActionListener(this);
     PIDColour.setLabel(MessageManager
-            .getString("label.percentage_identity"));
+            .getString("label.colourScheme_%_identity"));
     PIDColour.addActionListener(this);
     BLOSUM62Colour.setLabel(MessageManager
-            .getString("label.blosum62_score"));
+            .getString("label.colourScheme_blosum62"));
     BLOSUM62Colour.addActionListener(this);
-    tcoffeeColour
-            .setLabel(MessageManager.getString("label.tcoffee_scores"));
+    tcoffeeColour.setLabel(MessageManager
+            .getString("label.colourScheme_t-coffee_scores"));
     // it will be enabled only if a score file is provided
     tcoffeeColour.setEnabled(false);
     tcoffeeColour.addActionListener(this);
@@ -3510,7 +3517,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     abovePIDThreshold.setLabel(MessageManager
             .getString("label.above_identity_threshold"));
     abovePIDThreshold.addItemListener(this);
-    nucleotideColour.setLabel(MessageManager.getString("label.nucleotide"));
+    nucleotideColour.setLabel(MessageManager
+            .getString("label.colourScheme_nucleotide"));
     nucleotideColour.addActionListener(this);
     modifyPID.setLabel(MessageManager
             .getString("label.modify_identity_threshold"));
@@ -3550,7 +3558,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
             .getString("label.neighbour_joining_identity"));
     neighbourTreeMenuItem.addActionListener(this);
     avDistanceTreeBlosumMenuItem.setLabel(MessageManager
-            .getString("label.average_distance_bloslum62"));
+            .getString("label.average_distance_blosum62"));
     avDistanceTreeBlosumMenuItem.addActionListener(this);
     njTreeBlosumMenuItem.setLabel(MessageManager
             .getString("label.neighbour_blosum62"));
index 9d4779c..8196c2b 100644 (file)
@@ -24,8 +24,8 @@ import jalview.bin.JalviewLite;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceI;
-import jalview.io.FileParse;
 import jalview.io.DataSourceType;
+import jalview.io.FileParse;
 import jalview.io.StructureFile;
 import jalview.schemes.BuriedColourScheme;
 import jalview.schemes.HelixColourScheme;
@@ -93,27 +93,29 @@ public class AppletJmol extends EmbmenuFrame implements
   MenuItem charge = new MenuItem(
           MessageManager.getString("label.charge_cysteine"));
 
-  MenuItem zappo = new MenuItem(MessageManager.getString("label.zappo"));
+  MenuItem zappo = new MenuItem(
+          MessageManager.getString("label.colourScheme_zappo"));
 
-  MenuItem taylor = new MenuItem(MessageManager.getString("label.taylor"));
+  MenuItem taylor = new MenuItem(
+          MessageManager.getString("label.colourScheme_taylor"));
 
   MenuItem hydro = new MenuItem(
-          MessageManager.getString("label.hydrophobicity"));
+          MessageManager.getString("label.colourScheme_hydrophobic"));
 
   MenuItem helix = new MenuItem(
-          MessageManager.getString("label.helix_propensity"));
+          MessageManager.getString("label.colourScheme_helix_propensity"));
 
   MenuItem strand = new MenuItem(
-          MessageManager.getString("label.strand_propensity"));
+          MessageManager.getString("label.colourScheme_strand_propensity"));
 
   MenuItem turn = new MenuItem(
-          MessageManager.getString("label.turn_propensity"));
+          MessageManager.getString("label.colourScheme_turn_propensity"));
 
   MenuItem buried = new MenuItem(
-          MessageManager.getString("label.buried_index"));
+          MessageManager.getString("label.colourScheme_buried_index"));
 
   MenuItem purinepyrimidine = new MenuItem(
-          MessageManager.getString("label.purine_pyrimidine"));
+          MessageManager.getString("label.colourScheme_purine/pyrimidine"));
 
   MenuItem user = new MenuItem(
           MessageManager.getString("label.user_defined_colours"));
index a88b11f..4687913 100644 (file)
@@ -77,26 +77,13 @@ import jalview.io.JnetAnnotationMaker;
 import jalview.io.NewickFile;
 import jalview.io.TCoffeeScoreFile;
 import jalview.jbgui.GAlignFrame;
-import jalview.schemes.Blosum62ColourScheme;
-import jalview.schemes.BuriedColourScheme;
-import jalview.schemes.ClustalxColourScheme;
 import jalview.schemes.ColourSchemeI;
 import jalview.schemes.ColourSchemeProperty;
-import jalview.schemes.HelixColourScheme;
-import jalview.schemes.HydrophobicColourScheme;
-import jalview.schemes.NucleotideColourScheme;
-import jalview.schemes.PIDColourScheme;
-import jalview.schemes.PurinePyrimidineColourScheme;
-import jalview.schemes.RNAHelicesColour;
-import jalview.schemes.RNAHelicesColourChooser;
+import jalview.schemes.ColourSchemes;
 import jalview.schemes.ResidueColourScheme;
 import jalview.schemes.ResidueProperties;
-import jalview.schemes.StrandColourScheme;
 import jalview.schemes.TCoffeeColourScheme;
-import jalview.schemes.TaylorColourScheme;
-import jalview.schemes.TurnColourScheme;
 import jalview.schemes.UserColourScheme;
-import jalview.schemes.ZappoColourScheme;
 import jalview.util.MessageManager;
 import jalview.viewmodel.AlignmentViewport;
 import jalview.ws.DBRefFetcher;
@@ -127,6 +114,7 @@ import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
 import java.awt.event.KeyAdapter;
 import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.awt.print.PageFormat;
 import java.awt.print.PrinterJob;
@@ -141,12 +129,14 @@ import java.util.Hashtable;
 import java.util.List;
 import java.util.Vector;
 
+import javax.swing.ButtonGroup;
 import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JEditorPane;
 import javax.swing.JInternalFrame;
 import javax.swing.JLayeredPane;
 import javax.swing.JMenu;
 import javax.swing.JMenuItem;
+import javax.swing.JRadioButtonMenuItem;
 import javax.swing.JScrollPane;
 import javax.swing.SwingUtilities;
 
@@ -346,7 +336,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             alignPanel);
     if (viewport.getAlignmentConservationAnnotation() == null)
     {
-      BLOSUM62Colour.setEnabled(false);
+      // BLOSUM62Colour.setEnabled(false);
       conservationMenuItem.setEnabled(false);
       modifyConservation.setEnabled(false);
       // PIDColour.setEnabled(false);
@@ -366,19 +356,20 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       sortPairwiseMenuItem_actionPerformed(null);
     }
 
-    if (Desktop.desktop != null)
-    {
-      this.setDropTarget(new java.awt.dnd.DropTarget(this, this));
-      addServiceListeners();
-      setGUINucleotide(viewport.getAlignment().isNucleotide());
-    }
-
     this.alignPanel.av
             .setShowAutocalculatedAbove(isShowAutoCalculatedAbove());
 
     setMenusFromViewport(viewport);
     buildSortByAnnotationScoresMenu();
     buildTreeMenu();
+    buildColourMenu();
+
+    if (Desktop.desktop != null)
+    {
+      this.setDropTarget(new java.awt.dnd.DropTarget(this, this));
+      addServiceListeners();
+      setGUINucleotide();
+    }
 
     if (viewport.getWrapAlignment())
     {
@@ -845,11 +836,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   /**
    * Configure menu items that vary according to whether the alignment is
    * nucleotide or protein
-   * 
-   * @param nucleotide
    */
-  public void setGUINucleotide(boolean nucleotide)
+  public void setGUINucleotide()
   {
+    boolean nucleotide = viewport.getAlignment().isNucleotide();
+
     showTranslation.setVisible(nucleotide);
     showReverse.setVisible(nucleotide);
     showReverseComplement.setVisible(nucleotide);
@@ -857,30 +848,28 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     modifyConservation.setEnabled(!nucleotide);
     showGroupConservation.setEnabled(!nucleotide);
 
+    AlignmentI al = getViewport().getAlignment();
+
     /*
-     * enable / disable colour schemes
-     * - the old, simple way (based on the nucleotide flag), or
-     * - the new, generic way (interrogate the colour scheme)
+     * enable / disable colour schemes by querying whether they
+     * are applicable to the alignment data (for example, peptide or
+     * nucleotide specific, or require certain annotation present)
      */
-    AlignmentI al = getViewport().getAlignment();
-    clustalColour.setEnabled(!nucleotide);
-    zappoColour.setEnabled(!nucleotide);
-    taylorColour.setEnabled(!nucleotide);
-    hydrophobicityColour.setEnabled(!nucleotide);
-    helixColour.setEnabled(!nucleotide);
-    strandColour.setEnabled(!nucleotide);
-    turnColour.setEnabled(!nucleotide);
-    // buriedColour.setEnabled(!nucleotide);
-    // TODO make isApplicableTo static in ColourSchemeI in Java 8
-    buriedColour.setEnabled(new BuriedColourScheme().isApplicableTo(al));
-    rnahelicesColour.setEnabled(nucleotide);
-    nucleotideColour.setEnabled(nucleotide);
-    // purinePyrimidineColour.setEnabled(nucleotide);
-    purinePyrimidineColour.setEnabled(new PurinePyrimidineColourScheme()
-            .isApplicableTo(al));
-    tcoffeeColour
-            .setEnabled(new TCoffeeColourScheme(al).isApplicableTo(al));
-    // RNAInteractionColour.setEnabled(nucleotide);
+    for (Component menuItem : colourMenu.getMenuComponents())
+    {
+      if (menuItem instanceof JRadioButtonMenuItem)
+      {
+        String colourName = ((JRadioButtonMenuItem) menuItem).getName();
+        ColourSchemeI cs = ColourSchemes.getInstance().getColourScheme(
+                colourName, viewport);
+        if (cs != null)
+        {
+          ((JRadioButtonMenuItem) menuItem).setEnabled(cs
+                  .isApplicableTo(al));
+        }
+      }
+    }
+
     showComplementMenuItem.setText(nucleotide ? MessageManager
             .getString("label.protein") : MessageManager
             .getString("label.nucleotide"));
@@ -952,11 +941,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     autoCalculate.setSelected(av.autoCalculateConsensus);
     sortByTree.setSelected(av.sortByTree);
     listenToViewSelections.setSelected(av.followSelection);
-    // rnahelicesColour.setEnabled(av.getAlignment().hasRNAStructure());
-    rnahelicesColour.setEnabled(new RNAHelicesColour(av.getAlignment())
-            .isApplicableTo(av.getAlignment()));
-    rnahelicesColour
-            .setSelected(av.getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
 
     showProducts.setEnabled(canShowProducts());
     setGroovyEnabled(Desktop.getGroovyConsole() != null);
@@ -3343,121 +3327,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     changeColour(null);
   }
 
-  /**
-   * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
-   */
-  @Override
-  public void clustalColour_actionPerformed()
-  {
-    changeColour(new ClustalxColourScheme(viewport.getAlignment(),
-            viewport.getHiddenRepSequences()));
-  }
-
-  /**
-   * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
-   */
-  @Override
-  public void zappoColour_actionPerformed()
-  {
-    changeColour(new ZappoColourScheme());
-  }
-
-  /**
-   * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
-   */
-  @Override
-  public void taylorColour_actionPerformed()
-  {
-    changeColour(new TaylorColourScheme());
-  }
-
-  /**
-   * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
-   */
-  @Override
-  public void hydrophobicityColour_actionPerformed()
-  {
-    changeColour(new HydrophobicColourScheme());
-  }
-
-  /**
-   * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
-   */
-  @Override
-  public void helixColour_actionPerformed()
-  {
-    changeColour(new HelixColourScheme());
-  }
-
-  /**
-   * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
-   */
-  @Override
-  public void strandColour_actionPerformed()
-  {
-    changeColour(new StrandColourScheme());
-  }
-
-  /**
-   * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
-   */
-  @Override
-  public void turnColour_actionPerformed()
-  {
-    changeColour(new TurnColourScheme());
-  }
-
-  /**
-   * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
-   */
-  @Override
-  public void buriedColour_actionPerformed()
-  {
-    changeColour(new BuriedColourScheme());
-  }
-
-  /**
-   * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
-   */
-  @Override
-  public void nucleotideColour_actionPerformed()
-  {
-    changeColour(new NucleotideColourScheme());
-  }
-
-  @Override
-  public void purinePyrimidineColour_actionPerformed()
-  {
-    changeColour(new PurinePyrimidineColourScheme());
-  }
-
   /*
    * public void covariationColour_actionPerformed() {
    * changeColour(new
@@ -3476,27 +3345,35 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     new AnnotationColumnChooser(viewport, alignPanel);
   }
 
+  /**
+   * Action on the user checking or unchecking the option to apply the selected
+   * colour scheme to all groups. If unchecked, groups may have their own
+   * independent colour schemes.
+   * 
+   */
   @Override
-  public void rnahelicesColour_actionPerformed()
+  protected void applyToAllGroups_actionPerformed()
   {
-    new RNAHelicesColourChooser(viewport, alignPanel);
+    viewport.setColourAppliesToAllGroups(applyToAllGroups.isSelected());
   }
 
   /**
-   * DOCUMENT ME!
+   * Action on user selecting a colour from the colour menu
    * 
+   * @param name
+   *          the name (not the menu item label!) of the colour scheme
    */
-  @Override
-  protected void applyToAllGroups_actionPerformed()
+  public void changeColour_actionPerformed(String name)
   {
-    viewport.setColourAppliesToAllGroups(applyToAllGroups.isSelected());
+    ColourSchemeI cs = ColourSchemes.getInstance().getColourScheme(name,
+            viewport);
+    changeColour(cs);
   }
 
   /**
-   * DOCUMENT ME!
+   * Actions on setting or changing the alignment colour scheme
    * 
    * @param cs
-   *          DOCUMENT ME!
    */
   @Override
   public void changeColour(ColourSchemeI cs)
@@ -3518,11 +3395,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel,
                 cs, "Background"));
       }
-      if (cs instanceof TCoffeeColourScheme)
-      {
-        tcoffeeColour.setEnabled(true);
-        tcoffeeColour.setSelected(true);
-      }
     }
 
     viewport.setGlobalColourScheme(cs);
@@ -3605,57 +3477,15 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   }
 
   /**
-   * Action on the user selecting either a named user-defined colour from the
-   * colour menu, or the option "User Defined" to create or load a new colour
-   * scheme.
+   * Action on the user selecting the option "User Defined" to create or load a
+   * new colour scheme
    * 
    * @param e
    */
   @Override
   public void userDefinedColour_actionPerformed(ActionEvent e)
   {
-    if (e.getActionCommand().equals(
-            MessageManager.getString("action.user_defined")))
-    {
-      /*
-       * User Defined... option; open panel to
-       * load / create / apply / save user defined colour
-       */
-      new UserDefinedColours(alignPanel, null);
-    }
-    else
-    {
-      /*
-       * User chose an existing user defined colour
-       */
-      UserColourScheme udc = UserDefinedColours
-              .getUserColourSchemes().get(e.getActionCommand());
-      changeColour(udc);
-    }
-  }
-
-  /**
-   * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
-   */
-  @Override
-  public void PIDColour_actionPerformed()
-  {
-    changeColour(new PIDColourScheme());
-  }
-
-  /**
-   * DOCUMENT ME!
-   * 
-   * @param e
-   *          DOCUMENT ME!
-   */
-  @Override
-  public void BLOSUM62Colour_actionPerformed()
-  {
-    changeColour(new Blosum62ColourScheme());
+    new UserDefinedColours(alignPanel, null);
   }
 
   /**
@@ -4292,12 +4122,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     }
   }
 
-  @Override
-  protected void tcoffeeColorScheme_actionPerformed()
-  {
-    changeColour(new TCoffeeColourScheme(alignPanel.getAlignment()));
-  }
-
   public TreePanel ShowNewickTree(NewickFile nf, String title)
   {
     return ShowNewickTree(nf, title, 600, 500, 4, 5);
@@ -4963,8 +4787,18 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
           {
             if (tcf.annotateAlignment(viewport.getAlignment(), true))
             {
-              tcoffeeColour.setEnabled(true);
-              tcoffeeColour.setSelected(true);
+              // tcoffeeColour.setEnabled(true);
+              // tcoffeeColour.setSelected(true);
+              for (Component menuItem : colourMenu.getMenuComponents())
+              {
+                if (menuItem instanceof JRadioButtonMenuItem
+                        && ((JRadioButtonMenuItem) menuItem).getText()
+                                .equals("T-Coffee Scores"))
+                {
+                  ((JRadioButtonMenuItem) menuItem).setSelected(true);
+                }
+              }
+              buildColourMenu();
               changeColour(new TCoffeeColourScheme(viewport.getAlignment()));
               isAnnotation = true;
               statusBar
@@ -5894,6 +5728,124 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             true,
             (actionEvent.getModifiers() & (ActionEvent.META_MASK | ActionEvent.CTRL_MASK)) != 0);
   }
+
+  /**
+   * Rebuilds the Colour menu, including any user-defined colours which have
+   * been loaded either on startup or during the session
+   */
+  public void buildColourMenu()
+  {
+    colourMenu.removeAll();
+
+    /*
+     * ButtonGroup groups those items whose 
+     * selection is mutually exclusive
+     */
+    ButtonGroup colours = new ButtonGroup();
+
+    colourMenu.add(applyToAllGroups);
+    colourMenu.add(textColour);
+    colourMenu.addSeparator();
+    colourMenu.add(noColourmenuItem);
+    colours.add(noColourmenuItem);
+
+    /*
+     * scan registered colour schemes (built-in or user-defined
+     * and add them to the menu (in the order they were added)
+     */
+    Iterable<ColourSchemeI> colourSchemes = ColourSchemes.getInstance()
+            .getColourSchemes();
+    for (ColourSchemeI scheme : colourSchemes)
+    {
+      /*
+       * button text is i18n'd but the name is the canonical name of
+       * the colour scheme (inspected in changeColour_actionPerformed)
+       */
+      final String name = scheme.getSchemeName();
+      String label = MessageManager.getString("label.colourScheme_"
+              + name.toLowerCase().replace(" ", "_"));
+      final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(label);
+      radioItem.setName(name);
+      if (scheme instanceof UserColourScheme)
+      {
+        /*
+         * user-defined colour scheme loaded on startup or during the
+         * Jalview session; right-click on this offers the option to
+         * remove it as a colour choice
+         */
+        radioItem.setText(((UserColourScheme) scheme).getName());
+        radioItem.addMouseListener(new MouseAdapter()
+        {
+          @Override
+          public void mousePressed(MouseEvent evt)
+          {
+            if (evt.isPopupTrigger()) // Mac
+            {
+              offerRemoval();
+            }
+          }
+
+          @Override
+          public void mouseReleased(MouseEvent evt)
+          {
+            if (evt.isPopupTrigger()) // Windows
+            {
+              offerRemoval();
+            }
+          }
+
+          void offerRemoval()
+          {
+            ActionListener al = radioItem.getActionListeners()[0];
+            radioItem.removeActionListener(al);
+            int option = JvOptionPane.showInternalConfirmDialog(
+                    Desktop.desktop, MessageManager
+                            .getString("label.remove_from_default_list"),
+                    MessageManager
+                            .getString("label.remove_user_defined_colour"),
+                    JvOptionPane.YES_NO_OPTION);
+            if (option == JvOptionPane.YES_OPTION)
+            {
+              UserDefinedColours.removeColourFromDefaults(radioItem
+                      .getName());
+              ColourSchemes.getInstance().removeColourScheme(
+                      radioItem.getName());
+              colourMenu.remove(radioItem);
+            }
+            else
+            {
+              radioItem.addActionListener(al);
+            }
+          }
+        });
+      }
+      radioItem.addActionListener(new ActionListener()
+      {
+        @Override
+        public void actionPerformed(ActionEvent evt)
+        {
+          changeColour_actionPerformed(name);
+        }
+      });
+      colourMenu.add(radioItem);
+      colours.add(radioItem);
+    }
+
+    colourMenu.add(userDefinedColour);
+    colours.add(userDefinedColour);
+
+    colourMenu.addSeparator();
+    colourMenu.add(conservationMenuItem);
+    colourMenu.add(modifyConservation);
+    colourMenu.add(abovePIDThreshold);
+    colourMenu.add(modifyPID);
+    colourMenu.add(annotationColour);
+
+    setColourSelected(Cache.getDefault(Preferences.DEFAULT_COLOUR,
+            ResidueColourScheme.NONE));
+
+    setGUINucleotide();
+  }
 }
 
 class PrintThread extends Thread
index ebcb062..696f03d 100644 (file)
@@ -1300,7 +1300,8 @@ public class PopupMenu extends JPopupMenu
       }
     });
 
-    clustalColour.setText(MessageManager.getString("label.clustalx"));
+    clustalColour.setText(MessageManager
+            .getString("label.colourScheme_clustal"));
     clustalColour.setName(JalviewColourScheme.Clustal.toString());
     clustalColour.addActionListener(new ActionListener()
     {
@@ -1310,7 +1311,8 @@ public class PopupMenu extends JPopupMenu
         clustalColour_actionPerformed();
       }
     });
-    zappoColour.setText(MessageManager.getString("label.zappo"));
+    zappoColour.setText(MessageManager
+            .getString("label.colourScheme_zappo"));
     zappoColour.setName(JalviewColourScheme.Zappo.toString());
     zappoColour.addActionListener(new ActionListener()
     {
@@ -1320,7 +1322,8 @@ public class PopupMenu extends JPopupMenu
         zappoColour_actionPerformed();
       }
     });
-    taylorColour.setText(MessageManager.getString("label.taylor"));
+    taylorColour.setText(MessageManager
+            .getString("label.colourScheme_taylor"));
     taylorColour.setName(JalviewColourScheme.Taylor.toString());
     taylorColour.addActionListener(new ActionListener()
     {
@@ -1331,7 +1334,7 @@ public class PopupMenu extends JPopupMenu
       }
     });
     hydrophobicityColour.setText(MessageManager
-            .getString("label.hydrophobicity"));
+            .getString("label.colourScheme_hydrophobic"));
     hydrophobicityColour
             .setName(JalviewColourScheme.Hydrophobic.toString());
     hydrophobicityColour.addActionListener(new ActionListener()
@@ -1342,7 +1345,8 @@ public class PopupMenu extends JPopupMenu
         hydrophobicityColour_actionPerformed();
       }
     });
-    helixColour.setText(MessageManager.getString("label.helix_propensity"));
+    helixColour.setText(MessageManager
+            .getString("label.colourScheme_helix_propensity"));
     helixColour.setName(JalviewColourScheme.Helix.toString());
     helixColour.addActionListener(new ActionListener()
     {
@@ -1353,7 +1357,7 @@ public class PopupMenu extends JPopupMenu
       }
     });
     strandColour.setText(MessageManager
-            .getString("label.strand_propensity"));
+            .getString("label.colourScheme_strand_propensity"));
     strandColour.setName(JalviewColourScheme.Strand.toString());
     strandColour.addActionListener(new ActionListener()
     {
@@ -1363,7 +1367,8 @@ public class PopupMenu extends JPopupMenu
         strandColour_actionPerformed();
       }
     });
-    turnColour.setText(MessageManager.getString("label.turn_propensity"));
+    turnColour.setText(MessageManager
+            .getString("label.colourScheme_turn_propensity"));
     turnColour.setName(JalviewColourScheme.Turn.toString());
     turnColour.addActionListener(new ActionListener()
     {
@@ -1373,7 +1378,8 @@ public class PopupMenu extends JPopupMenu
         turnColour_actionPerformed();
       }
     });
-    buriedColour.setText(MessageManager.getString("label.buried_index"));
+    buriedColour.setText(MessageManager
+            .getString("label.colourScheme_buried_index"));
     buriedColour.setName(JalviewColourScheme.Buried.toString());
     buriedColour.addActionListener(new ActionListener()
     {
@@ -1395,7 +1401,6 @@ public class PopupMenu extends JPopupMenu
     });
     userDefinedColour.setText(MessageManager
             .getString("action.user_defined"));
-    userDefinedColour.setName(JalviewColourScheme.UserDefined.toString());
     userDefinedColour.addActionListener(new ActionListener()
     {
       @Override
@@ -1405,7 +1410,8 @@ public class PopupMenu extends JPopupMenu
       }
     });
     PIDColour
-            .setText(MessageManager.getString("label.percentage_identity"));
+.setText(MessageManager
+            .getString("label.colourScheme_%_identity"));
     PIDColour.setName(JalviewColourScheme.PID.toString());
     PIDColour.addActionListener(new ActionListener()
     {
@@ -1416,7 +1422,8 @@ public class PopupMenu extends JPopupMenu
       }
     });
     BLOSUM62Colour
-            .setText(MessageManager.getString("label.blosum62_score"));
+.setText(MessageManager
+            .getString("label.colourScheme_blosum62"));
     BLOSUM62Colour.setName(JalviewColourScheme.Blosum62.toString());
     BLOSUM62Colour.addActionListener(new ActionListener()
     {
@@ -1426,7 +1433,8 @@ public class PopupMenu extends JPopupMenu
         BLOSUM62Colour_actionPerformed();
       }
     });
-    nucleotideColour.setText(MessageManager.getString("label.nucleotide"));
+    nucleotideColour.setText(MessageManager
+            .getString("label.colourScheme_nucleotide"));
     nucleotideColour.setName(JalviewColourScheme.Nucleotide.toString());
     nucleotideColour.addActionListener(new ActionListener()
     {
@@ -1437,7 +1445,7 @@ public class PopupMenu extends JPopupMenu
       }
     });
     purinePyrimidineColour.setText(MessageManager
-            .getString("label.purine_pyrimidine"));
+            .getString("label.colourScheme_purine/pyrimidine"));
     purinePyrimidineColour.setName(JalviewColourScheme.PurinePyrimidine
             .toString());
     purinePyrimidineColour.addActionListener(new ActionListener()
@@ -1449,7 +1457,8 @@ public class PopupMenu extends JPopupMenu
       }
     });
 
-    tcoffeeColour.setText(MessageManager.getString("label.tcoffee_scores"));
+    tcoffeeColour.setText(MessageManager
+            .getString("label.colourScheme_t-coffee_scores"));
     tcoffeeColour.setName(JalviewColourScheme.TCoffee.toString());
     tcoffeeColour.addActionListener(new ActionListener()
     {
index 4777c85..d88c861 100755 (executable)
@@ -34,7 +34,8 @@ import jalview.io.JalviewFileChooser;
 import jalview.io.JalviewFileView;
 import jalview.jbgui.GPreferences;
 import jalview.jbgui.GSequenceLink;
-import jalview.schemes.JalviewColourScheme;
+import jalview.schemes.ColourSchemeI;
+import jalview.schemes.ColourSchemes;
 import jalview.schemes.ResidueColourScheme;
 import jalview.util.MessageManager;
 import jalview.util.Platform;
@@ -293,13 +294,11 @@ public class Preferences extends GPreferences
      */
     protColour.addItem(ResidueColourScheme.NONE);
     nucColour.addItem(ResidueColourScheme.NONE);
-    for (JalviewColourScheme cs : JalviewColourScheme.values())
+    for (ColourSchemeI cs : ColourSchemes.getInstance().getColourSchemes())
     {
-      if (cs != JalviewColourScheme.UserDefined)
-      {
-        protColour.addItem(cs.toString());
-        nucColour.addItem(cs.toString());
-      }
+      String name = cs.getSchemeName();
+      protColour.addItem(name);
+      nucColour.addItem(name);
     }
     String oldProp = Cache.getDefault(DEFAULT_COLOUR,
             ResidueColourScheme.NONE);
index 5cfff86..bb2676c 100755 (executable)
@@ -29,6 +29,7 @@ import jalview.jbgui.GUserDefinedColours;
 import jalview.schemabinding.version2.Colour;
 import jalview.schemabinding.version2.JalviewUserColours;
 import jalview.schemes.ColourSchemeI;
+import jalview.schemes.ColourSchemes;
 import jalview.schemes.ResidueProperties;
 import jalview.schemes.UserColourScheme;
 import jalview.util.ColorUtils;
@@ -888,7 +889,11 @@ public class UserDefinedColours extends GUserDefinedColours implements
     /*
      * add to the cache in this object
      */
-    userColourSchemes.put(schemeName.getText(), getSchemeFromButtons());
+    UserColourScheme ucs = getSchemeFromButtons();
+    String name = schemeName.getText();
+    userColourSchemes.put(name, ucs);
+
+    ColourSchemes.getInstance().registerColourScheme(ucs);
 
     /*
      * update the Colour menu items
@@ -1000,7 +1005,9 @@ public class UserDefinedColours extends GUserDefinedColours implements
             coloursFound.append("|");
           }
           coloursFound.append(file);
-          userColourSchemes.put(ucs.getSchemeName(), ucs);
+          String name = ucs.getName();
+          userColourSchemes.put(name, ucs);
+          ColourSchemes.getInstance().registerColourScheme(ucs);
         }
       } catch (Exception ex)
       {
index fba0efa..faa0d5d 100755 (executable)
@@ -23,15 +23,9 @@ package jalview.jbgui;
 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
 import jalview.api.SplitContainerI;
 import jalview.bin.Cache;
-import jalview.gui.Desktop;
-import jalview.gui.JvOptionPane;
 import jalview.gui.JvSwingUtils;
 import jalview.gui.Preferences;
-import jalview.gui.UserDefinedColours;
 import jalview.io.FileFormat;
-import jalview.schemes.JalviewColourScheme;
-import jalview.schemes.ResidueColourScheme;
-import jalview.schemes.UserColourScheme;
 import jalview.util.MessageManager;
 import jalview.util.Platform;
 
@@ -90,38 +84,8 @@ public class GAlignFrame extends JInternalFrame
 
   protected JRadioButtonMenuItem textColour;
 
-  protected JRadioButtonMenuItem clustalColour;
-
-  protected JRadioButtonMenuItem zappoColour;
-
-  protected JRadioButtonMenuItem taylorColour;
-
-  protected JRadioButtonMenuItem hydrophobicityColour;
-
-  protected JRadioButtonMenuItem helixColour;
-
-  protected JRadioButtonMenuItem strandColour;
-
-  protected JRadioButtonMenuItem turnColour;
-
-  protected JRadioButtonMenuItem buriedColour;
-
   protected JRadioButtonMenuItem userDefinedColour;
 
-  protected JRadioButtonMenuItem PIDColour;
-
-  protected JRadioButtonMenuItem BLOSUM62Colour;
-
-  protected JRadioButtonMenuItem nucleotideColour;
-
-  protected JRadioButtonMenuItem purinePyrimidineColour;
-
-  protected JRadioButtonMenuItem RNAInteractionColour;
-
-  // protected JRadioButtonMenuItem covariationColour;
-
-  protected JRadioButtonMenuItem tcoffeeColour;
-
   protected JCheckBoxMenuItem annotationPanelMenuItem = new JCheckBoxMenuItem();
 
   protected JCheckBoxMenuItem colourTextMenuItem = new JCheckBoxMenuItem();
@@ -134,7 +98,7 @@ public class GAlignFrame extends JInternalFrame
 
   protected JCheckBoxMenuItem conservationMenuItem;
 
-  JRadioButtonMenuItem noColourmenuItem;
+  protected JRadioButtonMenuItem noColourmenuItem;
 
   protected JCheckBoxMenuItem wrapMenuItem = new JCheckBoxMenuItem();
 
@@ -178,8 +142,6 @@ public class GAlignFrame extends JInternalFrame
 
   protected JCheckBoxMenuItem showDbRefsMenuitem = new JCheckBoxMenuItem();
 
-  protected ButtonGroup colours = new ButtonGroup();
-
   protected JMenuItem showTranslation = new JMenuItem();
 
   protected JMenuItem showReverse = new JMenuItem();
@@ -190,8 +152,6 @@ public class GAlignFrame extends JInternalFrame
 
   protected JMenuItem runGroovy = new JMenuItem();
 
-  protected JMenuItem rnahelicesColour;
-
   protected JCheckBoxMenuItem autoCalculate = new JCheckBoxMenuItem();
 
   protected JCheckBoxMenuItem sortByTree = new JCheckBoxMenuItem();
@@ -323,7 +283,6 @@ public class GAlignFrame extends JInternalFrame
   private void jbInit() throws Exception
   {
     initColourMenu();
-    buildColourMenu();
 
     JMenuItem saveAs = new JMenuItem(
             MessageManager.getString("action.save_as"));
@@ -642,7 +601,7 @@ public class GAlignFrame extends JInternalFrame
 
 
     JMenuItem avDistanceTreeBlosumMenuItem = new JMenuItem(
-            MessageManager.getString("label.average_distance_bloslum62"));
+            MessageManager.getString("label.average_distance_blosum62"));
     avDistanceTreeBlosumMenuItem.addActionListener(new ActionListener()
     {
       @Override
@@ -1982,144 +1941,6 @@ public class GAlignFrame extends JInternalFrame
   }
 
   /**
-   * Rebuilds the Colour menu, including any user-defined colours which have
-   * been loaded either on startup or during the session
-   */
-  public void buildColourMenu()
-  {
-    colourMenu.removeAll();
-    colours = new ButtonGroup();
-
-    colourMenu.add(applyToAllGroups);
-    colourMenu.add(textColour);
-    colourMenu.addSeparator();
-    colourMenu.add(noColourmenuItem);
-    colourMenu.add(clustalColour);
-    colourMenu.add(BLOSUM62Colour);
-    colourMenu.add(PIDColour);
-    colourMenu.add(zappoColour);
-    colourMenu.add(taylorColour);
-    colourMenu.add(hydrophobicityColour);
-    colourMenu.add(helixColour);
-    colourMenu.add(strandColour);
-    colourMenu.add(turnColour);
-    colourMenu.add(buriedColour);
-    colourMenu.add(nucleotideColour);
-    colourMenu.add(purinePyrimidineColour);
-    // colourMenu.add(RNAInteractionColour);
-    // colourMenu.add(covariationColour);
-    colourMenu.add(tcoffeeColour);
-
-    /*
-     * add any user-defined colours
-     */
-    Map<String, UserColourScheme> userColourSchemes = UserDefinedColours
-            .getUserColourSchemes();
-    if (userColourSchemes != null)
-    {
-      for (String userColour : userColourSchemes.keySet())
-      {
-        final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(
-                userColour);
-        radioItem.setName(userColour);
-        radioItem.addMouseListener(new MouseAdapter()
-        {
-          @Override
-          public void mousePressed(MouseEvent evt)
-          {
-            if (evt.isPopupTrigger()) // Mac
-            {
-              offerRemoval();
-            }
-          }
-
-          @Override
-          public void mouseReleased(MouseEvent evt)
-          {
-            if (evt.isPopupTrigger()) // Windows
-            {
-              offerRemoval();
-            }
-          }
-
-          void offerRemoval()
-          {
-            radioItem.removeActionListener(radioItem.getActionListeners()[0]);
-
-            int option = JvOptionPane.showInternalConfirmDialog(
-                    Desktop.desktop, MessageManager
-                            .getString("label.remove_from_default_list"),
-                    MessageManager
-                            .getString("label.remove_user_defined_colour"),
-                    JvOptionPane.YES_NO_OPTION);
-            if (option == JvOptionPane.YES_OPTION)
-            {
-              UserDefinedColours.removeColourFromDefaults(radioItem
-                      .getText());
-              colourMenu.remove(radioItem);
-            }
-            else
-            {
-              radioItem.addActionListener(new ActionListener()
-              {
-                @Override
-                public void actionPerformed(ActionEvent evt)
-                {
-                  userDefinedColour_actionPerformed(evt);
-                }
-              });
-            }
-          }
-        });
-        radioItem.addActionListener(new ActionListener()
-        {
-          @Override
-          public void actionPerformed(ActionEvent evt)
-          {
-            userDefinedColour_actionPerformed(evt);
-          }
-        });
-        colourMenu.add(radioItem);
-        colours.add(radioItem);
-      }
-    }
-
-    colourMenu.add(userDefinedColour);
-    colourMenu.addSeparator();
-    colourMenu.add(conservationMenuItem);
-    colourMenu.add(modifyConservation);
-    colourMenu.add(abovePIDThreshold);
-    colourMenu.add(modifyPID);
-    colourMenu.add(annotationColour);
-    colourMenu.add(rnahelicesColour);
-
-    /*
-     * add colours to a ButtonGroup to make their 
-     * selection mutually exclusive
-     */
-    colours.add(noColourmenuItem);
-    colours.add(clustalColour);
-    colours.add(zappoColour);
-    colours.add(taylorColour);
-    colours.add(hydrophobicityColour);
-    colours.add(helixColour);
-    colours.add(strandColour);
-    colours.add(turnColour);
-    colours.add(buriedColour);
-    colours.add(userDefinedColour);
-    colours.add(PIDColour);
-    colours.add(BLOSUM62Colour);
-    colours.add(nucleotideColour);
-    colours.add(purinePyrimidineColour);
-    // colours.add(covariationColour);
-    colours.add(tcoffeeColour);
-    // colours.add(RNAInteractionColour);
-    setColourSelected(Cache.getDefault(Preferences.DEFAULT_COLOUR,
-            ResidueColourScheme.NONE));
-
-  }
-
-  /**
    * Constructs the entries on the Colour menu (but does not add them to the
    * menu). The 'name' property of each item is set to the canonical name of the
    * corresponding colour scheme (may not match the display name), to allow
@@ -2148,101 +1969,10 @@ public class GAlignFrame extends JInternalFrame
         textColour_actionPerformed();
       }
     });
-    clustalColour = new JRadioButtonMenuItem(
-            MessageManager.getString("label.clustalx"));
-    clustalColour.setName(JalviewColourScheme.Clustal.toString());
-    clustalColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        clustalColour_actionPerformed();
-      }
-    });
-    zappoColour = new JRadioButtonMenuItem(
-            MessageManager.getString("label.zappo"));
-    zappoColour.setName(JalviewColourScheme.Zappo.toString());
-    zappoColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        zappoColour_actionPerformed();
-      }
-    });
-    taylorColour = new JRadioButtonMenuItem(
-            MessageManager.getString("label.taylor"));
-    taylorColour.setName(JalviewColourScheme.Taylor.toString());
-    taylorColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        taylorColour_actionPerformed();
-      }
-    });
-    hydrophobicityColour = new JRadioButtonMenuItem(
-            MessageManager
-            .getString("label.hydrophobicity"));
-    hydrophobicityColour
-            .setName(JalviewColourScheme.Hydrophobic.toString());
-    hydrophobicityColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        hydrophobicityColour_actionPerformed();
-      }
-    });
-    helixColour = new JRadioButtonMenuItem(
-            MessageManager.getString("label.helix_propensity"));
-    helixColour.setName(JalviewColourScheme.Helix.toString());
-    helixColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        helixColour_actionPerformed();
-      }
-    });
-    strandColour = new JRadioButtonMenuItem(
-            MessageManager
-            .getString("label.strand_propensity"));
-    strandColour.setName(JalviewColourScheme.Strand.toString());
-    strandColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        strandColour_actionPerformed();
-      }
-    });
-    turnColour = new JRadioButtonMenuItem(
-            MessageManager.getString("label.turn_propensity"));
-    turnColour.setName(JalviewColourScheme.Turn.toString());
-    turnColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        turnColour_actionPerformed();
-      }
-    });
-    buriedColour = new JRadioButtonMenuItem(
-            MessageManager.getString("label.buried_index"));
-    buriedColour.setName(JalviewColourScheme.Buried.toString());
-    buriedColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        buriedColour_actionPerformed();
-      }
-    });
+
     userDefinedColour = new JRadioButtonMenuItem(
             MessageManager
             .getString("action.user_defined"));
-    userDefinedColour.setName(JalviewColourScheme.UserDefined.toString());
     userDefinedColour.addActionListener(new ActionListener()
     {
       @Override
@@ -2251,81 +1981,6 @@ public class GAlignFrame extends JInternalFrame
         userDefinedColour_actionPerformed(e);
       }
     });
-    PIDColour = new JRadioButtonMenuItem(
-            MessageManager.getString("label.percentage_identity"));
-    PIDColour.setName(JalviewColourScheme.PID.toString());
-    PIDColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        PIDColour_actionPerformed();
-      }
-    });
-    BLOSUM62Colour = new JRadioButtonMenuItem(
-            MessageManager.getString("label.blosum62_score"));
-    BLOSUM62Colour.setName(JalviewColourScheme.Blosum62.toString());
-    BLOSUM62Colour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        BLOSUM62Colour_actionPerformed();
-      }
-    });
-    nucleotideColour = new JRadioButtonMenuItem(
-            MessageManager.getString("label.nucleotide"));
-    nucleotideColour.setName(JalviewColourScheme.Nucleotide.toString());
-    nucleotideColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        nucleotideColour_actionPerformed();
-      }
-    });
-    purinePyrimidineColour = new JRadioButtonMenuItem(
-            MessageManager.getString("label.purine_pyrimidine"));
-    purinePyrimidineColour.setName(JalviewColourScheme.PurinePyrimidine.toString());
-    purinePyrimidineColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        purinePyrimidineColour_actionPerformed();
-      }
-    });
-
-    tcoffeeColour = new JRadioButtonMenuItem(
-            MessageManager.getString("label.tcoffee_scores"));
-    tcoffeeColour.setName(JalviewColourScheme.TCoffee.toString());
-    tcoffeeColour.setEnabled(false);
-    tcoffeeColour.addActionListener(new ActionListener()
-    {
-
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        tcoffeeColorScheme_actionPerformed();
-      }
-    });
-
-    // RNAInteractionColour = new JRadioButtonMenuItem("RNA Interaction type");
-    // RNAInteractionColour.setName("RNA Interaction");
-    // RNAInteractionColour.addActionListener(new ActionListener()
-    // {
-    // @Override
-    // public void actionPerformed(ActionEvent e)
-    // {
-    // RNAInteractionColour_actionPerformed();
-    // }
-    // });
-    /*
-     * covariationColour = new JRadioButtonMenuItem("Covariation");
-     * covariationColour.addActionListener(new ActionListener() { public void
-     * actionPerformed(ActionEvent e) { covariationColour_actionPerformed(); }
-     * });
-     */
 
     conservationMenuItem = new JCheckBoxMenuItem(
             MessageManager.getString("action.by_conservation"));
@@ -2391,17 +2046,6 @@ public class GAlignFrame extends JInternalFrame
         annotationColour_actionPerformed();
       }
     });
-
-    rnahelicesColour = new JMenuItem(
-            MessageManager.getString("action.by_rna_helixes"));
-    rnahelicesColour.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        rnahelicesColour_actionPerformed();
-      }
-    });
   }
 
   protected void selectHighlightedColumns_actionPerformed(
@@ -2759,57 +2403,11 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
-  protected void clustalColour_actionPerformed()
-  {
-  }
-
-  protected void zappoColour_actionPerformed()
-  {
-  }
-
-  protected void taylorColour_actionPerformed()
-  {
-  }
-
-  protected void hydrophobicityColour_actionPerformed()
-  {
-  }
-
-  protected void helixColour_actionPerformed()
-  {
-  }
-
-  protected void strandColour_actionPerformed()
-  {
-  }
-
-  protected void turnColour_actionPerformed()
-  {
-  }
-
-  protected void buriedColour_actionPerformed()
-  {
-  }
-
   protected void userDefinedColour_actionPerformed(ActionEvent e)
   {
   }
 
-  protected void PIDColour_actionPerformed()
-  {
-  }
-
-  protected void BLOSUM62Colour_actionPerformed()
-  {
-  }
-
-  protected void purinePyrimidineColour_actionPerformed()
-  {
-  }
-
-  protected void RNAInteractionColour_actionPerformed()
-  {
-  }
+  
 
   /*
    * protected void covariationColour_actionPerformed() { }
@@ -2843,10 +2441,6 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
-  protected void nucleotideColour_actionPerformed()
-  {
-  }
-
   protected void deleteGroups_actionPerformed(ActionEvent e)
   {
   }
@@ -2927,16 +2521,6 @@ public class GAlignFrame extends JInternalFrame
 
   }
 
-  /**
-   * Template method to handle the 'Color T-Coffee scores' menu event.
-   * <p>
-   * Subclasses override this method to provide a custom action.
-   */
-  protected void tcoffeeColorScheme_actionPerformed()
-  {
-
-  }
-
   protected void jpred_actionPerformed(ActionEvent e)
   {
   }
@@ -3007,11 +2591,6 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
-  public void rnahelicesColour_actionPerformed()
-  {
-
-  }
-
   public void associatedData_actionPerformed(ActionEvent e)
   {
 
index daba592..52f745d 100644 (file)
@@ -281,7 +281,8 @@ public abstract class GStructureViewer extends JInternalFrame implements
       }
     });
     zappoColour = new JRadioButtonMenuItem();
-    zappoColour.setText(MessageManager.getString("label.zappo"));
+    zappoColour.setText(MessageManager
+            .getString("label.colourScheme_zappo"));
     zappoColour.addActionListener(new ActionListener()
     {
       @Override
@@ -291,7 +292,8 @@ public abstract class GStructureViewer extends JInternalFrame implements
       }
     });
     taylorColour = new JRadioButtonMenuItem();
-    taylorColour.setText(MessageManager.getString("label.taylor"));
+    taylorColour.setText(MessageManager
+            .getString("label.colourScheme_taylor"));
     taylorColour.addActionListener(new ActionListener()
     {
       @Override
@@ -301,7 +303,8 @@ public abstract class GStructureViewer extends JInternalFrame implements
       }
     });
     hydroColour = new JRadioButtonMenuItem();
-    hydroColour.setText(MessageManager.getString("label.hydrophobicity"));
+    hydroColour.setText(MessageManager
+            .getString("label.colourScheme_hydrophobic"));
     hydroColour.addActionListener(new ActionListener()
     {
       @Override
@@ -312,7 +315,7 @@ public abstract class GStructureViewer extends JInternalFrame implements
     });
     strandColour = new JRadioButtonMenuItem();
     strandColour.setText(MessageManager
-            .getString("label.strand_propensity"));
+            .getString("label.colourScheme_strand_propensity"));
     strandColour.addActionListener(new ActionListener()
     {
       @Override
@@ -322,7 +325,8 @@ public abstract class GStructureViewer extends JInternalFrame implements
       }
     });
     helixColour = new JRadioButtonMenuItem();
-    helixColour.setText(MessageManager.getString("label.helix_propensity"));
+    helixColour.setText(MessageManager
+            .getString("label.colourScheme_helix_propensity"));
     helixColour.addActionListener(new ActionListener()
     {
       @Override
@@ -332,7 +336,8 @@ public abstract class GStructureViewer extends JInternalFrame implements
       }
     });
     turnColour = new JRadioButtonMenuItem();
-    turnColour.setText(MessageManager.getString("label.turn_propensity"));
+    turnColour.setText(MessageManager
+            .getString("label.colourScheme_turn_propensity"));
     turnColour.addActionListener(new ActionListener()
     {
       @Override
@@ -342,7 +347,8 @@ public abstract class GStructureViewer extends JInternalFrame implements
       }
     });
     buriedColour = new JRadioButtonMenuItem();
-    buriedColour.setText(MessageManager.getString("label.buried_index"));
+    buriedColour.setText(MessageManager
+            .getString("label.colourScheme_buried_index"));
     buriedColour.addActionListener(new ActionListener()
     {
       @Override
@@ -352,7 +358,8 @@ public abstract class GStructureViewer extends JInternalFrame implements
       }
     });
     nucleotideColour = new JRadioButtonMenuItem();
-    nucleotideColour.setText(MessageManager.getString("label.nucleotide"));
+    nucleotideColour.setText(MessageManager
+            .getString("label.colourScheme_nucleotide"));
     nucleotideColour.addActionListener(new ActionListener()
     {
       @Override
@@ -363,7 +370,7 @@ public abstract class GStructureViewer extends JInternalFrame implements
     });
     purinePyrimidineColour = new JRadioButtonMenuItem();
     purinePyrimidineColour.setText(MessageManager
-            .getString("label.purine_pyrimidine"));
+            .getString("label.colourScheme_purine/pyrimidine"));
     purinePyrimidineColour.addActionListener(new ActionListener()
     {
       @Override
index 466a216..e3ef391 100755 (executable)
@@ -64,7 +64,7 @@ public class AnnotationColourGradient extends FollowerColourScheme
   IdentityHashMap<SequenceI, AlignmentAnnotation> seqannot = null;
 
   @Override
-  public ColourSchemeI applyTo(AnnotatedCollectionI sg,
+  public ColourSchemeI getInstance(AnnotatedCollectionI sg,
           Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
   {
     AnnotationColourGradient acg = new AnnotationColourGradient(annotation,
index 83a3cd6..5eabc75 100755 (executable)
@@ -20,6 +20,7 @@
  */
 package jalview.schemes;
 
+import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AnnotatedCollectionI;
 import jalview.datamodel.SequenceCollectionI;
 import jalview.datamodel.SequenceI;
@@ -38,6 +39,17 @@ public class Blosum62ColourScheme extends ResidueColourScheme
     super();
   }
 
+  /**
+   * Returns a new instance of this colour scheme with which the given data may
+   * be coloured
+   */
+  @Override
+  public ColourSchemeI getInstance(AnnotatedCollectionI coll,
+          Map<SequenceI, SequenceCollectionI> hrs)
+  {
+    return new Blosum62ColourScheme();
+  }
+
   @Override
   public Color findColour(char res, int j, SequenceI seq)
   {
@@ -101,14 +113,6 @@ public class Blosum62ColourScheme extends ResidueColourScheme
   }
 
   @Override
-  public ColourSchemeI applyTo(AnnotatedCollectionI sg,
-          Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
-  {
-    ColourSchemeI newcs = super.applyTo(sg, hiddenRepSequences);
-    return newcs;
-  }
-
-  @Override
   public boolean isPeptideSpecific()
   {
     return true;
@@ -119,4 +123,25 @@ public class Blosum62ColourScheme extends ResidueColourScheme
   {
     return JalviewColourScheme.Blosum62.toString();
   }
+
+  /**
+   * Answers true if Conservation annotation is present, else false
+   */
+  @Override
+  public boolean isApplicableTo(AnnotatedCollectionI ac)
+  {
+    AlignmentAnnotation[] anns = ac.getAlignmentAnnotation();
+    if (anns == null)
+    {
+      return false;
+    }
+    for (AlignmentAnnotation ann : anns)
+    {
+      if ("Conservation".equals(ann.label))
+      {
+        return true;
+      }
+    }
+    return false;
+  }
 }
index 6b07abd..a3b85b9 100755 (executable)
  */
 package jalview.schemes;
 
+import jalview.datamodel.AnnotatedCollectionI;
+import jalview.datamodel.SequenceCollectionI;
+import jalview.datamodel.SequenceI;
+
 import java.awt.Color;
+import java.util.Map;
 
 /**
  * DOCUMENT ME!
@@ -64,4 +69,15 @@ public class BuriedColourScheme extends ScoreColourScheme
   {
     return JalviewColourScheme.Buried.toString();
   }
+
+  /**
+   * Returns a new instance of this colour scheme with which the given data may
+   * be coloured
+   */
+  @Override
+  public ColourSchemeI getInstance(AnnotatedCollectionI coll,
+          Map<SequenceI, SequenceCollectionI> hrs)
+  {
+    return new BuriedColourScheme();
+  }
 }
index 7ff1c65..8ee4b78 100755 (executable)
@@ -77,6 +77,14 @@ public class ClustalxColourScheme extends ResidueColourScheme
 
   private boolean includeGaps = true;
 
+  /**
+   * Default constructor (required for Class.newInstance())
+   */
+  public ClustalxColourScheme()
+  {
+
+  }
+
   public ClustalxColourScheme(AnnotatedCollectionI alignment,
           Map<SequenceI, SequenceCollectionI> hiddenReps)
   {
@@ -330,7 +338,7 @@ public class ClustalxColourScheme extends ResidueColourScheme
   }
 
   @Override
-  public ColourSchemeI applyTo(AnnotatedCollectionI sg,
+  public ColourSchemeI getInstance(AnnotatedCollectionI sg,
           Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
   {
     ClustalxColourScheme css = new ClustalxColourScheme(sg,
index f2e888e..be8793b 100755 (executable)
@@ -130,13 +130,15 @@ public interface ColourSchemeI
 
   /**
    * Creates and returns a new instance of the colourscheme configured to colour
-   * the given connection
+   * the given collection. Note that even simple colour schemes should return a
+   * new instance for each call to this method, as different instances may have
+   * differing shading by consensus or percentage identity applied.
    * 
    * @param sg
    * @param hiddenRepSequences
-   * @return copy of current scheme with any inherited settings transfered
+   * @return copy of current scheme with any inherited settings transferred
    */
-  ColourSchemeI applyTo(AnnotatedCollectionI sg,
+  ColourSchemeI getInstance(AnnotatedCollectionI sg,
           Map<SequenceI, SequenceCollectionI> hiddenRepSequences);
 
   /**
index cee2cae..53e9b60 100755 (executable)
@@ -78,10 +78,16 @@ public class ColourSchemeProperty
       return null;
 
     }
-    JalviewColourScheme scheme = JalviewColourScheme.forName(name);
+
+    /*
+     * if this is the name of a registered colour scheme, just
+     * create a new instance of it
+     */
+    ColourSchemeI scheme = ColourSchemes.getInstance().getColourScheme(
+            name, forData);
     if (scheme != null)
     {
-      return scheme.getColourScheme(forData);
+      return scheme;
     }
 
     /*
@@ -91,14 +97,7 @@ public class ColourSchemeProperty
      * e.g. "red" or "ff00ed",
      * or failing that hash the name to a colour
      */
-    UserColourScheme ucs = null;
-    try
-    {
-      ucs = new UserColourScheme(name);
-    } catch (Exception e)
-    {
-      // System.err.println("Ignoring exception when parsing colourscheme as applet-parameter");
-    }
+    UserColourScheme ucs = new UserColourScheme(name);
     return ucs;
   }
 
diff --git a/src/jalview/schemes/ColourSchemes.java b/src/jalview/schemes/ColourSchemes.java
new file mode 100644 (file)
index 0000000..21faa2a
--- /dev/null
@@ -0,0 +1,144 @@
+package jalview.schemes;
+
+import jalview.api.AlignViewportI;
+import jalview.datamodel.AnnotatedCollectionI;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public class ColourSchemes
+{
+  /*
+   * singleton instance of this class
+   */
+  private static ColourSchemes instance = new ColourSchemes();
+
+  /*
+   * a map from scheme name to an instance of it
+   */
+  private Map<String, ColourSchemeI> schemes;
+
+  /**
+   * Returns the singleton instance of this class
+   * 
+   * @return
+   */
+  public static ColourSchemes getInstance()
+  {
+    return instance;
+  }
+
+  private ColourSchemes()
+  {
+    loadColourSchemes();
+  }
+
+  /**
+   * Loads an instance of each standard or user-defined colour scheme
+   * 
+   * @return
+   */
+  void loadColourSchemes()
+  {
+    /*
+     * store in an order-preserving map, so items can be added to menus 
+     * in the order in which they are 'discovered'
+     */
+    schemes = new LinkedHashMap<String, ColourSchemeI>();
+
+    for (JalviewColourScheme cs : JalviewColourScheme.values())
+    {
+      try
+      {
+        registerColourScheme(cs.getSchemeClass().newInstance());
+      } catch (InstantiationException | IllegalAccessException e)
+      {
+        System.err.println("Error instantiating colour scheme for "
+                + cs.toString() + " " + e.getMessage());
+      }
+    }
+  }
+
+  /**
+   * Registers a colour scheme
+   * 
+   * @param cs
+   */
+  public void registerColourScheme(ColourSchemeI cs)
+  {
+    String name = cs.getSchemeName();
+    if (name == null)
+    {
+      System.err.println("ColourScheme name may not be null");
+      return;
+    }
+
+    /*
+     * name is lower-case for non-case-sensitive lookup
+     * (name in the colour keeps its true case)
+     */
+    String lower = name.toLowerCase();
+    if (schemes.containsKey(lower))
+    {
+      System.err
+              .println("Warning: overwriting colour scheme named " + name);
+    }
+    schemes.put(lower, cs);
+  }
+
+  /**
+   * Removes a colour scheme by name
+   * 
+   * @param name
+   */
+  public void removeColourScheme(String name)
+  {
+    schemes.remove(name);
+  }
+  
+  /**
+   * Returns an instance of the colour scheme with which the given view may be
+   * coloured
+   * 
+   * @param name
+   *          name of the colour scheme
+   * @param viewport
+   * @return
+   */
+  public ColourSchemeI getColourScheme(String name, AlignViewportI viewport)
+  {
+    if (name == null)
+    {
+      return null;
+    }
+    ColourSchemeI cs = schemes.get(name.toLowerCase());
+    return cs == null ? null : cs.getInstance(viewport.getAlignment(),
+            viewport.getHiddenRepSequences());
+  }
+
+  /**
+   * Returns an instance of the colour scheme with which the given data may be
+   * coloured
+   * 
+   * @param name
+   * @param forData
+   * @return
+   */
+  public ColourSchemeI getColourScheme(String name,
+          AnnotatedCollectionI forData)
+  {
+    ColourSchemeI cs = schemes.get(name.toLowerCase());
+    return cs == null ? null : cs.getInstance(forData, null);
+  }
+
+  /**
+   * Returns an iterable set of the colour schemes, in the order in which they
+   * were added
+   * 
+   * @return
+   */
+  public Iterable<ColourSchemeI> getColourSchemes()
+  {
+    return schemes.values();
+  }
+}
index 5f8f4c1..ee78317 100644 (file)
 package jalview.schemes;
 
 import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AnnotatedCollectionI;
+import jalview.datamodel.SequenceCollectionI;
+import jalview.datamodel.SequenceI;
 
 import java.awt.Color;
 import java.util.Hashtable;
+import java.util.Map;
 
 /**
  * Became RNAHelicesColour.java. Placeholder for true covariation color scheme
@@ -42,6 +46,17 @@ public class CovariationColourScheme extends ResidueColourScheme
   public AlignmentAnnotation annotation;
 
   /**
+   * Returns a new instance of this colour scheme with which the given data may
+   * be coloured
+   */
+  @Override
+  public ColourSchemeI getInstance(AnnotatedCollectionI coll,
+          Map<SequenceI, SequenceCollectionI> hrs)
+  {
+    return new CovariationColourScheme(coll.getAlignmentAnnotation()[0]);
+  }
+
+  /**
    * Creates a new CovariationColourScheme object.
    */
   public CovariationColourScheme(AlignmentAnnotation annotation)
index aaa36f3..94f92b7 100644 (file)
 package jalview.schemes;
 
 import jalview.analysis.Conservation;
+import jalview.datamodel.AnnotatedCollectionI;
 import jalview.datamodel.ProfilesI;
+import jalview.datamodel.SequenceCollectionI;
+import jalview.datamodel.SequenceI;
+
+import java.util.Map;
 
 /**
  * Colourscheme that takes its colours from some other colourscheme
@@ -72,4 +77,15 @@ public class FollowerColourScheme extends ResidueColourScheme
     return "Follower";
   }
 
+  /**
+   * Returns a new instance of this colour scheme with which the given data may
+   * be coloured
+   */
+  @Override
+  public ColourSchemeI getInstance(AnnotatedCollectionI coll,
+          Map<SequenceI, SequenceCollectionI> hrs)
+  {
+    return new FollowerColourScheme();
+  }
+
 }
index f99274b..7123d93 100755 (executable)
  */
 package jalview.schemes;
 
+import jalview.datamodel.AnnotatedCollectionI;
+import jalview.datamodel.SequenceCollectionI;
+import jalview.datamodel.SequenceI;
+
 import java.awt.Color;
+import java.util.Map;
 
 public class HelixColourScheme extends ScoreColourScheme
 {
@@ -47,4 +52,15 @@ public class HelixColourScheme extends ScoreColourScheme
   {
     return JalviewColourScheme.Helix.toString();
   }
+
+  /**
+   * Returns a new instance of this colour scheme with which the given data may
+   * be coloured
+   */
+  @Override
+  public ColourSchemeI getInstance(AnnotatedCollectionI coll,
+          Map<SequenceI, SequenceCollectionI> hrs)
+  {
+    return new HelixColourScheme();
+  }
 }
index 121b864..69af3c9 100755 (executable)
  */
 package jalview.schemes;
 
+import jalview.datamodel.AnnotatedCollectionI;
+import jalview.datamodel.SequenceCollectionI;
+import jalview.datamodel.SequenceI;
+
 import java.awt.Color;
+import java.util.Map;
 
 /**
  * DOCUMENT ME!
@@ -64,4 +69,15 @@ public class HydrophobicColourScheme extends ScoreColourScheme
   {
     return JalviewColourScheme.Hydrophobic.toString();
   }
+
+  /**
+   * Returns a new instance of this colour scheme with which the given data may
+   * be coloured
+   */
+  @Override
+  public ColourSchemeI getInstance(AnnotatedCollectionI coll,
+          Map<SequenceI, SequenceCollectionI> hrs)
+  {
+    return new HydrophobicColourScheme();
+  }
 }
index 7044a10..185d2b4 100644 (file)
 package jalview.schemes;
 
-import jalview.datamodel.AnnotatedCollectionI;
-
-import java.util.HashMap;
-import java.util.Map;
 
 /**
  * An enum with the colour schemes supported by Jalview.
  */
 public enum JalviewColourScheme
 {
-  Clustal("Clustal")
-  {
-    @Override
-    public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
-    {
-      return new ClustalxColourScheme(coll, null);
-    }
-  },
-  Blosum62("Blosum62")
-  {
-    @Override
-    public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
-    {
-      return new Blosum62ColourScheme();
-    }
-  },
-  PID("% Identity")
-  {
-    @Override
-    public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
-    {
-      return new PIDColourScheme();
-    }
-  },
-  Zappo("Zappo")
-  {
-    @Override
-    public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
-    {
-      return new ZappoColourScheme();
-    }
-  },
-  Taylor("Taylor")
-  {
-    @Override
-    public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
-    {
-      return new TaylorColourScheme();
-    }
-  },
-  Hydrophobic("Hydrophobic")
-  {
-    @Override
-    public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
-    {
-      return new HydrophobicColourScheme();
-    }
-  },
-  Helix("Helix Propensity")
-  {
-    @Override
-    public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
-    {
-      return new HelixColourScheme();
-    }
-  },
-  Strand("Strand Propensity")
-  {
-    @Override
-    public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
-    {
-      return new StrandColourScheme();
-    }
-  },
-  Turn("Turn Propensity")
-  {
-    @Override
-    public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
-    {
-      return new TurnColourScheme();
-    }
-  },
-  Buried("Buried Index")
-  {
-    @Override
-    public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
-    {
-      return new BuriedColourScheme();
-    }
-  },
-  Nucleotide("Nucleotide")
-  {
-    @Override
-    public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
-    {
-      return new NucleotideColourScheme();
-    }
-  },
-  PurinePyrimidine("Purine/Pyrimidine")
-  {
-    @Override
-    public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
-    {
-      return new PurinePyrimidineColourScheme();
-    }
-  },
-  TCoffee("T-Coffee Scores")
-  {
-    @Override
-    public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
-    {
-      return new TCoffeeColourScheme(coll);
-    }
-  },
-  RNAHelices("RNA Helices")
-  {
-    @Override
-    public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
-    {
-      return new RNAHelicesColour(coll);
-    }
-  },
-  // RNAInteraction("RNA Interaction type")
-  // {
-  // @Override
-  // public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
-  // {
-  // return new RNAInteractionColourScheme();
-  // }
-  // },
-  UserDefined("User Defined")
-  {
-    @Override
-    public ColourSchemeI getColourScheme(AnnotatedCollectionI coll)
-    {
-      return new UserColourScheme("white");
-    }
-  };
-
-  static Map<String, JalviewColourScheme> names = new HashMap<String, JalviewColourScheme>();
+  /*
+   * the order of declaration is the default order in which 
+   * items are added to Colour menus
+   */
+  Clustal("Clustal", ClustalxColourScheme.class), Blosum62("Blosum62",
+          Blosum62ColourScheme.class), PID("% Identity",
+          PIDColourScheme.class), Zappo("Zappo", ZappoColourScheme.class),
+  Taylor("Taylor", TaylorColourScheme.class), Hydrophobic("Hydrophobic",
+          HydrophobicColourScheme.class), Helix("Helix Propensity",
+          HelixColourScheme.class), Strand("Strand Propensity",
+          StrandColourScheme.class), Turn("Turn Propensity",
+          TurnColourScheme.class), Buried("Buried Index",
+          BuriedColourScheme.class), Nucleotide("Nucleotide",
+          NucleotideColourScheme.class), PurinePyrimidine(
+          "Purine/Pyrimidine", PurinePyrimidineColourScheme.class),
+  RNAHelices("RNA Helices", RNAHelicesColour.class), TCoffee(
+          "T-Coffee Scores", TCoffeeColourScheme.class);
+  // RNAInteraction("RNA Interaction type", RNAInteractionColourScheme.class)
 
   private String name;
 
-  static
-  {
-    for (JalviewColourScheme scheme : values())
-    {
-      names.put(scheme.name.toLowerCase(), scheme);
-    }
-  }
-
-  /**
-   * Answers the colour scheme with the 'given name', or null if name is invalid
-   * or null. The name is not case-sensitive.
-   * 
-   * @param name
-   * @return
-   */
-  public static JalviewColourScheme forName(String name)
-  {
-    return name == null ? null : names.get(name.toLowerCase());
-  }
+  private Class<? extends ColourSchemeI> myClass;
 
   /**
    * Constructor given the name of the colour scheme (as used in Jalview
@@ -170,19 +36,21 @@ public enum JalviewColourScheme
    * 
    * @param s
    */
-  JalviewColourScheme(String s)
+  JalviewColourScheme(String s, Class<? extends ColourSchemeI> cl)
   {
     name = s;
+    myClass = cl;
   }
 
   /**
-   * Returns an instance of the colour scheme with which to colour the given
-   * data
+   * Returns the class of the colour scheme
    * 
-   * @param coll
    * @return
    */
-  public abstract ColourSchemeI getColourScheme(AnnotatedCollectionI coll);
+  public Class<? extends ColourSchemeI> getSchemeClass()
+  {
+    return myClass;
+  }
 
   /**
    * Returns the 'official' name of this colour scheme. This is the name that
index 3e6bd2f..3a71732 100755 (executable)
  */
 package jalview.schemes;
 
+import jalview.datamodel.AnnotatedCollectionI;
+import jalview.datamodel.SequenceCollectionI;
 import jalview.datamodel.SequenceI;
 
 import java.awt.Color;
+import java.util.Map;
 
 /**
  * DOCUMENT ME!
@@ -104,4 +107,15 @@ public class NucleotideColourScheme extends ResidueColourScheme
   {
     return JalviewColourScheme.Nucleotide.toString();
   }
+
+  /**
+   * Returns a new instance of this colour scheme with which the given data may
+   * be coloured
+   */
+  @Override
+  public ColourSchemeI getInstance(AnnotatedCollectionI coll,
+          Map<SequenceI, SequenceCollectionI> hrs)
+  {
+    return new NucleotideColourScheme();
+  }
 }
index 175e904..5628fcd 100755 (executable)
  */
 package jalview.schemes;
 
+import jalview.datamodel.AnnotatedCollectionI;
 import jalview.datamodel.ProfileI;
+import jalview.datamodel.SequenceCollectionI;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 import jalview.util.Comparison;
 
 import java.awt.Color;
+import java.util.Map;
 
 public class PIDColourScheme extends ResidueColourScheme
 {
@@ -100,4 +103,15 @@ public class PIDColourScheme extends ResidueColourScheme
   {
     return JalviewColourScheme.PID.toString();
   }
+
+  /**
+   * Returns a new instance of this colour scheme with which the given data may
+   * be coloured
+   */
+  @Override
+  public ColourSchemeI getInstance(AnnotatedCollectionI coll,
+          Map<SequenceI, SequenceCollectionI> hrs)
+  {
+    return new PIDColourScheme();
+  }
 }
index c7c519c..e451135 100644 (file)
  */
 package jalview.schemes;
 
+import jalview.datamodel.AnnotatedCollectionI;
+import jalview.datamodel.SequenceCollectionI;
+import jalview.datamodel.SequenceI;
+
 import java.awt.Color;
+import java.util.Map;
 
 /**
  * Class is based off of NucleotideColourScheme
@@ -100,4 +105,15 @@ public class PurinePyrimidineColourScheme extends ResidueColourScheme
   {
     return JalviewColourScheme.PurinePyrimidine.toString();
   }
+
+  /**
+   * Returns a new instance of this colour scheme with which the given data may
+   * be coloured
+   */
+  @Override
+  public ColourSchemeI getInstance(AnnotatedCollectionI coll,
+          Map<SequenceI, SequenceCollectionI> hrs)
+  {
+    return new PurinePyrimidineColourScheme();
+  }
 }
index 6448898..aacf557 100644 (file)
@@ -55,6 +55,14 @@ public class RNAHelicesColour extends ResidueColourScheme
   public AlignmentAnnotation annotation;
 
   /**
+   * Default constructor (required for ColourSchemes cache)
+   */
+  public RNAHelicesColour()
+  {
+
+  }
+
+  /**
    * Creates a new RNAHelicesColour object.
    */
   public RNAHelicesColour(AlignmentAnnotation annotation)
@@ -198,10 +206,10 @@ public class RNAHelicesColour extends ResidueColourScheme
   }
 
   @Override
-  public ColourSchemeI applyTo(AnnotatedCollectionI sg,
+  public ColourSchemeI getInstance(AnnotatedCollectionI sg,
           Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
   {
-    return new RNAHelicesColour(this);
+    return new RNAHelicesColour(sg);
   }
 
   @Override
@@ -216,6 +224,14 @@ public class RNAHelicesColour extends ResidueColourScheme
   @Override
   public boolean isApplicableTo(AnnotatedCollectionI ac)
   {
+    if (ac instanceof AlignmentI && ((AlignmentI) ac).hasRNAStructure())
+    {
+      return true;
+    }
+
+    /*
+     * check dataset
+     */
     AnnotatedCollectionI context = ac.getContext();
     if (context == null)
     {
index b1b3c5a..90cc14f 100644 (file)
@@ -25,8 +25,8 @@ import jalview.api.AlignmentViewPanel;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.SequenceGroup;
 
-import java.awt.event.ActionEvent;
 import java.util.Hashtable;
+import java.util.Map;
 import java.util.Vector;
 
 /**
@@ -34,8 +34,9 @@ import java.util.Vector;
  * change colors based on covariation.
  * 
  * @author Lauren Michelle Lui
- * 
+ * @deprecated this seems to be unfinished - just use RNAHelicesColour
  */
+@Deprecated
 public class RNAHelicesColourChooser
 {
 
@@ -45,9 +46,9 @@ public class RNAHelicesColourChooser
 
   ColourSchemeI oldcs;
 
-  Hashtable oldgroupColours;
+  Map<SequenceGroup, ColourSchemeI> oldgroupColours;
 
-  jalview.datamodel.AlignmentAnnotation currentAnnotation;
+  AlignmentAnnotation currentAnnotation;
 
   boolean adjusting = false;
 
@@ -57,7 +58,7 @@ public class RNAHelicesColourChooser
     oldcs = av.getGlobalColourScheme();
     if (av.getAlignment().getGroups() != null)
     {
-      oldgroupColours = new Hashtable();
+      oldgroupColours = new Hashtable<SequenceGroup, ColourSchemeI>();
       for (SequenceGroup sg : ap.getAlignment().getGroups())
       {
         if (sg.cs != null)
@@ -69,14 +70,8 @@ public class RNAHelicesColourChooser
     this.av = av;
     this.ap = ap;
 
-    if (oldcs instanceof RNAHelicesColour)
-    {
-      RNAHelicesColour rhc = (RNAHelicesColour) oldcs;
-
-    }
-
     adjusting = true;
-    Vector list = new Vector();
+    Vector<String> list = new Vector<String>();
     int index = 1;
     AlignmentAnnotation[] anns = av.getAlignment().getAlignmentAnnotation();
     if (anns != null)
@@ -96,9 +91,7 @@ public class RNAHelicesColourChooser
     }
 
     adjusting = false;
-
     changeColour();
-
   }
 
   void changeColour()
@@ -108,30 +101,10 @@ public class RNAHelicesColourChooser
     {
       return;
     }
-    RNAHelicesColour rhc = null;
-
-    rhc = new RNAHelicesColour(av.getAlignment());
+    RNAHelicesColour rhc = new RNAHelicesColour(av.getAlignment());
 
     av.setGlobalColourScheme(rhc);
 
     ap.paintAlignment(true);
   }
-
-  void reset()
-  {
-    av.setGlobalColourScheme(oldcs);
-    if (av.getAlignment().getGroups() != null)
-    {
-      for (SequenceGroup sg : ap.getAlignment().getGroups())
-      {
-        sg.cs = (ColourSchemeI) oldgroupColours.get(sg);
-      }
-    }
-  }
-
-  public void annotations_actionPerformed(ActionEvent e)
-  {
-    changeColour();
-  }
-
 }
index 707afd7..f4c831a 100644 (file)
  */
 package jalview.schemes;
 
+import jalview.datamodel.AnnotatedCollectionI;
+import jalview.datamodel.SequenceCollectionI;
 import jalview.datamodel.SequenceI;
 
 import java.awt.Color;
+import java.util.Map;
 
 public class RNAInteractionColourScheme extends ResidueColourScheme
 {
@@ -77,4 +80,15 @@ public class RNAInteractionColourScheme extends ResidueColourScheme
   {
     return "RNA Interaction type";
   }
+
+  /**
+   * Returns a new instance of this colour scheme with which the given data may
+   * be coloured
+   */
+  @Override
+  public ColourSchemeI getInstance(AnnotatedCollectionI coll,
+          Map<SequenceI, SequenceCollectionI> hrs)
+  {
+    return new RNAInteractionColourScheme();
+  }
 }
index 38ab622..9cc4bd1 100755 (executable)
@@ -29,7 +29,6 @@ import jalview.datamodel.SequenceCollectionI;
 import jalview.datamodel.SequenceI;
 import jalview.util.ColorUtils;
 import jalview.util.Comparison;
-import jalview.util.MessageManager;
 
 import java.awt.Color;
 import java.util.Map;
@@ -37,7 +36,7 @@ import java.util.Map;
 /**
  * Base class for residue-based colour schemes
  */
-public class ResidueColourScheme implements ColourSchemeI
+public abstract class ResidueColourScheme implements ColourSchemeI
 {
   public static final String NONE = "None";
 
@@ -117,6 +116,7 @@ public class ResidueColourScheme implements ColourSchemeI
   @Override
   public Color findColour()
   {
+    // TODO delete this method in favour of ColorUtils.parseColourString()?
     return findColour('A');
   }
 
@@ -346,24 +346,9 @@ public class ResidueColourScheme implements ColourSchemeI
   {
   }
 
-  @Override
-  public ColourSchemeI applyTo(AnnotatedCollectionI sg,
-          Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
-  {
-    try
-    {
-      return getClass().newInstance();
-    } catch (Exception q)
-    {
-      throw new Error(MessageManager.formatMessage(
-              "error.implementation_error_cannot_duplicate_colour_scheme",
-              new String[] { getClass().getName() }), q);
-    }
-  }
-
   /**
    * Answers false if the colour scheme is nucleotide or peptide specific, and
-   * the data does not match, else false. Override to modify or extend this test
+   * the data does not match, else true. Override to modify or extend this test
    * as required.
    */
   @Override
@@ -426,10 +411,4 @@ public class ResidueColourScheme implements ColourSchemeI
   {
     return false;
   }
-
-  @Override
-  public String getSchemeName()
-  {
-    return "Residue";
-  }
 }
index 57e8458..ec06e06 100755 (executable)
  */
 package jalview.schemes;
 
+import jalview.datamodel.AnnotatedCollectionI;
+import jalview.datamodel.SequenceCollectionI;
 import jalview.datamodel.SequenceI;
 
 import java.awt.Color;
+import java.util.Map;
 
 /**
  * DOCUMENT ME!
@@ -135,4 +138,15 @@ public class ScoreColourScheme extends ResidueColourScheme
   {
     return "Score";
   }
+
+  /**
+   * Returns a new instance of this colour scheme with which the given data may
+   * be coloured
+   */
+  @Override
+  public ColourSchemeI getInstance(AnnotatedCollectionI coll,
+          Map<SequenceI, SequenceCollectionI> hrs)
+  {
+    return new ScoreColourScheme(symbolIndex, scores, min, max);
+  }
 }
index a6e4595..5f11c29 100755 (executable)
  */
 package jalview.schemes;
 
+import jalview.datamodel.AnnotatedCollectionI;
+import jalview.datamodel.SequenceCollectionI;
+import jalview.datamodel.SequenceI;
+
 import java.awt.Color;
+import java.util.Map;
 
 /**
  * DOCUMENT ME!
@@ -64,4 +69,15 @@ public class StrandColourScheme extends ScoreColourScheme
   {
     return JalviewColourScheme.Strand.toString();
   }
+
+  /**
+   * Returns a new instance of this colour scheme with which the given data may
+   * be coloured
+   */
+  @Override
+  public ColourSchemeI getInstance(AnnotatedCollectionI coll,
+          Map<SequenceI, SequenceCollectionI> hrs)
+  {
+    return new StrandColourScheme();
+  }
 }
index 19c92a0..0611edc 100644 (file)
@@ -60,6 +60,14 @@ public class TCoffeeColourScheme extends ResidueColourScheme
   IdentityHashMap<SequenceI, Color[]> seqMap;
 
   /**
+   * Default constructor (required for Class.newInstance())
+   */
+  public TCoffeeColourScheme()
+  {
+
+  }
+
+  /**
    * the color scheme needs to look at the alignment to get and cache T-COFFEE
    * scores
    * 
@@ -136,7 +144,7 @@ public class TCoffeeColourScheme extends ResidueColourScheme
   }
 
   @Override
-  public ColourSchemeI applyTo(AnnotatedCollectionI sg,
+  public ColourSchemeI getInstance(AnnotatedCollectionI sg,
           Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
   {
     return new TCoffeeColourScheme(sg);
index 5887220..cae3e15 100755 (executable)
  */
 package jalview.schemes;
 
+import jalview.datamodel.AnnotatedCollectionI;
+import jalview.datamodel.SequenceCollectionI;
+import jalview.datamodel.SequenceI;
+
+import java.util.Map;
+
 public class TaylorColourScheme extends ResidueColourScheme
 {
   public TaylorColourScheme()
@@ -38,4 +44,15 @@ public class TaylorColourScheme extends ResidueColourScheme
   {
     return JalviewColourScheme.Taylor.toString();
   }
+
+  /**
+   * Returns a new instance of this colour scheme with which the given data may
+   * be coloured
+   */
+  @Override
+  public ColourSchemeI getInstance(AnnotatedCollectionI coll,
+          Map<SequenceI, SequenceCollectionI> hrs)
+  {
+    return new TaylorColourScheme();
+  }
 }
index ac16b5b..67116b8 100755 (executable)
  */
 package jalview.schemes;
 
+import jalview.datamodel.AnnotatedCollectionI;
+import jalview.datamodel.SequenceCollectionI;
+import jalview.datamodel.SequenceI;
+
 import java.awt.Color;
+import java.util.Map;
 
 /**
  * DOCUMENT ME!
@@ -64,4 +69,15 @@ public class TurnColourScheme extends ScoreColourScheme
   {
     return JalviewColourScheme.Turn.toString();
   }
+
+  /**
+   * Returns a new instance of this colour scheme with which the given data may
+   * be coloured
+   */
+  @Override
+  public ColourSchemeI getInstance(AnnotatedCollectionI coll,
+          Map<SequenceI, SequenceCollectionI> hrs)
+  {
+    return new TurnColourScheme();
+  }
 }
index 218c285..09cef92 100755 (executable)
@@ -56,7 +56,7 @@ public class UserColourScheme extends ResidueColourScheme
   }
 
   @Override
-  public ColourSchemeI applyTo(AnnotatedCollectionI sg,
+  public ColourSchemeI getInstance(AnnotatedCollectionI sg,
           Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
   {
     UserColourScheme usc = new UserColourScheme(colors);
@@ -294,7 +294,7 @@ public class UserColourScheme extends ResidueColourScheme
     {
       return schemeName;
     }
-    return JalviewColourScheme.UserDefined.toString();
+    return "User Defined";
   }
 
   /**
index 62c32d8..d193714 100755 (executable)
  */
 package jalview.schemes;
 
+import jalview.datamodel.AnnotatedCollectionI;
+import jalview.datamodel.SequenceCollectionI;
+import jalview.datamodel.SequenceI;
+
+import java.util.Map;
+
 /**
  * DOCUMENT ME!
  * 
@@ -47,4 +53,15 @@ public class ZappoColourScheme extends ResidueColourScheme
   {
     return JalviewColourScheme.Zappo.toString();
   }
+
+  /**
+   * Returns a new instance of this colour scheme with which the given data may
+   * be coloured
+   */
+  @Override
+  public ColourSchemeI getInstance(AnnotatedCollectionI coll,
+          Map<SequenceI, SequenceCollectionI> hrs)
+  {
+    return new ZappoColourScheme();
+  }
 }
index fecccb0..0171fd1 100644 (file)
@@ -642,7 +642,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
           sg.cs = null;
           continue;
         }
-        sg.cs = cs.applyTo(sg, getHiddenRepSequences());
+        sg.cs = cs.getInstance(sg, getHiddenRepSequences());
         sg.setConsPercGaps(ConsPercGaps);
         if (getAbovePIDThreshold() || cs instanceof PIDColourScheme
                 || cs instanceof Blosum62ColourScheme)
index af477f7..734bfe0 100644 (file)
@@ -45,6 +45,8 @@ import jalview.gui.JvOptionPane;
 import jalview.schemes.AnnotationColourGradient;
 import jalview.schemes.ColourSchemeI;
 import jalview.schemes.ColourSchemeProperty;
+import jalview.schemes.JalviewColourScheme;
+import jalview.schemes.RNAHelicesColour;
 import jalview.schemes.TCoffeeColourScheme;
 import jalview.structure.StructureImportSettings;
 import jalview.viewmodel.AlignmentViewport;
@@ -83,10 +85,10 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     assertTrue("Didn't read input file " + inFile, af != null);
     int olddsann = countDsAnn(af.getViewport());
     assertTrue("Didn't find any dataset annotations", olddsann > 0);
-    af.rnahelicesColour_actionPerformed();
-    assertTrue(
-            "Couldn't apply RNA helices colourscheme",
-            af.getViewport().getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
+    af.changeColour_actionPerformed(JalviewColourScheme.RNAHelices
+            .toString());
+    assertTrue("Couldn't apply RNA helices colourscheme", af.getViewport()
+            .getGlobalColourScheme() instanceof RNAHelicesColour);
     assertTrue("Failed to store as a project.",
             af.saveAlignment(tfile, FileFormat.Jalview));
     af.closeMenuItem_actionPerformed(true);
@@ -103,7 +105,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
                     + olddsann + ")");
     assertTrue(
             "RNA helices colourscheme was not applied on import.",
-            af.getViewport().getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
+            af.getViewport().getGlobalColourScheme() instanceof RNAHelicesColour);
   }
 
   @Test(groups = { "Functional" })
index c63f04d..2854784 100644 (file)
@@ -99,7 +99,7 @@ public class ColourSchemePropertyTest
     // 'None' is a special value
     assertNull(ColourSchemeProperty.getColourScheme(al, "None"));
     assertNull(ColourSchemeProperty.getColourScheme(al, "none"));
-    // default is to convert the name into a fixed coloour
+    // default is to convert the name into a fixed colour
     assertTrue(ColourSchemeProperty.getColourScheme(al, "elephants") instanceof UserColourScheme);
 
     /*
diff --git a/test/jalview/schemes/ColourSchemesTest.java b/test/jalview/schemes/ColourSchemesTest.java
new file mode 100644 (file)
index 0000000..7763002
--- /dev/null
@@ -0,0 +1,28 @@
+package jalview.schemes;
+
+import static org.testng.Assert.assertTrue;
+
+import java.util.Iterator;
+
+import org.testng.annotations.Test;
+
+public class ColourSchemesTest
+{
+  @Test(groups = "Functional")
+  public void testGetColourSchemes()
+  {
+    /*
+     * this just verifies that built-in colour schemes are loaded into ColourSchemes
+     * in the order in which they are declared in the JalviewColourScheme enum
+     * (this also determines their order in Colour menus)
+     */
+    Iterator<ColourSchemeI> schemes = ColourSchemes.getInstance().getColourSchemes().iterator();
+    JalviewColourScheme[] jalviewSchemes = JalviewColourScheme.values();
+    int i = 0;
+    while (schemes.hasNext()) {
+      assertTrue(schemes.next().getSchemeName()
+              .equals(jalviewSchemes[i].toString()));
+      i++;
+    }
+  }
+}
index b5246ba..d9403d2 100644 (file)
@@ -1,82 +1,48 @@
 package jalview.schemes;
 
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
 
-import jalview.datamodel.Alignment;
-import jalview.datamodel.AlignmentI;
-import jalview.datamodel.Sequence;
-import jalview.datamodel.SequenceI;
-
 import org.testng.annotations.Test;
 
 public class JalviewColourSchemeTest
 {
   @Test(groups = "Functional")
-  public void testForName()
+  public void testGetSchemeClass()
   {
-    assertSame(JalviewColourScheme.Clustal,
-            JalviewColourScheme.forName("Clustal"));
-    assertSame(JalviewColourScheme.Clustal,
-            JalviewColourScheme.forName("CLUSTAL"));
-    assertSame(JalviewColourScheme.Blosum62,
-            JalviewColourScheme.forName("Blosum62"));
-    assertSame(JalviewColourScheme.PID,
-            JalviewColourScheme.forName("% Identity"));
-    assertSame(JalviewColourScheme.Hydrophobic,
-            JalviewColourScheme.forName("Hydrophobic"));
-    assertSame(JalviewColourScheme.Zappo,
-            JalviewColourScheme.forName("Zappo"));
-    assertSame(JalviewColourScheme.Taylor,
-            JalviewColourScheme.forName("Taylor"));
-    assertSame(JalviewColourScheme.Helix,
-            JalviewColourScheme.forName("Helix Propensity"));
-    assertSame(JalviewColourScheme.Strand,
-            JalviewColourScheme.forName("Strand Propensity"));
-    assertSame(JalviewColourScheme.Turn,
-            JalviewColourScheme.forName("Turn Propensity"));
-    assertSame(JalviewColourScheme.Buried,
-            JalviewColourScheme.forName("Buried Index"));
-    assertSame(JalviewColourScheme.Nucleotide,
-            JalviewColourScheme.forName("Nucleotide"));
-    assertSame(JalviewColourScheme.PurinePyrimidine,
-            JalviewColourScheme.forName("Purine/Pyrimidine"));
-    assertSame(JalviewColourScheme.TCoffee,
-            JalviewColourScheme.forName("T-Coffee Scores"));
-    assertSame(JalviewColourScheme.RNAHelices,
-            JalviewColourScheme.forName("RNA Helices"));
-    // assertSame(JalviewColourScheme.RNAInteraction,
-    // JalviewColourScheme.forName("RNA Interaction type"));
-    assertSame(JalviewColourScheme.UserDefined,
-            JalviewColourScheme.forName("User Defined"));
-
-    assertNull(JalviewColourScheme.forName("PID"));
-    assertNull(JalviewColourScheme.forName(""));
-    assertNull(JalviewColourScheme.forName(null));
+    assertTrue(JalviewColourScheme.Clustal.getSchemeClass() == ClustalxColourScheme.class);
+    assertTrue(JalviewColourScheme.Blosum62.getSchemeClass() == Blosum62ColourScheme.class);
+    assertTrue(JalviewColourScheme.PID.getSchemeClass() == PIDColourScheme.class);
+    assertTrue(JalviewColourScheme.Hydrophobic.getSchemeClass() == HydrophobicColourScheme.class);
+    assertTrue(JalviewColourScheme.Zappo.getSchemeClass() == ZappoColourScheme.class);
+    assertTrue(JalviewColourScheme.Taylor.getSchemeClass() == TaylorColourScheme.class);
+    assertTrue(JalviewColourScheme.Helix.getSchemeClass() == HelixColourScheme.class);
+    assertTrue(JalviewColourScheme.Strand.getSchemeClass() == StrandColourScheme.class);
+    assertTrue(JalviewColourScheme.Turn.getSchemeClass() == TurnColourScheme.class);
+    assertTrue(JalviewColourScheme.Buried.getSchemeClass() == BuriedColourScheme.class);
+    assertTrue(JalviewColourScheme.Nucleotide.getSchemeClass() == NucleotideColourScheme.class);
+    assertTrue(JalviewColourScheme.PurinePyrimidine.getSchemeClass() == PurinePyrimidineColourScheme.class);
+    assertTrue(JalviewColourScheme.TCoffee.getSchemeClass() == TCoffeeColourScheme.class);
+    assertTrue(JalviewColourScheme.RNAHelices.getSchemeClass() == RNAHelicesColour.class);
   }
 
   @Test(groups = "Functional")
-  public void testGetColourScheme()
+  public void testToString()
   {
-    SequenceI seq = new Sequence("Seq1", "abcd");
-    AlignmentI al = new Alignment(new SequenceI[] { seq });
-    assertTrue(JalviewColourScheme.Clustal.getColourScheme(al) instanceof ClustalxColourScheme);
-    assertTrue(JalviewColourScheme.Blosum62.getColourScheme(al) instanceof Blosum62ColourScheme);
-    assertTrue(JalviewColourScheme.PID.getColourScheme(al) instanceof PIDColourScheme);
-    assertTrue(JalviewColourScheme.Hydrophobic.getColourScheme(al) instanceof HydrophobicColourScheme);
-    assertTrue(JalviewColourScheme.Zappo.getColourScheme(al) instanceof ZappoColourScheme);
-    assertTrue(JalviewColourScheme.Taylor.getColourScheme(al) instanceof TaylorColourScheme);
-    assertTrue(JalviewColourScheme.Helix.getColourScheme(al) instanceof HelixColourScheme);
-    assertTrue(JalviewColourScheme.Strand.getColourScheme(al) instanceof StrandColourScheme);
-    assertTrue(JalviewColourScheme.Turn.getColourScheme(al) instanceof TurnColourScheme);
-    assertTrue(JalviewColourScheme.Buried.getColourScheme(al) instanceof BuriedColourScheme);
-    assertTrue(JalviewColourScheme.Nucleotide.getColourScheme(al) instanceof NucleotideColourScheme);
-    assertTrue(JalviewColourScheme.PurinePyrimidine.getColourScheme(al) instanceof PurinePyrimidineColourScheme);
-    assertTrue(JalviewColourScheme.TCoffee.getColourScheme(al) instanceof TCoffeeColourScheme);
-    assertTrue(JalviewColourScheme.RNAHelices.getColourScheme(al) instanceof RNAHelicesColour);
-    // assertTrue(JalviewColourScheme.RNAInteraction.getColourScheme(al)
-    // instanceof RNAInteractionColourScheme);
-    assertTrue(JalviewColourScheme.UserDefined.getColourScheme(al) instanceof UserColourScheme);
+    assertEquals(JalviewColourScheme.Clustal.toString(), "Clustal");
+    assertEquals(JalviewColourScheme.Blosum62.toString(), "Blosum62");
+    assertEquals(JalviewColourScheme.PID.toString(), "% Identity");
+    assertEquals(JalviewColourScheme.Zappo.toString(), "Zappo");
+    assertEquals(JalviewColourScheme.Taylor.toString(), "Taylor");
+    assertEquals(JalviewColourScheme.Hydrophobic.toString(), "Hydrophobic");
+    assertEquals(JalviewColourScheme.Helix.toString(), "Helix Propensity");
+    assertEquals(JalviewColourScheme.Strand.toString(), "Strand Propensity");
+    assertEquals(JalviewColourScheme.Turn.toString(), "Turn Propensity");
+    assertEquals(JalviewColourScheme.Buried.toString(), "Buried Index");
+    assertEquals(JalviewColourScheme.Nucleotide.toString(), "Nucleotide");
+    assertEquals(JalviewColourScheme.PurinePyrimidine.toString(),
+            "Purine/Pyrimidine");
+    assertEquals(JalviewColourScheme.TCoffee.toString(), "T-Coffee Scores");
+    assertEquals(JalviewColourScheme.RNAHelices.toString(), "RNA Helices");
   }
 }
index 4e8ea52..e6dc9e6 100644 (file)
@@ -44,6 +44,11 @@ import org.testng.annotations.Test;
 
 public class ResidueColourSchemeTest
 {
+  @BeforeClass(alwaysRun = true)
+  public void setUp()
+  {
+
+  }
 
   @BeforeClass(alwaysRun = true)
   public void setUpJvOptionPane()
@@ -67,7 +72,7 @@ public class ResidueColourSchemeTest
     profiles[1] = new Profile(4, 0, 4, "R");
     profiles[2] = new Profile(4, 4, 0, "");
     profiles[3] = new Profile(4, 1, 2, "T");
-    ResidueColourScheme rcs = new ResidueColourScheme();
+    ResidueColourScheme rcs = new PIDColourScheme();
     rcs.setConsensus(new Profiles(profiles));
     
     /*
@@ -110,7 +115,7 @@ public class ResidueColourSchemeTest
   @Test(groups = "Functional")
   public void testApplyConservation()
   {
-    ResidueColourScheme rcs = new ResidueColourScheme();
+    ResidueColourScheme rcs = new PIDColourScheme();
 
     // no conservation present - no fading
     assertEquals(Color.RED, rcs.applyConservation(Color.RED, 12));
@@ -202,7 +207,8 @@ public class ResidueColourSchemeTest
             .isApplicableTo(peptide));
     assertFalse(new ClustalxColourScheme(nucleotide, null)
             .isApplicableTo(nucleotide));
-    assertTrue(new Blosum62ColourScheme().isApplicableTo(peptide));
+    // Blosum requires presence of Conservation annotation
+    assertFalse(new Blosum62ColourScheme().isApplicableTo(peptide));
     assertFalse(new Blosum62ColourScheme().isApplicableTo(nucleotide));
     assertTrue(new BuriedColourScheme().isApplicableTo(peptide));
     assertFalse(new BuriedColourScheme().isApplicableTo(nucleotide));
@@ -219,6 +225,11 @@ public class ResidueColourSchemeTest
     assertTrue(new ZappoColourScheme().isApplicableTo(peptide));
     assertFalse(new ZappoColourScheme().isApplicableTo(nucleotide));
 
+    peptide.addAnnotation(new AlignmentAnnotation("Conservation",
+            "Conservation", new Annotation[1], 0f, 11f,
+            AlignmentAnnotation.BAR_GRAPH));
+    assertTrue(new Blosum62ColourScheme().isApplicableTo(peptide));
+
     /*
      * nucleotide-specific colour schemes
      */
@@ -239,8 +250,9 @@ public class ResidueColourSchemeTest
             .isApplicableTo(peptide));
     assertTrue(new ScoreColourScheme(new int[] {}, new double[] {}, 0, 0d)
             .isApplicableTo(nucleotide));
-    assertTrue(new ResidueColourScheme().isApplicableTo(peptide));
-    assertTrue(new ResidueColourScheme().isApplicableTo(nucleotide));
+    ResidueColourScheme rcs = new PIDColourScheme();
+    assertTrue(rcs.isApplicableTo(peptide));
+    assertTrue(rcs.isApplicableTo(nucleotide));
     assertTrue(new PIDColourScheme().isApplicableTo(peptide));
     assertTrue(new PIDColourScheme().isApplicableTo(nucleotide));
     assertTrue(new FollowerColourScheme().isApplicableTo(peptide));
@@ -301,7 +313,7 @@ public class ResidueColourSchemeTest
     assertTrue(cs.isApplicableTo(peptide));
   }
 
-  @Test
+  @Test(groups = "Functional")
   public void testGetName()
   {
     SequenceI pep1 = new Sequence("pep1", "APQTWLS");
@@ -323,7 +335,6 @@ public class ResidueColourSchemeTest
     assertEquals("User Defined", new UserColourScheme().getSchemeName());
     assertEquals("Score", new ScoreColourScheme(new int[] {},
             new double[] {}, 0, 0d).getSchemeName());
-    assertEquals("Residue", new ResidueColourScheme().getSchemeName());
     assertEquals("% Identity", new PIDColourScheme().getSchemeName());
     assertEquals("Follower", new FollowerColourScheme().getSchemeName());
     assertEquals("T-Coffee Scores",