package jalview.gui;
-import jalview.datamodel.AlignmentAnnotation;
-import jalview.datamodel.HiddenColumns;
-import jalview.io.cache.JvCacheableInputBox;
-import jalview.schemes.AnnotationColourGradient;
-import jalview.util.MessageManager;
-import jalview.util.Platform;
-import jalview.viewmodel.annotationfilter.AnnotationFilterParameter;
-
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import javax.swing.JRadioButton;
import javax.swing.border.TitledBorder;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.HiddenColumns;
+import jalview.io.cache.JvCacheableInputBox;
+import jalview.schemes.AnnotationColourGradient;
+import jalview.util.MessageManager;
+import jalview.util.Platform;
+import jalview.viewmodel.annotationfilter.AnnotationFilterParameter;
import net.miginfocom.swing.MigLayout;
@SuppressWarnings("serial")
// filterAnnotations, because showing hidden columns has the side effect of
// adding them to the selection
av.showAllHiddenColumns();
- av.getColumnSelection().filterAnnotations(currentAnnotation.annotations,
+ av.getColumnSelection().filterAnnotations(currentAnnotation,
filterParams);
boolean hideCols = getActionOption() == ACTION_OPTION_HIDE;
import static org.testng.AssertJUnit.assertTrue;
import static org.testng.AssertJUnit.fail;
-import jalview.analysis.AlignmentGenerator;
-import jalview.gui.JvOptionPane;
-import jalview.viewmodel.annotationfilter.AnnotationFilterParameter;
-import jalview.viewmodel.annotationfilter.AnnotationFilterParameter.SearchableAnnotationField;
-import jalview.viewmodel.annotationfilter.AnnotationFilterParameter.ThresholdType;
-
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import jalview.analysis.AlignmentGenerator;
+import jalview.gui.JvOptionPane;
+import jalview.viewmodel.annotationfilter.AnnotationFilterParameter;
+import jalview.viewmodel.annotationfilter.AnnotationFilterParameter.SearchableAnnotationField;
+import jalview.viewmodel.annotationfilter.AnnotationFilterParameter.ThresholdType;
+
public class ColumnSelectionTest
{
public void testFilterAnnotations()
{
ColumnSelection cs = new ColumnSelection();
+ AlignmentAnnotation alann = new AlignmentAnnotation("dummy",
+ "dummyDesc", null);
/*
* filter with no conditions clears the selection
Annotation[] anns = new Annotation[] { null };
AnnotationFilterParameter filter = new AnnotationFilterParameter();
cs.addElement(3);
- int added = cs.filterAnnotations(anns, filter);
+ alann.annotations = anns;
+ int added = cs.filterAnnotations(alann, filter);
assertEquals(0, added);
assertTrue(cs.isEmpty());
filter.addRegexSearchField(SearchableAnnotationField.DESCRIPTION);
Annotation helix = new Annotation("(", "hello", '<', 2f);
Annotation sheet = new Annotation("(", "world", '<', 2f);
- added = cs.filterAnnotations(new Annotation[] { null, helix, sheet },
- filter);
+ alann.annotations = new Annotation[] { null, helix, sheet };
+ added = cs.filterAnnotations(alann, filter);
assertEquals(1, added);
assertTrue(cs.contains(2));
filter = new AnnotationFilterParameter();
filter.setRegexString("(");
filter.addRegexSearchField(SearchableAnnotationField.DISPLAY_STRING);
- added = cs.filterAnnotations(new Annotation[] { null, helix, sheet },
- filter);
+ alann.annotations = new Annotation[] { null, helix, sheet };
+ added = cs.filterAnnotations(alann, filter);
assertEquals(2, added);
assertTrue(cs.contains(1));
assertTrue(cs.contains(2));
sheet = new Annotation("x", "desc", 'E', 1f);
Annotation turn = new Annotation("x", "desc", 'S', 2f);
Annotation ann4 = new Annotation("x", "desc", 'Y', 3f);
- added = cs
- .filterAnnotations(new Annotation[]
- { null, helix, sheet, turn, ann4 }, filter);
+ alann.annotations = new Annotation[] { null, helix, sheet, turn, ann4 };
+ added = cs.filterAnnotations(alann, filter);
assertEquals(1, added);
assertTrue(cs.contains(1));
* select Helix and Sheet (E)
*/
filter.setFilterBetaSheet(true);
- added = cs
- .filterAnnotations(new Annotation[]
- { null, helix, sheet, turn, ann4 }, filter);
+ alann.annotations = new Annotation[] { null, helix, sheet, turn, ann4 };
+ added = cs.filterAnnotations(alann, filter);
assertEquals(2, added);
assertTrue(cs.contains(1));
assertTrue(cs.contains(2));
*/
filter.setFilterAlphaHelix(false);
filter.setFilterTurn(true);
- added = cs
- .filterAnnotations(new Annotation[]
- { null, helix, sheet, turn, ann4 }, filter);
+ alann.annotations = new Annotation[] { null, helix, sheet, turn, ann4 };
+ added = cs.filterAnnotations(alann, filter);
assertEquals(2, added);
assertTrue(cs.contains(2));
assertTrue(cs.contains(3));
filter = new AnnotationFilterParameter();
filter.setThresholdType(ThresholdType.BELOW_THRESHOLD);
filter.setThresholdValue(2f);
- added = cs
- .filterAnnotations(new Annotation[]
- { null, helix, sheet, turn, ann4 }, filter);
+ alann.annotations = new Annotation[] { null, helix, sheet, turn, ann4 };
+ added = cs.filterAnnotations(alann, filter);
assertEquals(2, added);
assertTrue(cs.contains(1));
assertTrue(cs.contains(2));
* select value > 2f (ann4 only)
*/
filter.setThresholdType(ThresholdType.ABOVE_THRESHOLD);
- added = cs
- .filterAnnotations(new Annotation[]
- { null, helix, sheet, turn, ann4 }, filter);
+ alann.annotations = new Annotation[] { null, helix, sheet, turn, ann4 };
+ added = cs.filterAnnotations(alann, filter);
assertEquals(1, added);
assertTrue(cs.contains(4));
* select >2f or Helix
*/
filter.setFilterAlphaHelix(true);
- added = cs
- .filterAnnotations(new Annotation[]
- { null, helix, sheet, turn, ann4 }, filter);
+ alann.annotations = new Annotation[] { null, helix, sheet, turn, ann4 };
+ added = cs.filterAnnotations(alann, filter);
assertEquals(2, added);
assertTrue(cs.contains(1));
assertTrue(cs.contains(4));
*/
filter.setThresholdType(ThresholdType.BELOW_THRESHOLD);
filter.setThresholdValue(1f);
- added = cs
- .filterAnnotations(new Annotation[]
- { null, helix, sheet, turn, ann4 }, filter);
+ alann.annotations = new Annotation[] { null, helix, sheet, turn, ann4 };
+ added = cs.filterAnnotations(alann, filter);
assertEquals(1, added);
assertTrue(cs.contains(1));
}