/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
* Copyright (C) 2014 The Jalview Authors
*
* This file is part of Jalview.
*
* Jalview is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
*
* Jalview is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
* The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.datamodel;
-import java.util.*;
+import jalview.util.ShiftList;
-import jalview.util.*;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Vector;
/**
* NOTE: Columns are zero based.
Vector selected = new Vector();
// Vector of int [] {startCol, endCol}
- Vector hiddenColumns;
+ Vector<int[]> hiddenColumns;
/**
* Add a column to the selection
* @param left
* shift in edit (+ve for removal, or -ve for inserts)
*/
- public Vector compensateForEdit(int start, int change)
+ public List<int[]> compensateForEdit(int start, int change)
{
- Vector deletedHiddenColumns = null;
+ List<int[]> deletedHiddenColumns = null;
for (int i = 0; i < size(); i++)
{
int temp = columnAt(i);
if (hiddenColumns != null)
{
- deletedHiddenColumns = new Vector();
+ deletedHiddenColumns = new ArrayList<int[]>();
int hSize = hiddenColumns.size();
for (int i = 0; i < hSize; i++)
{
- int[] region = (int[]) hiddenColumns.elementAt(i);
+ int[] region = hiddenColumns.elementAt(i);
if (region[0] > start && start + change > region[1])
{
- deletedHiddenColumns.addElement(hiddenColumns.elementAt(i));
+ deletedHiddenColumns.add(region);
hiddenColumns.removeElementAt(i);
i--;
{
for (int i = 0; i < hiddenColumns.size(); i++)
{
- int[] region = (int[]) hiddenColumns.elementAt(i);
+ int[] region = hiddenColumns.elementAt(i);
if (region[0] >= start)
{
region[0] -= change;
* int
* @return Vector
*/
- public Vector getHiddenColumns()
+ public List<int[]> getHiddenColumns()
{
return hiddenColumns;
}
{
for (int i = 0; i < hiddenColumns.size(); i++)
{
- int[] region = (int[]) hiddenColumns.elementAt(i);
+ int[] region = hiddenColumns.elementAt(i);
if (result >= region[0])
{
result += region[1] - region[0] + 1;
int[] region;
do
{
- region = (int[]) hiddenColumns.elementAt(index++);
+ region = hiddenColumns.elementAt(index++);
if (hiddenColumn > region[1])
{
result -= region[1] + 1 - region[0];
int gaps = 0;
do
{
- int[] region = (int[]) hiddenColumns.elementAt(index);
+ int[] region = hiddenColumns.elementAt(index);
if (hiddenRegion == 0)
{
return region[0];
int index = 0;
do
{
- int[] region = (int[]) hiddenColumns.elementAt(index);
+ int[] region = hiddenColumns.elementAt(index);
if (alPos < region[0])
{
return region[0];
int index = hiddenColumns.size() - 1;
do
{
- int[] region = (int[]) hiddenColumns.elementAt(index);
+ int[] region = hiddenColumns.elementAt(index);
if (alPos > region[1])
{
return region[1];
for (int i = 0; i < hiddenColumns.size(); i++)
{
- int[] region = (int[]) hiddenColumns.elementAt(i);
+ int[] region = hiddenColumns.elementAt(i);
if (start <= region[1] && end >= region[0])
{
hiddenColumns.removeElementAt(i);
{
for (int i = 0; i < hiddenColumns.size(); i++)
{
- int[] region = (int[]) hiddenColumns.elementAt(i);
+ int[] region = hiddenColumns.elementAt(i);
for (int j = region[0]; j < region[1] + 1; j++)
{
addElement(j);
{
for (int i = 0; i < hiddenColumns.size(); i++)
{
- int[] region = (int[]) hiddenColumns.elementAt(i);
+ int[] region = hiddenColumns.elementAt(i);
if (res == region[0])
{
for (int j = region[0]; j < region[1] + 1; j++)
public boolean isVisible(int column)
{
if (hiddenColumns != null)
+ {
for (int i = 0; i < hiddenColumns.size(); i++)
{
- int[] region = (int[]) hiddenColumns.elementAt(i);
+ int[] region = hiddenColumns.elementAt(i);
if (column >= region[0] && column <= region[1])
{
return false;
}
}
+ }
return true;
}
for (int i = 0, j = copy.hiddenColumns.size(); i < j; i++)
{
int[] rh, cp;
- rh = (int[]) copy.hiddenColumns.elementAt(i);
+ rh = copy.hiddenColumns.elementAt(i);
if (rh != null)
{
cp = new int[rh.length];
for (i = 0; i < iSize; i++)
{
StringBuffer visibleSeq = new StringBuffer();
- Vector regions = getHiddenColumns();
+ List<int[]> regions = getHiddenColumns();
int blockStart = start, blockEnd = end;
int[] region;
for (int j = 0; j < regions.size(); j++)
{
- region = (int[]) regions.elementAt(j);
+ region = regions.get(j);
hideStart = region[0];
hideEnd = region[1];
if (hiddenColumns != null && hiddenColumns.size() > 0)
{
Vector visiblecontigs = new Vector();
- Vector regions = getHiddenColumns();
+ List<int[]> regions = getHiddenColumns();
int vstart = start;
int[] region;
for (int j = 0; vstart < end && j < regions.size(); j++)
{
- region = (int[]) regions.elementAt(j);
+ region = regions.get(j);
hideStart = region[0];
hideEnd = region[1];
// then mangle the alignmentAnnotation annotation array
Vector annels = new Vector();
Annotation[] els = null;
- Vector regions = getHiddenColumns();
+ List<int[]> regions = getHiddenColumns();
int blockStart = start, blockEnd = end;
int[] region;
int hideStart, hideEnd, w = 0;
for (int j = 0; j < regions.size(); j++)
{
- region = (int[]) regions.elementAt(j);
+ region = regions.get(j);
hideStart = region[0];
hideEnd = region[1];
w += els.length;
}
if (w == 0)
+ {
return;
+ }
Enumeration e = annels.elements();
alignmentAnnotation.annotations = new Annotation[w];
w = 0;
}
}
}
+
+ /**
+ *
+ * @return true if there are columns marked
+ */
+ public boolean hasSelectedColumns()
+ {
+ return (selected != null && selected.size() > 0);
+ }
+
+ /**
+ *
+ * @return true if there are columns hidden
+ */
+ public boolean hasHiddenColumns()
+ {
+ return hiddenColumns != null && hiddenColumns.size() > 0;
+ }
+
+ /**
+ * mark the columns corresponding to gap characters as hidden in the column
+ * selection
+ *
+ * @param sr
+ */
+ public void hideInsertionsFor(SequenceI sr)
+ {
+ List<int[]> inserts = sr.getInsertions();
+ for (int[] r : inserts)
+ {
+ hideColumns(r[0], r[1]);
+ }
+ }
}