Merge branch 'develop' into feature/JAL-4386_calculate_tree_using_secondary_structure...
[jalview.git] / src / jalview / controller / AlignViewController.java
index 4434331..bccacfa 100644 (file)
@@ -500,4 +500,36 @@ public class AlignViewController implements AlignViewControllerI
     // 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;
+  }
 }