X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fjbgui%2FGAlignFrame.java;h=e546608959429e9c52203b7d2070b41c138b52b6;hb=ab43013b7e357b84b4abade0dba949668dfb2a0e;hp=35910565c9445833b7b068ce31d9b3ede740fccf;hpb=d305e02d8b425bb501141ad32142aeb8572adc57;p=jalview.git diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index 3591056..e546608 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -1,5 +1,5 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1) * Copyright (C) 2014 The Jalview Authors * * This file is part of Jalview. @@ -20,9 +20,10 @@ */ package jalview.jbgui; -import jalview.analysis.AnnotationSorter.SortOrder; +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; @@ -213,6 +214,8 @@ public class GAlignFrame extends JInternalFrame JMenuItem createPNG = new JMenuItem(); + JMenuItem createSVG = new JMenuItem(); + protected JMenuItem font = new JMenuItem(); public JCheckBoxMenuItem seqLimits = new JCheckBoxMenuItem(); @@ -307,13 +310,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 hideAllAnnotations = new JMenuItem(); + protected JMenuItem showAllAlAnnotations = new JMenuItem(); + + protected JMenuItem hideAllAlAnnotations = new JMenuItem(); protected JCheckBoxMenuItem sortAnnBySequence = new JCheckBoxMenuItem(); - protected JCheckBoxMenuItem sortAnnByType = new JCheckBoxMenuItem(); + protected JCheckBoxMenuItem sortAnnByLabel = new JCheckBoxMenuItem(); protected JCheckBoxMenuItem hiddenMarkers = new JCheckBoxMenuItem(); @@ -367,8 +374,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 @@ -1081,57 +1096,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) { - showAllAnnotations_actionPerformed(); + hideAllAnnotations_actionPerformed(false, true); } }); - hideAllAnnotations.setText(MessageManager - .getString("label.hide_all_annotations")); - hideAllAnnotations.setEnabled(annotationPanelMenuItem.getState()); - hideAllAnnotations.addActionListener(new ActionListener() + showAllSeqAnnotations.setText(MessageManager + .getString("label.show_all_seq_annotations")); + showAllSeqAnnotations.setEnabled(isAnnotationPanelShown); + showAllSeqAnnotations.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - hideAllAnnotations_actionPerformed(); + 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) { - sortAnnBySequence.setEnabled(false); - sortAnnBySequence.setState(true); - sortAnnByType.setEnabled(true); - sortAnnByType.setState(false); - sortAnnotations_actionPerformed(SortOrder.SEQUENCE_AND_TYPE); + boolean newState = sortAnnBySequence.getState(); + sortAnnByLabel.setSelected(false); + setAnnotationSortOrder(newState ? SequenceAnnotationOrder.SEQUENCE_AND_LABEL + : SequenceAnnotationOrder.NONE); + sortAnnotations_actionPerformed(); } }); - sortAnnByType.setText(MessageManager - .getString("label.sort_annotations_by_type")); - sortAnnByType.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) { - sortAnnByType.setEnabled(false); - sortAnnByType.setState(true); - sortAnnBySequence.setEnabled(true); - sortAnnBySequence.setState(false); - sortAnnotations_actionPerformed(SortOrder.TYPE_AND_SEQUENCE); + boolean newState = sortAnnByLabel.getState(); + sortAnnBySequence.setSelected(false); + setAnnotationSortOrder(newState ? SequenceAnnotationOrder.LABEL_AND_SEQUENCE + : SequenceAnnotationOrder.NONE); + sortAnnotations_actionPerformed(); } }); colourTextMenuItem.setText(MessageManager @@ -1374,13 +1417,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")); @@ -1524,6 +1593,7 @@ public class GAlignFrame extends JInternalFrame createPNG.setActionCommand(MessageManager .getString("label.save_png_image")); createPNG.setText("PNG"); + font.setText(MessageManager.getString("action.font")); font.addActionListener(new java.awt.event.ActionListener() { @@ -1554,6 +1624,17 @@ public class GAlignFrame extends JInternalFrame createEPS(null); } }); + + createSVG.setText("SVG"); + createSVG.addActionListener(new java.awt.event.ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + createSVG(null); + } + }); + LoadtreeMenuItem.setActionCommand(MessageManager .getString("label.load_tree_for_sequence_set")); LoadtreeMenuItem.setText(MessageManager @@ -1672,7 +1753,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 @@ -2188,10 +2269,18 @@ public class GAlignFrame extends JInternalFrame viewMenu.addSeparator(); viewMenu.add(followHighlightMenuItem); annotationsMenu.add(annotationPanelMenuItem); - annotationsMenu.add(showAllAnnotations); - annotationsMenu.add(hideAllAnnotations); + annotationsMenu.addSeparator(); + annotationsMenu.add(showAllAlAnnotations); + annotationsMenu.add(hideAllAlAnnotations); + annotationsMenu.addSeparator(); + annotationsMenu.add(showAllSeqAnnotations); + annotationsMenu.add(hideAllSeqAnnotations); annotationsMenu.add(sortAnnBySequence); - annotationsMenu.add(sortAnnByType); + annotationsMenu.add(sortAnnByLabel); + annotationsMenu.addSeparator(); + autoAnnMenu.add(showAutoFirst); + autoAnnMenu.add(showAutoLast); + autoAnnMenu.addSeparator(); autoAnnMenu.add(applyAutoAnnotationSettings); autoAnnMenu.add(showConsensusHistogram); autoAnnMenu.add(showSequenceLogo); @@ -2264,6 +2353,7 @@ public class GAlignFrame extends JInternalFrame jMenu2.add(htmlMenuItem); jMenu2.add(epsFile); jMenu2.add(createPNG); + jMenu2.add(createSVG); addSequenceMenu.add(addFromFile); addSequenceMenu.add(addFromText); addSequenceMenu.add(addFromURL); @@ -2315,32 +2405,50 @@ public class GAlignFrame extends JInternalFrame * * @param sortOrder */ - protected void sortAnnotations_actionPerformed(SortOrder 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) { } @@ -2756,6 +2864,10 @@ public class GAlignFrame extends JInternalFrame { } + public void createSVG(java.io.File f) + { + + } protected void LoadtreeMenuItem_actionPerformed(ActionEvent e) { @@ -2989,4 +3101,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; + } }