Merge branch 'develop' into features/JAL-518_justify_seqs_in_region
authorJim Procter <jprocter@dundee.ac.uk>
Mon, 13 May 2024 12:44:27 +0000 (13:44 +0100)
committerJim Procter <jprocter@dundee.ac.uk>
Mon, 13 May 2024 12:44:27 +0000 (13:44 +0100)
 Conflicts:
src/jalview/api/AlignViewControllerI.java
src/jalview/api/AlignViewportI.java
src/jalview/controller/AlignViewController.java

1  2 
help/help/html/menus/alwedit.html
resources/lang/Messages.properties
src/jalview/api/AlignViewControllerI.java
src/jalview/api/AlignViewportI.java
src/jalview/controller/AlignViewController.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/PopupMenu.java
src/jalview/jbgui/GAlignFrame.java
src/jalview/viewmodel/AlignmentViewport.java

Simple merge
Simple merge
@@@ -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);
  }
@@@ -552,10 -565,6 +565,16 @@@ public interface AlignViewportI extend
     * @return
     */
    Iterator<int[]> 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);
  }
@@@ -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<SequenceI> 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<SequenceI> 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;
 +  }
  }
Simple merge
Simple merge
Simple merge