X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2Ffeatures%2FFeatureStoreJS.java;h=3afbfb2d1afe1b53bc765cd12ec03bfdfe08e404;hb=99b6c1ca13af92cd8867971986a05664b0cd787c;hp=295d7a0302f5b0cebbd3ca0602e8c21f2e5b4ddc;hpb=5b833c4ea17f7e45fe1532b36219fcbfba3c0e4a;p=jalview.git diff --git a/src/jalview/datamodel/features/FeatureStoreJS.java b/src/jalview/datamodel/features/FeatureStoreJS.java index 295d7a0..3afbfb2 100644 --- a/src/jalview/datamodel/features/FeatureStoreJS.java +++ b/src/jalview/datamodel/features/FeatureStoreJS.java @@ -48,6 +48,30 @@ public class FeatureStoreJS extends FeatureStore } /** + * Add a contact feature to the lists that hold them ordered by start (first + * contact) and by end (second contact) position, ensuring the lists remain + * ordered, and returns true. This method allows duplicate features to be + * added, so test before calling to avoid this. + * + * @param feature + * @return + */ + @Override + protected synchronized boolean addContactFeature(SequenceFeature feature) + { + if (contactFeatureStarts == null) + { + contactFeatureStarts = new ArrayList<>(); + contactFeatureEnds = new ArrayList<>(); + } + contactFeatureStarts.add( + findFirstBegin(contactFeatureStarts, feature.begin), feature); + contactFeatureEnds.add(findFirstEnd(contactFeatureEnds, feature.end), + feature); + return true; + } + + /** * Returns a (possibly empty) list of features whose extent overlaps the given * range. The returned list is not ordered. Contact features are included if * either of the contact points lies within the range. @@ -451,7 +475,8 @@ public class FeatureStoreJS extends FeatureStore } } - public static int findFirstBegin(List list, long pos) + @Override + protected int findFirstBegin(List list, long pos) { int start = 0; int end = list.size() - 1; @@ -473,7 +498,8 @@ public class FeatureStoreJS extends FeatureStore return matched; } - public static int findFirstEnd(List list, long pos) + @Override + protected int findFirstEnd(List list, long pos) { int start = 0; int end = list.size() - 1;