From: Jim Procter Date: Tue, 10 Feb 2015 14:29:38 +0000 (+0000) Subject: JAL-966 @mungo TODO complete: List rather than bare int array X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=dd81a4ab9d1ffc6168e7a041c7d488db37298cce;p=jalview.git JAL-966 @mungo TODO complete: List rather than bare int array --- diff --git a/src/jalview/api/AlignViewportI.java b/src/jalview/api/AlignViewportI.java index d23fc75..7f8ffb1 100644 --- a/src/jalview/api/AlignViewportI.java +++ b/src/jalview/api/AlignViewportI.java @@ -318,10 +318,9 @@ public interface AlignViewportI extends ViewStyleI * first column (inclusive, from 0) * @param max * last column (exclusive) - * @return int[][] range of {start,end} visible positions TODO: change to list - * of int ranges + * @return int[][] range of {start,end} visible positions */ - int[][] getVisibleRegionBoundaries(int min, int max); + List getVisibleRegionBoundaries(int min, int max); /** * This method returns an array of new SequenceI objects derived from the diff --git a/src/jalview/appletgui/APopupMenu.java b/src/jalview/appletgui/APopupMenu.java index 3b37b62..bb290d4 100644 --- a/src/jalview/appletgui/APopupMenu.java +++ b/src/jalview/appletgui/APopupMenu.java @@ -56,6 +56,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.util.List; import java.util.Vector; public class APopupMenu extends java.awt.PopupMenu implements @@ -619,10 +620,9 @@ public class APopupMenu extends java.awt.PopupMenu implements else if (source == toUpper || source == toLower || source == toggleCase) { SequenceGroup sg = ap.av.getSelectionGroup(); - Vector regions = new Vector(); if (sg != null) { - int[][] startEnd = ap.av.getVisibleRegionBoundaries( + List startEnd = ap.av.getVisibleRegionBoundaries( sg.getStartRes(), sg.getEndRes() + 1); String description; diff --git a/src/jalview/commands/ChangeCaseCommand.java b/src/jalview/commands/ChangeCaseCommand.java index 47b4d9d..cc0502f 100644 --- a/src/jalview/commands/ChangeCaseCommand.java +++ b/src/jalview/commands/ChangeCaseCommand.java @@ -20,7 +20,10 @@ */ package jalview.commands; -import jalview.datamodel.*; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.SequenceI; + +import java.util.List; public class ChangeCaseCommand implements CommandI { @@ -36,10 +39,10 @@ public class ChangeCaseCommand implements CommandI SequenceI[] seqs; - int[][] regions; + List regions; public ChangeCaseCommand(String description, SequenceI[] seqs, - int[][] regions, int caseChange) + List regions, int caseChange) { this.description = description; this.seqs = seqs; @@ -73,21 +76,21 @@ public class ChangeCaseCommand implements CommandI String sequence; int start, end; char nextChar; - for (int r = 0; r < regions.length; r++) + for (int[] r : regions) { - start = regions[r][0]; + start = r[0]; for (int s = 0; s < seqs.length; s++) { sequence = seqs[s].getSequenceAsString(); StringBuffer newSeq = new StringBuffer(); - if (regions[r][1] > sequence.length()) + if (r[1] > sequence.length()) { end = sequence.length(); } else { - end = regions[r][1]; + end = r[1]; } if (start > 0) diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 06efcf3..2b1d1a0 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -2572,7 +2572,8 @@ public class PopupMenu extends JPopupMenu if (sg != null) { - int[][] startEnd = ap.av.getVisibleRegionBoundaries(sg.getStartRes(), + List startEnd = ap.av.getVisibleRegionBoundaries( + sg.getStartRes(), sg.getEndRes() + 1); String description; diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 3293291..67db6fc 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -52,7 +52,6 @@ import java.util.HashMap; import java.util.Hashtable; import java.util.List; import java.util.Map; -import java.util.Vector; /** * base class holding visualization and analysis attributes and common logic for @@ -1489,9 +1488,9 @@ public abstract class AlignmentViewport implements AlignViewportI, @Override - public int[][] getVisibleRegionBoundaries(int min, int max) + public List getVisibleRegionBoundaries(int min, int max) { - Vector regions = new Vector(); + ArrayList regions = new ArrayList(); int start = min; int end = max; @@ -1515,7 +1514,7 @@ public abstract class AlignmentViewport implements AlignViewportI, } } - regions.addElement(new int[] + regions.add(new int[] { start, end }); if (colSel != null && colSel.hasHiddenColumns()) @@ -1527,10 +1526,7 @@ public abstract class AlignmentViewport implements AlignViewportI, int[][] startEnd = new int[regions.size()][2]; - regions.copyInto(startEnd); - - return startEnd; - + return regions; } @Override