From 5143fe21d91fa16c40be42cc0923be0d6f2f6536 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 28 Feb 2019 16:41:55 +0000 Subject: [PATCH] JAL-3140 confine intervalstore imports to jalview.datamodel.features --- src/jalview/datamodel/Range.java | 72 ++++++++++++++++++++ src/jalview/datamodel/Sequence.java | 4 +- src/jalview/datamodel/SequenceI.java | 3 +- .../renderer/seqfeatures/FeatureRenderer.java | 5 +- 4 files changed, 76 insertions(+), 8 deletions(-) create mode 100644 src/jalview/datamodel/Range.java diff --git a/src/jalview/datamodel/Range.java b/src/jalview/datamodel/Range.java new file mode 100644 index 0000000..8b6f617 --- /dev/null +++ b/src/jalview/datamodel/Range.java @@ -0,0 +1,72 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ +package jalview.datamodel; + +/** + * An immutable data bean that models a start-end range + */ +public class Range implements ContiguousI +{ + public final int start; + + public final int end; + + @Override + public int getBegin() + { + return start; + } + + @Override + public int getEnd() + { + return end; + } + + public Range(int i, int j) + { + start = i; + end = j; + } + + @Override + public String toString() + { + return String.valueOf(start) + "-" + String.valueOf(end); + } + + @Override + public int hashCode() + { + return start * 31 + end; + } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof Range) + { + Range r = (Range) obj; + return (start == r.start && end == r.end); + } + return false; + } +} diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index 674fabe..37e3278 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -40,8 +40,6 @@ import java.util.ListIterator; import java.util.Vector; import fr.orsay.lri.varna.models.rna.RNA; -import intervalstore.api.IntervalI; -import intervalstore.impl.Range; /** * @@ -1071,7 +1069,7 @@ public class Sequence extends ASequence implements SequenceI * {@inheritDoc} */ @Override - public IntervalI findPositions(int fromColumn, int toColumn) + public ContiguousI findPositions(int fromColumn, int toColumn) { if (toColumn < fromColumn || fromColumn < 1) { diff --git a/src/jalview/datamodel/SequenceI.java b/src/jalview/datamodel/SequenceI.java index ed8e8e4..f33132a 100755 --- a/src/jalview/datamodel/SequenceI.java +++ b/src/jalview/datamodel/SequenceI.java @@ -29,7 +29,6 @@ import java.util.List; import java.util.Vector; import fr.orsay.lri.varna.models.rna.RNA; -import intervalstore.api.IntervalI; /** * Methods for manipulating a sequence, its metadata and related annotation in @@ -214,7 +213,7 @@ public interface SequenceI extends ASequenceI * @param toColumn * @return */ - public IntervalI findPositions(int fromColum, int toColumn); + public ContiguousI findPositions(int fromColum, int toColumn); /** * Returns an int array where indices correspond to each residue in the diff --git a/src/jalview/renderer/seqfeatures/FeatureRenderer.java b/src/jalview/renderer/seqfeatures/FeatureRenderer.java index 9db55d3..13885b4 100644 --- a/src/jalview/renderer/seqfeatures/FeatureRenderer.java +++ b/src/jalview/renderer/seqfeatures/FeatureRenderer.java @@ -22,6 +22,7 @@ package jalview.renderer.seqfeatures; import jalview.api.AlignViewportI; import jalview.api.FeatureColourI; +import jalview.datamodel.ContiguousI; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; import jalview.util.Comparison; @@ -34,8 +35,6 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.util.List; -import intervalstore.api.IntervalI; - public class FeatureRenderer extends FeatureRendererModel { private static final AlphaComposite NO_TRANSPARENCY = AlphaComposite @@ -273,7 +272,7 @@ public class FeatureRenderer extends FeatureRendererModel /* * if columns are all gapped, or sequence has no features, nothing to do */ - IntervalI visiblePositions = seq.findPositions(start + 1, end + 1); + ContiguousI visiblePositions = seq.findPositions(start + 1, end + 1); if (visiblePositions == null || !seq.getFeatures().hasFeatures()) { return null; -- 1.7.10.2