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;
import javax.swing.JMenuItem;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
+import javax.swing.event.MenuEvent;
+import javax.swing.event.MenuListener;
/**
* DOCUMENT ME!
sortPairwiseMenuItem_actionPerformed(null);
}
- this.alignPanel.av
- .setShowAutocalculatedAbove(isShowAutoCalculatedAbove());
-
setMenusFromViewport(viewport);
buildSortByAnnotationScoresMenu();
calculateTree.addActionListener(new ActionListener()
}
});
+ /*
+ * 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)
+ {
+ }
+ });
}
/**
}
/**
- * Store selected annotation sort order for the view and repaint.
+ * Sorts annotations and repaints the alignment
*/
@Override
- protected void sortAnnotations_actionPerformed()
+ protected void sortAnnotations()
{
- this.alignPanel.av.setSortAnnotationsBy(getAnnotationSortOrder());
- this.alignPanel.av
- .setShowAutocalculatedAbove(isShowAutoCalculatedAbove());
+ alignPanel.sortAnnotations();
alignPanel.paintAlignment(false, false);
}
}
}
+
+ @Override
+ protected boolean setShowAutoCalculatedAbove(
+ boolean showAutoCalculatedAbove)
+ {
+ if (viewport.isShowAutocalculatedAbove() != showAutoCalculatedAbove)
+ {
+ viewport.setShowAutocalculatedAbove(showAutoCalculatedAbove);
+
+ /*
+ * 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