*
* 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.
* @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);
if (region[0] > start && start + change > region[1])
{
- deletedHiddenColumns.addElement(hiddenColumns.elementAt(i));
+ deletedHiddenColumns.add(region);
hiddenColumns.removeElementAt(i);
i--;
public boolean isVisible(int column)
{
if (hiddenColumns != null)
+ {
for (int i = 0; i < hiddenColumns.size(); i++)
{
int[] region = (int[]) hiddenColumns.elementAt(i);
return false;
}
}
+ }
return true;
}
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]);
+ }
+ }
}