X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FAlignFrame.java;h=092cf477ef0363b8723753141d340ada337e2c39;hb=23d8036c19be1f358742c213d0251163e0ab67a0;hp=8dd6d0cc5645218457849c85ca77cb0f8004dc54;hpb=2a7635954a40451d363a03e71393bf558413ef1e;p=jalview.git diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 8dd6d0c..092cf47 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -22,6 +22,7 @@ package jalview.gui; import jalview.analysis.AlignmentSorter; import jalview.analysis.AlignmentUtils; +import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; import jalview.analysis.CrossRef; import jalview.analysis.Dna; import jalview.analysis.GeneticCodeI; @@ -145,6 +146,8 @@ import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.JScrollPane; import javax.swing.SwingUtilities; +import javax.swing.event.MenuEvent; +import javax.swing.event.MenuListener; /** * DOCUMENT ME! @@ -362,9 +365,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, sortPairwiseMenuItem_actionPerformed(null); } - this.alignPanel.av - .setShowAutocalculatedAbove(isShowAutoCalculatedAbove()); - setMenusFromViewport(viewport); buildSortByAnnotationScoresMenu(); calculateTree.addActionListener(new ActionListener() @@ -481,6 +481,35 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } }); + /* + * ensure By Label/Sequence are not selected if annotations + * have been reordered manually to CUSTOM order + */ + annotationsMenu.addMenuListener(new MenuListener() + { + @Override + public void menuSelected(MenuEvent e) + { + SequenceAnnotationOrder sortAnnotationsBy = viewport + .getSortAnnotationsBy(); + sortAnnByLabel.setSelected( + sortAnnotationsBy == SequenceAnnotationOrder.LABEL_AND_SEQUENCE); + sortAnnBySequence.setSelected( + sortAnnotationsBy == SequenceAnnotationOrder.SEQUENCE_AND_LABEL); + } + + @Override + public void menuDeselected(MenuEvent e) + { + } + + @Override + public void menuCanceled(MenuEvent e) + { + } + }); + + alignPanel.sortAnnotations(); } /** @@ -974,7 +1003,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public void setStatus(String text) { - statusBar.setText(text); + statusBar.setText(text == null || text.isEmpty() ? " " : text); } /* @@ -3104,7 +3133,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, protected void scaleAbove_actionPerformed(ActionEvent e) { viewport.setScaleAboveWrapped(scaleAbove.isSelected()); - // TODO: do we actually need to update overview for scale above change ? + alignPanel.updateLayout(); alignPanel.paintAlignment(true, false); } @@ -3118,6 +3147,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, protected void scaleLeft_actionPerformed(ActionEvent e) { viewport.setScaleLeftWrapped(scaleLeft.isSelected()); + alignPanel.updateLayout(); alignPanel.paintAlignment(true, false); } @@ -3131,6 +3161,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, protected void scaleRight_actionPerformed(ActionEvent e) { viewport.setScaleRightWrapped(scaleRight.isSelected()); + alignPanel.updateLayout(); alignPanel.paintAlignment(true, false); } @@ -3352,6 +3383,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, * otherwise set the chosen colour scheme (or null for 'None') */ ColourSchemeI cs = ColourSchemes.getInstance().getColourScheme(name, + viewport, viewport.getAlignment(), viewport.getHiddenRepSequences()); changeColour(cs); } @@ -5308,7 +5340,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { PaintRefresher.Refresh(this, viewport.getSequenceSetId()); alignPanel.updateAnnotation(); - alignPanel.paintAlignment(true, true); + alignPanel.paintAlignment(true, + viewport.needToUpdateStructureViews()); } } @@ -5406,14 +5439,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } /** - * Store selected annotation sort order for the view and repaint. + * Sorts annotations and repaints the alignment */ @Override - protected void sortAnnotations_actionPerformed() + public void sortAnnotations() { - this.alignPanel.av.setSortAnnotationsBy(getAnnotationSortOrder()); - this.alignPanel.av - .setShowAutocalculatedAbove(isShowAutoCalculatedAbove()); + alignPanel.sortAnnotations(); alignPanel.paintAlignment(false, false); } @@ -5641,6 +5672,40 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } } + + /** + * Sets the flag for whether auto-calculated annotations should be shown above + * other annotations. If the given value is the same as the current setting, + * simply returns false. Otherwise updates the setting, and returns true. If + * annotation sort order is currently set to 'Custom', this is changed to + * 'None', because 'Custom' ordering ignores all sort options. + */ + @Override + public boolean setShowAutoCalculatedAbove(boolean b) + { + if (viewport.isShowAutocalculatedAbove() != b) + { + viewport.setShowAutocalculatedAbove(b); + + /* + * change CUSTOM annotation ordering to NONE + * so that sorting actually does something + */ + if (viewport.getSortAnnotationsBy() == SequenceAnnotationOrder.CUSTOM) + { + viewport.setSortAnnotationsBy(SequenceAnnotationOrder.NONE); + } + return true; + } + return false; + } + + @Override + public void setAnnotationSortOrder( + SequenceAnnotationOrder annotationSortOrder) + { + viewport.setSortAnnotationsBy(annotationSortOrder); + } } class PrintThread extends Thread