From 92bd4313e2f23a65df1eb965e836d178c1eacdd1 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 21 Dec 2016 15:18:41 +0000 Subject: [PATCH] JAL-2360 ColourMenuHelper now builds and selects items in colour menu for align frame and popup menus --- src/jalview/gui/AlignFrame.java | 202 ++------ src/jalview/gui/ColourMenuHelper.java | 219 ++++++++ src/jalview/gui/PopupMenu.java | 576 ++------------------- src/jalview/jbgui/GAlignFrame.java | 77 +-- src/jalview/schemes/ColourSchemeProperty.java | 2 +- src/jalview/schemes/ColourSchemes.java | 23 +- src/jalview/schemes/ResidueColourScheme.java | 20 +- test/jalview/schemes/ColourSchemesTest.java | 34 +- test/jalview/schemes/ResidueColourSchemeTest.java | 8 +- 9 files changed, 338 insertions(+), 823 deletions(-) create mode 100644 src/jalview/gui/ColourMenuHelper.java diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 5127342..29a160c 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -59,6 +59,7 @@ import jalview.datamodel.SeqCigar; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; +import jalview.gui.ColourMenuHelper.ColourChangeListener; import jalview.gui.ViewSelectionMenu.ViewSetProvider; import jalview.io.AlignmentProperties; import jalview.io.AnnotationFile; @@ -78,12 +79,10 @@ import jalview.io.NewickFile; import jalview.io.TCoffeeScoreFile; import jalview.jbgui.GAlignFrame; import jalview.schemes.ColourSchemeI; -import jalview.schemes.ColourSchemeProperty; import jalview.schemes.ColourSchemes; import jalview.schemes.ResidueColourScheme; import jalview.schemes.ResidueProperties; import jalview.schemes.TCoffeeColourScheme; -import jalview.schemes.UserColourScheme; import jalview.util.MessageManager; import jalview.viewmodel.AlignmentViewport; import jalview.ws.DBRefFetcher; @@ -114,7 +113,6 @@ 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; @@ -129,14 +127,12 @@ 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; @@ -147,7 +143,7 @@ import javax.swing.SwingUtilities; * @version $Revision$ */ public class AlignFrame extends GAlignFrame implements DropTargetListener, - IProgressIndicator, AlignViewControllerGuiI + IProgressIndicator, AlignViewControllerGuiI, ColourChangeListener { public static final int DEFAULT_WIDTH = 700; @@ -839,7 +835,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, */ public void setGUINucleotide() { - boolean nucleotide = viewport.getAlignment().isNucleotide(); + AlignmentI al = getViewport().getAlignment(); + boolean nucleotide = al.isNucleotide(); showTranslation.setVisible(nucleotide); showReverse.setVisible(nucleotide); @@ -848,37 +845,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, modifyConservation.setEnabled(!nucleotide); showGroupConservation.setEnabled(!nucleotide); - AlignmentI al = getViewport().getAlignment(); - - /* - * 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) - */ - 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")); - - String selectedColourScheme = Cache.getDefault( - nucleotide ? Preferences.DEFAULT_COLOUR_NUC - : Preferences.DEFAULT_COLOUR_PROT, - ResidueColourScheme.NONE); - setColourSelected(selectedColourScheme); } /** @@ -930,8 +899,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, showSequenceLogo.setSelected(av.isShowSequenceLogo()); normaliseSequenceLogo.setSelected(av.isNormaliseSequenceLogo()); - setColourSelected(ColourSchemeProperty.getColourName(av - .getGlobalColourScheme())); + ColourMenuHelper.setColourSelected(colourMenu, + av.getGlobalColourScheme()); showSeqFeatures.setSelected(av.isShowSequenceFeatures()); hiddenMarkers.setState(av.getShowHiddenMarkers()); @@ -3315,18 +3284,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, new TextColourChooser().chooseColour(alignPanel, null); } - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - @Override - protected void noColourmenuItem_actionPerformed() - { - changeColour(null); - } - /* * public void covariationColour_actionPerformed() { * changeColour(new @@ -3363,10 +3320,24 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, * @param name * the name (not the menu item label!) of the colour scheme */ + @Override public void changeColour_actionPerformed(String name) { + /* + * 'User Defined' opens a panel to configure or load a + * user-defined colour scheme + */ + if (ResidueColourScheme.USER_DEFINED.equals(name)) + { + new UserDefinedColours(alignPanel, null); + return; + } + + /* + * otherwise set the chosen colour scheme (or null for 'None') + */ ColourSchemeI cs = ColourSchemes.getInstance().getColourScheme(name, - viewport); + viewport.getAlignment(), viewport.getHiddenRepSequences()); changeColour(cs); } @@ -3381,7 +3352,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, // TODO: pull up to controller method if (cs != null) { - setColourSelected(cs.getSchemeName()); + ColourMenuHelper.setColourSelected(colourMenu, cs.getSchemeName()); // Make sure viewport is up to date w.r.t. any sliders if (viewport.getAbovePIDThreshold()) { @@ -3477,18 +3448,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } /** - * 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) - { - new UserDefinedColours(alignPanel, null); - } - - /** * DOCUMENT ME! * * @param e @@ -4787,17 +4746,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { if (tcf.annotateAlignment(viewport.getAlignment(), 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; @@ -5737,101 +5685,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { 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 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.getStringOrReturn("label.colourScheme_" - + name.toLowerCase().replace(" ", "_"), name); - 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.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); + ColourMenuHelper + .addMenuItems(colourMenu, this, viewport.getAlignment()); colourMenu.addSeparator(); colourMenu.add(conservationMenuItem); @@ -5840,10 +5699,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, colourMenu.add(modifyPID); colourMenu.add(annotationColour); - setColourSelected(Cache.getDefault(Preferences.DEFAULT_COLOUR, - ResidueColourScheme.NONE)); + /* + * select the default colour for the alignment (this may be + * overridden later) + */ + boolean nucleotide = viewport.getAlignment().isNucleotide(); + String defaultColourScheme = Cache.getDefault( + nucleotide ? Preferences.DEFAULT_COLOUR_NUC + : Preferences.DEFAULT_COLOUR_PROT, + ResidueColourScheme.NONE); - setGUINucleotide(); + ColourMenuHelper.setColourSelected(colourMenu, defaultColourScheme); } } diff --git a/src/jalview/gui/ColourMenuHelper.java b/src/jalview/gui/ColourMenuHelper.java new file mode 100644 index 0000000..a5f4355 --- /dev/null +++ b/src/jalview/gui/ColourMenuHelper.java @@ -0,0 +1,219 @@ +package jalview.gui; + +import jalview.datamodel.AnnotatedCollectionI; +import jalview.schemes.ColourSchemeI; +import jalview.schemes.ColourSchemes; +import jalview.schemes.ResidueColourScheme; +import jalview.schemes.UserColourScheme; +import jalview.util.MessageManager; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.ButtonGroup; +import javax.swing.JMenu; +import javax.swing.JRadioButtonMenuItem; + +public class ColourMenuHelper +{ + public interface ColourChangeListener + { + void changeColour_actionPerformed(String name); + } + + /** + * Adds items to the colour menu, as mutually exclusive members of a button + * group. The callback handler is responsible for the action on selecting any + * of these options. It is returned the name of the selected colour, or "None" + * or "User Defined". + * + * + * @param colourMenu + * the menu to attach items to + * @param client + * a callback to handle menu selection + * @param coll + * the data the menu is being built for + */ + public static void addMenuItems(final JMenu colourMenu, + final ColourChangeListener client, AnnotatedCollectionI coll) + { + /* + * ButtonGroup groups those items whose + * selection is mutually exclusive + */ + ButtonGroup colours = new ButtonGroup(); + JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem( + MessageManager.getString("label.none")); + noColourmenuItem.setName(ResidueColourScheme.NONE); + noColourmenuItem.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + client.changeColour_actionPerformed(ResidueColourScheme.NONE); + } + }); + 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 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.getStringOrReturn("label.colourScheme_" + + name.toLowerCase().replace(" ", "_"), name); + final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(label); + radioItem.setName(name); + radioItem.setEnabled(scheme.isApplicableTo(coll)); + 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.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) + { + client.changeColour_actionPerformed(name); + } + }); + colourMenu.add(radioItem); + colours.add(radioItem); + } + + final String label = MessageManager.getString("action.user_defined"); + JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem(label); + userDefinedColour.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + client.changeColour_actionPerformed(ResidueColourScheme.USER_DEFINED); + } + }); + colourMenu.add(userDefinedColour); + colours.add(userDefinedColour); + } + + /** + * Marks as selected the colour menu item matching the given name, or the + * first item ('None') if no match is found + * + * @param colourMenu + * @param colourName + */ + public static void setColourSelected(JMenu colourMenu, String colourName) + { + if (colourName == null) + { + return; + } + + JRadioButtonMenuItem none = null; + + /* + * select the radio button whose name matches the colour name + * (not the button text, as it may be internationalised) + */ + for (Component menuItem : colourMenu.getMenuComponents()) + { + if (menuItem instanceof JRadioButtonMenuItem) + { + String buttonName = ((JRadioButtonMenuItem) menuItem).getName(); + if (colourName.equals(buttonName)) + { + ((JRadioButtonMenuItem) menuItem).setSelected(true); + return; + } + if (ResidueColourScheme.NONE.equals(buttonName)) + { + none = (JRadioButtonMenuItem) menuItem; + } + } + } + if (none != null) + { + none.setSelected(true); + } + } + + /** + * Marks as selected the colour menu item matching the given colour scheme, or + * the first item ('None') if no match is found + * + * @param colourMenu + * @param cs + */ + public static void setColourSelected(JMenu colourMenu, ColourSchemeI cs) + { + setColourSelected(colourMenu, cs == null ? ResidueColourScheme.NONE + : cs.getSchemeName()); + } +} diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 696f03d..b6fd5fc 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -38,34 +38,22 @@ import jalview.datamodel.Sequence; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; +import jalview.gui.ColourMenuHelper.ColourChangeListener; import jalview.io.FileFormat; import jalview.io.FileFormatI; import jalview.io.FormatAdapter; import jalview.io.SequenceAnnotationReport; import jalview.schemes.AnnotationColourGradient; import jalview.schemes.Blosum62ColourScheme; -import jalview.schemes.BuriedColourScheme; -import jalview.schemes.ClustalxColourScheme; -import jalview.schemes.ColourSchemeI; -import jalview.schemes.HelixColourScheme; -import jalview.schemes.HydrophobicColourScheme; -import jalview.schemes.JalviewColourScheme; -import jalview.schemes.NucleotideColourScheme; +import jalview.schemes.ColourSchemes; import jalview.schemes.PIDColourScheme; -import jalview.schemes.PurinePyrimidineColourScheme; -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.schemes.ResidueColourScheme; import jalview.util.GroupUrlLink; import jalview.util.GroupUrlLink.UrlStringTooLongException; import jalview.util.MessageManager; import jalview.util.UrlLink; import java.awt.Color; -import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Arrays; @@ -79,13 +67,11 @@ import java.util.SortedMap; import java.util.TreeMap; import java.util.Vector; -import javax.swing.ButtonGroup; import javax.swing.JCheckBoxMenuItem; import javax.swing.JColorChooser; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.JPopupMenu; -import javax.swing.JRadioButtonMenuItem; /** * DOCUMENT ME! @@ -93,46 +79,14 @@ import javax.swing.JRadioButtonMenuItem; * @author $author$ * @version $Revision: 1.118 $ */ -public class PopupMenu extends JPopupMenu +public class PopupMenu extends JPopupMenu implements ColourChangeListener { JMenu groupMenu = new JMenu(); JMenuItem groupName = new JMenuItem(); - protected JRadioButtonMenuItem clustalColour = new JRadioButtonMenuItem(); - - protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem(); - - protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem(); - - protected JRadioButtonMenuItem hydrophobicityColour = new JRadioButtonMenuItem(); - - protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem(); - - protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem(); - - protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem(); - - protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem(); - protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem(); - protected JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem(); - - protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem(); - - protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem(); - - JRadioButtonMenuItem nucleotideColour = new JRadioButtonMenuItem(); - - protected JRadioButtonMenuItem purinePyrimidineColour = new JRadioButtonMenuItem(); - - protected JRadioButtonMenuItem tcoffeeColour = new JRadioButtonMenuItem(); - - // protected JRadioButtonMenuItem RNAInteractionColour; - - JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem(); - protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem(); AlignmentPanel ap; @@ -467,7 +421,7 @@ public class PopupMenu extends JPopupMenu groupName.setText(MessageManager .getString("label.edit_name_and_description_current_group")); - setColourSelected(sg.cs); + ColourMenuHelper.setColourSelected(colourMenu, sg.cs); if (sg.cs != null && sg.cs.conservationApplied()) { @@ -1013,16 +967,14 @@ public class PopupMenu extends JPopupMenu }); sequenceSelDetails.setText(MessageManager .getString("label.sequence_details")); - sequenceSelDetails -.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - sequenceSelectionDetails_actionPerformed(); - } - }); - PIDColour.setFocusPainted(false); + sequenceSelDetails.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + sequenceSelectionDetails_actionPerformed(); + } + }); unGroupMenuItem .setText(MessageManager.getString("action.remove_group")); unGroupMenuItem.addActionListener(new ActionListener() @@ -1252,6 +1204,7 @@ public class PopupMenu extends JPopupMenu sequenceMenu.add(sequenceDetails); sequenceMenu.add(makeReferenceSeq); + initColourMenu(); buildColourMenu(); editMenu.add(copy); @@ -1271,8 +1224,6 @@ public class PopupMenu extends JPopupMenu jMenu1.add(showColourText); jMenu1.add(outline); jMenu1.add(displayNonconserved); - - initColourMenu(); } /** @@ -1290,105 +1241,6 @@ public class PopupMenu extends JPopupMenu textColour_actionPerformed(); } }); - noColourmenuItem.setText(MessageManager.getString("label.none")); - noColourmenuItem.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - noColourmenuItem_actionPerformed(); - } - }); - - clustalColour.setText(MessageManager - .getString("label.colourScheme_clustal")); - clustalColour.setName(JalviewColourScheme.Clustal.toString()); - clustalColour.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - clustalColour_actionPerformed(); - } - }); - zappoColour.setText(MessageManager - .getString("label.colourScheme_zappo")); - zappoColour.setName(JalviewColourScheme.Zappo.toString()); - zappoColour.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - zappoColour_actionPerformed(); - } - }); - taylorColour.setText(MessageManager - .getString("label.colourScheme_taylor")); - taylorColour.setName(JalviewColourScheme.Taylor.toString()); - taylorColour.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - taylorColour_actionPerformed(); - } - }); - hydrophobicityColour.setText(MessageManager - .getString("label.colourScheme_hydrophobic")); - hydrophobicityColour - .setName(JalviewColourScheme.Hydrophobic.toString()); - hydrophobicityColour.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - hydrophobicityColour_actionPerformed(); - } - }); - helixColour.setText(MessageManager - .getString("label.colourScheme_helix_propensity")); - helixColour.setName(JalviewColourScheme.Helix.toString()); - helixColour.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - helixColour_actionPerformed(); - } - }); - strandColour.setText(MessageManager - .getString("label.colourScheme_strand_propensity")); - strandColour.setName(JalviewColourScheme.Strand.toString()); - strandColour.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - strandColour_actionPerformed(); - } - }); - turnColour.setText(MessageManager - .getString("label.colourScheme_turn_propensity")); - turnColour.setName(JalviewColourScheme.Turn.toString()); - turnColour.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - turnColour_actionPerformed(); - } - }); - buriedColour.setText(MessageManager - .getString("label.colourScheme_buried_index")); - buriedColour.setName(JalviewColourScheme.Buried.toString()); - buriedColour.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - buriedColour_actionPerformed(); - } - }); abovePIDColour.setText(MessageManager .getString("label.above_identity_threshold")); abovePIDColour.addActionListener(new ActionListener() @@ -1399,81 +1251,6 @@ public class PopupMenu extends JPopupMenu abovePIDColour_actionPerformed(); } }); - userDefinedColour.setText(MessageManager - .getString("action.user_defined")); - userDefinedColour.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - userDefinedColour_actionPerformed(e); - } - }); - PIDColour -.setText(MessageManager - .getString("label.colourScheme_%_identity")); - PIDColour.setName(JalviewColourScheme.PID.toString()); - PIDColour.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - PIDColour_actionPerformed(); - } - }); - BLOSUM62Colour -.setText(MessageManager - .getString("label.colourScheme_blosum62")); - BLOSUM62Colour.setName(JalviewColourScheme.Blosum62.toString()); - BLOSUM62Colour.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - BLOSUM62Colour_actionPerformed(); - } - }); - nucleotideColour.setText(MessageManager - .getString("label.colourScheme_nucleotide")); - nucleotideColour.setName(JalviewColourScheme.Nucleotide.toString()); - nucleotideColour.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - nucleotideMenuItem_actionPerformed(); - } - }); - purinePyrimidineColour.setText(MessageManager - .getString("label.colourScheme_purine/pyrimidine")); - purinePyrimidineColour.setName(JalviewColourScheme.PurinePyrimidine - .toString()); - purinePyrimidineColour.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - purinePyrimidineColour_actionPerformed(); - } - }); - - tcoffeeColour.setText(MessageManager - .getString("label.colourScheme_t-coffee_scores")); - tcoffeeColour.setName(JalviewColourScheme.TCoffee.toString()); - tcoffeeColour.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - tcoffeeColorScheme_actionPerformed(); - } - }); - - /* - * covariationColour.addActionListener(new ActionListener() { - * public void actionPerformed(ActionEvent e) { - * covariationColour_actionPerformed(); } }); - */ conservationMenuItem.setText(MessageManager .getString("action.by_conservation")); @@ -1483,8 +1260,8 @@ public class PopupMenu extends JPopupMenu public void actionPerformed(ActionEvent e) { conservationMenuItem_actionPerformed(); - } - }); + } + }); } /** @@ -1497,95 +1274,12 @@ public class PopupMenu extends JPopupMenu colourMenu.removeAll(); colourMenu.add(textColour); colourMenu.addSeparator(); - colourMenu.add(noColourmenuItem); - colourMenu.add(clustalColour); - // in Java 8, isApplicableTo can be a static method on the interface - clustalColour.setEnabled(new ClustalxColourScheme(sg, null) - .isApplicableTo(sg)); - colourMenu.add(BLOSUM62Colour); - BLOSUM62Colour - .setEnabled(new Blosum62ColourScheme().isApplicableTo(sg)); - colourMenu.add(PIDColour); - PIDColour.setEnabled(new PIDColourScheme().isApplicableTo(sg)); - colourMenu.add(zappoColour); - zappoColour.setEnabled(new ZappoColourScheme().isApplicableTo(sg)); - colourMenu.add(taylorColour); - taylorColour.setEnabled(new TaylorColourScheme().isApplicableTo(sg)); - colourMenu.add(hydrophobicityColour); - hydrophobicityColour.setEnabled(new HydrophobicColourScheme() - .isApplicableTo(sg)); - colourMenu.add(helixColour); - helixColour.setEnabled(new HelixColourScheme().isApplicableTo(sg)); - colourMenu.add(strandColour); - strandColour.setEnabled(new StrandColourScheme().isApplicableTo(sg)); - colourMenu.add(turnColour); - turnColour.setEnabled(new TurnColourScheme().isApplicableTo(sg)); - colourMenu.add(buriedColour); - buriedColour.setEnabled(new BuriedColourScheme().isApplicableTo(sg)); - colourMenu.add(nucleotideColour); - nucleotideColour.setEnabled(new NucleotideColourScheme() - .isApplicableTo(sg)); - colourMenu.add(purinePyrimidineColour); - purinePyrimidineColour.setEnabled(new PurinePyrimidineColourScheme() - .isApplicableTo(sg)); - colourMenu.add(tcoffeeColour); - tcoffeeColour - .setEnabled(new TCoffeeColourScheme(sg).isApplicableTo(sg)); - /* - * add some of these items to a ButtonGroup so their - * selection is mutually exclusive - */ - ButtonGroup colours = new ButtonGroup(); - - /* - * add any user-defined colours loaded on startup or - * during the application session - */ - SortedMap userColourSchemes = UserDefinedColours - .getUserColourSchemes(); - if (userColourSchemes != null) - { - for (String userColour : userColourSchemes.keySet()) - { - JRadioButtonMenuItem item = new JRadioButtonMenuItem(userColour); - item.setName(userColour); // button name identifies selected colour - item.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent evt) - { - userDefinedColour_actionPerformed(evt); - } - }); - colourMenu.add(item); - colours.add(item); - } - } - colourMenu.add(userDefinedColour); + ColourMenuHelper.addMenuItems(colourMenu, this, sg); colourMenu.addSeparator(); colourMenu.add(conservationMenuItem); colourMenu.add(abovePIDColour); - - colours.add(noColourmenuItem); - colours.add(clustalColour); - colours.add(BLOSUM62Colour); - colours.add(PIDColour); - colours.add(zappoColour); - colours.add(taylorColour); - colours.add(hydrophobicityColour); - colours.add(helixColour); - colours.add(strandColour); - colours.add(turnColour); - colours.add(buriedColour); - colours.add(purinePyrimidineColour); - colours.add(tcoffeeColour); - colours.add(nucleotideColour); - colours.add(userDefinedColour); - colours.add(abovePIDColour); - // colours.add(RNAInteractionColour); - } /** @@ -1759,127 +1453,6 @@ public class PopupMenu extends JPopupMenu PaintRefresher.Refresh(this, ap.av.getSequenceSetId()); } - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - protected void clustalColour_actionPerformed() - { - SequenceGroup sg = getGroup(); - sg.cs = new ClustalxColourScheme(sg, ap.av.getHiddenRepSequences()); - refresh(); - } - - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - protected void zappoColour_actionPerformed() - { - getGroup().cs = new ZappoColourScheme(); - refresh(); - } - - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - protected void taylorColour_actionPerformed() - { - getGroup().cs = new TaylorColourScheme(); - refresh(); - } - - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - protected void hydrophobicityColour_actionPerformed() - { - getGroup().cs = new HydrophobicColourScheme(); - refresh(); - } - - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - protected void helixColour_actionPerformed() - { - getGroup().cs = new HelixColourScheme(); - refresh(); - } - - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - protected void strandColour_actionPerformed() - { - getGroup().cs = new StrandColourScheme(); - refresh(); - } - - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - protected void turnColour_actionPerformed() - { - getGroup().cs = new TurnColourScheme(); - refresh(); - } - - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - protected void buriedColour_actionPerformed() - { - getGroup().cs = new BuriedColourScheme(); - refresh(); - } - - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - public void nucleotideMenuItem_actionPerformed() - { - getGroup().cs = new NucleotideColourScheme(); - refresh(); - } - - protected void purinePyrimidineColour_actionPerformed() - { - getGroup().cs = new PurinePyrimidineColourScheme(); - refresh(); - } - - protected void tcoffeeColorScheme_actionPerformed() - { - getGroup().cs = new TCoffeeColourScheme(getGroup()); - refresh(); - } - /* * protected void covariationColour_actionPerformed() { getGroup().cs = new * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); } @@ -1921,30 +1494,6 @@ public class PopupMenu extends JPopupMenu } /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - protected void userDefinedColour_actionPerformed(ActionEvent e) - { - SequenceGroup sg = getGroup(); - - if (e.getSource().equals(userDefinedColour)) - { - new UserDefinedColours(ap, sg); - } - else - { - UserColourScheme udc = UserDefinedColours - .getUserColourSchemes().get(e.getActionCommand()); - - sg.cs = udc; - } - refresh(); - } - - /** * Open a panel where the user can choose which types of sequence annotation * to show or hide. * @@ -1962,53 +1511,6 @@ public class PopupMenu extends JPopupMenu * @param e * DOCUMENT ME! */ - protected void PIDColour_actionPerformed() - { - SequenceGroup sg = getGroup(); - sg.cs = new PIDColourScheme(); - sg.cs.setConsensus(AAFrequency.calculate( - sg.getSequences(ap.av.getHiddenRepSequences()), - sg.getStartRes(), sg.getEndRes() + 1)); - refresh(); - } - - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - protected void BLOSUM62Colour_actionPerformed() - { - SequenceGroup sg = getGroup(); - - sg.cs = new Blosum62ColourScheme(); - - sg.cs.setConsensus(AAFrequency.calculate( - sg.getSequences(ap.av.getHiddenRepSequences()), - sg.getStartRes(), sg.getEndRes() + 1)); - - refresh(); - } - - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ - protected void noColourmenuItem_actionPerformed() - { - getGroup().cs = null; - refresh(); - } - - /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! - */ protected void conservationMenuItem_actionPerformed() { SequenceGroup sg = getGroup(); @@ -2420,35 +1922,37 @@ public class PopupMenu extends JPopupMenu } /** - * Marks as selected the colour menu item matching the given name, or the - * first item ('None') if no match is found - * - * @param cs + * Action on user selecting an item from the colour menu (that does not have + * its bespoke action handler) */ - protected void setColourSelected(ColourSchemeI cs) + @Override + public void changeColour_actionPerformed(String colourSchemeName) { - noColourmenuItem.setSelected(true); - if (cs == null) + SequenceGroup sg = getGroup(); + if (ResidueColourScheme.USER_DEFINED.equals(colourSchemeName)) { - return; + /* + * open a panel to load or configure a user-defined colour scheme + */ + new UserDefinedColours(ap, sg); } - - String schemeName = cs.getSchemeName(); - /* - * look for a radio button with a name that matches the colour name - * (note the button text may not as it may be internationalised) - */ - for (Component menuItem : colourMenu.getMenuComponents()) + else { - if (menuItem instanceof JRadioButtonMenuItem) + /* + * switch to the chosen colour scheme (or null for None) + */ + sg.cs = ColourSchemes.getInstance().getColourScheme(colourSchemeName, + sg, ap.av.getHiddenRepSequences()); + if (sg.cs instanceof Blosum62ColourScheme + || sg.cs instanceof PIDColourScheme) { - if (schemeName.equals(((JRadioButtonMenuItem) menuItem).getName())) - { - ((JRadioButtonMenuItem) menuItem).setSelected(true); - return; - } + sg.cs.setConsensus(AAFrequency.calculate( + sg.getSequences(ap.av.getHiddenRepSequences()), + sg.getStartRes(), sg.getEndRes() + 1)); } } + + refresh(); } } diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index faa0d5d..dff20d3 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -31,7 +31,6 @@ import jalview.util.Platform; import java.awt.BorderLayout; import java.awt.Color; -import java.awt.Component; import java.awt.GridLayout; import java.awt.Toolkit; import java.awt.event.ActionEvent; @@ -84,8 +83,6 @@ public class GAlignFrame extends JInternalFrame protected JRadioButtonMenuItem textColour; - protected JRadioButtonMenuItem userDefinedColour; - protected JCheckBoxMenuItem annotationPanelMenuItem = new JCheckBoxMenuItem(); protected JCheckBoxMenuItem colourTextMenuItem = new JCheckBoxMenuItem(); @@ -98,8 +95,6 @@ public class GAlignFrame extends JInternalFrame protected JCheckBoxMenuItem conservationMenuItem; - protected JRadioButtonMenuItem noColourmenuItem; - protected JCheckBoxMenuItem wrapMenuItem = new JCheckBoxMenuItem(); protected JCheckBoxMenuItem renderGapsMenuItem = new JCheckBoxMenuItem(); @@ -249,37 +244,6 @@ public class GAlignFrame extends JInternalFrame } } - /** - * Marks as selected the colour menu item matching the given name, or the - * first item ('None') if no match is found - * - * @param colourName - */ - protected void setColourSelected(String colourName) - { - noColourmenuItem.setSelected(true); - if (colourName == null) - { - return; - } - - /* - * look for a radio button with a name that matches the colour name - * (note the button text may not as it may be internationalised) - */ - for (Component menuItem : colourMenu.getMenuComponents()) - { - if (menuItem instanceof JRadioButtonMenuItem) - { - if (colourName.equals(((JRadioButtonMenuItem) menuItem).getName())) - { - ((JRadioButtonMenuItem) menuItem).setSelected(true); - return; - } - } - } - } - private void jbInit() throws Exception { initColourMenu(); @@ -1942,9 +1906,7 @@ public class GAlignFrame extends JInternalFrame /** * 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 - * selection of items by colour scheme name. + * menu). */ protected void initColourMenu() { @@ -1970,18 +1932,6 @@ public class GAlignFrame extends JInternalFrame } }); - userDefinedColour = new JRadioButtonMenuItem( - MessageManager - .getString("action.user_defined")); - userDefinedColour.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - userDefinedColour_actionPerformed(e); - } - }); - conservationMenuItem = new JCheckBoxMenuItem( MessageManager.getString("action.by_conservation")); conservationMenuItem.addActionListener(new ActionListener() @@ -1992,17 +1942,6 @@ public class GAlignFrame extends JInternalFrame conservationMenuItem_actionPerformed(); } }); - noColourmenuItem = new JRadioButtonMenuItem( - MessageManager.getString("label.none")); - noColourmenuItem.setName("None"); - noColourmenuItem.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - noColourmenuItem_actionPerformed(); - } - }); abovePIDThreshold = new JCheckBoxMenuItem( MessageManager.getString("label.above_identity_threshold")); @@ -2403,20 +2342,6 @@ public class GAlignFrame extends JInternalFrame { } - protected void userDefinedColour_actionPerformed(ActionEvent e) - { - } - - - - /* - * protected void covariationColour_actionPerformed() { } - */ - - protected void noColourmenuItem_actionPerformed() - { - } - protected void conservationMenuItem_actionPerformed() { } diff --git a/src/jalview/schemes/ColourSchemeProperty.java b/src/jalview/schemes/ColourSchemeProperty.java index 53e9b60..5190c72 100755 --- a/src/jalview/schemes/ColourSchemeProperty.java +++ b/src/jalview/schemes/ColourSchemeProperty.java @@ -84,7 +84,7 @@ public class ColourSchemeProperty * create a new instance of it */ ColourSchemeI scheme = ColourSchemes.getInstance().getColourScheme( - name, forData); + name, forData, null); if (scheme != null) { return scheme; diff --git a/src/jalview/schemes/ColourSchemes.java b/src/jalview/schemes/ColourSchemes.java index 21faa2a..33ec966 100644 --- a/src/jalview/schemes/ColourSchemes.java +++ b/src/jalview/schemes/ColourSchemes.java @@ -1,7 +1,8 @@ package jalview.schemes; -import jalview.api.AlignViewportI; import jalview.datamodel.AnnotatedCollectionI; +import jalview.datamodel.SequenceCollectionI; +import jalview.datamodel.SequenceI; import java.util.LinkedHashMap; import java.util.Map; @@ -102,33 +103,39 @@ public class ColourSchemes * * @param name * name of the colour scheme - * @param viewport + * @param forData + * the data to be coloured + * @param optional + * map from hidden representative sequences to the sequences they + * represent * @return */ - public ColourSchemeI getColourScheme(String name, AlignViewportI viewport) + public ColourSchemeI getColourScheme(String name, + AnnotatedCollectionI forData, + Map hiddenRepSequences) { if (name == null) { return null; } ColourSchemeI cs = schemes.get(name.toLowerCase()); - return cs == null ? null : cs.getInstance(viewport.getAlignment(), - viewport.getHiddenRepSequences()); + return cs == null ? null : cs.getInstance(forData, hiddenRepSequences); } /** - * Returns an instance of the colour scheme with which the given data may be + * Returns an instance of the colour scheme with which the given view may be * coloured * * @param name + * name of the colour scheme * @param forData + * the data to be coloured * @return */ public ColourSchemeI getColourScheme(String name, AnnotatedCollectionI forData) { - ColourSchemeI cs = schemes.get(name.toLowerCase()); - return cs == null ? null : cs.getInstance(forData, null); + return getColourScheme(name, forData, null); } /** diff --git a/src/jalview/schemes/ResidueColourScheme.java b/src/jalview/schemes/ResidueColourScheme.java index 9cc4bd1..92de7ac 100755 --- a/src/jalview/schemes/ResidueColourScheme.java +++ b/src/jalview/schemes/ResidueColourScheme.java @@ -40,6 +40,8 @@ public abstract class ResidueColourScheme implements ColourSchemeI { public static final String NONE = "None"; + public static final String USER_DEFINED = "User Defined"; + /* * lookup up by character value e.g. 'G' to the colors array index * e.g. if symbolIndex['K'] = 11 then colors[11] is the colour for K @@ -360,12 +362,16 @@ public abstract class ResidueColourScheme implements ColourSchemeI } /* - * inspect the data context (alignment dataset) for residue type + * inspect the data context (alignment) for residue type */ boolean nucleotide = false; - AnnotatedCollectionI context = ac.getContext(); - if (context != null) + if (ac instanceof AlignmentI) + { + nucleotide = ((AlignmentI) ac).isNucleotide(); + } + else { + AnnotatedCollectionI context = ac.getContext(); if (context instanceof AlignmentI) { nucleotide = ((AlignmentI) context).isNucleotide(); @@ -376,14 +382,6 @@ public abstract class ResidueColourScheme implements ColourSchemeI return true; } } - else if (ac instanceof AlignmentI) - { - nucleotide = ((AlignmentI) ac).isNucleotide(); - } - else - { - return true; - } /* * does data type match colour scheme type? diff --git a/test/jalview/schemes/ColourSchemesTest.java b/test/jalview/schemes/ColourSchemesTest.java index 1bc6348..e44ed71 100644 --- a/test/jalview/schemes/ColourSchemesTest.java +++ b/test/jalview/schemes/ColourSchemesTest.java @@ -5,6 +5,7 @@ import static org.testng.Assert.assertTrue; import jalview.bin.Cache; import jalview.bin.Jalview; +import jalview.datamodel.AlignmentI; import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.SequenceCollectionI; import jalview.datamodel.SequenceI; @@ -57,8 +58,8 @@ public class ColourSchemesTest } @Override - public ColourSchemeI getInstance(AnnotatedCollectionI sg, - Map hiddenRepSequences) + public ColourSchemeI getInstance(AnnotatedCollectionI ac, + Map hrs) { return null; } @@ -194,34 +195,35 @@ public class ColourSchemesTest ColourSchemes cs = ColourSchemes.getInstance(); AlignViewport viewport = af.getViewport(); + AlignmentI alignment = viewport.getAlignment(); assertTrue(cs.getColourScheme(JalviewColourScheme.Blosum62.toString(), - viewport) instanceof Blosum62ColourScheme); + alignment) instanceof Blosum62ColourScheme); assertTrue(cs.getColourScheme(JalviewColourScheme.Buried.toString(), - viewport) instanceof BuriedColourScheme); + alignment) instanceof BuriedColourScheme); assertTrue(cs.getColourScheme(JalviewColourScheme.Clustal.toString(), - viewport) instanceof ClustalxColourScheme); + alignment) instanceof ClustalxColourScheme); assertTrue(cs.getColourScheme(JalviewColourScheme.Helix.toString(), - viewport) instanceof HelixColourScheme); + alignment) instanceof HelixColourScheme); assertTrue(cs.getColourScheme( - JalviewColourScheme.Hydrophobic.toString(), viewport) instanceof HydrophobicColourScheme); + JalviewColourScheme.Hydrophobic.toString(), alignment) instanceof HydrophobicColourScheme); assertTrue(cs.getColourScheme( - JalviewColourScheme.Nucleotide.toString(), viewport) instanceof NucleotideColourScheme); + JalviewColourScheme.Nucleotide.toString(), alignment) instanceof NucleotideColourScheme); assertTrue(cs.getColourScheme(JalviewColourScheme.PID.toString(), - viewport) instanceof PIDColourScheme); + alignment) instanceof PIDColourScheme); assertTrue(cs.getColourScheme( - JalviewColourScheme.PurinePyrimidine.toString(), viewport) instanceof PurinePyrimidineColourScheme); + JalviewColourScheme.PurinePyrimidine.toString(), alignment) instanceof PurinePyrimidineColourScheme); assertTrue(cs.getColourScheme( - JalviewColourScheme.RNAHelices.toString(), viewport) instanceof RNAHelicesColour); + JalviewColourScheme.RNAHelices.toString(), alignment) instanceof RNAHelicesColour); assertTrue(cs.getColourScheme(JalviewColourScheme.Strand.toString(), - viewport) instanceof StrandColourScheme); + alignment) instanceof StrandColourScheme); assertTrue(cs.getColourScheme(JalviewColourScheme.Taylor.toString(), - viewport) instanceof TaylorColourScheme); + alignment) instanceof TaylorColourScheme); assertTrue(cs.getColourScheme(JalviewColourScheme.TCoffee.toString(), - viewport) instanceof TCoffeeColourScheme); + alignment) instanceof TCoffeeColourScheme); assertTrue(cs.getColourScheme(JalviewColourScheme.Turn.toString(), - viewport) instanceof TurnColourScheme); + alignment) instanceof TurnColourScheme); assertTrue(cs.getColourScheme(JalviewColourScheme.Zappo.toString(), - viewport) instanceof ZappoColourScheme); + alignment) instanceof ZappoColourScheme); af.closeMenuItem_actionPerformed(true); } diff --git a/test/jalview/schemes/ResidueColourSchemeTest.java b/test/jalview/schemes/ResidueColourSchemeTest.java index e6dc9e6..077abd4 100644 --- a/test/jalview/schemes/ResidueColourSchemeTest.java +++ b/test/jalview/schemes/ResidueColourSchemeTest.java @@ -207,8 +207,7 @@ public class ResidueColourSchemeTest .isApplicableTo(peptide)); assertFalse(new ClustalxColourScheme(nucleotide, null) .isApplicableTo(nucleotide)); - // Blosum requires presence of Conservation annotation - assertFalse(new Blosum62ColourScheme().isApplicableTo(peptide)); + assertTrue(new Blosum62ColourScheme().isApplicableTo(peptide)); assertFalse(new Blosum62ColourScheme().isApplicableTo(nucleotide)); assertTrue(new BuriedColourScheme().isApplicableTo(peptide)); assertFalse(new BuriedColourScheme().isApplicableTo(nucleotide)); @@ -225,11 +224,6 @@ 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 */ -- 1.7.10.2