From: gmungoc Date: Thu, 5 Jan 2017 12:24:37 +0000 (+0000) Subject: Merge branch 'develop' into features/JAL-2360colourSchemeApplicability X-Git-Tag: Release_2_10_3b1~357^2~16^2~3 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=67ba2560892f47d848754a97c7a809c7b8f8b3fb;p=jalview.git Merge branch 'develop' into features/JAL-2360colourSchemeApplicability Conflicts: src/jalview/gui/PopupMenu.java --- 67ba2560892f47d848754a97c7a809c7b8f8b3fb diff --cc src/jalview/appletgui/APopupMenu.java index 2f5ac3a,6e5f130..b0f8347 --- a/src/jalview/appletgui/APopupMenu.java +++ b/src/jalview/appletgui/APopupMenu.java @@@ -41,11 -41,10 +41,13 @@@ import jalview.io.SequenceAnnotationRep 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.PIDColourScheme; +import jalview.schemes.PurinePyrimidineColourScheme; import jalview.schemes.StrandColourScheme; import jalview.schemes.TaylorColourScheme; import jalview.schemes.TurnColourScheme; @@@ -78,33 -76,33 +80,37 @@@ public class APopupMenu extends java.aw MenuItem editGroupName = new MenuItem(); -- protected MenuItem clustalColour = new MenuItem(); ++ CheckboxMenuItem noColour = new CheckboxMenuItem(); -- protected MenuItem zappoColour = new MenuItem(); ++ protected CheckboxMenuItem clustalColour = new CheckboxMenuItem(); -- protected MenuItem taylorColour = new MenuItem(); ++ protected CheckboxMenuItem zappoColour = new CheckboxMenuItem(); -- protected MenuItem hydrophobicityColour = new MenuItem(); ++ protected CheckboxMenuItem taylorColour = new CheckboxMenuItem(); -- protected MenuItem helixColour = new MenuItem(); ++ protected CheckboxMenuItem hydrophobicityColour = new CheckboxMenuItem(); -- protected MenuItem strandColour = new MenuItem(); ++ protected CheckboxMenuItem helixColour = new CheckboxMenuItem(); -- protected MenuItem turnColour = new MenuItem(); ++ protected CheckboxMenuItem strandColour = new CheckboxMenuItem(); -- protected MenuItem buriedColour = new MenuItem(); ++ protected CheckboxMenuItem turnColour = new CheckboxMenuItem(); -- protected CheckboxMenuItem abovePIDColour = new CheckboxMenuItem(); ++ protected CheckboxMenuItem buriedColour = new CheckboxMenuItem(); -- protected MenuItem userDefinedColour = new MenuItem(); ++ protected CheckboxMenuItem PIDColour = new CheckboxMenuItem(); -- protected MenuItem PIDColour = new MenuItem(); ++ protected CheckboxMenuItem BLOSUM62Colour = new CheckboxMenuItem(); -- protected MenuItem BLOSUM62Colour = new MenuItem(); ++ CheckboxMenuItem nucleotideColour = new CheckboxMenuItem(); -- MenuItem noColourmenuItem = new MenuItem(); ++ CheckboxMenuItem purinePyrimidineColour = new CheckboxMenuItem(); -- protected CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem(); ++ protected MenuItem userDefinedColour = new MenuItem(); ++ ++ protected CheckboxMenuItem abovePIDColour = new CheckboxMenuItem(); ++ ++ protected CheckboxMenuItem conservationColour = new CheckboxMenuItem(); final AlignmentPanel ap; @@@ -112,10 -110,8 +118,6 @@@ MenuItem createGroupMenuItem = new MenuItem(); -- MenuItem nucleotideMenuItem = new MenuItem(); -- - MenuItem purinePyrimidineMenuItem = new MenuItem(); - Menu colourMenu = new Menu(); CheckboxMenuItem showBoxes = new CheckboxMenuItem(); @@@ -248,8 -244,12 +250,13 @@@ { menu1.setLabel(MessageManager.getString("action.edit_group")); groupMenu.remove(createGroupMenuItem); + if (sg.cs != null) + { + abovePIDColour.setState(sg.cs.getThreshold() > 0); - conservationMenuItem.setState(sg.cs.conservationApplied()); ++ conservationColour.setState(sg.cs.conservationApplied()); + } } - ++ setSelectedColour(sg.cs); } else { @@@ -307,6 -307,6 +314,35 @@@ } /** ++ * Select the menu item (if any) matching the current colour scheme. This ++ * works by matching the menu item name (not display text) to the canonical ++ * name of the colour scheme. ++ * ++ * @param cs ++ */ ++ protected void setSelectedColour(ColourSchemeI cs) ++ { ++ if (cs == null) ++ { ++ noColour.setState(true); ++ } ++ else ++ { ++ for (int i = 0; i < colourMenu.getItemCount(); i++) ++ { ++ MenuItem item = colourMenu.getItem(i); ++ if (item instanceof CheckboxMenuItem) ++ { ++ if (cs.getSchemeName().equals(item.getName())) ++ { ++ ((CheckboxMenuItem) item).setState(true); ++ } ++ } ++ } ++ } ++ } ++ ++ /** * Adds a 'Link' menu item with a sub-menu item for each hyperlink provided. * * @param seq @@@ -501,38 -501,43 +537,28 @@@ linkMenu.add(item); } ++ /** ++ * Actions on selecting / unselecting a checkbox menu item ++ */ @Override public void itemStateChanged(ItemEvent evt) { - if (evt.getSource() == abovePIDColour) - { - abovePIDColour_itemStateChanged(); - } - else if (evt.getSource() == showColourText) - { - showColourText_itemStateChanged(); - } - else if (evt.getSource() == showText) + Object source = evt.getSource(); - if (source == abovePIDColour) - { - abovePIDColour_itemStateChanged(); - } - else if (source == conservationMenuItem) ++ if (source == noColour) { - showText_itemStateChanged(); - conservationMenuItem_itemStateChanged(); - } - else if (source == showColourText) - { - showColourText_itemStateChanged(); - } - else if (source == showText) - { - showText_itemStateChanged(); ++ noColourmenuItem_actionPerformed(); } - else if (evt.getSource() == showBoxes) - else if (source == showBoxes) ++ else if (source == clustalColour) { -- showBoxes_itemStateChanged(); ++ clustalColour_actionPerformed(); } - else if (evt.getSource() == displayNonconserved) - else if (source == displayNonconserved) ++ else if (source == BLOSUM62Colour) { -- this.showNonconserved_itemStateChanged(); ++ BLOSUM62Colour_actionPerformed(); } -- } -- -- @Override -- public void actionPerformed(ActionEvent evt) -- { -- Object source = evt.getSource(); -- if (source == clustalColour) ++ else if (source == PIDColour) { -- clustalColour_actionPerformed(); ++ PIDColour_actionPerformed(); } else if (source == zappoColour) { @@@ -562,34 -567,26 +588,50 @@@ { buriedColour_actionPerformed(); } -- else if (source == nucleotideMenuItem) ++ else if (source == nucleotideColour) { nucleotideMenuItem_actionPerformed(); } - else if (source == purinePyrimidineMenuItem) - - else if (source == userDefinedColour) ++ else if (source == purinePyrimidineColour) { - userDefinedColour_actionPerformed(); + purinePyrimidineColour_actionPerformed(); } - - else if (source == userDefinedColour) - else if (source == PIDColour) ++ else if (source == abovePIDColour) { - userDefinedColour_actionPerformed(); - PIDColour_actionPerformed(); ++ abovePIDColour_itemStateChanged(); } - else if (source == PIDColour) - else if (source == BLOSUM62Colour) ++ else if (source == conservationColour) { - PIDColour_actionPerformed(); - BLOSUM62Colour_actionPerformed(); ++ conservationMenuItem_itemStateChanged(); } - else if (source == BLOSUM62Colour) - else if (source == noColourmenuItem) ++ else if (source == showColourText) { - BLOSUM62Colour_actionPerformed(); - noColourmenuItem_actionPerformed(); ++ showColourText_itemStateChanged(); + } - else if (source == noColourmenuItem) ++ else if (source == showText) + { - noColourmenuItem_actionPerformed(); ++ showText_itemStateChanged(); + } - else if (source == conservationMenuItem) ++ else if (source == showBoxes) + { - conservationMenuItem_itemStateChanged(); ++ showBoxes_itemStateChanged(); ++ } ++ else if (source == displayNonconserved) ++ { ++ this.showNonconserved_itemStateChanged(); ++ } ++ } ++ ++ /** ++ * Actions on clicking a menu item ++ */ ++ @Override ++ public void actionPerformed(ActionEvent evt) ++ { ++ Object source = evt.getSource(); ++ if (source == userDefinedColour) ++ { ++ userDefinedColour_actionPerformed(); } else if (source == unGroupMenuItem) { @@@ -938,7 -940,7 +980,7 @@@ groupMenu.add(unGroupMenuItem); groupMenu.add(menu1); -- colourMenu.add(noColourmenuItem); ++ colourMenu.add(noColour); colourMenu.add(clustalColour); colourMenu.add(BLOSUM62Colour); colourMenu.add(PIDColour); @@@ -949,62 -951,48 +991,80 @@@ colourMenu.add(strandColour); colourMenu.add(turnColour); colourMenu.add(buriedColour); -- colourMenu.add(nucleotideMenuItem); - colourMenu.add(purinePyrimidineMenuItem); ++ colourMenu.add(nucleotideColour); ++ colourMenu.add(purinePyrimidineColour); colourMenu.add(userDefinedColour); colourMenu.addSeparator(); colourMenu.add(abovePIDColour); -- colourMenu.add(conservationMenuItem); ++ colourMenu.add(conservationColour); -- noColourmenuItem.setLabel(MessageManager.getString("label.none")); -- noColourmenuItem.addActionListener(this); ++ noColour.setLabel(MessageManager.getString("label.none")); ++ noColour.addItemListener(this); ++ /* ++ * setName allows setSelectedColour to do its thing ++ */ clustalColour.setLabel(MessageManager - .getString("label.clustalx_colours")); - clustalColour.addActionListener(this); - zappoColour.setLabel(MessageManager.getString("label.zappo")); - zappoColour.addActionListener(this); - taylorColour.setLabel(MessageManager.getString("label.taylor")); - taylorColour.addActionListener(this); + .getString("label.colourScheme_clustal")); - clustalColour.addActionListener(this); ++ clustalColour.setName(JalviewColourScheme.Clustal.toString()); ++ clustalColour.addItemListener(this); ++ BLOSUM62Colour.setLabel(MessageManager ++ .getString("label.colourScheme_blosum62")); ++ BLOSUM62Colour.setName(JalviewColourScheme.Blosum62.toString()); ++ BLOSUM62Colour.addItemListener(this); ++ PIDColour.setLabel(MessageManager ++ .getString("label.colourScheme_%_identity")); ++ PIDColour.setName(JalviewColourScheme.PID.toString()); ++ PIDColour.addItemListener(this); + zappoColour.setLabel(MessageManager + .getString("label.colourScheme_zappo")); - zappoColour.addActionListener(this); ++ zappoColour.setName(JalviewColourScheme.Zappo.toString()); ++ zappoColour.addItemListener(this); + taylorColour.setLabel(MessageManager + .getString("label.colourScheme_taylor")); - taylorColour.addActionListener(this); ++ taylorColour.setName(JalviewColourScheme.Taylor.toString()); ++ taylorColour.addItemListener(this); hydrophobicityColour.setLabel(MessageManager - .getString("label.hydrophobicity")); - hydrophobicityColour.addActionListener(this); - helixColour - .setLabel(MessageManager.getString("label.helix_propensity")); - helixColour.addActionListener(this); + .getString("label.colourScheme_hydrophobic")); - hydrophobicityColour.addActionListener(this); ++ hydrophobicityColour ++ .setName(JalviewColourScheme.Hydrophobic.toString()); ++ hydrophobicityColour.addItemListener(this); + helixColour.setLabel(MessageManager + .getString("label.colourScheme_helix_propensity")); - helixColour.addActionListener(this); ++ helixColour.setName(JalviewColourScheme.Helix.toString()); ++ helixColour.addItemListener(this); strandColour.setLabel(MessageManager - .getString("label.strand_propensity")); - strandColour.addActionListener(this); - turnColour.setLabel(MessageManager.getString("label.turn_propensity")); - turnColour.addActionListener(this); - buriedColour.setLabel(MessageManager.getString("label.buried_index")); - buriedColour.addActionListener(this); - abovePIDColour.setLabel(MessageManager - .getString("label.above_identity_percentage")); + .getString("label.colourScheme_strand_propensity")); - strandColour.addActionListener(this); ++ strandColour.setName(JalviewColourScheme.Strand.toString()); ++ strandColour.addItemListener(this); + turnColour.setLabel(MessageManager + .getString("label.colourScheme_turn_propensity")); - turnColour.addActionListener(this); ++ turnColour.setName(JalviewColourScheme.Turn.toString()); ++ turnColour.addItemListener(this); + buriedColour.setLabel(MessageManager + .getString("label.colourScheme_buried_index")); - buriedColour.addActionListener(this); - abovePIDColour.setLabel(MessageManager - .getString("label.above_identity_threshold")); ++ buriedColour.setName(JalviewColourScheme.Buried.toString()); ++ buriedColour.addItemListener(this); ++ nucleotideColour.setLabel(MessageManager ++ .getString("label.colourScheme_nucleotide")); ++ nucleotideColour.setName(JalviewColourScheme.Nucleotide.toString()); ++ nucleotideColour.addItemListener(this); ++ purinePyrimidineColour.setLabel(MessageManager ++ .getString("label.colourScheme_purine/pyrimidine")); ++ purinePyrimidineColour.setName(JalviewColourScheme.PurinePyrimidine ++ .toString()); ++ purinePyrimidineColour.addItemListener(this); userDefinedColour.setLabel(MessageManager .getString("action.user_defined")); userDefinedColour.addActionListener(this); -- PIDColour.setLabel(MessageManager - .getString("label.colourScheme_%_identity")); - PIDColour.addActionListener(this); - BLOSUM62Colour.setLabel(MessageManager - .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); - .getString("label.percentage_identity")); - PIDColour.addActionListener(this); - BLOSUM62Colour.setLabel("BLOSUM62"); - BLOSUM62Colour.addActionListener(this); - conservationMenuItem.setLabel(MessageManager ++ ++ abovePIDColour.setLabel(MessageManager ++ .getString("label.above_identity_threshold")); + abovePIDColour.addItemListener(this); ++ conservationColour.setLabel(MessageManager + .getString("label.conservation")); ++ conservationColour.addItemListener(this); editMenu.add(copy); copy.addActionListener(this); @@@ -1182,7 -1164,7 +1242,7 @@@ return; } -- if (conservationMenuItem.getState()) ++ if (conservationColour.getState()) { sg.cs.setConservation(Conservation.calculateConservation("Group", sg .getSequences(ap.av.getHiddenRepSequences()), 0, ap.av diff --cc src/jalview/gui/PopupMenu.java index ffa8b9c,a93c92e..f3927df --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@@ -421,11 -476,74 +421,18 @@@ public class PopupMenu extends JPopupMe groupName.setText(MessageManager .getString("label.edit_name_and_description_current_group")); - if (sg.cs instanceof ZappoColourScheme) - { - zappoColour.setSelected(true); - } - else if (sg.cs instanceof TaylorColourScheme) - { - taylorColour.setSelected(true); - } - else if (sg.cs instanceof PIDColourScheme) - { - PIDColour.setSelected(true); - } - else if (sg.cs instanceof Blosum62ColourScheme) - { - BLOSUM62Colour.setSelected(true); - } - else if (sg.cs instanceof UserColourScheme) - { - userDefinedColour.setSelected(true); - } - else if (sg.cs instanceof HydrophobicColourScheme) - { - hydrophobicityColour.setSelected(true); - } - else if (sg.cs instanceof HelixColourScheme) - { - helixColour.setSelected(true); - } - else if (sg.cs instanceof StrandColourScheme) - { - strandColour.setSelected(true); - } - else if (sg.cs instanceof TurnColourScheme) - { - turnColour.setSelected(true); - } - else if (sg.cs instanceof BuriedColourScheme) - { - buriedColour.setSelected(true); - } - else if (sg.cs instanceof ClustalxColourScheme) - { - clustalColour.setSelected(true); - } - else if (sg.cs instanceof PurinePyrimidineColourScheme) - { - purinePyrimidineColour.setSelected(true); - } - - /* - * else if (sg.cs instanceof CovariationColourScheme) { - * covariationColour.setSelected(true); } - */ - else - { - noColourmenuItem.setSelected(true); - } + ColourMenuHelper.setColourSelected(colourMenu, sg.cs); - if (sg.cs != null && sg.cs.conservationApplied()) + if (sg.cs != null) { - conservationMenuItem.setSelected(true); + if (sg.cs.conservationApplied()) + { - conservationMenuItem.setSelected(true); ++ conservationMenuItem.setSelected(true); + } + if (sg.cs.getThreshold() > 0) + { + abovePIDColour.setSelected(true); + } } displayNonconserved.setSelected(sg.getShowNonconserved()); showText.setSelected(sg.getDisplayText());