X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fjbgui%2FGAlignFrame.java;h=4ecedafd4a54ab4dcfe23cde33200a2058e94c66;hb=b28bddf12e2791a019fba9c233d46407deb65976;hp=5146128e1b793077c2f4b372eeee2a785aadc3e3;hpb=a3b4ec9805c4cee4c2dbe2a4c98913ee9c189c6b;p=jalview.git diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index 5146128..4ecedaf 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -20,8 +20,10 @@ */ package jalview.jbgui; +import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; import jalview.bin.Cache; import jalview.gui.JvSwingUtils; +import jalview.gui.Preferences; import jalview.schemes.ColourSchemeProperty; import jalview.util.MessageManager; @@ -65,6 +67,8 @@ public class GAlignFrame extends JInternalFrame protected JMenu viewMenu = new JMenu(); + protected JMenu annotationsMenu = new JMenu(); + protected JMenu colourMenu = new JMenu(); protected JMenu calculateMenu = new JMenu(); @@ -210,6 +214,8 @@ public class GAlignFrame extends JInternalFrame JMenuItem createPNG = new JMenuItem(); + JMenuItem createBioJS = new JMenuItem(); + JMenuItem createSVG = new JMenuItem(); protected JMenuItem font = new JMenuItem(); @@ -262,6 +268,8 @@ public class GAlignFrame extends JInternalFrame JMenuItem annotationColour = new JMenuItem(); + JMenuItem annotationColumn = new JMenuItem(); + protected JMenuItem rnahelicesColour = new JMenuItem(); JMenuItem associatedData = new JMenuItem(); @@ -306,9 +314,17 @@ public class GAlignFrame extends JInternalFrame JMenuItem showAllhidden = new JMenuItem(); - protected JMenuItem showAllAnnotations = new JMenuItem(); + protected JMenuItem showAllSeqAnnotations = new JMenuItem(); + + protected JMenuItem hideAllSeqAnnotations = new JMenuItem(); + + protected JMenuItem showAllAlAnnotations = new JMenuItem(); + + protected JMenuItem hideAllAlAnnotations = new JMenuItem(); - protected JMenuItem hideAllAnnotations = new JMenuItem(); + protected JCheckBoxMenuItem sortAnnBySequence = new JCheckBoxMenuItem(); + + protected JCheckBoxMenuItem sortAnnByLabel = new JCheckBoxMenuItem(); protected JCheckBoxMenuItem hiddenMarkers = new JCheckBoxMenuItem(); @@ -362,8 +378,16 @@ public class GAlignFrame extends JInternalFrame protected JCheckBoxMenuItem applyAutoAnnotationSettings = new JCheckBoxMenuItem(); + protected JRadioButtonMenuItem showAutoFirst = new JRadioButtonMenuItem(); + + protected JRadioButtonMenuItem showAutoLast = new JRadioButtonMenuItem(); + private JMenuItem grpsFromSelection = new JMenuItem(); + private SequenceAnnotationOrder annotationSortOrder; + + private boolean showAutoCalculatedAbove = false; + public GAlignFrame() { try @@ -613,6 +637,7 @@ public class GAlignFrame extends JInternalFrame }); editMenu.setText(MessageManager.getString("action.edit")); viewMenu.setText(MessageManager.getString("action.view")); + annotationsMenu.setText(MessageManager.getString("action.annotations")); colourMenu.setText(MessageManager.getString("action.colour")); calculateMenu.setText(MessageManager.getString("action.calculate")); webService.setText(MessageManager.getString("action.web_service")); @@ -1075,29 +1100,85 @@ public class GAlignFrame extends JInternalFrame annotationPanelMenuItem_actionPerformed(e); } }); - /* - * Show/hide all annotations only enabled if annotation panel is shown - */ - showAllAnnotations.setText(MessageManager - .getString("label.show_all_annotations")); - showAllAnnotations.setEnabled(annotationPanelMenuItem.getState()); - showAllAnnotations.addActionListener(new ActionListener() + showAllAlAnnotations.setText(MessageManager + .getString("label.show_all_al_annotations")); + final boolean isAnnotationPanelShown = annotationPanelMenuItem + .getState(); + showAllAlAnnotations.setEnabled(isAnnotationPanelShown); + showAllAlAnnotations.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + showAllAnnotations_actionPerformed(false, true); + } + }); + hideAllAlAnnotations.setText(MessageManager + .getString("label.hide_all_al_annotations")); + hideAllAlAnnotations.setEnabled(isAnnotationPanelShown); + hideAllAlAnnotations.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + hideAllAnnotations_actionPerformed(false, true); + } + }); + showAllSeqAnnotations.setText(MessageManager + .getString("label.show_all_seq_annotations")); + showAllSeqAnnotations.setEnabled(isAnnotationPanelShown); + showAllSeqAnnotations.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + showAllAnnotations_actionPerformed(true, false); + } + }); + hideAllSeqAnnotations.setText(MessageManager + .getString("label.hide_all_seq_annotations")); + hideAllSeqAnnotations.setEnabled(isAnnotationPanelShown); + hideAllSeqAnnotations.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + hideAllAnnotations_actionPerformed(true, false); + } + }); + SequenceAnnotationOrder sortAnnotationsBy = SequenceAnnotationOrder + .valueOf(Cache.getDefault(Preferences.SORT_ANNOTATIONS, + SequenceAnnotationOrder.NONE.name())); + sortAnnBySequence.setText(MessageManager + .getString("label.sort_annotations_by_sequence")); + sortAnnBySequence + .setSelected(sortAnnotationsBy == SequenceAnnotationOrder.SEQUENCE_AND_LABEL); + sortAnnBySequence.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - showAllAnnotations_actionPerformed(); + boolean newState = sortAnnBySequence.getState(); + sortAnnByLabel.setSelected(false); + setAnnotationSortOrder(newState ? SequenceAnnotationOrder.SEQUENCE_AND_LABEL + : SequenceAnnotationOrder.NONE); + sortAnnotations_actionPerformed(); } }); - hideAllAnnotations.setText(MessageManager - .getString("label.hide_all_annotations")); - hideAllAnnotations.setEnabled(annotationPanelMenuItem.getState()); - hideAllAnnotations.addActionListener(new ActionListener() + sortAnnByLabel.setText(MessageManager + .getString("label.sort_annotations_by_label")); + sortAnnByLabel + .setSelected(sortAnnotationsBy == SequenceAnnotationOrder.LABEL_AND_SEQUENCE); + sortAnnByLabel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - hideAllAnnotations_actionPerformed(); + boolean newState = sortAnnByLabel.getState(); + sortAnnBySequence.setSelected(false); + setAnnotationSortOrder(newState ? SequenceAnnotationOrder.LABEL_AND_SEQUENCE + : SequenceAnnotationOrder.NONE); + sortAnnotations_actionPerformed(); } }); colourTextMenuItem.setText(MessageManager @@ -1120,6 +1201,19 @@ public class GAlignFrame extends JInternalFrame htmlMenuItem_actionPerformed(e); } }); + + // TODO uncomment when supported by MassageManager + // createBioJS.setText(MessageManager.getString("label.biojs_html_export")); + createBioJS.setText("BioJS"); + createBioJS.addActionListener(new java.awt.event.ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + bioJSMenuItem_actionPerformed(e); + } + }); + overviewMenuItem.setText(MessageManager .getString("label.overview_window")); overviewMenuItem.addActionListener(new java.awt.event.ActionListener() @@ -1340,13 +1434,39 @@ public class GAlignFrame extends JInternalFrame applyAutoAnnotationSettings.setVisible(true); applyAutoAnnotationSettings.addActionListener(new ActionListener() { - @Override public void actionPerformed(ActionEvent e) { applyAutoAnnotationSettings_actionPerformed(e); } + }); + ButtonGroup buttonGroup = new ButtonGroup(); + buttonGroup.add(showAutoFirst); + buttonGroup.add(showAutoLast); + showAutoFirst.setText(MessageManager.getString("label.show_first")); + showAutoFirst.setSelected(Cache.getDefault( + Preferences.SHOW_AUTOCALC_ABOVE, + false)); + showAutoFirst.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + setShowAutoCalculatedAbove(showAutoFirst.isSelected()); + sortAnnotations_actionPerformed(); + } + }); + showAutoLast.setText(MessageManager.getString("label.show_last")); + showAutoLast.setSelected(!showAutoFirst.isSelected()); + showAutoLast.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + setShowAutoCalculatedAbove(!showAutoLast.isSelected()); + sortAnnotations_actionPerformed(); + } }); nucleotideColour.setText(MessageManager.getString("label.nucleotide")); @@ -1500,7 +1620,6 @@ public class GAlignFrame extends JInternalFrame font_actionPerformed(e); } }); - seqLimits.setText(MessageManager .getString("label.show_sequence_limits")); seqLimits.setState(jalview.bin.Cache.getDefault("SHOW_JVSUFFIX", true)); @@ -1650,7 +1769,7 @@ public class GAlignFrame extends JInternalFrame sortByAnnotScore.setText(MessageManager .getString("label.sort_by_score")); sort.add(sortByAnnotScore); - sortByAnnotScore.addMenuListener(new javax.swing.event.MenuListener() + sort.addMenuListener(new javax.swing.event.MenuListener() { @Override @@ -1757,6 +1876,17 @@ public class GAlignFrame extends JInternalFrame } }); + annotationColumn.setText(MessageManager + .getString("action.select_by_annotation")); + annotationColumn.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + annotationColumn_actionPerformed(e); + } + }); + rnahelicesColour.setText(MessageManager .getString("action.by_rna_helixes")); rnahelicesColour.addActionListener(new ActionListener() @@ -2115,6 +2245,7 @@ public class GAlignFrame extends JInternalFrame alignFrameMenuBar.add(editMenu); alignFrameMenuBar.add(selectMenu); alignFrameMenuBar.add(viewMenu); + alignFrameMenuBar.add(annotationsMenu); alignFrameMenuBar.add(formatMenu); alignFrameMenuBar.add(colourMenu); alignFrameMenuBar.add(calculateMenu); @@ -2164,9 +2295,19 @@ public class GAlignFrame extends JInternalFrame viewMenu.add(hideMenu); viewMenu.addSeparator(); viewMenu.add(followHighlightMenuItem); - viewMenu.add(annotationPanelMenuItem); - viewMenu.add(showAllAnnotations); - viewMenu.add(hideAllAnnotations); + annotationsMenu.add(annotationPanelMenuItem); + annotationsMenu.addSeparator(); + annotationsMenu.add(showAllAlAnnotations); + annotationsMenu.add(hideAllAlAnnotations); + annotationsMenu.addSeparator(); + annotationsMenu.add(showAllSeqAnnotations); + annotationsMenu.add(hideAllSeqAnnotations); + annotationsMenu.add(sortAnnBySequence); + annotationsMenu.add(sortAnnByLabel); + annotationsMenu.addSeparator(); + autoAnnMenu.add(showAutoFirst); + autoAnnMenu.add(showAutoLast); + autoAnnMenu.addSeparator(); autoAnnMenu.add(applyAutoAnnotationSettings); autoAnnMenu.add(showConsensusHistogram); autoAnnMenu.add(showSequenceLogo); @@ -2174,7 +2315,7 @@ public class GAlignFrame extends JInternalFrame autoAnnMenu.addSeparator(); autoAnnMenu.add(showGroupConservation); autoAnnMenu.add(showGroupConsensus); - viewMenu.add(autoAnnMenu); + annotationsMenu.add(autoAnnMenu); viewMenu.addSeparator(); viewMenu.add(showSeqFeatures); // viewMenu.add(showSeqFeaturesHeight); @@ -2239,6 +2380,7 @@ public class GAlignFrame extends JInternalFrame jMenu2.add(htmlMenuItem); jMenu2.add(epsFile); jMenu2.add(createPNG); + jMenu2.add(createBioJS); jMenu2.add(createSVG); addSequenceMenu.add(addFromFile); addSequenceMenu.add(addFromText); @@ -2279,6 +2421,7 @@ public class GAlignFrame extends JInternalFrame selectMenu.add(unGroup); selectMenu.add(grpsFromSelection); selectMenu.add(deleteGroups); + selectMenu.add(annotationColumn); calculateMenu.add(expandAlignment); // TODO - determine if the listenToViewSelections button is needed : see bug // JAL-574 @@ -2287,27 +2430,54 @@ public class GAlignFrame extends JInternalFrame } /** + * Action on clicking sort annotations by type. + * + * @param sortOrder + */ + protected void sortAnnotations_actionPerformed() + { + } + + /** * Action on clicking Show all annotations. + * + * @param forSequences + * update sequence-related annotations + * @param forAlignment + * update non-sequence-related annotations */ - protected void showAllAnnotations_actionPerformed() + protected void showAllAnnotations_actionPerformed(boolean forSequences, + boolean forAlignment) { - setAllAnnotationsVisibility(true); + setAnnotationsVisibility(true, forSequences, forAlignment); } /** * Action on clicking Hide all annotations. + * + * @param forSequences + * update sequence-related annotations + * @param forAlignment + * update non-sequence-related annotations */ - protected void hideAllAnnotations_actionPerformed() + protected void hideAllAnnotations_actionPerformed(boolean forSequences, + boolean forAlignment) { - setAllAnnotationsVisibility(false); + setAnnotationsVisibility(false, forSequences, forAlignment); } /** - * Set the visibility of all annotations to true or false. + * Set the visibility of annotations to true or false. Can act on + * sequence-related annotations, or alignment-related, or both. * * @param visible + * @param forSequences + * update sequence-related annotations + * @param forAlignment + * update non-sequence-related annotations */ - protected void setAllAnnotationsVisibility(boolean visible) + protected void setAnnotationsVisibility(boolean visible, + boolean forSequences, boolean forAlignment) { } @@ -2470,6 +2640,11 @@ public class GAlignFrame extends JInternalFrame { } + protected void bioJSMenuItem_actionPerformed(ActionEvent e) + { + + } + protected void closeMenuItem_actionPerformed(boolean b) { } @@ -2825,6 +3000,11 @@ public class GAlignFrame extends JInternalFrame } + public void annotationColumn_actionPerformed(ActionEvent e) + { + + } + public void rnahelicesColour_actionPerformed(ActionEvent e) { @@ -2960,4 +3140,24 @@ public class GAlignFrame extends JInternalFrame // TODO Auto-generated method stub } + + protected boolean isShowAutoCalculatedAbove() + { + return showAutoCalculatedAbove; + } + + protected void setShowAutoCalculatedAbove(boolean showAutoCalculatedAbove) + { + this.showAutoCalculatedAbove = showAutoCalculatedAbove; + } + + protected SequenceAnnotationOrder getAnnotationSortOrder() + { + return annotationSortOrder; + } + + protected void setAnnotationSortOrder(SequenceAnnotationOrder annotationSortOrder) + { + this.annotationSortOrder = annotationSortOrder; + } }