- ColumnSelection cs = viewport.getColumnSelection();
- if (bs.cardinality() > 0 || invert)
- {
- if (cs == null)
- {
- cs = new ColumnSelection();
- }
- else
- {
- if (!extendCurrent)
- {
- cs.clear();
- }
- }
- if (invert)
- {
- // invert only in the currently selected sequence region
- for (int i = bs.nextClearBit(alStart), ibs = bs.nextSetBit(alStart); i >= alStart
- && i < (alw);)
- {
- if (ibs < 0 || i < ibs)
- {
- if (toggle && cs.contains(i))
- {
- cs.removeElement(i++);
- }
- else
- {
- cs.addElement(i++);
- }
- }
- else
- {
- i = bs.nextClearBit(ibs);
- ibs = bs.nextSetBit(i);
- }
- }
- }
- else
- {
- for (int i = bs.nextSetBit(alStart); i >= alStart; i = bs
- .nextSetBit(i + 1))
- {
- if (toggle && cs.contains(i))
- {
- cs.removeElement(i);
- }
- else
- {
- cs.addElement(i);
- }
- }
- }
- viewport.setColumnSelection(cs);
- alignPanel.paintAlignment(true);
- avcg.setStatus(MessageManager.formatMessage("label.view_controller_toggled_marked",
- new String[]{
- (toggle ? MessageManager.getString("label.toggled") : MessageManager.getString("label.marked")),
- (invert ? (Integer.valueOf((alw - alStart) - bs.cardinality()).toString()):(Integer.valueOf(bs.cardinality()).toString())),
- featureType, Integer.valueOf(nseq).toString()
- }));
- return true;
- }
- else
- {
- avcg.setStatus(MessageManager.formatMessage("label.no_feature_of_type_found", new String[]{featureType}));
- if (!extendCurrent && cs != null)
- {
- cs.clear();
- alignPanel.paintAlignment(true);
- }
- return false;
- }
- }
-
- public static boolean filterAnnotations(Annotation[] annotations,
- AnnotationFilterParameter filterParams, ColumnSelection cs)
- {
- cs.revealAllHiddenColumns();
- cs.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<SearchableAnnotationField> 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)
- {
- cs.addElement(count);
- }
- }
- count++;
- } while (count < annotations.length);
- return false;