From: gmungoc Date: Thu, 5 Mar 2015 13:50:58 +0000 (+0000) Subject: Merge branch 'develop' into features/JAL-845splitPaneMergeDevelop X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=286715d8408510556366a454a748daf8f60444f1;p=jalview.git Merge branch 'develop' into features/JAL-845splitPaneMergeDevelop Conflicts: src/jalview/datamodel/SequenceGroup.java --- 286715d8408510556366a454a748daf8f60444f1 diff --cc src/jalview/datamodel/ColumnSelection.java index c661f37,1d8b127..3093304 --- a/src/jalview/datamodel/ColumnSelection.java +++ b/src/jalview/datamodel/ColumnSelection.java @@@ -25,8 -25,8 +25,7 @@@ import jalview.viewmodel.annotationfilt import jalview.viewmodel.annotationfilter.AnnotationFilterParameter.SearchableAnnotationField; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Enumeration; +import java.util.Collections; - import java.util.Enumeration; import java.util.List; import java.util.Vector; @@@ -35,7 -35,7 +34,7 @@@ */ public class ColumnSelection { -- Vector selected = new Vector(); ++ Vector selected = new Vector(); // Vector of int [] {startCol, endCol} Vector hiddenColumns; @@@ -64,7 -64,7 +63,7 @@@ } /** -- * removes col from selection ++ * Removes value 'col' from the selection (not the col'th item) * * @param col * index of column to be removed @@@ -75,6 -75,6 +74,8 @@@ if (selected.contains(colInt)) { ++ // if this ever changes to List.remove(), ensure Integer not int argument ++ // as List.remove(int i) removes the i'th item which is wrong selected.removeElement(colInt); } } @@@ -131,7 -131,7 +132,7 @@@ */ public int columnAt(int i) { -- return ((Integer) selected.elementAt(i)).intValue(); ++ return selected.elementAt(i).intValue(); } /** @@@ -201,6 -201,6 +202,7 @@@ if (temp >= start) { ++ // if this ever changes to List.set(), swap parameter order!! selected.setElementAt(new Integer(temp - change), i); } } @@@ -258,6 -258,6 +260,7 @@@ if (temp >= start) { ++ // if this ever changes to List.set(), swap parameter order!! selected.setElementAt(new Integer(temp - change), i); } } @@@ -303,7 -303,7 +306,7 @@@ { if (shiftrecord != null) { - List shifts = shiftrecord.getShifts(); - Vector shifts = shiftrecord.shifts; ++ final List shifts = shiftrecord.getShifts(); if (shifts != null && shifts.size() > 0) { int shifted = 0; @@@ -328,12 -328,12 +331,13 @@@ * @param intervals * @return */ - private boolean pruneIntervalVector(List shifts, Vector intervals) - private boolean pruneIntervalVector(Vector deletions, Vector intervals) ++ private boolean pruneIntervalVector(final List shifts, ++ Vector intervals) { boolean pruned = false; - int i = 0, j = intervals.size() - 1, s = 0, t = deletions.size() - 1; - int hr[] = (int[]) intervals.elementAt(i); - int sr[] = (int[]) deletions.elementAt(s); + int i = 0, j = intervals.size() - 1, s = 0, t = shifts.size() - 1; - int hr[] = (int[]) intervals.elementAt(i); ++ int hr[] = intervals.elementAt(i); + int sr[] = shifts.get(s); while (i <= j && s <= t) { boolean trailinghn = hr[1] >= sr[0]; @@@ -341,7 -341,7 +345,7 @@@ { if (i < j) { -- hr = (int[]) intervals.elementAt(++i); ++ hr = intervals.elementAt(++i); } else { @@@ -374,7 -374,7 +378,7 @@@ j--; if (i <= j) { -- hr = (int[]) intervals.elementAt(i); ++ hr = intervals.elementAt(i); } continue; } @@@ -414,15 -414,15 +418,16 @@@ // operations. } - private boolean pruneColumnList(List shifts, Vector list) - private boolean pruneColumnList(Vector deletion, Vector list) ++ private boolean pruneColumnList(final List shifts, ++ Vector list) { - int s = 0, t = deletion.size(); - int[] sr = (int[]) list.elementAt(s++); + int s = 0, t = shifts.size(); + int[] sr = shifts.get(s++); boolean pruned = false; int i = 0, j = list.size(); while (i < j && s <= t) { -- int c = ((Integer) list.elementAt(i++)).intValue(); ++ int c = list.elementAt(i++).intValue(); if (sr[0] <= c) { if (sr[1] + sr[0] >= c) @@@ -453,7 -453,7 +458,7 @@@ { if (deletions != null) { - List shifts = deletions.getShifts(); - Vector shifts = deletions.shifts; ++ final List shifts = deletions.getShifts(); if (shifts != null && shifts.size() > 0) { // delete any intervals intersecting. @@@ -644,7 -644,7 +649,7 @@@ { if (hiddenColumns == null) { -- hiddenColumns = new Vector(); ++ hiddenColumns = new Vector(); } boolean added = false; @@@ -780,7 -780,7 +785,7 @@@ { if (copy.selected != null) { -- selected = new Vector(); ++ selected = new Vector(); for (int i = 0, j = copy.selected.size(); i < j; i++) { selected.addElement(copy.selected.elementAt(i)); @@@ -788,7 -788,7 +793,7 @@@ } if (copy.hiddenColumns != null) { -- hiddenColumns = new Vector(copy.hiddenColumns.size()); ++ hiddenColumns = new Vector(copy.hiddenColumns.size()); for (int i = 0, j = copy.hiddenColumns.size(); i < j; i++) { int[] rh, cp; @@@ -885,7 -885,7 +890,7 @@@ { if (hiddenColumns != null && hiddenColumns.size() > 0) { -- Vector visiblecontigs = new Vector(); ++ List visiblecontigs = new ArrayList(); List regions = getHiddenColumns(); int vstart = start; @@@ -904,7 -904,7 +909,7 @@@ } if (hideStart > vstart) { -- visiblecontigs.addElement(new int[] ++ visiblecontigs.add(new int[] { vstart, hideStart - 1 }); } vstart = hideEnd + 1; @@@ -912,18 -912,18 +917,18 @@@ if (vstart < end) { -- visiblecontigs.addElement(new int[] ++ visiblecontigs.add(new int[] { vstart, end - 1 }); } int[] vcontigs = new int[visiblecontigs.size() * 2]; for (int i = 0, j = visiblecontigs.size(); i < j; i++) { -- int[] vc = (int[]) visiblecontigs.elementAt(i); -- visiblecontigs.setElementAt(null, i); ++ int[] vc = visiblecontigs.get(i); ++ visiblecontigs.set(i, null); vcontigs[i * 2] = vc[0]; vcontigs[i * 2 + 1] = vc[1]; } -- visiblecontigs.removeAllElements(); ++ visiblecontigs.clear(); return vcontigs; } else @@@ -970,7 -970,7 +975,7 @@@ if (hiddenColumns != null && hiddenColumns.size() > 0) { // then mangle the alignmentAnnotation annotation array -- Vector annels = new Vector(); ++ Vector annels = new Vector(); Annotation[] els = null; List regions = getHiddenColumns(); int blockStart = start, blockEnd = end; @@@ -1026,12 -1026,12 +1031,12 @@@ { return; } -- Enumeration e = annels.elements(); ++ alignmentAnnotation.annotations = new Annotation[w]; w = 0; -- while (e.hasMoreElements()) ++ ++ for (Annotation [] chnk : annels) { -- Annotation[] chnk = (Annotation[]) e.nextElement(); System.arraycopy(chnk, 0, alignmentAnnotation.annotations, w, chnk.length); w += chnk.length; @@@ -1079,15 -1079,15 +1084,13 @@@ { if (colsel != null && colsel.size() > 0) { -- Enumeration e = colsel.getSelected().elements(); -- while (e.hasMoreElements()) ++ for (Integer col : colsel.getSelected()) { -- Object eo = e.nextElement(); -- if (hiddenColumns != null && isVisible(((Integer) eo).intValue())) ++ if (hiddenColumns != null && isVisible(col.intValue())) { -- if (!selected.contains(eo)) ++ if (!selected.contains(col)) { -- selected.addElement(eo); ++ selected.addElement(col); } } } @@@ -1102,22 -1102,22 +1105,20 @@@ */ public void setElementsFrom(ColumnSelection colsel) { -- selected = new Vector(); ++ selected = new Vector(); if (colsel.selected != null && colsel.selected.size() > 0) { if (hiddenColumns != null && hiddenColumns.size() > 0) { // only select visible columns in this columns selection -- selected = new Vector(); addElementsFrom(colsel); } else { // add everything regardless -- Enumeration en = colsel.selected.elements(); -- while (en.hasMoreElements()) ++ for (Integer col : colsel.getSelected()) { -- selected.addElement(en.nextElement()); ++ addElement(col); } } } diff --cc src/jalview/datamodel/SequenceGroup.java index beb6b51,c6b9cbd..739c8a0 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@@ -1307,12 -1295,12 +1295,15 @@@ public class SequenceGroup implements A return false; } + /** + * Remove all sequences from the group (leaving other properties unchanged). + */ public void clear() { - sequences.clear(); + synchronized (sequences) + { + sequences.clear(); + } } private AnnotatedCollectionI context; diff --cc src/jalview/util/ShiftList.java index 3b8c68f,2b3a8a4..8b37f0a --- a/src/jalview/util/ShiftList.java +++ b/src/jalview/util/ShiftList.java @@@ -47,20 -46,21 +47,23 @@@ public class ShiftLis */ public void addShift(int pos, int shift) { -- int sidx = 0; -- int[] rshift = null; - while (sidx < shifts.size() && (rshift = shifts.get(sidx))[0] < pos) - { - sidx++; - } - if (sidx == shifts.size()) - while (sidx < shifts.size() - && (rshift = (int[]) shifts.elementAt(sidx))[0] < pos) - { - sidx++; - } - if (sidx == shifts.size()) ++ synchronized (shifts) { - shifts.add(sidx, new int[] - { pos, shift }); - } - else - { - rshift[1] += shift; - shifts.insertElementAt(new int[] - { pos, shift }, sidx); - } - else - { - rshift[1] += shift; ++ int sidx = 0; ++ int[] rshift = null; ++ while (sidx < shifts.size() && (rshift = shifts.get(sidx))[0] < pos) ++ { ++ sidx++; ++ } ++ if (sidx == shifts.size()) ++ { ++ shifts.add(sidx, new int[] ++ { pos, shift }); ++ } ++ else ++ { ++ rshift[1] += shift; ++ } } } @@@ -91,9 -91,9 +94,9 @@@ /** * clear all shifts */ -- public void clear() ++ public synchronized void clear() { - shifts.removeAllElements(); + shifts.clear(); } /** @@@ -104,15 -104,15 +107,17 @@@ public ShiftList getInverse() { ShiftList inverse = new ShiftList(); -- if (shifts != null) ++ synchronized (shifts) { -- for (int i = 0, j = shifts.size(); i < j; i++) ++ if (shifts != null) { - int[] sh = shifts.get(i); - if (sh != null) - int[] sh = (int[]) shifts.elementAt(i); - if (sh != null) ++ for (int[] sh : shifts) { - inverse.shifts.add(new int[] - { sh[0], -sh[1] }); - inverse.shifts.addElement(new int[] - { sh[0], -sh[1] }); ++ if (sh != null) ++ { ++ inverse.shifts.add(new int[] ++ { sh[0], -sh[1] }); ++ } } } }