From: Jim Procter Date: Mon, 13 May 2024 12:44:27 +0000 (+0100) Subject: Merge branch 'develop' into features/JAL-518_justify_seqs_in_region X-Git-Tag: Release_2_11_4_0~45^2~3 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c8d80485038ab96fb06bd0885c323803646d8e57;p=jalview.git Merge branch 'develop' into features/JAL-518_justify_seqs_in_region Conflicts: src/jalview/api/AlignViewControllerI.java src/jalview/api/AlignViewportI.java src/jalview/controller/AlignViewController.java --- c8d80485038ab96fb06bd0885c323803646d8e57 diff --cc src/jalview/api/AlignViewControllerI.java index 4d92d8e,3e689d1..25e4873 --- a/src/jalview/api/AlignViewControllerI.java +++ b/src/jalview/api/AlignViewControllerI.java @@@ -111,6 -111,12 +111,18 @@@ public interface AlignViewController boolean markHighlightedColumns(boolean invert, boolean extendCurrent, boolean toggle); - boolean justify_Region(boolean left); + /** + * copies each distinct highlighted region on the current view as a new + * sequence on the clipboard + * + * @return + */ + boolean copyHighlightedRegionsToClipboard(); ++ /** ++ * Justify alignment or currently selected region left or right ++ * @param left - true - means justify left ++ * @return ++ */ ++ boolean justify_Region(boolean left); } diff --cc src/jalview/api/AlignViewportI.java index 43c6a13,0cfd03d..e7afee0 --- a/src/jalview/api/AlignViewportI.java +++ b/src/jalview/api/AlignViewportI.java @@@ -552,10 -565,6 +565,16 @@@ public interface AlignViewportI extend * @return */ Iterator getViewAsVisibleContigs(boolean selectedRegionOnly); - + /** + * notify all concerned that the alignment data has changed and derived data + * needs to be recalculated + */ + public void notifyAlignmentChanged(); + ++ /** ++ * retrieve a matrix associated with the view's alignment's annotation ++ * @param alignmentAnnotation ++ * @return contact matrix or NULL ++ */ + ContactMatrixI getContactMatrix(AlignmentAnnotation alignmentAnnotation); } diff --cc src/jalview/controller/AlignViewController.java index 756fe5a,4434331..bccacfa --- a/src/jalview/controller/AlignViewController.java +++ b/src/jalview/controller/AlignViewController.java @@@ -472,34 -474,30 +474,62 @@@ public class AlignViewController implem } @Override + public boolean copyHighlightedRegionsToClipboard() + { + if (!viewport.hasSearchResults()) + { + // do nothing if no selection exists + return false; + } + + SearchResultsI searchResults = viewport.getSearchResults(); + if (searchResults.isEmpty()) + { + return false; // shouldn't happen + } + List seqs = searchResults.getMatchingSubSequences(); + + // TODO: pass in hiddenColumns according to intersection of searchResults + // and visible columns. Currently this isn't done, since each contig becomes + // a single subsequence + Desktop.jalviewClipboard = new Object[] { + seqs.toArray(new SequenceI[0]), + alignPanel.getAlignment().getDataset(), null }; + avcg.setStatus(MessageManager.formatMessage( + "label.copied_sequences_to_clipboard", seqs.size())); + // Technically we should return false, since view has not changed + return false; + } ++ ++ @Override + public boolean justify_Region(boolean left) + { + AlignmentI al = viewport.getAlignment(); + SequenceGroup reg = viewport.getSelectionGroup(); + int from, to; + List seqs; + + from = 0; + to = al.getWidth() - 1; + seqs = al.getSequences(); + if (reg != null) + { + seqs = reg.getSequences(); + from = reg.getStartRes(); + to = reg.getEndRes(); + } + + if ((to - from) < 1) + { + return false; + } + + al.padGaps(); + jalview.commands.JustifyLeftOrRightCommand finalEdit = new jalview.commands.JustifyLeftOrRightCommand( + "Justify " + (left ? "Left" : "Right"), left, seqs, from, to, + al); + avcg.addHistoryItem(finalEdit); + viewport.notifyAlignmentChanged(); + return true; + } }