package jalview.gui;
-import jalview.api.AnnotationRowFilterI;
+import jalview.api.analysis.AnnotationFilterParameter;
+import jalview.api.analysis.AnnotationFilterParameter.SearchableAnnotationField;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Annotation;
import jalview.datamodel.ColumnSelection;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
+import java.util.List;
import java.util.Vector;
import javax.swing.JCheckBox;
import javax.swing.event.ChangeListener;
@SuppressWarnings("serial")
-public abstract class AnnotationRowFilter extends JPanel implements
- AnnotationRowFilterI
+public abstract class AnnotationRowFilter extends JPanel
{
protected AlignViewport av;
}
- @Override
public Vector<String> getAnnotationItems(boolean isSeqAssociated)
{
Vector<String> list = new Vector<String>();
}
}
}
- // seqAssociated.setEnabled(enableSeqAss);
this.annmap = new int[list.size()];
System.arraycopy(anmap, 0, this.annmap, 0, this.annmap.length);
return list;
return false;
}
- protected boolean markColumnsContaining(
- AlignmentAnnotation currentAnnotation, int thresholdComparisonType)
+ protected boolean filterAnnotations(Annotation[] annotations,
+ AnnotationFilterParameter filterParams, ColumnSelection cs)
{
- try
+ av.showAllHiddenColumns();
+ cs.clear();
+ int count = 0;
+ do
{
- if (currentAnnotation != null)
+ if (annotations[count] != null)
{
- Annotation[] annotations = currentAnnotation.annotations;
- ColumnSelection cs = av.getColumnSelection();
- cs.clear();
- if (thresholdComparisonType == AnnotationColourGradient.NO_THRESHOLD)
+
+ boolean itemMatched = false;
+
+ if (filterParams.getThresholdType() == AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD
+ && annotations[count].value > currentAnnotation.threshold.value)
{
- int count = 0;
- do
- {
- if (annotations[count] != null)
- {
- if (currentAnnotation.label.equals("Secondary Structure")
- && annotations[count].secondaryStructure != ' ')
- {
- cs.addElement(count);
- }
- else if (currentAnnotation.label
- .equals("Iron Sulphur Contacts"))
- {
- cs.addElement(count);
- }
- else if (annotations[count].value != 0.0)
- {
- cs.addElement(count);
- }
+ itemMatched = true;
+ }
+ if (filterParams.getThresholdType() == AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD
+ && annotations[count].value < currentAnnotation.threshold.value)
+ {
+ itemMatched = true;
+ }
- }
- count++;
- } while (count < annotations.length);
+ if (filterParams.isFilterAlphaHelix()
+ && annotations[count].secondaryStructure == 'H')
+ {
+ itemMatched = true;
}
- else
+
+ 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())
{
- int count = 0;
- do
+ List<SearchableAnnotationField> fields = filterParams
+ .getRegexSearchFields();
+ try
{
- if (annotations[count] != null)
+ if (fields.contains(SearchableAnnotationField.DISPLAY_STRING)
+ && annotations[count].displayCharacter
+ .matches(regexSearchString))
{
- if (thresholdComparisonType == AnnotationColourGradient.ABOVE_THRESHOLD)
- {
- if (annotations[count].value > currentAnnotation.threshold.value)
- {
- cs.addElement(count);
- }
- }
- else if (thresholdComparisonType == AnnotationColourGradient.BELOW_THRESHOLD)
- {
- if (annotations[count].value < currentAnnotation.threshold.value)
- {
- cs.addElement(count);
- }
- }
-
+ itemMatched = true;
+ }
+ } catch (java.util.regex.PatternSyntaxException pse)
+ {
+ if (annotations[count].displayCharacter
+ .equals(regexSearchString))
+ {
+ itemMatched = true;
}
- count++;
- } while (count < annotations.length);
+ }
+ if (fields.contains(SearchableAnnotationField.DESCRIPTION)
+ && annotations[count].description != null
+ && annotations[count].description
+ .matches(regexSearchString))
+ {
+ itemMatched = true;
+ }
}
- }
- return true;
- } catch (Exception e)
- {
- e.printStackTrace();
- return false;
- }
+ if (itemMatched)
+ {
+ cs.addElement(count);
+ }
+ }
+ count++;
+ } while (count < annotations.length);
+ return false;
}
public jalview.datamodel.AlignmentAnnotation getCurrentAnnotation()
this.currentAnnotation = currentAnnotation;
}
+ public abstract void valueChanged(boolean updateAllAnnotation);
+
+ public abstract void updateView();
+
+ public abstract void reset();
}