X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FColumnSelection.java;fp=src%2Fjalview%2Fdatamodel%2FColumnSelection.java;h=6acca320ca96439cd09fba484af5d70d7cdf7d23;hb=f58113903c158201e64b3db50cc6cd57a8db6ae6;hp=f1c6cc4a2f6ca38e3c4febc9811f021d602a1d24;hpb=4884e25f5b34c098cbfe5f207b2a3d938c9b82c4;p=jalview.git diff --git a/src/jalview/datamodel/ColumnSelection.java b/src/jalview/datamodel/ColumnSelection.java index f1c6cc4..6acca32 100644 --- a/src/jalview/datamodel/ColumnSelection.java +++ b/src/jalview/datamodel/ColumnSelection.java @@ -21,8 +21,11 @@ package jalview.datamodel; import jalview.util.ShiftList; +import jalview.viewmodel.annotationfilter.AnnotationFilterParameter; +import jalview.viewmodel.annotationfilter.AnnotationFilterParameter.SearchableAnnotationField; import java.util.ArrayList; +import java.util.Arrays; import java.util.Enumeration; import java.util.List; import java.util.Vector; @@ -477,16 +480,13 @@ public class ColumnSelection } /** - * This Method is used to return all the HiddenColumn regions less than the - * given index. - * - * @param end - * int - * @return Vector + * This Method is used to return all the HiddenColumn regions + * @return empty list or List of hidden column intervals */ public List getHiddenColumns() { - return hiddenColumns; + return hiddenColumns == null ? Arrays.asList(new int[] + {}) : hiddenColumns; } /** @@ -1283,6 +1283,15 @@ public class ColumnSelection { return hiddenColumns != null && hiddenColumns.size() > 0; } + + /** + * + * @return true if there are more than one set of columns hidden + */ + public boolean hasManyHiddenColumns() + { + return hiddenColumns != null && hiddenColumns.size() > 1; + } /** * mark the columns corresponding to gap characters as hidden in the column @@ -1298,4 +1307,89 @@ public class ColumnSelection hideColumns(r[0], r[1]); } } + + public boolean filterAnnotations(Annotation[] annotations, + AnnotationFilterParameter filterParams) + { + this.revealAllHiddenColumns(); + this.clear(); + int count = 0; + do + { + if (annotations[count] != null) + { + + boolean itemMatched = false; + + if (filterParams.getThresholdType() == AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD + && annotations[count].value >= filterParams + .getThresholdValue()) + { + itemMatched = true; + } + if (filterParams.getThresholdType() == AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD + && annotations[count].value <= filterParams + .getThresholdValue()) + { + itemMatched = true; + } + + if (filterParams.isFilterAlphaHelix() + && annotations[count].secondaryStructure == 'H') + { + itemMatched = true; + } + + if (filterParams.isFilterBetaSheet() + && annotations[count].secondaryStructure == 'E') + { + itemMatched = true; + } + + if (filterParams.isFilterTurn() + && annotations[count].secondaryStructure == 'S') + { + itemMatched = true; + } + + String regexSearchString = filterParams.getRegexString(); + if (regexSearchString != null + && !filterParams.getRegexSearchFields().isEmpty()) + { + List fields = filterParams + .getRegexSearchFields(); + try + { + if (fields.contains(SearchableAnnotationField.DISPLAY_STRING) + && annotations[count].displayCharacter + .matches(regexSearchString)) + { + itemMatched = true; + } + } catch (java.util.regex.PatternSyntaxException pse) + { + if (annotations[count].displayCharacter + .equals(regexSearchString)) + { + itemMatched = true; + } + } + if (fields.contains(SearchableAnnotationField.DESCRIPTION) + && annotations[count].description != null + && annotations[count].description + .matches(regexSearchString)) + { + itemMatched = true; + } + } + + if (itemMatched) + { + this.addElement(count); + } + } + count++; + } while (count < annotations.length); + return false; + } }