From: gmungoc Date: Fri, 8 Nov 2019 09:37:12 +0000 (+0000) Subject: JAL-3081 restore annotation ordering from project (work in progress) X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=23d8036c19be1f358742c213d0251163e0ab67a0;p=jalview.git JAL-3081 restore annotation ordering from project (work in progress) --- diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index e3c42a7..092cf47 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -5442,7 +5442,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, * Sorts annotations and repaints the alignment */ @Override - protected void sortAnnotations() + public void sortAnnotations() { alignPanel.sortAnnotations(); alignPanel.paintAlignment(false, false); @@ -5673,13 +5673,19 @@ 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 - protected boolean setShowAutoCalculatedAbove( - boolean showAutoCalculatedAbove) + public boolean setShowAutoCalculatedAbove(boolean b) { - if (viewport.isShowAutocalculatedAbove() != showAutoCalculatedAbove) + if (viewport.isShowAutocalculatedAbove() != b) { - viewport.setShowAutocalculatedAbove(showAutoCalculatedAbove); + viewport.setShowAutocalculatedAbove(b); /* * change CUSTOM annotation ordering to NONE diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 502ab9d..c606b9f 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -21,6 +21,7 @@ package jalview.gui; import jalview.analysis.AnnotationSorter; +import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; import jalview.bin.Cache; @@ -821,14 +822,18 @@ public class AlignmentPanel extends GAlignmentPanel implements } /** - * Sorts annotations according to currently selected preference + * Sorts annotations according to currently selected preferences. Does nothing + * if currently set to 'Custom' (manual) ordering. */ void sortAnnotations() { - final AnnotationSorter sorter = new AnnotationSorter(getAlignment(), - av.isShowAutocalculatedAbove()); - sorter.sort(getAlignment().getAlignmentAnnotation(), - av.getSortAnnotationsBy()); + SequenceAnnotationOrder sortBy = av.getSortAnnotationsBy(); + if (sortBy != SequenceAnnotationOrder.CUSTOM) + { + final AnnotationSorter sorter = new AnnotationSorter(getAlignment(), + av.isShowAutocalculatedAbove()); + sorter.sort(getAlignment().getAlignmentAnnotation(), sortBy); + } } /** diff --git a/src/jalview/project/Jalview2XML.java b/src/jalview/project/Jalview2XML.java index 02b405e..e15bb1a 100644 --- a/src/jalview/project/Jalview2XML.java +++ b/src/jalview/project/Jalview2XML.java @@ -24,6 +24,7 @@ import static jalview.math.RotatableMatrix.Axis.X; import static jalview.math.RotatableMatrix.Axis.Y; import static jalview.math.RotatableMatrix.Axis.Z; +import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; import jalview.analysis.Conservation; import jalview.analysis.PCA; import jalview.analysis.scoremodels.ScoreModels; @@ -1479,6 +1480,8 @@ public class Jalview2XML view.setRenderGaps(av.isRenderGaps()); view.setShowAnnotation(av.isShowAnnotation()); view.setShowBoxes(av.getShowBoxes()); + view.setShowAutocalcAbove(av.isShowAutocalculatedAbove()); + view.setSortAnnotationsBy(av.getSortAnnotationsBy().name()); view.setShowColourText(av.getColourText()); view.setShowFullId(av.getShowJVSuffix()); view.setRightAlignIds(av.isRightAlignIds()); @@ -4916,9 +4919,8 @@ public class Jalview2XML viewport.setColourText(safeBoolean(view.isShowColourText())); - viewport - .setConservationSelected( - safeBoolean(view.isConservationSelected())); + viewport.setConservationSelected( + safeBoolean(view.isConservationSelected())); viewport.setIncrement(safeInt(view.getConsThreshold())); viewport.setShowJVSuffix(safeBoolean(view.isShowFullId())); viewport.setRightAlignIds(safeBoolean(view.isRightAlignIds())); @@ -4934,10 +4936,27 @@ public class Jalview2XML viewport.setWrapAlignment(safeBoolean(view.isWrapAlignment())); viewport.setShowAnnotation(safeBoolean(view.isShowAnnotation())); - viewport.setShowBoxes(safeBoolean(view.isShowBoxes())); + Boolean autocalcFirst = view.isShowAutocalcAbove(); + if (autocalcFirst != null) + { + af.setShowAutoCalculatedAbove(autocalcFirst.booleanValue()); + } + String sortBy = view.getSortAnnotationsBy(); + if (sortBy != null) + { + try + { + viewport.setSortAnnotationsBy( + SequenceAnnotationOrder.valueOf(sortBy)); + } catch (IllegalArgumentException e) + { + Cache.log.error( + "Invalid annotation sort specifier in project: " + sortBy); + } + } + viewport.setShowBoxes(safeBoolean(view.isShowBoxes())); viewport.setShowText(safeBoolean(view.isShowText())); - viewport.setTextColour(new Color(safeInt(view.getTextCol1()))); viewport.setTextColour2(new Color(safeInt(view.getTextCol2()))); viewport.setThresholdTextColour(safeInt(view.getTextColThreshold())); @@ -5177,6 +5196,7 @@ public class Jalview2XML // recompute any autoannotation af.alignPanel.updateAnnotation(false, true); reorderAutoannotation(af, al, autoAlan); + af.sortAnnotations(); af.alignPanel.alignmentChanged(); } else